"This skill should be used when the user asks to 'fix analysis', 'wrong results', 'notebook error', 'reviewer feedback', 'data changed', 'debug notebook', or needs mid-analysis course-correction for wrong results, notebook errors, or data changes."
Resources
1Install
npx skillscat add edwinhu/workflows/ds-fix Install via the SkillsCat registry.
Announce: "Using ds-fix for mid-analysis course correction."
Where This Fits
/ds (entry) → brainstorm → plan → implement → review → verify
↑
/ds-fix (midpoint) ─────────────────┘This is the re-entry point. Jump back into a DS workflow that needs fixing.
## The Iron Law of DS EditingDIAGNOSE BEFORE FIXING. This is not negotiable.
Before changing ANY analysis code, you MUST:
- Load the workflow context
- Identify WHAT is wrong (specific, not vague)
- Identify WHY it's wrong (root cause)
- Only THEN fix it (with output-first verification)
If you're about to change code without diagnosing first, STOP.
Red Flags - STOP Immediately If You Think:
| Thought | Why It's Wrong | Do Instead |
|---|---|---|
| "I'll just re-run everything" | Brute force hides root cause | Trace to the specific failing step |
| "The data probably changed" | Your guess isn't a diagnosis | Compare data profiles before/after |
| "Let me tweak the parameters" | Tweaking without understanding is p-hacking | Understand WHY parameters are wrong first |
| "I'll fix it and check later" | You're skipping output-first | Fix AND verify in the same step |
Step 1: Load Context
Read workflow state:
Read(".claude/SPEC.md")
Read(".claude/PLAN.md")
Read(".claude/LEARNINGS.md")If no workflow state exists, suggest starting with /ds instead.
Step 2: Diagnose
Identify the issue category:
| Category | Symptoms | Route To |
|---|---|---|
| Runtime Error | Traceback, cell failure, import error | Debug Protocol |
| Wrong Results | Numbers don't match expectations, sanity checks fail | Re-analysis Protocol |
| Unclear Root Cause | 3+ plausible explanations, mysterious data quality issues | Competing Hypothesis Investigation |
| Reviewer Feedback | Specific methodology concerns, requested changes | Revision Protocol |
| Data Change | New data available, source updated, schema changed | Re-profiling Protocol |
| Scope Change | New questions, expanded requirements | Spec Update → re-plan |
Ask user if ambiguous:
AskUserQuestion(questions=[
{
"question": "What needs fixing in your analysis?",
"header": "Issue type",
"options": [
{"label": "Runtime error", "description": "Code fails, traceback, import error"},
{"label": "Wrong results", "description": "Numbers don't look right, sanity checks fail"},
{"label": "Unclear root cause", "description": "Multiple plausible explanations, mysterious data quality"},
{"label": "Reviewer feedback", "description": "Specific changes requested by reviewer"},
{"label": "Data/scope change", "description": "New data, updated requirements, new questions"}
],
"multiSelect": false
}
])Step 3: Fix by Category
Runtime Error → Debug Protocol
- Identify the failing cell/script
- Read the error traceback
- Check LEARNINGS.md for prior context on this step
- Fix with output-first verification:
- Print state BEFORE the failing operation
- Fix the operation
- Print state AFTER
- Verify output matches expectations from PLAN.md
For notebook-specific errors, load notebook-debug patterns:
Read("${CLAUDE_PLUGIN_ROOT}/skills/notebook-debug/SKILL.md")Wrong Results → Re-analysis Protocol
**Trace backwards. Do NOT guess forward.**The bug is at the FIRST step where output diverges from expected. Find that step.
- Identify WHICH results are wrong
- Trace backwards through the pipeline:
- Check final output → is the aggregation wrong?
- Check intermediate data → is the transformation wrong?
- Check input data → is the loading/filtering wrong?
- Find the FIRST step where output diverges from expected
- Fix that step with output-first verification
- Re-run downstream steps and verify
Reviewer Feedback → Revision Protocol
- Document each piece of feedback as a task
- For each task:
- Locate the relevant code/output
- Apply the change
- Verify with output-first protocol
- Document in LEARNINGS.md
- After all changes, re-run review checks:
Read("${CLAUDE_PLUGIN_ROOT}/lib/skills/ds-review/SKILL.md")Data/Scope Change → Re-profiling Protocol
- Profile the new data (shape, dtypes, distributions)
- Compare to original data profile in LEARNINGS.md
- Identify what changed (schema, volume, distributions)
- Update PLAN.md if pipeline steps need changing
- Re-run affected pipeline steps with output-first verification
- Update LEARNINGS.md with new observations
Scope Change → Spec Update
If the question itself changed:
- Update SPEC.md with new objectives
- Review PLAN.md — which tasks are still valid?
- Add new tasks for new objectives
- Return to implement phase for new tasks
Unclear Root Cause → Competing Hypothesis Investigation
When 3+ plausible explanations exist, sequential investigation failed, or contradictory evidence is found, use the competing hypothesis protocol.
Read the full protocol: references/competing-hypothesis.md
Key steps:
- Generate 3-5 competing hypotheses (Data Quality, Methodology, Implementation, Domain)
- Spawn investigation team (one agent per hypothesis)
- Scientific debate with cross-examination
- Evidence synthesis with confidence scoring (≥90 to proceed)
- Fix implementation via ds-delegate
Step 4: Verify Fix
After fixing, apply output-first verification:
- Re-run the fixed step: verify output shape, sample, stats
- Re-run downstream steps: verify no cascading issues
- Check against SPEC.md success criteria
- Update LEARNINGS.md with fix documentation
Delegation
Main chat orchestrates. Task agents do the fixing:
Task(subagent_type="general-purpose", prompt="""
Fix [SPECIFIC ISSUE] in the analysis.
Context:
- Read .claude/LEARNINGS.md for prior steps
- Read .claude/PLAN.md for task details
- Read .claude/SPEC.md for objectives
Fix Protocol:
1. Trace to root cause (do NOT guess)
2. Fix with output-first verification
3. Print state BEFORE and AFTER fix
4. Re-run downstream steps
5. Update LEARNINGS.md
Report: what was wrong, what was fixed, verification output.
""")When Fix Requires Rethinking
If the fix reveals the analysis approach is fundamentally wrong:
- Document findings in LEARNINGS.md
- Report to user: "The approach needs rethinking because [specific reason]"
- Suggest returning to
/dsfor re-planning
Don't try to salvage a broken approach with patches. A fresh plan costs less than cascading fixes.