wrong-number-debugging

Diagnose wrong computed results by bisecting data pipelines to locate the failing stage.

2|Updated Jun 8, 2026
One-click install
npx skills add https://github.com/lancegui/causal-powers --skill wrong-number-debugging-lancegui
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: wrong-number-debugging
Source: https://github.com/lancegui/causal-powers/tree/main/skills/wrong-number-debugging
Command: npx skills add https://github.com/lancegui/causal-powers --skill wrong-number-debugging-lancegui

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Data pipelines often run without errors yet produce wrong numbers — totals that don't reconcile, inflated revenue after a join, or coefficients with the wrong sign. This Skill replaces guess-and-patch debugging with a systematic bisection method that traces provenance backward through joins, filters, aggregations, and recodes to find the exact stage where the number went bad. ## Core Features & Use Cases - Pipeline Bisection: Reproduce the wrong number minimally, then binary-search the pipeline stages (load, join, filter, group-by, recode) to localize the bug in a few checks. - Fix-at-Source Discipline: Distinguish data-bug fixes (restoring the agreed analysis) from analytical-design changes (sample, spec, or estimand changes that must be surfaced to the user before proceeding). - Regression Prevention: Add a data-contracts invariant that would have caught the bug, verify it fails on the broken version, and log the lesson to the project's docs/LESSONS.md. - Use Case: Revenue tripled after a join in an R or Python analysis. The Skill checks key uniqueness and row counts before and after each join, identifies the fan-out caused by a non-unique key, fixes the join at the source, and adds a standing uniqueness check. ## Quick Start Ask the assistant to debug why a computed total looks wrong by bisecting the data pipeline stage by stage instead of patching the output.

Frequently Asked Questions about wrong-number-debugging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug a wrong number in a data pipeline?▼

Reproduce the wrong number on a minimal subset of rows, then bisect the pipeline by checking the value after each stage — load, join, filter, group-by, recode. Once you find the stage where it goes wrong, explain the mechanism in one sentence before fixing at the source.

How do I find which join is inflating my totals?▼

Check row counts before and after every join and verify key uniqueness on both sides. A fan-out join typically inflates totals by a clean 2x or 3x; use an anti-join or duplicated-key check to identify the non-unique key causing the duplication.

Does this debugging approach work in R, Python, and Julia?▼

Yes, the bisection method is language-agnostic and includes a cheat-sheet for each: nrow and anti_join in R, len and merge with indicator in Python, and nrow and antijoin in Julia. The same stage-by-stage checks apply across all three.

Why is adding distinct() or dropna() to fix a number discouraged?▼

Patching the final output hides the symptom without identifying which rows were duplicated or dropped and why. The same underlying bug remains in the pipeline and can silently corrupt other results downstream.

When should a data fix be escalated to the user instead of applied directly?▼

When the remedy would change the research design, specification, sample, or estimand — for example winsorizing, dropping outliers, or restricting the sample. Those are analytical decisions the user must approve, not data-bug fixes.