{"slug": "claude-code-stuck-hung-looping-or-waiting", "title": "Claude Code stuck: hung, looping, or waiting", "summary": "A developer built Caprock, a tool that distinguishes three states a stalled Claude Code session can be in — a hung process, a looping agent, and an unanswered permission prompt — which all look identical on a terminal. Caprock reads each session's process and event stream to classify it as working, idle, waiting on you, done, looping or error, with a team edition covering every machine. The writeup pairs each state with a remedy: Ctrl+C then `claude --resume` for a hang, Esc for a loop, and a keypress for a waiting prompt.", "body_md": "*Tell a hung Claude Code session from a loop or a waiting prompt, what to do for each, and how a team sees one repeating a call five times in three minutes.*\n\nA Claude Code session that stopped moving is in one of three states, and\n\nthe terminal shows all three the same way: a hung process, a loop, or a\n\nprompt nobody has answered. The first needs Ctrl+C and `claude --resume`;\n\nthe second needs someone to notice before it drains the week's window; the\n\nthird needs one keypress from whoever can see the question. Caprock tells\n\nthe three apart for every session on the machine, and the team edition for\n\nevery machine.\n\n**In short**\n\n`claude --resume` in the same directory. The conversation is kept.`/status`, Ctrl + C or `/exit`, `codex resume`. Caprock runs the same loop detector over Codex sessions.\nA terminal shows the last thing drawn on it. A process that stopped\n\nanswering, an agent repeating one command, and a dialog waiting under a\n\nspinner that stopped all leave the same still screen. The difference is in\n\nthe process and in the stream of events it writes, which is where Caprock\n\nreads it: each session carries one of working, idle, waiting on you, done, looping or error.\n\n*What a stuck Claude Code session looks like, what it is, and what to do.*\n\n| What you see | What it is | What to do | \n|---|---|---|\n| No new text, no spinner, keys do nothing | Hung: the process stopped answering | Ctrl+C. Then close the terminal and `claude --resume` | \n| Spinner on, the same command or edit scrolls past again | Looping: one call repeated | Esc, then say what is wrong and what to do instead | \n| Spinner off, a dialog or a question at the bottom | Waiting: a permission prompt or a question is open | Answer it. Nothing happens until someone does | \n| `Usage limit reached · limit resets 3:45pm` | Not stuck: waiting for the window to reset | Leave it. Esc at an empty prompt cancels the wait | \n\n*The last row from the interactive-mode page, read 30 October 2026: since v2.1.234 Claude Code waits in the open session and continues on its own after the reset.*\n\nThe three need three different people: the hung one needs you at the\n\nkeyboard, the loop needs anyone who can read the transcript, the waiting one\n\nneeds whoever the question was for.\n\nAnthropic's troubleshooting page has one section for it, \"Command hangs or\n\nfreezes\", read 30 October 2026:\n\nIf Claude Code seems unresponsive: 1. Press Ctrl+C to attempt to cancel the current operation. 2. If unresponsive, you may need to close the terminal and restart.\n\n— Claude Code docs, Troubleshooting\n\nThen: \"Restarting doesn't lose your conversation. Run `claude --resume` in the same directory to pick the session back up.\" The keys that stop a turn without closing the\n\nsession, from the interactive-mode page the same day:\n\n`Esc` opens the rewind menu\", to go back to an earlier point in the code and the conversation.`fg` to resume\"\nTo come back after a restart: `claude --continue`. \"This resumes the most recent session in the current directory; if there isn't one yet, it prints `No conversation found to continue` and exits.\"\n\n\"Use `claude --resume` to choose from a list, or `/resume` from inside a running session.\"\n\nWhat the same page says about the two causes that look like a hang:\n\n`claude --continue` to resume the conversation in a fresh process.\" Before that, `/compact`, a restart between large tasks, and `claude --safe-mode` to test whether a plugin, MCP server or hook is the load: \"It disables all customizations for the session; if usage drops, see Debug your configuration to find which one\".`Autocompact is thrashing: the context refilled to the limit...` means automatic compaction succeeded but a file or tool output immediately refilled the context window several times in a row. Claude Code stops retrying to avoid wasting API calls on a loop that isn't making progress. Read the large file in ranges, `/clear`.`/doctor` inside Claude Code for an automated check of your installation, settings, extensions, and context usage; it proposes fixes it can apply after you confirm\". \"If `claude` won't start at all, run `claude doctor` from your shell instead.\"\nThe page names no time after which a turn counts as hung. A session that is\n\nquiet because a long command runs, and one whose process has stopped, read\n\nthe same at the terminal; Caprock's session row shows the last event's time\n\nand the command it is on, which is how you tell a 20-minute test suite from\n\na dead process without killing either.\n\nA loop in the transcript is one tool call, then the same call, then the same\n\ncall: an edit whose `old_string` is not in the file any more, applied five\n\ntimes; a command that fails and is run again unchanged; a script re-run\n\nagainst the same error. Every repeat re-sends the whole conversation to the\n\nmodel, so the loop costs what the context costs, each time, and spends the\n\nfive-hour and the weekly window with it\n\n([Claude usage limits](https://caprock.dev/guides/claude-code-usage-limits/)).\n\nCaprock's rule, as `internal/config/config.go` and `internal/loop/loop.go`\n\nstate it: **5 calls of the same tool with similar input within 3 minutes raise one alert**,\n\nper session and per subagent, once per episode. \"Similar\" means the tool name\n\nand its input with numbers, hex hashes, temp paths and whitespace collapsed,\n\nand an edit's text compared on its first 200 characters, so a retry counter\n\nor a line number does not hide a loop. `description`, `timeout`, `run_in_background`\n\nare ignored. Both numbers are yours to change in `config.json`\n\n(`loop_k`, `loop_t_minutes`).\n\nTwo kinds of call never count:\n\n`Read`, `Glob`, `Grep`, `ToolSearch`, `NotebookRead`. Measured on 64,733 tool calls of one developer's history, the detector fired 436 times, and 236 of those, 54%, were a repeated Read of one file: re-reading after an edit, or while searching. A tool call is billed at $0, so none of them was about the budget; leaving them out cut the alerts to 174.\nWhat you get is one card, the same on the Now screen, in the Agent panel and\n\non the session page. It says one sentence, in the form\n\n*caprock ran the same command 5 times in 3 minutes (python3 …/p2e.py)*, with the whole input on hover and the span\n\nmeasured from the first call to the last. Under it, two figures each named\n\nfor what it is: the context those calls re-read, at cache-read rates, and the\n\nsession total. Then three actions:\n\n`[Caprock]` and ends \"(Sent by Caprock's loop alert — not by the user.)\", so the agent does not take a heads-up for an instruction from you, and it carries the exact repeated input, which the agent will recognise. Offered only for a session Caprock started; Caprock never types into a process it did not start.\nWhat to tell the agent, in your own words or the card's: name the exact call,\n\nsay it has run 5 times with the same result, and say what to do instead:\n\nread the error it is getting, try a different approach, or stop and report.\n\nEsc in the terminal does the same from the keyboard, and \"Claude keeps the work done so far.\"\n\nTo have the agent catch its own loop, install the [loop-guard\nskill](https://caprock.dev/skills/loop-guard/): when the same step fails again, it stops, names\n\nthe assumption that was wrong and changes approach.\n\nOne thing the card never says is \"stuck\". The session page's hour view\n\ncounts *×N same call*, the most-repeated identical call in six minutes, and\n\nit is worded as a measurement, not a verdict: polling a file with repeated\n\nreads looks exactly like being stuck, and only the person working knows\n\nwhich it was.\n\nThe third state is the quietest. Claude Code drew a permission dialog, or\n\nasked a question with `AskUserQuestion`, and the turn is paused until\n\nsomeone answers. In the terminal the spinner is gone and the dialog sits at\n\nthe bottom; from across the room, or from another machine, it looks like an\n\nagent that finished. The interactive-mode page notes the shape of the\n\nproblem itself: while a session waits for a usage limit to reset,\n\n\"Claude Code still asks for permissions as usual, so the task can stop on a prompt while you're away.\"\n\nCaprock stores the dialog as it is drawn. Claude Code's `PermissionRequest`\n\nhook fires for every session on the machine; Caprock forwards it and never\n\nanswers it, so the dialog appears exactly as without Caprock, and keeps it\n\nas a `permission.prompt` event. From that event the session reads *waiting for approval*,\n\nnaming the call; *waiting for your answer* for `AskUserQuestion`;\n\n*plan to approve* for a plan. A turn that ended without a dialog is\n\nread from its last message: on 4,133 turn ends on one developer's Mac, 19 August to\n\n21 October 2026, 16% ended asking something, and those read *waiting on you* too, marked as a\n\nguess you can correct.\n\nThe row on the Now screen appears once a session has waited 15 minutes by\n\ndefault: a question asked two minutes ago is not a problem. It names the\n\nsession, not only the project, and *what did it ask?* opens the question in\n\nplace. The row is one button into that session: in the desktop app its tab,\n\na terminal when Caprock started it and a read-only view when your own\n\nterminal holds it. There is no \"all clear\" state; the strip is empty when\n\nnothing is wrong, because an always-on banner teaches people to stop\n\nreading the space where the warning will appear.\n\n**Your phone hears it through your own Telegram bot.** Set up a bot in\n\nSettings and switch the alert on; it is off until you do, and free. The\n\nmessage says which agent, project and session, what happened, the folder and branch, and for a dialog the tool and the command, file, URL or question it asks about, clipped to 100 characters; a finished run adds\n\nits duration, cost, tool calls and changed files and, unless you switch it off, the first line of the final reply (120 characters). Code, diffs and tool output are never sent, and nothing is\n\nsent until you set up a bot. A needs-approval message goes at once; a\n\nfinished one after a minute with nothing new, so an owner replying at the\n\nkeyboard is never paged; at most one of a kind per session in 3 minutes and 20 an\n\nhour across all sessions. Under it, a link to the session on the address phone access listens on, left out when phone access is off.\n\nThe fix that is not one: `--dangerously-skip-permissions`. It removes the\n\nwaiting state by turning off permission prompts and safety checks, protected\n\npaths included; only ask rules and a few critical actions still prompt. The\n\npermission-modes page's own warning is to use it \"in isolated environments\n\nlike containers, VMs, or dev containers without internet access, where Claude\n\nCode cannot damage your host system.\" On a team it also removes the one\n\nmoment a person reads a command before it runs. Allow rules\n\nfor the commands you trust, auto mode, and an alert that reaches a phone\n\nanswer the same problem without it:\n\n[claude --dangerously-skip-permissions](https://caprock.dev/guides/claude-dangerously-skip-permissions/).\n\nCodex's developer-commands page for the CLI, read 30 October 2026,\n\ndocuments the controls:\n\n`codex exec resume --last`: \"Resume an exec session by ID or add --last to continue the most recent session from the current working directory.\"\nWhat the page does not list is a key that stops the turn and keeps the\n\nsession, the way Esc does in Claude Code; Ctrl + C closes it. OpenAI's\n\ntroubleshooting page covers the desktop app and says nothing about a hung\n\nCLI. What exists is the issue tracker. Three reports open on 30 October 2026,\n\nas their authors titled them:\n\nThese are reports, not facts about the product; the third is the waiting\n\nstate wearing Codex's clothes, an approval prompt that keeps coming back\n\nwhile the task sits.\n\nCaprock reads Codex's own session files and stores each tool call in the\n\nsame shape as Claude Code's, with `shell` and `exec` calls described by the\n\nline they ran, so the loop detector above runs over Codex sessions with the\n\nsame 5-in-3 rule and names the shell command on the card. A call still\n\nwithout a result when Codex's own record says the turn ended is marked\n\ninterrupted, from that record, not from a clock. Codex writes no approval\n\nprompt in a form Caprock reads, so the waiting row and the phone alert are\n\nClaude Code's for now.\n\nThe reason a loop matters is what a session spends. The heaviest session in\n\nthirty days on my Mac, 29 September to 28 October 2026, priced at API list\n\nrates as Claude Code's own `/usage` prices it:\n\nThat is 47% of the month's $7,409, in one session. It was not a loop. Checked against its own stored calls on\n\n30 October 2026: the most-repeated non-read-only call inside any\n\nthree-minute window was 18 Edits to one file, each a different edit; by the\n\ndetector's own signature the densest repeat was 7 runs of one query; 53\n\nscreenshots in all 373 hours. It was long work, at $9 an hour on average. A session that size is where the\n\ndetector earns its place: an hour of it looping costs what an hour of it\n\nworking does, and nobody at the keyboard is the one who notices.\n\nThat is also why the figure beside the loop card is labelled *session total*\n\nand never the loop's cost. The session's whole spend, bare beside \"stuck in a\n\nloop\", read as the price of the repetition: a $58.85 the loop had not cost.\n\nCharging the loop's own window instead was tried and was wrong too: measured\n\non a real 2-hour loop, its window held $47.64, every cent of it the useful\n\nwork happening alongside: the 176 repeated calls billed $0.00, the 389 turns\n\nbeside them the $47.64. So the card keeps the number what it is and says so.\n\nOn one machine the loop card is seen by whoever is looking at that machine,\n\nand a loop on a laptop whose owner went to lunch is seen by nobody until the\n\nwindow is gone. [Caprock for Teams](https://caprock.dev/teams/) moves the alert off the laptop:\n\nthe detector runs on each machine as above, and the team view shows it to\n\nanyone on the team, with the session and the repository, while the window\n\nstill has something left.\n\nThe team screen reports by work unit, not by person: cost, sessions and stuck-session counts per repository, per PR, per release, per week. A per-person view is a documented switch the team turns on\n\nknowingly, off by default, and every developer's own dashboard shows the same\n\naggregates the lead sees. What the reporter sends is what the free product\n\nalready computes, session identity, totals and the activity phrase.\n\n\"It never sends prompts, replies or tool output. That is not a setting: the payload has no field for them, so a misconfiguration cannot leak one.\"\n\n[Buying Caprock](https://caprock.dev/buy/) is one flat price for the team.\n\n*Originally published at [caprock.dev](https://caprock.dev/guides/claude-code-stuck/), where it is kept up to date.*", "url": "https://wpnews.pro/news/claude-code-stuck-hung-looping-or-waiting", "canonical_source": "https://dev.to/dspv/claude-code-stuck-hung-looping-or-waiting-5c6d", "published_at": "2026-12-02 14:39:04+00:00", "updated_at": "2026-12-02 14:45:16.581809+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-products"], "entities": ["Claude Code", "Anthropic", "Caprock", "Codex"], "also_reported_by": [], "takeaway": "A stalled Claude Code session is a hang, a loop or an unanswered prompt, and Caprock tells them apart by reading the process and event stream rather than the terminal, which renders all three as the same still screen.", "recommendation": {"advice": "Classify stalled agent sessions by their event stream, not the terminal, so you can tell a hang (Ctrl+C, then `claude --resume`) from a loop (Esc) or a waiting prompt (answer it).", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/claude-code-stuck-hung-looping-or-waiting", "markdown": "https://wpnews.pro/news/claude-code-stuck-hung-looping-or-waiting.md", "text": "https://wpnews.pro/news/claude-code-stuck-hung-looping-or-waiting.txt", "jsonld": "https://wpnews.pro/news/claude-code-stuck-hung-looping-or-waiting.jsonld"}}