Claude Code Prettier Format Conflict (2026)

The Error

[warn] src/components/Button.tsx
[warn] Code style issues found in the above file. Run Prettier to fix.
# Or after Claude Code edits a file:
error: You have unstaged changes. Please commit or stash them.
  (Prettier reformatted files that Claude Code just wrote)
# Or in pre-commit:
✖ prettier --check failed without output (SIGKILL)
  src/utils/helpers.ts — Formatting differs from Prettier config

The Fix

  1. Tell Claude Code about your Prettier config in CLAUDE.md
# Check your current Prettier settings
cat .prettierrc 2>/dev/null || cat .prettierrc.json 2>/dev/null || echo "No .prettierrc found"
# Add formatting rules to CLAUDE.md
cat >> CLAUDE.md << 'EOF'
## Code Formatting
- Use single quotes (singleQuote: true)
- Tab width: 2 spaces
- Semicolons: required
- Trailing commas: all
- Print width: 80
- Always match the format in .prettierrc
EOF
  1. Auto-format Claude Code output with a hook
# Add to .claude/settings.json or use a post-edit hook:
# After Claude edits files, run Prettier automatically
npx prettier --write "src/**/*.{ts,tsx,js,jsx}" --config .prettierrc
  1. Verify the fix:
npx prettier --check "src/**/*.{ts,tsx}" 2>&1 | tail -5
# Expected: All matched files use Prettier code style!

Why This Happens

Claude Code generates code based on patterns in its training data, which may default to different formatting conventions than your project’s Prettier configuration. For example, Claude might output double quotes when your .prettierrc specifies single quotes, or use 4-space indentation when your project uses 2. Since Prettier is opinionated and deterministic, any deviation from your config is flagged as an error during checks. The conflict appears in pre-commit hooks, CI pipelines, or manual prettier --check runs.

If That Doesn’t Work

  • Alternative 1: Set up lint-staged to auto-format on commit: "*.{ts,tsx}": ["prettier --write"] in package.json
  • Alternative 2: Use the VS Code Prettier extension with format-on-save to catch issues immediately
  • Check: Run npx prettier --find-config-path src/file.ts to confirm Prettier is finding your config file

Prevention

Add to your CLAUDE.md:

Format all code according to this project's .prettierrc: single quotes, 2-space indent, semicolons, trailing commas. Run `npx prettier --write` on every file you create or modify. Never override .prettierrc settings.

Related articles: ESLint Prettier Conflict Fix, Git Hook Pre-commit Conflict, Verbose Mode Debugging

This fix also applies if you see variations of this error:

  • Connection or process errors with similar root causes in the same subsystem
  • Timeout variants where the operation starts but does not complete
  • Permission variants where access is denied to the same resource
  • Configuration variants where the same setting is missing or malformed

If your specific error message differs slightly from the one shown above, the fix is likely the same. The key indicator is the operation that failed (shown in the stack trace) rather than the exact wording of the message.

Frequently Asked Questions

Does this error affect all operating systems?

This error can occur on macOS, Linux, and Windows (WSL). The exact error message may differ slightly between platforms, but the root cause and fix are the same. macOS users may see additional Gatekeeper or notarization prompts. Linux users should check that the relevant system packages are installed. Windows users should ensure they are running inside WSL2, not native Windows.

Will this error come back after updating Claude Code?

Updates can occasionally reintroduce this error if the update changes default configurations or dependency requirements. After updating Claude Code, verify your project still builds and runs correctly. If the error returns, reapply the fix and check the changelog for breaking changes.

Can this error cause data loss?

No, this error occurs before or during an operation and does not corrupt existing files. Claude Code’s edit operations are atomic — they either complete fully or not at all. However, if the error occurs during a multi-step operation, you may have partial changes that need to be reviewed with git diff before continuing.

How do I report this error to Anthropic if the fix does not work?

Open an issue at github.com/anthropics/claude-code with: (1) the full error message including stack trace, (2) your Node.js version (node --version), (3) your Claude Code version (claude --version), (4) your operating system and version, and (5) the command or operation that triggered the error.

Configure permissions → Build your settings with our Permission Configurator.

Try it: Paste your error into our Error Diagnostic for an instant fix.