agentleFS
CristhianzlCristhianzl/pocket-claude/.claude/skills/debugging-agent-runs/SKILL.md

debugging-agent-runs

Skill2 starsChanged 3 months agoMITView on GitHub

Recover when the AGENT itself is stuck — looping, repeating the same failed action, burning tokens/budget, overflowing context, drifting from the goal, or acting on stale state. Use when a run isn't converging and reworded retries aren't helping. This is a workflow you follow, not a hidden runtime that auto-heals. For bugs in the product code use fixing-bugs.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is 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.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run these in order — most stuck runs are fixed by step 1–2:

    line 28
  2. Distinctive:

    Restate the real objective in one sentence: If you can't, that's the bug.

    line 30
  3. Distinctive:

    Only then retry — and change the approach,: not just the wording. If the new info didn't change your plan, you're still looping.

    line 34
  4. Distinctive:

    After one full recovery pass with no progress — or on a budget/rate-limit wall — stop and surface it: the objective, what you verified, the …

    line 45
  5. Very specific:

    If a project-specific failure mode or recovery trick shows up, append a learnings/YYYY-MM-DD-slug.md (or use /learn).

    line 49

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

Debugging agent runs

When the problem is the run, not the code: the agent keeps trying variations of the same thing, talks itself in circles, or acts on what it remembers instead of what's true. This skill is a recovery loop to break that. Be honest: it's a discipline you apply — it can't magically fix a stuck process.

Read first (always)

List learnings/ and read anything relevant — past failure modes specific to this project belong there.

Recognize the failure mode

SymptomLikely cause
Same action retried with slightly reworded promptsLoop / no new information between attempts
Output truncated, "forgetting" earlier contextContext overflow → compact or restart with a tighter scope
Repeated 429 / timeoutsRate limit → back off, batch, slow down
Edits land on the wrong branch/files; conflictsBranch / diff drift → re-verify git state
Confident claims that don't match realityStale state → trusting memory over the world
Scope keeps widening while nothing landsScope creep → shrink to one verifiable thing

The recovery loop

Run these in order — most stuck runs are fixed by step 1–2:

  1. Restate the real objective in one sentence. If you can't, that's the bug. Re-anchor to the user's actual goal, not the sub-task you spiraled into.
  2. Verify world state — don't trust memory. Re-read the files, git status/diff, and the actual test/command output. The model's recollection is often stale; reality isn't.
  3. Shrink the failing scope. Reduce to the smallest reproduction or the single failing unit. Big scope hides the cause.
  4. Run one discriminating check — the single command/test whose result tells you which branch of the problem you're in. Don't guess; get one new bit of information.
  5. Only then retry — and change the approach, not just the wording. If the new info didn't change your plan, you're still looping.

Anti-patterns

  • Retrying the same action three times with reworded prompts (no new information = a loop).
  • Trusting your memory of the code/state instead of re-reading it.
  • Widening scope when stuck (the opposite of step 3).
  • Fabricating that something "should now work" without a check that proves it.

When to stop and ask the human

After one full recovery pass with no progress — or on a budget/rate-limit wall — stop and surface it: the objective, what you verified, the one check you ran, and where it's blocked. A clear handoff beats more silent retries.

Capture a learning

If a project-specific failure mode or recovery trick shows up, append a learnings/YYYY-MM-DD-slug.md (or use /learn).

See also

  • skills/fixing-bugs — once you've isolated a real code bug, switch to the reproduce-first fix workflow.
  • skills/running-agent-loops — stop conditions and escalation for unattended loops.

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.