Home › All prompts › Claude Code Code Mode: Try It Without Breaking Your Safety Checks
Mini pack
Free
Claude Code Code Mode: Try It Without Breaking Your Safety Checks
Claude Code has a new experimental feature called Code Mode, and the docs say it is experimental, off by default, and may change or be removed in any release. These 9 free prompts help you check whether it suits your work and your setup, try it for one session, make sure your permission rules and PreToolUse hooks still catch chained commands, and write down when to use it.
Find out if Code Mode fits your work, try it for one session, make sure your permission rules and PreToolUse hooks still catch what they should, and write down when to use it.
9 prompts in 4 sections. Replace everything in [BRACKETS IN CAPS], then copy and paste into your AI tool.
Claude Code: all 9 prompts are pasted into Claude Code in the terminal, opened in the reader's project, and each one tells Claude to read the official Code Mode page (code.claude.com/docs/en/code-mode) first, use only code.claude.com pages for settings, versions and availability, and stop if it can't open the page. Prompts 1.1, 1.2, 2.1 and 3.1 only read and report; 2.2 runs one read-only task in a normal session and in a Code Mode session for comparison; 3.2 (a PreToolUse hook that checks every part of a chained command), 3.3 (an ask rule for REPL), 4.1 (a PostToolUse redaction hook on REPL, tested with a fake value) and 4.2 (a short CLAUDE.md note) show the change first and wait for a "go". No prompt turns Code Mode on; the reader does that in their own shell. Keys and tokens are reported as present or not, never printed. The core rule: get your rules and hooks ready before you try Code Mode.
Code Mode: experimental, off by default and may change or be removed in any release; Claude writes JavaScript that makes several tool calls in one step and Claude Code runs it in the session; CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in the shell or the env block of ~/.claude/settings.json (ignored in project settings files; a 0 anywhere keeps it off); first-run confirmation and the "Code Mode (experimental) is on" line; Ctrl+O to read Code rows; resume only with Code Mode on; requirements (v2.1.323 or later at the time of checking, interactive terminal session, native build, supported models, no gateway); rules and PreToolUse hooks written under the tool's usual name; hooks may see chained commands like cd 'app' && git push; REPL hooks read tool_input.code; ask rule for REPL; onFailure "block"; PostToolUse redaction with updatedToolOutput; UserPromptSubmit hooks no longer receive code output on newer versions; sandbox covers shell commands only. All checked against Anthropic's Code Mode, hooks, permissions, permission modes and tools reference pages on Nov 25, 2026.
Left out: every X post (none quoted or summarized), OpenTelemetry monitoring, organization-wide blocking through managed settings, agent teams, mods, cloud provider sign-in details and the full troubleshooting table (readers are pointed to the docs page).
Not repeated here: first-time permission rules and hooks point to Claude Code Guardrails (2.1 for secret files, 2.2 for risky commands, Section 3 for hooks in general); long runs while away to Leave Claude Code Running Without It Getting Stuck; reading session history afterwards to What Did My Agent Actually Do?; model choice to Use the Cheap Model for the Easy Stuff.
No stats or X claims: no numbers beyond Anthropic's own documented versions and limits, no X posts quoted, and no affiliate or sponsor copy.
Written for use with Claude Code. Not yet tested against it.
Use this when you've heard about Code Mode and want a plain explanation of what it does differently. It's for deciding whether your kind of work would benefit, and which of its limits would bother you.
Fill in: [WHAT I USUALLY ASK CLAUDE CODE TO DO] (e.g. "small bug fixes, renaming things across many files, running tests"), [HOW I USUALLY WORK] (e.g. "I approve each step", "auto mode", "I resume old sessions a lot", "I use the VS Code panel").
Don't change any files and don't turn anything on. First read the official Claude Code page about Code Mode: https://code.claude.com/docs/en/code-mode. Use only that page and other code.claude.com pages for facts. If you can't open it, tell me and stop.
What I usually ask you to do: [WHAT I USUALLY ASK CLAUDE CODE TO DO]
How I usually work: [HOW I USUALLY WORK]
Please:
1. Explain in plain words, in 5 sentences or fewer, how Code Mode changes the way you use your tools, compared with normal mode.
2. Tell me what the page says about whether it's experimental, on or off by default, and whether it may change.
3. Go through the kinds of tasks the page says Code Mode suits, and tell me which of my usual tasks fit and which don't.
4. Go through every limit the page lists, and mark each one "affects me", "doesn't affect me" or "not sure", based on how I work.
5. Give me a one-line verdict: worth trying, try it later, or skip it for now, with the main reason.
Quote the page for anything about settings, versions or availability. If the page doesn't say something, write "the docs don't say". Then stop.
Tips to customize: If the verdict is "skip it for now", that's a fine answer. Code Mode is off by default, so nothing changes until you turn it on. If you rely on resuming old sessions, read the resume limit closely: the docs say a Code Mode session can only be resumed with Code Mode on.
1.2 Can My Setup Run Code Mode?
Untested: not yet run against a model.
Use this when you want to try Code Mode and need to know if your version, model and setup meet the requirements first. It's for a simple pass, fail or "check yourself" list, without changing anything.
Don't change any files or settings and don't update anything. First read the Requirements section of https://code.claude.com/docs/en/code-mode. Use only that page for the requirements. If you can't open it, tell me and stop.
My computer: [MY COMPUTER]
How I sign in: [HOW I SIGN IN]
Please check my setup against every requirement on the page:
1. Run claude --version and compare it with the version the page asks for, for my kind of setup.
2. Check what you can safely see yourself: how Claude Code is installed, which model this session uses, whether I'm in an interactive terminal session, and any settings the page says block Code Mode (like an API key helper or a gateway).
3. For keys and tokens, only tell me whether a setting is present or not. Never print its value, not even part of it.
4. For anything you can't check yourself (like my organization's settings), write "check yourself" and tell me where to look or who to ask.
5. Put it all in a table: requirement, what you found, pass, fail or check yourself.
6. For each fail, tell me the fix the page gives. Don't apply it.
Then stop.
Tips to customize: When we checked on Nov 25, 2026, the docs listed Claude Code v2.1.323 or later and an interactive claude session in a terminal (not the VS Code panel, the Desktop app or cloud sessions). These can change, so trust the page over this tip. If an update is needed, run claude update yourself. If Code Mode won't start later, the page has a troubleshooting table that matches the reason shown at the top of your session to a fix.
Section 2: Try It for One Session
2.1 My Steps to Try Code Mode Once, and Turn It Off
Untested: not yet run against a model.
Use this when your setup passes the checks and you want the exact steps for your computer, written down before you start. It's for trying Code Mode in one session only, with a clear way back.
Fill in: [MY COMPUTER] (e.g. "Mac", "Windows PowerShell", "Linux", "WSL").
Don't change any files or settings, and don't turn Code Mode on. First read the "Try Code Mode" and "Turn off Code Mode" parts of https://code.claude.com/docs/en/code-mode. Use only that page for setting names and steps. If you can't open it, tell me and stop.
My computer: [MY COMPUTER]
Write me a short step-by-step card I can follow in my own terminal:
1. How to start one Claude Code session with Code Mode on for my computer, using the shell method from the page (not the settings file, so it lasts only for that session).
2. What I'll be asked to confirm the first time, and the exact line the page says I'll see near the top of the session when it's on.
3. What to do if I see a different line or none.
4. How to see the code you write during the session.
5. How to turn Code Mode off again, including what the page says about a "0" value.
6. What the page warns about resuming a Code Mode session later.
7. Why setting it in this project's settings files won't work, according to the page.
Keep it under 20 lines. Then stop.
Tips to customize: When we checked on Nov 25, 2026, the docs said to start one session on Mac, Linux or WSL with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude. Check the page in case that has changed. Save the card somewhere outside your project, or just keep this chat open. The docs say Claude Code ignores this setting in a project's settings files, so a repository you clone can't turn on Code Mode for you. Turning it on in ~/.claude/settings.json makes it the default for every new session, so start with the shell method until you've decided you like it.
2.2 Same Task, With and Without Code Mode
Untested: not yet run against a model.
Use this when you want to see the difference for yourself on a small, safe task. It's for running the same read-only job in a normal session and in a Code Mode session, then comparing.
Fill in: [A SMALL READ-ONLY TASK] (e.g. "Read every Markdown file in this project and list links to local files that don't exist"), [WHICH SESSION THIS IS] ("normal mode" or "Code Mode").
This is a test run. Don't edit, create or delete any files, and don't run any command that changes something. Only read and report.
The task: [A SMALL READ-ONLY TASK]
This session is: [WHICH SESSION THIS IS]
Do the task, then add a short report at the end:
1. The answer to the task.
2. Roughly how many tool calls you made, and which tools (Bash, Read, Grep and so on).
3. Every command you ran, in one list.
4. Anything you skipped or weren't sure about.
5. If this is the Code Mode session, one plain sentence on what your code did in each step.
If you find anything that looks like a key, token or password, don't print it. Write "(hidden)" instead.
Tips to customize: Paste the exact same prompt into two separate sessions: one normal, one started with Code Mode on (Prompt 2.1). The task example above comes from Claude Code's own docs. In the Code Mode session, press Ctrl+O to open the transcript viewer, expand a Code row to read the JavaScript, and press Ctrl+O again to go back. Then paste both reports into either session and say: "Compare these two runs: answers, tool calls, commands and anything that looks wrong."
Section 3: Keep Your Rules and Hooks Working
3.1 Which of My Rules and Hooks Could Miss Something?
Untested: not yet run against a model.
Use this when you already have permission rules or PreToolUse hooks and want to know which ones could miss a command inside Claude's code. It's for a read-only check of every rule and hook, before you turn Code Mode on.
Fill in: [WHAT MY CHECKS MUST STOP] (e.g. "git push, deleting files, reading .env, my database reset script").
Don't change any files or settings. First read https://code.claude.com/docs/en/code-mode (the Permission checks and hooks parts) and the compound commands part of https://code.claude.com/docs/en/permissions. Use only code.claude.com pages for facts. If you can't open them, tell me and stop.
What my checks must stop: [WHAT MY CHECKS MUST STOP]
Please:
1. List every permission rule (allow, ask, deny) and every PreToolUse and PostToolUse hook that's active here, and which settings file each comes from.
2. For each hook script, read it and explain in one plain sentence how it decides. Flag any hook that only checks how a command starts, or matches the whole command text exactly, because the docs say a command can arrive chained, like "cd 'app' && git push".
3. Flag anything that would stop working or change in Code Mode, based on the docs. For example: a deny rule on REPL, a hook with no "onFailure" setting that I rely on to block things, or a UserPromptSubmit hook that I use to check output.
4. Check each item in my list above against my rules and hooks, and say which ones aren't covered at all.
5. Give me a table: rule or hook, what it protects, risk in Code Mode (high, medium, low), and why.
Don't print the contents of any secret file. Then stop.
Tips to customize: The docs say Bash permission rules already split chained commands, so a deny or ask rule like Bash(git push *) still applies when git push is one part of a longer line. Your own hook scripts don't get that for free: they see whatever command text arrives, so they need to split it themselves (Prompt 3.2). The docs also warn that Bash rules match command text, so a command written in a different form can still get past them, with or without Code Mode. For limits that don't depend on command text, the docs point to sandboxing.
3.2 Make My Hook Check Each Part of a Command
Untested: not yet run against a model.
Use this when Prompt 3.1 flagged a PreToolUse hook that only checks how a command starts. It's for rewriting that hook so it checks every part of a chained command, then proving it with safe tests.
Fill in: [MY HOOK SCRIPT PATH] (e.g. ".claude/hooks/block-push.sh"), [WHAT IT MUST BLOCK] (e.g. "git push and rm -rf"), [WHAT IT MUST ALLOW] (e.g. "git status and npm test").
Help me make one PreToolUse hook check every part of a shell command, as the Claude Code docs recommend for Code Mode. First read the hooks parts of https://code.claude.com/docs/en/code-mode and https://code.claude.com/docs/en/hooks. Use only code.claude.com pages for facts.
My hook script: [MY HOOK SCRIPT PATH]
It must block: [WHAT IT MUST BLOCK]
It must allow: [WHAT IT MUST ALLOW]
Please:
1. Explain in plain words what the hook does now and what it would miss, using the docs' example "cd 'app' && git push".
2. Rewrite it so it splits the command on the separators the permissions docs list (like &&, ||, ;, | and new lines) and checks each part on its own. Keep my current language and the way it reports a block.
3. Tell me honestly what it still won't catch, like a command hidden inside another program.
4. Tell me whether to set "onFailure": "block" on this hook, and what the docs say happens when a hook times out or fails with and without it.
5. Show me the full new script and any settings change, and wait for my "go" before saving.
6. After saving, test it without running any real command: pipe sample JSON into the script, like the hooks docs show, for three cases: a plain blocked command, the same command chained after "cd 'app' &&", and an allowed command. Report each as expected result, real result, pass or fail.
Tips to customize: The tests only feed text into your script, so nothing actually gets pushed or deleted. If a test fails, ask: "Show me the exact text the hook received and why it didn't match." If you have hooks for MCP tools too, the docs say Code Mode calls them under their usual names, so your existing matchers still apply. Run the three tests again whenever you edit the hook or update Claude Code.
3.3 Approve Each Piece of Code Before It Runs
Untested: not yet run against a model.
Use this when you want to read Claude's code and say yes or no before it starts, at least while you're getting used to Code Mode. It's for adding one ask rule for REPL and knowing how to answer the prompts.
Fill in: [MY USUAL PERMISSION MODE] (e.g. "manual, I approve things", "accept edits", "auto mode", "not sure").
Help me set Claude Code to ask me before running each piece of code in Code Mode. First read the "Approve each piece of code first" and "Answer a permission prompt while code runs" parts of https://code.claude.com/docs/en/code-mode. Use only that page for the rule and how prompts work.
My usual permission mode: [MY USUAL PERMISSION MODE]
Please:
1. Explain in plain words what an ask rule for REPL does, and what changes if I approve code in my permission mode, according to the page.
2. Show me the exact rule and the settings file the page saves it in. Keep everything already in that file, and show me the final file before saving.
3. Tell me how to read the code before I answer, since the page says the prompt itself doesn't include it.
4. Explain the difference between answering No, No with a comment, and pressing Esc while code runs.
5. Tell me what the page says to do if the code can't start a subagent with this rule on.
Wait for my "go" before saving anything.
Tips to customize: The docs save this rule in ~/.claude/settings.json, your personal settings, so it applies to every project on your computer. If the code is hard to read, ask: "Before I approve, explain this code in plain words, one line per step." If you work in auto mode, the docs say the classifier reviews each piece of code, not each tool call, and it can't see values worked out while the code runs. So keep your deny and ask rules for anything you must control, like git push (Claude Code Guardrails Prompt 2.2 sets those up). Once you trust it, you can remove the REPL rule and rely on those.
Section 4: Check What Comes Back, and Write It Down
4.1 Hide Secrets in What the Code Returns
Untested: not yet run against a model.
Use this when you worry that Claude's code could read a file with a key in it and pass that value back into the chat. It's for a PostToolUse hook on REPL that replaces secrets with placeholder text, tested with a fake value.
Fill in: [WHAT COUNTS AS A SECRET HERE] (e.g. "API keys, tokens, anything after 'password='"), [MY PREFERRED SCRIPT LANGUAGE] (e.g. "bash with jq", "Node", "Python", "you pick").
Help me write a PostToolUse hook that hides secrets in what Code Mode code returns. First read the "Check code output with a hook" part of https://code.claude.com/docs/en/code-mode. Use only that page and https://code.claude.com/docs/en/hooks for field names and output format.
What counts as a secret here: [WHAT COUNTS AS A SECRET HERE]
Script language: [MY PREFERRED SCRIPT LANGUAGE]
Please:
1. Explain in plain words which fields of the code's output the page says to redact, and why the copy has to keep the same shape.
2. Write the hook script and the settings entry that matches REPL. Replace each secret with the word REDACTED.
3. Make it handle the cases the page lists: a missing result, an error, and what to return when the hook blocks or hits an error.
4. Tell me what the page says this hook can't hide.
5. Show me everything and wait for my "go" before saving.
6. To test it, create a test file containing only the fake value FAKE-TOKEN-12345, never a real key. Tell me the prompt to send in a Code Mode session to check that the reply shows REDACTED, then delete the test file when I say the test is done.
Never open, print or copy any real secret file, like .env, while doing this.
Tips to customize: The docs warn not to rely on this hook to hide a value inside a refused tool call's input, such as a Bash command, because that can be repeated back to Claude unchanged. It's a second layer, not the first: the best fix is still to keep Claude from reading secret files at all (Claude Code Guardrails Prompt 2.1). If you used to check output with a UserPromptSubmit hook, the docs say to move that check to a PostToolUse hook, because newer versions don't send code output to UserPromptSubmit hooks.
4.2 A Short Note: When to Use Code Mode, and When Not To
Untested: not yet run against a model.
Use this when you've tried Code Mode and want to remember what you decided. It's for a short note in your project's CLAUDE.md about when Code Mode helps, when to stay in normal mode, and what to check first.
Fill in: [WHAT I LEARNED FROM TRYING IT] (e.g. "great for renaming across files, confusing for small fixes"), [MY SAFETY CHECKS FOR CODE MODE] (e.g. "ask rule on REPL, hook splits chained commands, redaction hook"), [WHO ELSE WORKS IN THIS PROJECT] (e.g. "just me", "two friends").
Write a short note for this project's CLAUDE.md about when to use Code Mode. Don't change any settings and don't turn Code Mode on or off.
What I learned from trying it: [WHAT I LEARNED FROM TRYING IT]
My safety checks for Code Mode: [MY SAFETY CHECKS FOR CODE MODE]
Who else works in this project: [WHO ELSE WORKS IN THIS PROJECT]
The note should:
1. Be 12 lines or fewer, in plain words, under a heading "Code Mode (experimental)".
2. Say it's experimental, off by default and may change, and link to https://code.claude.com/docs/en/code-mode.
3. List the kinds of tasks where we use it, and the kinds where we stay in normal mode, based on what I learned.
4. List the safety checks that should be in place first, from my list.
5. Remind us that a Code Mode session can only be resumed with Code Mode on.
6. Include no keys, tokens, passwords or personal settings values.
Show me the note and where it goes in CLAUDE.md, keep everything already there, and wait for my "go" before saving.
Tips to customize: A note in CLAUDE.md is a reminder for you, your teammates and Claude. It can't turn Code Mode on or off, and it doesn't enforce anything; your rules and hooks do that. Check the Code Mode page every so often and update the note, since the docs say the feature may change or be removed in any release.
Get new free packs in your inbox
Optional. Every prompt here is free, and you don't need to sign up to use any of them. We email when we add new free packs. Unsubscribe anytime.
Thanks, you're on the list. Watch your inbox for the next prompt drop.