subtest-isolation
FreeNo executable scriptsNot checkedCreate minimal subtests to isolate and fix complex bugs. Use when a test fails and the issue is buried in complexity.
About this skill
Subtest Isolation Methodology
When a test fails with complex output or multiple issues, create a minimal subtest to isolate and fix ONE specific problem at a time.
When to Use This Approach
Use subtest isolation when:
- ✅ Test has multiple moving parts and you can't identify the root cause
- ✅ Visual diff shows one specific element is wrong among many
- ✅ You need to add debug output but the full test is too noisy
- ✅ The bug is structural (wrong algorithm) not just a value mismatch
- ✅ You've tried quick fixes and they didn't work
Don't use for:
- ❌ Simple value mismatches you can debug directly
- ❌ Obvious typos or off-by-one errors
- ❌ Issues you can already see the cause of
The Process
1. Identify the Specific Problem
Look at the failing test output and pinpoint EXACTLY what's wrong:
- Which element is mispositioned?
- Which calculation is producing wrong values?
- Which feature is broken?
Example from test45:
Problem identified: Bottom box has all text overlapping incorrectly.
"center" text appearing at the very top instead of middle.
2. Create Minimal Reproduction
Create a new test file (e.g., test45b.pikchr) with ONLY the problematic element:
# test45b.pikchr - isolate the bottom box issue
box "rjust" rjust above "center" center "ljust" ljust above \
"rjust" rjust below "ljust" ljust below big big
Key principles:
- ✅ Include ONLY what's needed to reproduce the bug
- ✅ Remove all unrelated elements (other boxes, arrows, files, etc.)
- ✅ Keep the exact attributes that trigger the bug
- ✅ Name it
<original>b.pikchrfor clarity
3. Verify It Fails the Same Way
Run the subtest and confirm it shows the SAME bug:
cargo run --example simple -- vendor/pikchr-c/tests/test45b.pikchr
# OR
mcp__pikru-test__run_pikru_test test45b
Check that:
- The specific problem reproduces
- The failure mode is identical
- You haven't accidentally "fixed" it by simplifying
4. Add Debug Output
Add targeted debug output to understand what's happening:
eprintln!("[SLOT HEIGHT] text='{}' slot={:?} font_scale={} charht={} h={}",
text.value, slot, text.font_scale(), charht, h);
eprintln!("[Y OFFSET] text='{}' slot={:?} calc=[{}] y_offset={} final_y={}",
positioned_text.value, slot, offset_calc, y_offset, center.y + svg_y_offset);
Debug output best practices:
- Use
eprintln!so it goes to stderr (doesn't corrupt SVG output) - Use clear prefixes like
[SLOT HEIGHT],[Y OFFSET]for easy grepping - Show both inputs and outputs of calculations
- Include the actual formula/calculation being performed
- Show intermediate values, not just final results
5. Run and Analyze
Run the subtest and analyze the debug output:
cargo run --example simple -- vendor/pikchr-c/tests/test45b.pikchr 2>&1 | grep '\[SLOT'
Look for:
- Wrong values (expected vs actual)
- Wrong assignments (text getting wrong slot)
- Wrong calculations (formula producing wrong result)
- Missing or unexpected branches taken
Example output that revealed the bug:
[SLOT HEIGHT] text='center' slot=Above2 font_scale=1 charht=0.14 h=0.14
→ BUG FOUND: "center" text assigned to Above2 instead of Center!
6. Compare with C Implementation
Run the C implementation on the same subtest:
vendor/pikchr-c/pikchr --svg-only vendor/pikchr-c/tests/test45b.pikchr | grep '<text'
Compare:
- Element positions (x, y coordinates)
- Slot assignments (if you can infer them)
- Final output structure
Example comparison:
C output: <text y="38.16" ...>center</text>
Rust output: <text y="12.24" ...>center</text>
→ Confirms the bug: Rust placing center text way too high
7. Fix the Bug
Based on debug output and comparison:
- Identify the root cause
- Make the minimal fix needed
- Don't over-engineer - fix THIS bug only
Example fix:
// BUG: wasn't checking t.center
else if t.center {
Some(TextVSlot::Center) // ← FIX: explicitly assign Center slot
}
8. Verify Subtest Passes
Run the subtest again - it should now MATCH:
mcp__pikru-test__run_pikru_test test45b
Expect:
{"test_name":"test45b","status":"match","comparison":{"ssim":1.0, ...}}
9. Remove Debug Output
Clean up the debug statements you added:
// Remove all the eprintln! statements
// Keep the code clean for production
10. Verify Original Test Passes
Run the original test to confirm the fix works in context:
mcp__pikru-test__run_pikru_test test45
If it still fails:
- There may be MULTIPLE bugs (repeat the process)
- The subtest wasn't complete enough (add more context)
- There's an interaction bug (debug the interaction)
If it passes:
- ✅ Bug is fixed!
- ✅ Verify a few other tests still pass
- ✅ Commit with clear message about the fix
11. Keep or Remove Subtest
Keep the subtest if:
- It tests an important edge case worth preservi
Install subtest-isolation in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the subtest-isolation skill do?
Create minimal subtests to isolate and fix complex bugs. Use when a test fails and the issue is buried in complexity.
How do I install the subtest-isolation skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the subtest-isolation skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic