Claude Code --safe-mode Flag: When and Why to Use It (June 2026)
Claude Code —safe-mode Flag: When and Why to Use It (June 2026)
Claude Code v2.1.169 (June 8, 2026) added the —safe-mode flag, which launches Claude Code with all customizations disabled. This page covers what —safe-mode actually disables, the debugging scenarios it solves, the safety-sensitive scenarios it enables, and when to use it vs other approaches.
Last verified: June 16, 2026.
TL;DR
- What: Launch Claude Code with all customizations off — no Skills, no MCP servers, no CLAUDE.md, no agents directory, no slash-command overrides.
- How:
claude --safe-modeor set env varCLAUDECODESAFEMODE=1. - When for debugging: Any time Claude Code behaves unexpectedly and you need to bisect core vs customizations.
- When for safety: Any session where you want full isolation from project context — sensitive client work, security audits, prompt-injection investigation.
- Alternatives: Sometimes still useful to actually delete the customization that’s causing problems after —safe-mode confirms it.
What —safe-mode actually disables
Per the Claude Code v2.1.169 release notes:
| Customization | Disabled? |
|---|---|
Custom Skills (.claude/skills/) | Yes |
MCP server connections (.mcp.json) | Yes |
| Project CLAUDE.md | Yes |
.claude/agents/ directory | Yes |
| Custom slash-command overrides | Yes |
| User-level claude.md | Yes |
| Built-in slash commands | No, still work |
| Built-in tools (Read, Write, Edit, exec, etc.) | No, still work |
| Anthropic system prompt | No, still active |
So you get vanilla Claude Code — the built-in behavior, no project or user customizations layered on. Quitting without the flag restores everything to normal.
Debugging scenarios where —safe-mode helps
Scenario 1: Claude is making weird decisions
You ask Claude Code to refactor a function and it tries to delete the entire file. You ask it to add tests and it modifies unrelated code. You ask it to commit and it pushes to main against your wishes.
Root cause is almost always a Skill or CLAUDE.md instruction telling Claude to do something you forgot you wrote. Run with —safe-mode. If the weird behavior goes away, you know it’s a customization. Bisect by re-enabling things one at a time. The fastest bisect: start by adding back just CLAUDE.md (the highest-frequency culprit), then Skills, then MCP servers, then agents.
Scenario 2: Claude is hanging or timing out
Claude Code hangs on startup, or takes 30 seconds to respond to the first prompt, or returns mysterious errors. Run with —safe-mode. If startup is now fast, you have an MCP server that’s slow or crashing. Disconnect MCP servers one by one (or check the .mcp.json file for ones you don’t recognize) to find the culprit.
This was a common debugging path even before —safe-mode existed; the difference is —safe-mode is now the one-step diagnostic instead of manually editing config files.
Scenario 3: Slash commands don’t work
You type /something and either get an error or nothing happens. Custom slash-command overrides in .claude/commands/ can shadow built-in commands. Run with —safe-mode to confirm whether the issue is in your override or in the built-in.
Scenario 4: Skills not loading when expected
You expected a Skill to load on a particular kind of task and it didn’t. Run with —safe-mode (which disables Skills entirely) to confirm Claude’s default behavior on the task, then run without —safe-mode to see what the Skill changes. The before-after comparison tells you whether the Skill is loading at all and whether its instructions are having the intended effect.
Safety-sensitive scenarios where —safe-mode helps
Sensitive client work
You’re working on a project for Client A, your CLAUDE.md and Skills reference Client A’s stack, conventions, and people. You want to spin up a Claude Code session for Client B without any of that context bleeding in. Run —safe-mode. Vanilla Claude Code with no project context. When you’re done, quit without the flag and your customizations come back for the next session.
Security audits or pen-testing adjacent work
You want zero ambient context for an audit. You don’t want Claude to pre-load assumptions about the codebase that might mask vulnerabilities. —safe-mode strips all of that.
This is not the same as Claude being more secure; —safe-mode doesn’t change Anthropic’s underlying safety behaviors. It just removes your project customizations from the context. For genuinely security-sensitive work, layer —safe-mode with a sandboxed environment, restricted filesystem access, and explicit pre-prompt-injection mitigations.
Investigating prompt injection
You suspect a Skill, CLAUDE.md, or MCP server output is doing prompt-injection-style manipulation. Run —safe-mode. If the weird behavior goes away, the injection vector is in your customizations. Bisect to find it.
Prompt injection through MCP servers specifically is an underrated risk in mid-2026. MCP servers return tool outputs that get spliced into Claude’s context. A malicious or compromised MCP server can return outputs crafted to manipulate Claude. —safe-mode is the diagnostic step that rules this out.
When —safe-mode is the wrong answer
When you want to selectively disable just one customization
—safe-mode is the nuclear option. If you only want to disable Skills (and keep MCP servers and CLAUDE.md), you’ll need to manually move the .claude/skills/ directory aside or use the per-Skill enable/disable. —safe-mode disables everything; that’s not always what you want.
When you want to keep customizations but reset Claude’s context
Sometimes Claude has loaded a bad assumption mid-session and you want to start fresh. —safe-mode helps if the bad assumption came from a customization; it doesn’t help if the bad assumption was generated inside the conversation itself. For mid-session context reset, you just need a new session, with or without —safe-mode.
When the actual issue is the model or rate limits
—safe-mode disables your customizations but does not change which model Claude Code is using or whether Anthropic’s API is responding. If you’re hitting elevated errors (see status.claude.com), —safe-mode won’t help. Diagnose the model/API issue first.
How to use it in practice
The minimal commands:
# Launch with safe-mode
claude --safe-mode
# Or with env var
CLAUDECODESAFEMODE=1 claude
# Verify by checking what Claude knows about your project
> What do you know about this project from CLAUDE.md or Skills?
In safe-mode, the third command should produce a response indicating no project-specific knowledge is loaded. If Claude still reports knowing your project, something is wrong with —safe-mode itself (or there’s a customization location it doesn’t recognize). File a bug.
Workflow recommendation
For debugging unexpected behavior:
- Reproduce the issue without —safe-mode (you already did this when you noticed it).
- Run the same task with —safe-mode.
- If reproduces in —safe-mode: it’s a Claude Code core issue. File a bug at the Claude Code repo with the exact reproduction.
- If doesn’t reproduce in —safe-mode: it’s in your customizations. Bisect — re-enable CLAUDE.md, then Skills, then MCP servers, then agents, running the task each time. The first customization that brings the issue back is the culprit.
- Fix the culprit. Re-test without —safe-mode to confirm fixed.
This is the standard bisect debugging workflow. —safe-mode just makes the “everything off” step easy.
Bottom line
—safe-mode is a small feature that solves a real debugging problem. It is the bisect step you reach for when Claude Code is misbehaving and you don’t know if the issue is core or customizations. It is also useful as a session-isolation tool for sensitive work where you don’t want project context loaded.
It is not a magic safety button. It does not make Claude Code more secure in the traditional sense — it just isolates your customizations. For genuinely security-sensitive work, combine it with sandboxed environments and explicit defenses against the prompt-injection vectors that MCP servers can introduce.
Use it. It’s a five-character flag that saves you hours when something goes weird.
See also
- Claude Code background sub-agents vs Skills vs Dynamic Workflows (June 2026)
- Cursor 3.7 vs Cursor 4 vs Windsurf vs Claude Code (June 2026)
- Dynamic Workflows 1000 sub-agents cap explained (June 2026)
Last verified: June 16, 2026.