agentleFS
SandAI-orgSandAI-org/MagiAttention/.cursor/skills/debug-test-failures/SKILL.md

debug-test-failures

Skill971 starsChanged 7 months agoApache-2.0View on GitHub

Systematic approach to debug failing tests. Use when a user reports test failures, regression bugs, or assertion mismatches. Core method: reproduce the failure, then use git history to determine whether the failure is caused by a recent commit or by the user's uncommitted changes.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. microsoft/haste★ 110same name
    2. LJMStark/geo-doctor★ 0same 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 repositoryOne other file it gives its agents.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the failing test, capture full output:

    line 19
  2. Distinctive:

    Check if this test *ever* passed on the current branch:

    line 33
  3. Distinctive:

    Read the diff carefully. The bug is likely in the uncommitted changes.

    line 51
  4. Distinctive:

    Ensure the original intent of the offending commit is preserved

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Debug Test Failures

Principle

Test failures always have a cause in code changes. The fastest debugging path is to figure out which change broke it, not to guess at the logic.

Step 1: Reproduce and Extract Key Info

Run the failing test, capture full output:

python -m pytest -sq <test_file> 2>&1 | head -80
python -m pytest -sq <test_file> 2>&1 | tail -50

Extract from the error:

  • Which test case(s) failed
  • The actual vs expected values
  • The file and line of the failing assertion

Step 2: Determine the Scope of Failure

Check if this test ever passed on the current branch:

# What files have uncommitted changes?
git status

# What committed changes touch files related to the failure?
git log --oneline -20 -- <relevant_source_files>

This splits into two cases:

Case A: The user has uncommitted changes in related files

git diff -- <relevant_source_files>

Read the diff carefully. The bug is likely in the uncommitted changes. Compare the diff against the assertion error to find the mismatch.

Case B: No uncommitted changes in related files

The regression was introduced by a recent commit. Proceed to Step 3.

Step 3: Walk Git History to Find the Offending Commit

# List recent commits touching the relevant files
git log --oneline --all -- <file_path>

Then inspect each suspect commit:

git show <commit_hash> -- <file_path>

Walk commits chronologically and identify:

  1. Last known good state — what the logic looked like before
  2. Offending commit — where behavior changed
  3. Intent — was the change a refactor, feature, or bugfix?

Common regression patterns:

  • Refactoring that widens a condition — e.g. merging two flags into one, where the new condition covers more cases than intended
  • Default value changes — a dataclass/config default was changed, silently affecting callers that relied on the old default
  • Silent override in initialization — __init__ / __post_init__ / constructor overwrites a user-provided value under a too-broad condition

Step 4: Confirm Root Cause by Comparing Before/After

Once you identify the suspect commit, compare the old and new logic side by side. Verify that:

  • The old logic would produce the expected test output
  • The new logic produces the actual (wrong) test output
  • The behavioral difference is unintentional (not a deliberate design change)

Step 5: Apply Minimal Fix and Verify

  1. Make the smallest change that restores correct behavior
  2. Ensure the original intent of the offending commit is preserved
  3. Re-run the failing test to confirm all cases pass
python -m pytest -sq <test_file> 2>&1 | tail -5

Anti-Patterns

  • Don't update expected values to match broken output without understanding why they differ — the tests encode domain knowledge.
  • Don't guess at the fix without tracing the cause — always check git history first.
  • Don't ignore the "other case" — if the fix narrows a condition, verify that the broader case (which the offending commit intended to handle) still works correctly.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.