agentsclimarketplace

Diagnose before retry

Skill jcdavis131/cursor-agent-skills/skills/diagnose-before-retry

42 agent-discipline skills for Cursor, distilled by watching an autonomous terminal coding agent (Claude Code + Fable 5). Includes the derivation method.

Install
npx -y skills add jcdavis131/cursor-agent-skills --skill diagnose-before-retry

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 29 days oldThe repository was created 29 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

When an operation fails, form a hypothesis from the logs/evidence before retrying — never retry blindly. Distinguish op-caused failures from self-caused artifacts (your own stops/kills), state the hypothesis with supporting context and appropriate uncertainty, and retry in the foreground with a timeout and observability so the retry is also a test of the hypothesis. Use when a long command (migrate, build, install, deploy, fetch) fails and you're tempted to just re-run it.

SKILL.md

4.5 KB, 992 tokens by cl100k_base, as published. Nobody here has run it

Diagnose Before Retry

A blind retry of a failed op reproduces the failure and wastes a cycle. A diagnosed retry tests a hypothesis and either confirms the fix or refines it.

The move

  1. Don't retry immediately. The urge to re-run is strong; resist it. A failure is information — read it first.
  2. Read the relevant log/evidence. The op's own output, the service's server log, the exit code, the state it left behind. Find the failure line and what preceded it.
  3. Name how far the op got. "Created the migrations table, then lost connectivity mid-run." This matters for idempotency — a partially-applied migration may need rollback, not a naive retry.
  4. Distinguish op-caused failure from self-caused artifact. Your own TaskStop / kill / cancellation shows up in logs as a disconnect or EOF. Don't misdiagnose your own stop as an infrastructure failure:

    "Postgres itself is healthy — the disconnect line is my TaskStop."

  5. Form a hypothesis with supporting context + appropriate uncertainty.

    "The failure may have been transient load (three parallel jobs at the time)." Name the cause, the supporting context, and use uncertainty language ("may have been", "likely") — don't assert certainty you can't back.

  6. Retry in a way that tests the hypothesis. If the hypothesis is "transient load from parallel jobs", retry in the foreground with no parallel load. The retry both attempts the op and tests the hypothesis.

The retry-with-observability idiom

timeout <N> <command> 2>&1 | tr '\r' '\n' | grep -vE "^\s*$" | tail -15
  • Foreground, not backgrounded — direct view for a retry you care about.
  • timeout <N> — bound it so a hung retry can't hang forever (the original failure mode may recur).
  • tr '\r' '\n' — progress bars use carriage returns; converting to newlines stops them smearing into one unreadable line.
  • grep -vE "^\s*$" — strip blank lines.
  • tail -15 — bound the output; the last 15 lines show the result.

When a blind retry IS okay

  • The failure was a known-transient external blip (a flaky network, a registry 5xx) and the op is idempotent and cheap.
  • The op has no partial state (a read-only command, a fresh build to a clean dir).
  • You've already diagnosed the same failure mode before in this session and confirmed the retry strategy.

If any of those is false, diagnose first.

Fix the structural cause, not the symptom

When a retry fixes the symptom, ask why the failure happened and fix the structure so it can't recur:

"Corpora now travel with the repo — the build can't miss them."

A prior build missed the corpora; instead of patching the build to fetch them, move the corpora into the repo so the build structurally can't miss them. The fix makes the failure mode impossible, not just unlikely. This is the highest form of diagnosis: change the structure so the bug can't recur, rather than adding a check for the symptom. A symptom-check fix leaves the root cause; a structural fix removes it.

Anti-patterns

  • Blind retry. "It failed, let me run it again." Reproduces the failure; teaches nothing.
  • Misdiagnosing self-caused artifacts. Your own TaskStop shows as a disconnect; "Postgres is down" → you "fix" healthy infra.
  • Certainty you can't back. "It was definitely transient load." You don't know; say "may have been".
  • Unbounded retry. No timeout → a hung retry hangs forever.
  • Backgrounding the retry. You care about this one; foreground it for direct view.
  • Ignoring how far it got. A partially-applied migration retried naively can double-apply or conflict.

Pair with

  • silent-op-recovery — the retry-with-observability idiom extends that skill's capture-exit-and-sample.
  • background-failure-triage — the failure that triggered the diagnosis was likely a backgrounded op.
  • correct-assumptions — "the documented blocker was wrong" is one possible diagnosis.
  • cost-transparency — a second retry of a 7m op should be diagnosed, not blindly re-run.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,984. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.