Claude Code Troubleshooting: 10 Errors & Fixes (2026)

Claude Code turns a capable developer into a faster one — but when it breaks, the failures are specific and frustrating. The revert loop that undoes a morning of progress. The context compaction that fires right as you're adding the last feature. The autonomous edit that touches five files when you only asked about one. At AppStuck, we rescue and complete apps built with AI tools including Claude Code. The errors below are the ones that appear most often in real production projects — not the basic setup issues, but the failures that block experienced developers mid-feature or corrupt a codebase that was otherwise clean. Each section covers the exact symptom, the root cause, and the specific fix — including the CLAUDE.md configurations and permission settings that prevent these issues from recurring. These aren't theoretical edge cases. They're the patterns we see in codebases that come to us after Claude Code ran further than intended, or stopped running when it was needed most. If you've worked through these fixes and your project is still stuck, AppStuck can review your codebase within 24 hours and give you a clear recovery plan.

1. Claude Code Reverts Changes It Just Made

What it looks like: You ask Claude Code to implement a feature. It makes the changes, confirms they're done. You ask for something else, and it reverts — or partially reverts — the previous changes while implementing the new request. Work you thought was completed disappears.

Why it happens: Claude Code operates within a context window. When a later instruction conflicts with an earlier assumption, or when the model re-reads a file and interprets its state differently from what it wrote, it may regenerate content that overwrites previous changes. This is more common when prompts don't reference specific file states or when the instruction implies a "clean slate" approach.

How to fix it:

  • Use git commits after each meaningful change: git add . && git commit -m "checkpoint". This gives you a recovery point and gives Claude Code a clear reference for what's already done.
  • When issuing a new instruction, explicitly state what should be preserved: "Without changing [specific file or function], add [new feature]."
  • Add a CLAUDE.md file to your project root with a "Current state" section that you update after each session, describing what's implemented and what's in progress. Claude Code reads this file automatically.
  • If changes were reverted: git diff HEAD~1 shows what changed. You can restore specific files with git checkout HEAD~1 -- path/to/file.

Quick-fix checklist

  • Commit after every meaningful change (not just at the end)
  • Explicitly state what should NOT change in each prompt
  • Use CLAUDE.md to document current project state
  • Use git diff to identify what was reverted

When to call an expert: If a revert loop has left your codebase in an inconsistent state — some files at the new version, others at the old — untangling this manually is time-consuming and error-prone. A developer can audit the git history and restore a clean state in 1-2 hours.

2. Context Compaction Fires Mid-Feature

What it looks like: You're deep in a session, implementing a complex feature across multiple files. Claude Code suddenly behaves as if it forgot earlier context — it asks questions you already answered, misses constraints you established, or generates code that contradicts decisions made earlier in the session.

Why it happens: Claude Code's context window is finite (200K tokens). When it fills up, Claude Code automatically compacts the conversation — summarising earlier context rather than keeping the full detail. After compaction, nuanced constraints and specific implementation decisions from the early session may not survive the summary accurately.

How to fix it:

  • Before starting a long session, write the key constraints and decisions into your CLAUDE.md file rather than stating them in the chat. CLAUDE.md is always loaded fresh, so its contents survive compaction.
  • Break large features into smaller, self-contained tasks that can complete within one session. Start a new session for each logical unit.
  • After compaction happens, check with: "Summarise what we've built so far and what constraints are in place." Correct any inaccuracies before proceeding.
  • Use the /compact command proactively before the window fills, so you control when it happens rather than having it trigger mid-task.

Quick-fix checklist

  • Write constraints to CLAUDE.md, not just the chat
  • Use /compact proactively between major tasks
  • Break large features into session-sized chunks
  • After compaction: verify Claude Code's understanding before continuing

When to call an expert: If context compaction happened during a critical implementation and the resulting code is in an inconsistent state across multiple files, a manual audit is faster than trying to prompt Claude Code through a recovery. A developer can review the diff and identify what needs to be fixed directly.

3. Claude Code Modifies Files Outside the Requested Scope

What it looks like: You ask Claude Code to change one component. It changes that component — and also "helpfully" refactors three other files, renames a variable it found inconsistent, or restructures a utility function. The direct change is correct but you now have unexpected modifications in files you didn't intend to touch.

Why it happens: Claude Code's agentic mode is designed to solve the full problem, which sometimes means it identifies related issues and fixes them proactively. Without explicit scope constraints, it will act on anything it determines is relevant to the task.

How to fix it:

  • Be explicit about scope in every prompt: "Only modify src/components/Button.tsx. Do not change any other files."
  • Review the list of files Claude Code plans to modify before approving: when using interactive mode, Claude Code shows a list of planned changes. Check this before allowing edits.
  • Use git diff --name-only after a session to see which files were touched. If unexpected files were modified, review those changes specifically.
  • Add scope constraints to your CLAUDE.md: "Do not modify files in src/lib/ or src/utils/ unless explicitly asked."

Quick-fix checklist

  • Name specific files in every prompt
  • Review planned file list before approving changes
  • Run git diff --name-only to audit scope after each session
  • Add off-limits directories to CLAUDE.md

When to call an expert: Out-of-scope edits in authentication, payment, or data access code can introduce security vulnerabilities even when the edits look superficially correct. If Claude Code touched sensitive code paths you didn't intend, a security review of those specific changes is worth doing before the next deploy.

4. Permission Denials Breaking the Workflow

What it looks like: Claude Code stops mid-task with a permission denial. It can't read a file, run a command, or access a tool. The workflow halts. Or it prompts for permission repeatedly on actions you've already approved, interrupting an otherwise automated session.

Why it happens: Claude Code has a layered permission system. Some actions are restricted by default for safety. Others require explicit per-session or persistent approval. In auto-accept mode, some categories of actions may still require confirmation. Configuration inconsistencies between .claude/settings.json and the actual project structure can also cause unexpected blocks.

How to fix it:

  • For persistent permissions, configure .claude/settings.json in your project root. Add tools and bash commands you trust to the allow list for that project.
  • For one-off sessions, use the --dangerously-skip-permissions flag only when you fully trust the task and have a git commit to recover from.
  • If Claude Code is repeatedly asking permission for the same action, add it to the project-level settings rather than approving per-session.
  • Check that file paths referenced in prompts match the actual filesystem structure — Claude Code may be denied access to a path that doesn't exist rather than one that's restricted.

Quick-fix checklist

  • Configure persistent permissions in .claude/settings.json
  • Verify file paths exist before referencing in prompts
  • Use --dangerously-skip-permissions only with a git safety net
  • Check Claude Code version — permission UX improved significantly in 2026 releases

When to call an expert: Permission configuration issues in CI/CD pipelines or multi-developer setups require careful thought about what access each context needs. If you're integrating Claude Code into an automated pipeline, the permission model needs to be designed deliberately.

Claude Code ran further than you expected? AppStuck can audit what changed, identify unintended modifications, and get your codebase back to a clean state. Book a free 30-minute assessment — we'll review the diff and tell you what needs attention.

5. Generated Code Conflicts with Existing Architecture

What it looks like: Claude Code builds the feature you asked for, but the implementation contradicts your existing patterns. It uses a different state management approach than the rest of the codebase, introduces a new HTTP client when you already have one, or duplicates logic that exists in a shared utility.

Why it happens: Claude Code reads the files you reference explicitly and those nearby, but it doesn't automatically scan the full codebase for existing patterns. If your utility functions, shared hooks, or base components aren't in the files Claude Code is reading, it won't know to reuse them.

How to fix it:

  • At the start of each session, provide context about existing patterns: "We use React Query for data fetching, Zustand for global state, and all API calls go through src/lib/api.ts. Use these — do not introduce alternatives."
  • Add your architectural conventions to CLAUDE.md: state management pattern, HTTP client, component structure, naming conventions. Claude Code will follow these without being reminded each session.
  • When implementing a new feature, explicitly reference the existing pattern: "Follow the same pattern as src/features/users/UserList.tsx."
  • After implementation, do a quick search for duplicate utility functions: grep -r "functionName" src/ to catch cases where Claude Code recreated existing logic.

Quick-fix checklist

  • Document architectural patterns in CLAUDE.md once, not per-session
  • Reference existing files as pattern examples in prompts
  • Search for duplicate utilities after implementation sessions
  • Review imports in new files — check for redundant dependencies

When to call an expert: Architectural inconsistency compounds over time. A codebase where half the components use Redux and half use Zustand, or where three different HTTP clients coexist, becomes progressively harder to maintain and extend. A refactor audit catches this early and establishes the patterns for subsequent AI sessions.

6. TypeScript Errors Accumulate Across Sessions

What it looks like: Each Claude Code session introduces a few TypeScript errors. Individually they look minor. After several sessions, you have 30+ type errors and the build is failing. Claude Code's fixes for the type errors introduce new ones.

Why it happens: Claude Code generates code that works at the point of writing but may not account for type changes in other files made in earlier sessions. TypeScript errors from one file propagate — a type change in a shared interface breaks every file that imports it, and Claude Code may not realise the cascade it's creating.

How to fix it:

  • Run tsc --noEmit at the end of every session to catch type errors before they accumulate. Fix them before starting the next session.
  • If you have a backlog of errors, use Claude Code specifically to fix TypeScript issues: "Run tsc --noEmit and fix all type errors, starting with the ones in shared interfaces and working outward."
  • When changing a shared type or interface, explicitly ask Claude Code to check for affected files: "What other files import UserType? Update them to match the new type definition."
  • Enable strict mode in tsconfig.json if you haven't — catching errors early at the type level prevents them from cascading.

Quick-fix checklist

  • Run tsc --noEmit at the end of every Claude Code session
  • Fix type errors before starting a new session, not after
  • When changing shared types, ask Claude Code to audit affected files
  • Enable strict TypeScript mode to catch issues earlier

When to call an expert: A large TypeScript error backlog in a codebase with many shared types is a systematic problem, not a collection of individual bugs. A developer can audit the type architecture and establish a clean baseline in a way that makes subsequent AI sessions less likely to re-introduce the same issues.

7. Claude Code Gets Confused by Monorepo Structure

What it looks like: Your project is a monorepo with multiple packages (frontend, backend, shared types). Claude Code edits the wrong package, uses the wrong package's imports, runs commands from the wrong directory, or can't find files it should be able to locate.

Why it happens: Monorepos have implicit structure that Claude Code needs to be told about explicitly. It doesn't automatically understand that packages/web/src and packages/api/src are separate applications, or that packages/shared/types is the single source of truth for types used across both.

How to fix it:

  • Create a CLAUDE.md in the monorepo root that describes the package structure: what each package is, how they relate, and which commands to run from which directory.
  • For each Claude Code session, explicitly state which package you're working in: "We are working in packages/web. All imports should use the @repo/shared package for shared types."
  • Specify the working directory when asking Claude Code to run commands: "Run this command from packages/api: npm run build."
  • If Claude Code is modifying the wrong package, stop and clarify: "You modified packages/api/src/users.ts. The change should have been in packages/web/src/pages/users.tsx."

Quick-fix checklist

  • Add monorepo structure documentation to root CLAUDE.md
  • State the target package explicitly at the start of each session
  • Specify working directory for all terminal commands
  • Reference package names in imports, not relative paths

When to call an expert: Monorepo setups that have been worked on by Claude Code without clear structure documentation often develop cross-package inconsistencies — type mismatches, duplicated utilities, conflicting versions of shared dependencies. A developer can audit and clean this up, then set up the CLAUDE.md conventions that prevent it recurring.

8. Token Limits Hit on Large Codebases

What it looks like: Claude Code refuses to read certain files or truncates its analysis. It can't hold the full context of a large feature in one session. Tasks that work on smaller projects fail on yours because there's too much code to fit in the context window.

Why it happens: Claude Code's 200K token context window is large but not unlimited. A codebase with 100+ files, each a few hundred lines, can exhaust the available context when Claude Code tries to read everything relevant to a complex task.

How to fix it:

  • Guide Claude Code to read only the files directly relevant to the task: "Read only src/auth/ and src/middleware/ — ignore everything else for this task."
  • For large refactors, break them into file-by-file tasks rather than "refactor the entire auth system."
  • Use .claudeignore to exclude directories Claude Code shouldn't read: node_modules/, dist/, .git/, and any generated files.
  • Keep CLAUDE.md concise — a very long CLAUDE.md consumes token budget that could be used for actual code.

Quick-fix checklist

  • Direct Claude Code to specific files, not the whole codebase
  • Add a .claudeignore for generated and irrelevant directories
  • Break large tasks into per-file or per-module sessions
  • Keep CLAUDE.md concise — it counts against context budget

When to call an expert: Large codebase work that requires holding the full architecture in context — major refactors, security audits, performance optimisation — benefits from a developer who can read the full codebase independently and direct Claude Code at specific targeted tasks rather than asking it to reason about the whole system.

9. Claude Code and Cursor Running on the Same Project

What it looks like: You use both Claude Code (for autonomous multi-file tasks) and Cursor (for in-editor suggestions and quick edits) on the same project. They start contradicting each other — Cursor suggests reverting what Claude Code just did, or Claude Code overwrites Cursor's edits because it read an older version of the file.

Why it happens: Claude Code and Cursor operate independently on the filesystem. Neither knows what the other did. If Claude Code starts a session with a stale read of a file that Cursor modified, it will write based on the old state. Compound this over multiple sessions and you get genuine conflicts that neither tool can resolve.

How to fix it:

  • Establish clear boundaries: use Claude Code for autonomous multi-file tasks and major feature implementations. Use Cursor for in-editor completions and quick single-file edits.
  • Commit all Cursor changes before starting a Claude Code session. This ensures Claude Code reads the current state of every file.
  • Don't run both tools simultaneously on the same files — decide which tool owns a task before starting it.
  • If conflicts have already accumulated: git log --oneline -20 to see the recent history. Identify the last clean commit and review what each tool changed since then.

Quick-fix checklist

  • Commit all changes before switching between tools
  • Define which tool owns which type of task
  • Never run both tools on the same files simultaneously
  • Use git history to untangle conflicts if they've accumulated

When to call an expert: A codebase that's been worked on by multiple AI tools without clear boundaries often has inconsistent patterns that are hard to trace. If you're not sure what each tool changed or why, a developer can audit the git history and establish a clean state. See our Cursor troubleshooting guide for Cursor-specific issues.

10. Autonomous Changes That Are Hard to Audit or Revert

What it looks like: Claude Code ran an agentic session — it read files, made changes, ran commands. The output looks right, but you're not sure exactly what it changed or why. A week later, something breaks and you can't trace it back to the Claude Code session without significant effort.

Why it happens: Claude Code's agentic mode is designed for autonomous multi-step work. Without a discipline of committing between steps, the changes from an entire session appear as one large diff that's hard to decompose into logical units.

How to fix it:

  • Instruct Claude Code to commit after each logical step: "After each major change, run git add -p and commit with a message describing what changed and why."
  • Use Claude Code's /summarise command at the end of a session to get a description of everything it did — paste this into the final commit message or a session log.
  • For complex agentic tasks, review the diff before committing: git diff shows all changes. If a change you didn't expect appears, ask Claude Code to explain it before accepting.
  • Keep agentic sessions focused on one concern at a time. "Fix the auth bug" is reviewable. "Refactor auth, add tests, and clean up the database layer" is not.

Quick-fix checklist

  • Ask Claude Code to commit after each logical step
  • Review git diff before accepting agentic session results
  • Keep agentic tasks focused on one concern at a time
  • Use /summarise for a session log you can reference later

When to call an expert: If a Claude Code session produced changes you can't fully audit and something has broken in production, a developer can trace the issue through the git history, identify the specific change that caused it, and implement a targeted fix — without requiring a full revert of the session's work.

Still stuck after trying these fixes? AppStuck rescues and completes apps built with AI coding tools including Claude Code. We've fixed all of these issues in real production codebases. Book a free 30-minute assessment and we'll review your codebase and tell you exactly what it needs to get back on track.

```

Need Help with Your AI Project?

If you're dealing with a stuck AI-generated project, we're here to help. Get your free consultation today.

Get Free Consultation