Skip to content
Back to skills

Stuck

ASecurity

Use when the agent is in a fix-retry loop, an error keeps recurring after multiple attempts, or the user says 'stuck', 'loop', 'going in circles', '/stuck'. Snapshot what was tried, surface to user, never silent-retry past 3 attempts.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 28, 2026
developmentgobashgitapi

Works with

  • api

Security analysis

A100/100

Scanned November 28, 2026

npx -y skills add fo0/traygent --skill stuck --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stuck?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Stuck
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/fo0-stuck/badge)](https://www.skillsdirectory.com/skills/fo0-stuck)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: stuck
description: "Use when the agent is in a fix-retry loop, an error keeps recurring after multiple attempts, or the user says 'stuck', 'loop', 'going in circles', '/stuck'. Snapshot what was tried, surface to user, never silent-retry past 3 attempts."
metadata:
  origin: claude-code-optimizer
---

# Stuck — Loop / Dead-End Recovery

## When to Use

- User says "stuck", "loop", "going in circles", "/stuck"
- Agent self-detects a loop:
  - Same error after 2nd fix attempt → log warning, third attempt MAY proceed if a different angle is being tried
  - Same error after 3rd attempt → STOP, invoke this skill
  - Same file edited 5+ times in one session for the same defect
- A test passes locally but fails in CI 2+ consecutive runs without a code change in between (likely flake — see CI-skill rules)

## Scope Boundaries

**Owns:** breaking a fix-retry loop — snapshot, attempt log, diagnosis of the loop type, escalation.
**Does not own:** undoing the damage (`rollback`), the review that would have caught the defect (`basic-review`), the decision to abandon the approach — that one is escalated, never taken here.

## Workflow

### 1. Snapshot

Capture exact current state:

```bash
git status --porcelain
git diff --stat
git log --oneline -10
```

Plus:

- Last error message verbatim (no paraphrasing)
- Last 3 commands run and their exit codes
- Files touched in this loop

### 2. Attempt Log

Build an explicit list of what's been tried this session:

```
Attempt 1: <approach> → <result>
Attempt 2: <approach> → <result>
Attempt 3: <approach> → <result>
```

If you can't articulate the attempts as distinct approaches → that itself is the diagnosis (you've been trying the same thing).

### 3. Diagnose Loop Type

| Pattern                                         | Likely cause                                 | Action                                 |
| ----------------------------------------------- | -------------------------------------------- | -------------------------------------- |
| Same fix re-applied because tests still fail    | Test is wrong, not the code                  | Question the test                      |
| Type error surviving every cast                 | Wrong type model, not wrong cast             | Step back, redesign types              |
| Test flake (passes/fails non-deterministically) | Async race / shared state / clock dependency | Treat as flake → BACKLOG.md            |
| Network / external-API error                    | Unmocked external dep                        | Apply autonomy + zero-cost rule — mock |
| Build infra (timeout / OOM / runner)            | NOT a code defect                            | Surface to CI skill, do not "fix" code |

### 4. Surface to User

Strict format:

```
🛑 Stuck — escalating after <N> attempts on the same defect.

Snapshot:
- Branch: <branch>
- Last error: <verbatim, fenced>
- Files touched repeatedly: <list>

Attempts:
1. <approach> → <result>
2. <approach> → <result>
3. <approach> → <result>

Diagnosis: <loop type from table above, OR "unknown — pattern doesn't match">

Options for the user:
A) <concrete next-step option>
B) <alternative angle>
C) revert the loop work — `/rollback`
D) defer to BACKLOG and move on

What would you like?

| # | Question | Recommendation | Why |
|---|---|---|---|
| 1 | Which option? | <letter> | <best practice or experience behind it> |

<one single-line handoff prompt for the option you recommend — CLAUDE.md → *Handoff Prompt*>
```

Then **stop**. Do NOT take a 4th attempt without user input. The handoff prompt is part of the escalation, not a
replacement for the options: the options above are the menu, and the block below them is the **one** — a single
line, one command, no second block beside it — that you would pick, ready to send. The table between them is
the question with your pick and its reason (CLAUDE.md → _Chat Layout_), headers in the chat language.

### 4b. Unattended run — same snapshot, no question

`$CLAUDE_CODE_REMOTE=true` (web/cloud session, routine runs included) means nobody will answer, and a run that ends on
"What would you like?" is a run that ended on nothing (CLAUDE.md → _Autonomy_). Same 3-attempt cap, same snapshot,
different landing:

1. Write the snapshot and the options as one `BACKLOG.md` entry under `## Open` (`agent_docs/backlog_process.md` format), status **Deferred** — the reason is the 3-attempt cap.
2. Leave the loop work uncommitted, or `/rollback` it if it made the tree worse. Never commit a defect to get past it.
3. Continue with the parts of the task that do **not** depend on the stuck defect — being blocked on one thing is not
   being blocked on everything.
4. End with the run's normal report, naming the defect, the backlog entry and what was finished around it.

Option D of the interactive format is the unattended default; A and B need a human and are recorded, not chosen, and C runs only as step 2 allows.

## Hard Rules

- **3-attempt cap on the same defect.** No exceptions. The 4th try without user input is forbidden.
- **Snapshot before escalating.** No vague "I'm stuck" — show evidence.
- **Verbatim error messages.** Never paraphrase the error when escalating.
- **No silent retries.** If you've tried X and it didn't work, say so.
- **Loop work doesn't get committed silently.** Either user picks a path or rollback the loop.
- **Never end an unattended run with a question.** Escalation there means step 4b: backlog entry plus report.

## After User Response

- User picks a concrete option → execute, with attempt counter reset for the _new_ approach (not for the underlying defect).
- User asks for more info → produce the requested data, do NOT take it as license to retry.
- User says "keep trying" → ask once: "Same approach or a new angle? If same, I will stop after one more attempt." Then enforce that.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.