Troubleshooting guide for Claude Code, Codex and Cursor
PLTroubleshooting Claude Code, Codex and Cursor starts with finding which layer failed before retrying: the installation, login and billing, usage limits, configuration (instructions, permissions, MCP servers), the conversation’s context, or the output itself. Each tool ships a health check for the first layers, and a fix counts only when the repository’s own checks pass again.
This page is for developers who use one or more of these agents every day, and for the tech lead who fields “it stopped working” messages from a team. The agent stopped halfway through a refactor with an error you have never seen. Or it keeps ignoring the rule that is plainly in AGENTS.md, or a teammate’s session bills an old API key instead of the team plan. Retrying the same prompt harder fixes none of these, and it burns your allowance.
Tool-specific depth lives elsewhere: troubleshooting a Claude Code session, Codex error recovery, Cursor error handling, and MCP connection issues. This page is the cross-tool triage that tells you which of them you need.
What this troubleshooting guide gives you
Section titled “What this troubleshooting guide gives you”- A six-layer triage table that names the failing layer in under two minutes
- The health-check commands for each tool, checked against Claude Code 2.1.283 (the
latestchannel) and codex-cli 0.157.1 on 2026-09-26 - Fixes for the failures that generate most support questions:
command not found, the wrong credential, usage limits, ignored instructions, context drift, and lost work - Three copy-paste prompts: triage before retrying, a clean hand-off to a fresh session, and proof that the recovery is sound
- A checklist for a bug report that maintainers can act on
Which layer broke? Triage before you retry
Section titled “Which layer broke? Triage before you retry”Match the symptom to a layer, run the first check, and stop at the first check that fails. Most wasted hours come from fixing a prompt when the problem was a credential, or reinstalling when the problem was context.
| Layer | Typical symptom | First check |
|---|---|---|
| Installation | command not found, an old version, a feature from the changelog missing | claude --version / codex --version, then the health check below |
| Login and billing | Login loop, 401, usage billed to the wrong account | /status or claude auth status; codex login status |
| Limits and capacity | “usage limit reached”, 429, “overloaded” | /usage in Claude Code or Codex |
| Configuration | Rules in CLAUDE.md or AGENTS.md ignored, a permission rule that “doesn’t work”, MCP tools missing | /memory and /permissions (Claude Code); /debug-config (Codex); the Rules and MCP settings (Cursor) |
| Context | Repeats work, reopens decisions, forgets a constraint from an hour ago | /context (Claude Code); /status (Codex) |
| Output | A diff that is too big, off-task, or breaks the build | git diff --stat, then your test and type-check commands |
Run the built-in health checks
Section titled “Run the built-in health checks”Each CLI has a read-only health check. Run it before you edit a setting, and again after the fix.
# Terminalclaude --version # latest and stable channels differ by about a weekclaude doctor # installation health and problems in the settings filesclaude auth status # which account and method are activeInside a session, /doctor runs a fuller checkup that can also fix what it finds, and /status shows version, model, account, API connectivity, and tool status. To test whether your own customizations cause the problem, start once with claude --safe-mode, which disables CLAUDE.md, skills, plugins, hooks and MCP servers for that session.
# Terminalcodex --versioncodex doctor # installation, config, auth and runtime healthcodex doctor --json # redacted machine-readable report for a bug reportcodex login statusInside the TUI, /status shows the session configuration and token usage, and /debug-config shows the config layers and requirement sources, which is how you find the file that overrides yours. codex --strict-config makes Codex exit on keys in config.toml that this version does not recognize, instead of silently ignoring them.
Cursor is a desktop editor, so its checks live in the UI rather than a doctor command. Open the MCP settings to see each server’s status, the Rules settings to see which rules apply, and Help > Toggle Developer Tools for the console errors behind a failed request.
cursor.com could not be reached when this page was checked on 2026-09-26, so confirm the current menu names in Cursor’s documentation. Every recovery step on this page also works with git alone.
Fix “command not found” after installing
Section titled “Fix “command not found” after installing”A new install that the shell cannot find is almost always a PATH problem or two competing binaries.
- Open a new terminal. The terminal you installed from still has the old
PATH. - Check for duplicates:
which -a claudemust print exactly one path. Two paths usually mean an old npm install alongside the native one. - If
~/.local/bin/claudeexists but is not found, add the directory toPATHin your shell profile:Terminal window echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc - Reinstall with the native installer,
curl -fsSL https://claude.ai/install.sh | bash, and confirm withclaude doctor.
Never use sudo npm install -g. On native Windows, Claude Code uses Git Bash when Git for Windows is installed and the PowerShell tool otherwise, so a missing Git no longer blocks the install. The Claude Code installation guide covers every install method and release channel.
- Open a new terminal and run
which -a codex. One path should print. - If you installed with npm and get
EACCES, fix the npm prefix or use a Node version manager rather thansudo. - Reinstall with one method only:
npm install -g @openai/codex, orbrew install --cask codexon macOS. - Confirm with
codex --versionandcodex doctor.
The Codex installation guide covers the install script and Windows.
Cursor installs as a desktop app. If it will not start after an update, quit it completely and start it again with extensions disabled, then re-enable them one at a time to find the one that breaks startup. See Cursor installation and setup.
Fix login loops and usage billed to the wrong account
Section titled “Fix login loops and usage billed to the wrong account”Most login problems are two credentials competing, not a broken login.
- Claude Code bills an API key instead of your plan. An exported
ANTHROPIC_API_KEYcan win over the subscription login. Run/statusorclaude auth status --textto see the active method, remove the variable from your shell profile, and runclaude auth login. The Claude Code authentication guide lists the full precedence order. - Codex uses a key you did not expect.
codex login statusreads the stored login in~/.codex/auth.json; theauthrow ofcodex doctoralso names keys that come from the environment. Unset staleOPENAI_API_KEYorCODEX_API_KEYvalues before you sign in again. - No browser on the machine (SSH, a container). Use
codex login --device-authfor Codex. For Claude Code, see the SSH and CI sections of its authentication guide. - A CI job fails at a login prompt. CI never uses a person’s session. Give the job an API key from the CI secret store, as the Codex authentication guide shows for
codex exec.
Never paste a key into a command line or a prompt; read it from an environment variable or a secret manager.
Why did I hit a usage limit or an “overloaded” error?
Section titled “Why did I hit a usage limit or an “overloaded” error?”Three different things produce “limit” messages, and each has a different fix.
| Message | What it means | What to do |
|---|---|---|
| Plan usage limit reached | Claude Code and Codex subscriptions meter usage in rolling five-hour and weekly windows | Run /usage in either tool: Claude Code shows what is contributing to your limits, Codex shows account usage and any usage-limit reset you can apply |
| 429 or rate limit on an API key | The API account’s own rate limit, separate from subscription windows | Slow parallel jobs down, or raise the tier in the provider console |
| “Overloaded” or 529 | The provider is at capacity; nothing is wrong with your setup | Wait and retry once. In Claude Code, --fallback-model names a model to fall back to when the default is overloaded |
The biggest self-inflicted drain is a retry loop: each retry re-sends the whole conversation. Before retrying a long session, run /compact or start fresh with the hand-off prompt below. Model choice and effort are covered on the models hub, and spending controls on Claude Code cost control and Codex cost management.
Why is the agent ignoring my instructions or permissions?
Section titled “Why is the agent ignoring my instructions or permissions?”When the agent ignores a rule, first prove the rule loaded, then prove it applies to this action.
/memorylists theCLAUDE.mdfiles in play. Claude Code readsAGENTS.mdonly when a project has noCLAUDE.md(v2.1.277 and later, both release channels on 2026-10-12)./permissionsshows each rule and the settings file it comes from. A deny rule in a file that is not loaded does nothing.- If
claude --safe-modemakes the problem disappear, the cause is one of your customizations; bisect them. The Claude Code troubleshooting page walks through the permission-rule traps.
- Since 0.150.0, an untrusted project does not supply project-level
AGENTS.md. If Codex ignores the repository’s file, check whether you trusted the project. /debug-configshows which config layer set each value, including admin constraints fromrequirements.toml./permissionsshows what Codex may do. The Codex AGENTS.md guide covers file discovery and length.
- Open the Rules settings and confirm the rule is listed and applies to the files in question.
- Keep rules short and specific. A rule the agent cannot check (“write clean code”) is not a rule.
- The Cursor project rules guide covers scoping.
A rule that must never be broken belongs in a hook, a permission rule or a CI gate, not only in prose. Permissions and sandboxing shows how to move a rule from “please” to “cannot”.
Why does the agent forget earlier decisions?
Section titled “Why does the agent forget earlier decisions?”Long sessions degrade quietly. When the context fills, the tool compacts older turns into a summary, and a decision made an hour ago can drop out of it. The symptoms are repeated work, reopened decisions and ignored constraints.
| Tool | See the usage | Summarize | Start clean |
|---|---|---|---|
| Claude Code | /context | /compact | /clear |
| Codex | /status | /compact | /new |
In Cursor, start a new chat. In every tool, starting clean works better than compacting when the task changed, provided you carry the decisions across with the hand-off note below. Read context windows for how to keep sessions small from the start.
Start the new session with “Read HANDOFF.md and continue from the next step.”
Fix an MCP server that will not connect
Section titled “Fix an MCP server that will not connect”The three checks below find most causes. Run them in order.
- Print the entry the client actually uses:
claude mcp get <name>,codex mcp get <name> --json, or the block in.cursor/mcp.json. - Run the entry’s
commandandargsin a terminal. If it exits with an error, the client fails the same way. - Check that every variable the server needs is set in the entry’s
env, and that remote OAuth is complete (/mcpin Claude Code,codex mcp login <name>in Codex).
Timeouts, spawn ENOENT, 401s on remote servers, and the CLI flags that save a broken entry are covered in MCP connection issues.
Recover work an agent overwrote
Section titled “Recover work an agent overwrote”Stop the agent first, so it does not keep “fixing” the damage. Then pick the smallest undo that covers it.
- Press Esc to stop the current turn, and run
git statusandgit diff --statto see what changed. - Undo inside the tool when the damage is recent:
- Claude Code:
/rewind, or Esc twice, restores code, conversation or both to an earlier checkpoint. - Cursor: restore the checkpoint from before the response that broke things. Checkpoints cover one chat’s file edits (Cursor’s checkpoint page could not be re-checked on 2026-09-26).
- Codex: 0.157.1 has no undo slash command, so git is the undo.
/diffshows the working-tree changes, including untracked files.
- Claude Code:
- Undo with git when the tool cannot:
git restore <path>for one file,git stashto park everything, orgit reset --hard <commit>to return to a known commit. - Recover a lost commit with
git reflog. It records whereHEADpointed, so it rescues commits, not edits you never committed. - Undo side effects by hand. No checkpoint covers what the agent did through the terminal: an applied migration, an installed package, a pushed branch.
Prevention costs one command. Commit before any large agent task, or run the agent in its own worktree (claude --worktree, codex --worktree), so the undo is always git reset to that commit. The per-tool recovery pages go further: Claude Code error recovery, Codex error recovery, and Cursor error handling.
How do you prove the fix actually worked?
Section titled “How do you prove the fix actually worked?”A fix is done when the evidence says so, not when the agent says so. You should not need to read every changed line to know.
- Re-run the thing that failed. The same command, the same health check, the same MCP tool call. Green output replaces “it should work now”.
- Run the repository’s gates. Tests, type check and lint, the same ones CI runs. A recovery that skips them has only moved the failure.
- Check the scope.
git diff --statagainst the last good commit should show only the files the fix needed. Unexpected files are the next incident. - Record it. A one-line note in the pull request or the team channel: symptom, layer, fix, evidence. The developer who ran the fix signs off; the tech lead owns any change to shared settings files.
When the same failure keeps recurring, it is a harness problem, not a bad day. The failure taxonomy shows how to classify it and pick the control that catches it earlier.
What goes wrong while troubleshooting agents?
Section titled “What goes wrong while troubleshooting agents?”The fix can do more damage than the fault. These are the traps that show up most often.
| Trap | Why it hurts | Do this instead |
|---|---|---|
| Retrying the same prompt in a loop | Each retry re-sends the whole context and drains the usage window | Triage first; compact or hand off before retrying |
Silencing permission prompts with --dangerously-skip-permissions or --dangerously-bypass-approvals-and-sandbox | Removes the only guard between the agent and your machine | Add a specific allow rule; use full bypass only in a disposable, network-restricted sandbox |
Deleting ~/.claude, ~/.codex or .cursor/ to “reset” | Loses settings, credentials, session history and MCP entries (for .cursor/: project rules and MCP config) | Use claude --safe-mode or codex doctor to isolate the cause; back up before deleting anything |
| Reinstalling with a second method | Leaves two binaries on PATH; the old one keeps winning | which -a, remove the extra one, keep one install method |
| Attaching raw debug logs to a public issue | Logs can contain paths, prompts and tokens | Use codex doctor --json (redacted) and read any log before you share it |
| Stale worktrees after a crashed parallel run | Branches stay locked and disk fills up | git worktree list, then git worktree prune |
How do I report a bug maintainers can act on?
Section titled “How do I report a bug maintainers can act on?”When the health check is green, the config is minimal, and the failure still reproduces, report it.
- Claude Code:
/feedbackor/bugsends a report from inside the session, or open an issue at anthropics/claude-code. - Codex:
/feedbacksends logs to the maintainers, or open an issue at openai/codex. - Cursor: report through the app or the Cursor forum.
Include the version, the operating system, the exact error text, the minimal steps to reproduce it (ideally with claude --safe-mode or a bare config.toml), and what you already ruled out with the triage table.
Where to go next after troubleshooting
Section titled “Where to go next after troubleshooting”- Troubleshoot a Claude Code session: permission rules,
CLAUDE.md, over-built diffs - Codex error recovery and Cursor error handling: undo and restart decisions per tool
- MCP connection issues: every MCP failure in detail
- Permissions and sandboxing: turn recurring “please don’t” into enforced rules
- Frequently asked questions: short answers on plans, models and setup
Did this guide help you?
One tap, no sign-in.
What will you do with it?
How did it read?
What got in the way? Pick any that apply
Your role?
Thanks. I read every answer. Michał Jaskólski
Did this guide help?
One tap each. Close whenever you like.
no sign-in
Frequently asked questions
What should I do first when an AI coding agent misbehaves?
Stop retrying and find the failing layer: install, login and billing, limits and capacity, configuration (instructions, permissions, MCP), context, or the output itself. Run the tool's health check first: claude doctor or /doctor in Claude Code, codex doctor in Codex.
Why is Claude Code billing an API key instead of my subscription?
An ANTHROPIC_API_KEY exported in your shell can take precedence over the subscription login. Run /status in a session or claude auth status in a terminal to see the active method, then unset the variable and log in again.
How do I recover code an agent overwrote?
Stop the agent, run git status and git diff to see the damage, then restore: /rewind (Esc Esc) in Claude Code, Cursor's checkpoints inside one chat, or git for everything else. Codex 0.157.1 has no undo slash command, so git is its undo. git reflog recovers commits, not uncommitted edits.
Why did I hit a usage limit so quickly?
Claude Code and Codex subscriptions meter usage in rolling five-hour and weekly windows. Run /usage in either tool to see what is consuming the allowance, clear or compact long sessions, and stop retry loops that re-send the same large context.