DEV Community

Cover image for Claude Code Has a Code Mode Now
Shrey Shah
Shrey Shah Subscriber

Posted on Originally published at thefactoryengineer.substack.com

Claude Code Has a Code Mode Now

Claude Code just shipped Code Mode.

With Code Mode on, Claude writes a small program that reads the tool results for it and hands back only what matters.

On my research test, Code Mode used 63% fewer tokens and finished 29% faster.

It helps most on big jobs where tools return lots of results to sort through.

Two things before we start

  1. Save this. You'll want the setup steps and the prompt the next time you start a big job.
  2. Share it with a teammate who uses Claude Code.

1. What Code Mode is

Code Mode is a new way for Claude Code to use its tools.

Normal mode. When Claude uses a tool like web search, every page and snippet of the result lands in the conversation. Claude carries all of it forward and rereads it on each next step.

Code Mode. Claude writes a short program. The program calls the tools, collects the results, drops duplicates and junk, and passes Claude a short summary. Claude reads the summary and keeps working from there.

Picture a research assistant. In normal mode, the assistant drops a stack of printouts on your desk and leaves the sorting to you. With Code Mode, the assistant reads the whole stack and hands you a one-page brief. The same work gets done, and you (and Claude) read far less.

2. Turn it on

You need Claude Code version 2.1.323 or newer.

Step 1. Open your terminal and check your version:

claude --version
Enter fullscreen mode Exit fullscreen mode

Step 2. If it's older than 2.1.323, update:

claude update
Enter fullscreen mode Exit fullscreen mode

Step 3. Start Claude Code with Code Mode on:

CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude
Enter fullscreen mode Exit fullscreen mode

Checking the version and starting Claude Code with Code Mode
Check the version, then start Claude Code with the Code Mode switch.

Step 4. A one-time screen asks if you want it. Pick "Yes, turn on Code Mode".

A banner then says Code Mode (experimental) is on. That means it worked.

The Code Mode banner
This banner means Code Mode is running in this session.

To resume a session you started with Code Mode, start Claude Code with Code Mode on again.

Make it permanent. To skip the long command, open ~/.claude/settings.json and add this:

{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1"
  }
}
Enter fullscreen mode Exit fullscreen mode

Now plain claude starts with Code Mode every time. Put this in your user file at ~/.claude/settings.json, because the user file is the one settings file that can turn Code Mode on.

Turn it off. Remove that line, or change the "1" to "0".

Where it works. Code Mode runs in the regular terminal app. The VS Code panel, the Desktop app, the cloud, and claude -p stay in normal mode.

3. See the code

You can watch exactly what Code Mode did.

Press Ctrl+O to open the full transcript. Look for a folded row labeled "Code". That row holds the program Claude wrote, along with every tool call it made.

The transcript showing the Code row
Press Ctrl+O and find the Code row.

Open the row to read the program itself.

The program Claude wrote
The short program Claude wrote to run the tools and filter the results.

In plain words, the code calls a tool many times, keeps the useful parts of each result, and returns a tidy summary to Claude. You can read it whenever you want to check what ran.

4. Where it shines

Code Mode pays off when results pile up and need filtering:

  • Research across many sources. Dozens of searches, lots of overlap, one clean list at the end.
  • Big results from MCP tools. Any connected tool that returns long pages or large data.
  • Loops over many tool calls. Jobs where you want the final outcome, and the program can hold the raw output of each call.

Normal mode already handles everyday work efficiently. For small tasks, file edits, and a handful of searches, it runs one command for the file changes and sends the searches side by side. Use normal mode for that work, and switch to Code Mode when results pile up.

5. Try it: the research example

Research shows Code Mode at work most clearly. I used Tavily, a search tool built for AI. Claude Code talks to it through an MCP server, which works like a plug that lets Claude use an outside app.

Step 1. Add Tavily. Get an API key from your Tavily account first, since setup asks for it. Then open Claude Code and type:

Add the Tavily MCP server for me. The address is https://mcp.tavily.com/mcp/
Enter fullscreen mode Exit fullscreen mode

Claude Code sets it up for you. (The underlying command is claude mcp add, if you prefer to do it yourself.)

Step 2. Check the connection. Inside Claude Code, type:

/mcp
Enter fullscreen mode Exit fullscreen mode

When Tavily shows up in the list, you're ready.

The prompt. This is the exact prompt I tested. Copy it:

Use the Tavily MCP server only. Research this question: [your question]. Run at least 20 different searches covering different angles. Collect every source, remove duplicates, and keep only sources from [year]. Then give me the total number of unique sources and a table of the 12 most credible sources with title, publisher, date, and one-line key finding.
Enter fullscreen mode Exit fullscreen mode

Fill in your question and the year you care about, and keep the rest. The "at least 20 searches" and "remove duplicates" parts give Code Mode plenty of results to filter, and filtering is where it helps.

What you'll see. Claude writes a program that runs the searches, merges the sources, and returns the table. My question was about the real results companies report from using AI coding agents. Here's the end of the answer:

The research result with Code Mode on
The end of the answer: what it couldn't confirm, and the full source list saved to a file.

Code Mode also found more sources, 212 unique ones compared with ~168 in normal mode.

6. One safety note

Your usual permission rules apply in Code Mode too. If you've told Claude Code to ask before using a tool, it asks for each call the program makes. In auto mode, the safety check reviews the whole program once before it runs, so give Code Mode jobs you'd trust it to run on its own.

Recap

  1. Code Mode lets Claude write a small program that runs tools and returns only what matters.
  2. Update Claude Code to 2.1.323 or newer.
  3. Start it with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude, or add it to ~/.claude/settings.json.
  4. Press Ctrl+O and open the Code row to see the program.
  5. Use it when results pile up; keep normal mode for small jobs.
  6. Try it on research: connect Tavily, check with /mcp, paste the prompt.

The official docs are here: https://code.claude.com/docs/en/code-mode

Save this for your next big job, and share it with a teammate who uses Claude Code.

Top comments (0)