debug-failing-test
Skill146 starsChanged 9 months agoMITView on GitHub
Debug a failing test using an iterative logging approach, then clean up and document the learning.
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 14 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Use console.log('[DEBUG]', ...) with descriptive labels
- Distinctive: line 25
Add timestamps if timing might be relevant
- Distinctive: line 35
If root cause is clear → proceed to fix
- Distinctive: line 36
If more information needed → add more targeted logging and repeat
- Very specific: line 47
Delete all console.log('[DEBUG]', ...) statements added
- Distinctive: line 48
Remove any temporary variables or code added for debugging
- Distinctive: line 49
Ensure the code is in a clean, production-ready state
- Distinctive: line 51
Verify the test still passes: after cleanup
- Distinctive: line 61
Add it to the "Learnings" section of the most relevant instruction file
- Distinctive: line 62
If a similar learning already exists, increment its counter instead
- Distinctive: line 66
When adding debug logging, use this format for easy identification and removal:
- Distinctive: line 85
Prefer targeted logging over flooding the output
- Distinctive: line 86
Start with the failing assertion and work backwards
- Distinctive: line 87
Consider async timing issues, race conditions, and mock setup problems
- Distinctive: line 88
Check that mocks are returning expected values
- Distinctive: line 89
Verify test setup/teardown is correct
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Debug a failing unit test by iteratively adding verbose logging, running the test, and analyzing the output until the root cause is found and fixed.
Workflow
Phase 1: Initial Assessment
- Run the failing test to capture the current error message and stack trace
- Read the test file to understand what is being tested
- Read the source file being tested to understand the expected behavior
- Identify the assertion that fails and what values are involved
Phase 2: Iterative Debugging Loop
Repeat until the root cause is understood:
- Add verbose logging around the suspicious code:
- Use
console.log('[DEBUG]', ...)with descriptive labels - Log input values, intermediate states, and return values
- Log before/after key operations
- Add timestamps if timing might be relevant
- Use
- Run the test and capture output
- Assess the logging output:
- What values are unexpected?
- Where does the behavior diverge from expectations?
- What additional logging would help narrow down the issue?
- Decide next action:
- If root cause is clear → proceed to fix
- If more information needed → add more targeted logging and repeat
Phase 3: Fix and Verify
- Implement the fix based on findings
- Run the test to verify it passes
- Run related tests to ensure no regressions
Phase 4: Clean Up
- Remove ALL debugging artifacts:
- Delete all
console.log('[DEBUG]', ...)statements added - Remove any temporary variables or code added for debugging
- Ensure the code is in a clean, production-ready state
- Delete all
- Verify the test still passes after cleanup
Phase 5: Document and Learn
- Provide a summary to the user (1-3 sentences):
- What was the bug?
- What was the fix?
- Record the learning by following the learning instructions (if you have them):
- Extract a single, clear learning from this debugging session
- Add it to the "Learnings" section of the most relevant instruction file
- If a similar learning already exists, increment its counter instead
Logging Conventions
When adding debug logging, use this format for easy identification and removal:
console.log('[DEBUG] <location>:', <value>);
console.log('[DEBUG] before <operation>:', { input, state });
console.log('[DEBUG] after <operation>:', { result, state });Example Debug Session
// Added logging example:
console.log('[DEBUG] getEnvironments input:', { workspaceFolder });
const envs = await manager.getEnvironments(workspaceFolder);
console.log('[DEBUG] getEnvironments result:', { count: envs.length, envs });Notes
- Prefer targeted logging over flooding the output
- Start with the failing assertion and work backwards
- Consider async timing issues, race conditions, and mock setup problems
- Check that mocks are returning expected values
- Verify test setup/teardown is correct
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- qazando/skills-qas★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- cross-platform-pathsSkill
- generate-snapshotSkill
- python-manager-discoverySkill
- run-e2e-testsSkill
- run-integration-testsSkill
- run-pre-commit-checksSkill
- run-smoke-testsSkill
- settings-precedenceSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

