agentleFS
jars-demojars-demo/jars-skills/skills/debug-session/SKILL.md

debug-session

Skill0 starsChanged 31 days agoMITView on GitHub

Diagnose and fix bugs systematically. Use when the user reports an error, unexpected behaviour, a failing test, or a crash. Reads logs and code, reproduces the issue, isolates the root cause, fixes it, and verifies the fix — without guessing or changing code blindly.

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

26 rules. 0 are common, 25 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 25

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Understand before touching code: Read the error, the logs, and the relevant code first.

    line 13
  2. Distinctive:

    Verify the fix: Run the failing test or reproduce the original steps after the fix.

    line 18
  3. Distinctive:

    Ask the user (or find in context):

    line 28
  4. Distinctive:

    When did it start? (after a deploy, a dependency bump, a code change?)

    line 32
  5. Distinctive:

    Read the full error. The last line of a stack trace is rarely the root cause — trace back up to the first frame in your own code.

    line 35
  6. Distinctive:

    Before changing anything, reproduce the issue:

    line 40
  7. Distinctive:

    If you cannot reproduce it, say so.

    line 52
  8. Distinctive:

    Do not skim. Read the actual lines involved, not just the function signature.

    line 70
  9. Distinctive:

    If your hypothesis does not explain every symptom, keep looking.

    line 84
  10. Distinctive:

    Before writing a fix, confirm the theory:

    line 88
  11. Distinctive:

    Add a temporary log or assertion to confirm the bad value is what you think it is

    line 90
  12. Distinctive:

    Check whether the condition you identified actually occurs in the reproduction steps

    line 91
  13. Distinctive:

    Read the git log for this file — was this code recently changed?

    line 92
  14. Distinctive:

    If the hypothesis is wrong, go back to step 3.

    line 99
  15. Distinctive:

    Write the minimal change that addresses the root cause:

    line 104
  16. Distinctive:

    No new errors or warnings appeared

    line 133
  17. Distinctive:

    If you added a temporary log or assertion in step 5, remove it now.

    line 135
  18. Distinctive:

    If a test for this case does not exist, write one:

    line 139
  19. Distinctive:

    Ask for logs from multiple occurrences — look for a pattern (time of day, load, specific input, specific user)

    line 173
  20. Distinctive:

    Check for shared mutable state, race conditions, or time-dependent logic

    line 175
  21. Distinctive:

    Add structured logging around the suspect area and ask the user to capture the next occurrence

    line 176
  22. Distinctive:

    Do not guess a fix for a bug you cannot reproduce

    line 178
  23. Distinctive:

    If after two hypotheses you have not found the cause:

    line 182
  24. Very specific:

    Check recent changes: git log --oneline -20 -- <affected area>

    line 185
  25. Distinctive:

    Check for known issues: search the issue tracker or changelog for similar symptoms

    line 186
  26. Distinctive:

    Do not keep making changes hoping something sticks.

    line 190

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “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 session

Work through a bug methodically: understand what is broken, reproduce it, find the root cause, fix only what needs fixing, and confirm it stays fixed. No blind changes, no guessing.

Ground rules

  • Understand before touching code. Read the error, the logs, and the relevant code first. A fix written without understanding the cause often creates a new bug.
  • One hypothesis at a time. Form a theory, test it, confirm or rule it out, then move on.
  • Minimal fix. Change only what the root cause requires. Do not refactor unrelated code while fixing a bug.
  • Verify the fix. Run the failing test or reproduce the original steps after the fix. "It looks right" is not verification.
  • Never suppress an error to make it disappear. Swallowing exceptions or adding try/except: pass is not a fix.
  • Report honestly. Say what you found, what you changed, and what you could not verify.

Workflow

1. Understand the symptom

Ask the user (or find in context):

  • What is the exact error message, stack trace, or wrong behaviour?
  • How do you reproduce it? (steps, command, request, input)
  • When did it start? (after a deploy, a dependency bump, a code change?)
  • Is it consistent or intermittent?

Read the full error. The last line of a stack trace is rarely the root cause — trace back up to the first frame in your own code.

2. Reproduce it

Before changing anything, reproduce the issue:

# Run the failing test
pytest path/to/test_file.py::test_name -x
# or
npm test -- --testNamePattern "failing test name"

# Run the application and trigger the error
# Follow the exact steps the user described

If you cannot reproduce it, say so. An unreproducible bug needs more information before any fix is attempted.

3. Read the relevant code

# Find where the error originates
grep -rn "FunctionName\|ErrorMessage" src/

# Read the file and the call chain around the error

Trace the execution path from the entry point to the crash:

  • What inputs trigger it?
  • What state or data does the code depend on?
  • Where does the value come from that causes the problem?

Do not skim. Read the actual lines involved, not just the function signature.

4. Form a hypothesis

State your theory in one sentence before acting:

"The crash happens because user.profile can be None when the user skips onboarding, but line 42 accesses user.profile.avatar_url without a null check."

A good hypothesis names:

  • The specific condition that triggers the bug
  • The specific line or function where it fails
  • Why the code does the wrong thing there

If your hypothesis does not explain every symptom, keep looking.

5. Verify the hypothesis

Before writing a fix, confirm the theory:

  • Add a temporary log or assertion to confirm the bad value is what you think it is
  • Check whether the condition you identified actually occurs in the reproduction steps
  • Read the git log for this file — was this code recently changed?
git log --oneline -10 -- path/to/file.py
git show <commit> -- path/to/file.py

If the hypothesis is wrong, go back to step 3. Do not skip this step and jump straight to a fix.

6. Fix it

Write the minimal change that addresses the root cause:

Root cause typeFix approach
Null / undefined accessGuard with a check, return early, or ensure the value is always set
Wrong assumption about inputValidate input at the entry point; add a clear error for bad input
Off-by-oneTrace the index arithmetic; fix the boundary condition
Race conditionAdd a lock, use an atomic operation, or remove the shared mutable state
Wrong error handlingCatch the right exception; surface it clearly; do not swallow
Stale cache / stateInvalidate at the right time, or remove the cache if it is not worth it
Dependency bugPin the last good version; add a comment; open an issue upstream

Stage only the fix. Do not bundle unrelated changes into the same commit.

7. Verify the fix

# Re-run the exact reproduction steps
# Re-run the failing test
pytest path/to/test_file.py::test_name -x

# Run the full test suite for the affected area
pytest path/to/

Confirm:

  • The original error no longer occurs
  • Existing tests still pass
  • No new errors or warnings appeared

If you added a temporary log or assertion in step 5, remove it now.

8. Write a regression test

If a test for this case does not exist, write one:

def test_profile_access_when_onboarding_skipped():
    user = User(profile=None)
    # Should return a default, not raise AttributeError
    assert get_avatar_url(user) == DEFAULT_AVATAR

The test name should describe the bug scenario, not the implementation. If adding a test is out of scope, say so and leave a # TODO: comment with the scenario.

9. Report

Summarise what you found and did:

Root cause: `user.profile` was None for users who skipped onboarding.
            Line 42 accessed `.avatar_url` without a guard.

Fix: Added an early return in `get_avatar_url()` that returns DEFAULT_AVATAR
     when `profile` is None.

Verified: `test_profile_access_when_onboarding_skipped` passes.
          Full unit suite: 94 passed, 0 failed.

Not verified: behaviour in production with real onboarding-skip users
              (no staging environment available).

Intermittent bugs

For bugs that do not reproduce reliably:

  • Ask for logs from multiple occurrences — look for a pattern (time of day, load, specific input, specific user)
  • Check for shared mutable state, race conditions, or time-dependent logic
  • Add structured logging around the suspect area and ask the user to capture the next occurrence
  • Do not guess a fix for a bug you cannot reproduce

When you are stuck

If after two hypotheses you have not found the cause:

  1. Widen the search — read one level up in the call stack
  2. Check recent changes: git log --oneline -20 -- <affected area>
  3. Check for known issues: search the issue tracker or changelog for similar symptoms
  4. Tell the user what you have ruled out and ask for more information (more logs, a minimal reproduction case, or access to the environment)

Do not keep making changes hoping something sticks.

Examples

ShortcutCorrect approach
Change the code until the error goes awayReproduce → hypothesise → verify → fix
except Exception: passCatch the specific exception; handle or re-raise it
"It works on my machine"Add logging; ask for the exact environment and inputs
Fix the symptom (hide the None)Find why None is there; fix the upstream cause
Refactor the whole function while fixing a bugMinimal fix first; refactor in a separate commit

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.