# Claude Code Code Mode with a Data MCP: 30 Real Repo Calls, Simulated Script

> Claude Code Code Mode with the EveryInfra MCP: 30 real repo calls returned 2.95M characters; a simulated Code Mode script in Node.js returned 1,687.

- Canonical page: [https://everyinfra.com/en/blog/claude-code-code-mode](https://everyinfra.com/en/blog/claude-code-code-mode?utm_medium=ai_doc&utm_campaign=page_md)
- Published: 2026-11-22T14:38:00+08:00 · Fact-checked: 2026-11-22T13:30:00+08:00

First, what is real and what is simulated. The data API side is real. On 2026-11-22, from 12:43 to 12:51 Singapore time (SGT), we pulled the newest issues of 30 popular open source repositories through the EveryInfra remote MCP, one `github/repository_issues` call per repository. The 30 tool results came to 2,953,102 characters. With the token ratio that Anthropic publishes, that is about 1.1 million tokens (an estimate), more than the 1 million token context window of Opus 5.5. In 28 of the 30 calls, one result was larger than the 50,000-character limit at which Claude Code saves an MCP result to a file. Two later scripts made 66 more real calls, and we kept every raw result and charge.

The Claude Code side is simulated. Code Mode itself never turned on in this test: `claude -p` on this machine replied "Not logged in", and Code Mode works only in the interactive terminal anyway. The "Code Mode style script" in this article is JavaScript that we wrote by hand, following the Code Mode docs, and ran in Node.js. Claude did not write it inside Code Mode. Model tokens and model turns are estimates from character counts or inferred from how each method works. They were not measured.

With that caveat, from 12:51 to 12:55 SGT the script read 2,502,282 characters for 25 repositories locally. It kept only issues from the last 7 days that are not pull requests and that match words such as regression, crash or security. The object it returned had 1,687 characters, about 627 tokens (estimate). That is 0.067% of the per-call volume for the same 25 repositories. On the EveryInfra side, both methods cost the same: $0.000958 per successful call. The calls that were rate limited or failed cost nothing.

> **Key points**
>
> - Claude Code Code Mode arrived in v2.1.323 (npm publish time 2026-11-12 20:29 UTC). It is off by default. You turn it on with `CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1`, and it works only in the interactive terminal.
> - One call per turn for 30 repositories gave 2,953,102 characters of tool output, about 1.1 million tokens (estimate). 28 results were above 50,000 characters.
> - A Code Mode style script that we ran in Node.js (Code Mode itself did not turn on) read 2,502,282 characters for 25 repositories and returned 1,687 characters, about 627 tokens (estimate).
> - The EveryInfra fee does not change with the method: `github/repository_issues` costs $0.000958 per call, and failed or rate-limited calls cost $0.
> - The script cut the context by more than 99%, but its filter was wrong in 5 of 10 matches, and the model had no way to see that.

![Illustration of two conveyor lanes. On the left, folders arrive one by one and pile up on a desk in a messy stack. On the right, the same number of folders drop into a small machine with a round sieve on top. Only one small card slides out onto a clean desk.](https://everyinfra.com/articles/claude-code-code-mode/img-explain.webp?utm_medium=ai_doc&utm_campaign=page_md)

One call per turn sends every raw result into the conversation. Code Mode lets a script read and filter locally, and only the result goes to the model. [Generated illustration, no real data](https://code.claude.com/docs/en/code-mode)

## What is claude code code mode?

By default, Claude Code uses tools one at a time. The model sends one Bash, Read, Edit or MCP tool call. Claude Code runs it and puts the full result back into the conversation. Then the model reads the result and decides the next step. The [Code Mode docs](https://code.claude.com/docs/en/code-mode) describe a different loop. The model writes a block of JavaScript, and that code calls the tools.

The code can run commands in parallel and pass one result into the next call. At the end, it returns only the part that the model needs to read. In the conversation you still see the tool calls and the diffs of any edits. To see the code itself, press `Ctrl+O` to open the [transcript viewer](https://code.claude.com/docs/en/interactive-mode). Then expand the collapsed Code row.

The switch arrived in Claude Code v2.1.323. The [changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) entry calls it experimental and opt-in, a mode where Claude writes JavaScript to call its tools. The npm registry shows 2.1.323 published at 2026-11-12 20:29 UTC. On 2026-11-22, the newest version was 2.1.330, from 2026-11-20. Each of the five versions between them has at least one Code Mode fix.

Some of those fixes change how you use it. In 2.1.326, Code Mode works together with agent teams. In 2.1.328, time at a permission prompt no longer counts toward the 10-minute limit. In 2.1.329, Code Mode starts while OpenTelemetry events and metrics are on. In 2.1.330, a long pause after a script read hundreds of files is gone. On 2026-11-22, the feature still had the experimental label.

![Timeline from November 12 to November 20, 2026, with seven version dots. 2.1.323 on 11/12 adds Code Mode. 2.1.325 on 11/13 has fixes. 2.1.326 on 11/16 works with agent teams. 2.1.327 on 11/17 has fixes. 2.1.328 on 11/18 stops counting prompt wait time toward the 10-minute limit. 2.1.329 on 11/19 allows OpenTelemetry events and metrics. 2.1.330 on 11/20 removes a pause after hundreds of files. Five dots with feature changes are teal, two fix-only dots are grey.](https://everyinfra.com/articles/claude-code-code-mode/fig-08-version-timeline.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

| Item | What the source said on 2026-11-22 | Source |
| --- | --- | --- |
| Minimum version | v2.1.323; v2.1.326 to use it with agent teams | Code Mode docs, changelog |
| How to turn it on | `CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1` in the shell or in the `env` block of `~/.claude/settings.json`; project settings are ignored | Code Mode docs |
| Account | Claude subscription or Console account; not through a gateway, Bedrock, Google Cloud or Foundry | Code Mode docs |
| Models | Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2 | Code Mode docs |
| Where it works | Only the interactive `claude` session in a terminal; not the VS Code panel, the Desktop app or cloud sessions | Code Mode docs |
| Time limit | Code that Claude waits on stops after 10 minutes; in auto or bypassPermissions mode, code can run in the background for up to 2 hours | Code Mode docs |
| How to turn it off | Set the variable to `0`; a `0` anywhere wins; admins can turn it off in managed settings | Code Mode docs |

![Flow chart with two columns. Left column, one call per turn: the model reads the result and picks the next step. It sends one MCP tool call to everyinfra_call_api. The tool result of 4,538 to 323,135 characters enters the context. A dashed arrow goes back to the model with the label x 30 turns. Right column, Code Mode: the model writes JavaScript for the REPL tool. The script runs 30 calls, filters and fetches comments locally. It returns one object of 1,687 characters. A teal arrow goes back to the model with the label 2 turns.](https://everyinfra.com/articles/claude-code-code-mode/fig-01-two-loops-flow.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

## What is real and what is simulated

When we planned this article, we wanted a real A/B run inside Claude Code. The plan was the same 30 targets, Code Mode off and on, with model tokens, request counts and time for each run. This machine has the Claude desktop app, which includes a Claude Code 2.1.328 binary. At 12:40 SGT on 2026-11-22, we ran `claude -p` with `CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1`. The reply was "Not logged in · Please run /login". The tool list in the init message also had no `REPL` tool, which is the tool that runs the code.

That matches the docs. Code Mode supports only the interactive terminal, and `-p` and the Desktop app are not on the list. The [wmedia test](https://wmedia.es/en/tips/claude-code-code-mode-turn-on) also shows the message that `-p` gives: "for now it only works in the interactive terminal". We did not log in to an interactive session, so the Code Mode on/off comparison did not happen.

On the EveryInfra side, every number comes from real calls. On the Claude Code side, we filled the gap in two ways. First, we wrote a script in the Code Mode style by hand and ran it in Node.js, with a small function in place of the tool call. Per the docs, with Code Mode on the model reads the final object of the script, so the size of that object is measured. But it is the output of our script, not of a script that Claude wrote.

Second, we did not measure model tokens. We estimated them with the Anthropic [glossary](https://platform.claude.com/docs/en/about-claude/glossary). It gives about 3.5 English characters per token for older tokenizers. Claude 4.7 and later tokenizers produce about 30% more tokens for the same text. So we use 2.69 characters per token, and every table marks these numbers as estimates. For exact numbers, the [token counting endpoint](https://platform.claude.com/docs/en/build-with-claude/token-counting) is free. Run your own text through it with your model ID.

| Part | What we did | Evidence we kept |
| --- | --- | --- |
| 30 `github/repository_issues` calls | Real, through the EveryInfra remote MCP; 41 attempts, 30 successes | Every raw result and its `charged_usd` |
| 66 calls inside the two scripts | Real; the script that sent them was written by us and ran in Node.js | Run logs and raw results |
| Code Mode switch and the `REPL` tool | Did not turn on; `claude -p` replied "Not logged in" | Tool list in the init message |
| The 1,687 and 908 characters the scripts returned | Measured, but Claude did not write the script | The final object of each script |
| Model tokens and model turns | Estimated (2.69 characters per token) or inferred | None; run your own on/off comparison |
| Model cost | Estimated from list prices | Claude API pricing page |

## The job: 30 dependency repos, one week of regressions

We picked a job that Claude Code users often do and that needs many related calls: an issue check of a project's dependencies. The list has 30 common JavaScript and Python repositories, from React, Next.js, Vite, TypeScript and ESLint to Flask, FastAPI, Requests, Pydantic and pandas. For each repository, we pull the newest 30 issues. We keep issues opened in the last 7 days that are not pull requests. The title or labels must include a word such as regress, breaking, crash, security, CVE, memory leak, hang or fails.

Then we sort the matches by comment count and pull the latest comments for the top 3. This job has three useful properties. The repositories do not depend on each other, so the calls can run in parallel. Each repository returns tens or hundreds of thousands of characters, and only a few lines are worth keeping.

The second step uses the result of the first step. The Code Mode docs list three good use cases. They are the same change in many files, a search that filters before reading, and independent commands. This job fits the last two.

The data comes from the EveryInfra [GitHub data API](/en/github-api). We used two capabilities. [`github/repository_issues`](/en/github-api/repository_issues) takes a repository URL and returns the newest issues. [`github/issue_comments`](/en/github-api/issue_comments) takes an issue URL and returns its comments.

We read the free catalog (`GET /api/v1/social/catalog`) at 12:38:05 SGT. At that time it listed 714 capabilities, 683 available. Both capabilities are synchronous and cost $0.000958 per call. `repository_issues` returns 30 items by default and 100 at most.

The result has more than 20 fields, such as `title`, `text`, `is_pull_request`, `labels`, `comment_count` and `posted_at`. The `text` field holds the full issue body and decides most of the result size. Our technical targets: the data that the script returns to the model must be 10% or less of the per-call volume, and the job must need 3 model turns or fewer (turns are inferred, not measured).

## claude code mcp code mode setup: connect the EveryInfra remote MCP

In Code Mode, the script can call the tools that your session has. You add MCP servers with `claude mcp add`, as usual. The EveryInfra remote MCP is at `https://api.everyinfra.com/mcp`. It uses the HTTP transport, and the key goes in the `Authorization` header. The [Claude Code MCP docs](https://code.claude.com/docs/en/mcp) give this pattern. Keep the key in an environment variable, not in a project file.

```bash
# 1) Keep the key only in an environment variable (for example, an env file that ~/.zshrc reads)
export EVERYINFRA_API_KEY=ei_xxx   # use a key that you create in the console

# 2) Add the remote MCP at user scope, so it stays out of the project repo
claude mcp add --transport http everyinfra https://api.everyinfra.com/mcp \
  --scope user --header 'Authorization: Bearer ${EVERYINFRA_API_KEY}'

# 3) Turn on Code Mode for this session only
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude
```

The single quotes in step 2 are on purpose. The config stores the literal text `${EVERYINFRA_API_KEY}`, and Claude Code expands it each time it connects. The MCP docs have a special rule for remote servers. In `url` and `headers`, some credential variables such as `ANTHROPIC_AUTH_TOKEN` expand to an empty value.

This stops a project `.mcp.json` from sending your Claude credentials to a server that it names. `EVERYINFRA_API_KEY` is not on that list, so it expands normally. If the connection returns 401, use `claude --debug-file` and look for a "never expanded toward a remote server" line.

To keep Code Mode on, put the variable in the `env` block of your user settings. The Code Mode docs say that project settings cannot turn it on. So when you clone someone else's repository, that repository cannot turn it on for you.

```text
{
  "env": { "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1" },
  "permissions": {
    "allow": ["mcp__everyinfra__everyinfra_call_api", "mcp__everyinfra__everyinfra_list_capabilities"],
    "deny": ["mcp__everyinfra__everyinfra_create_ticket", "mcp__everyinfra__everyinfra_get_topup_link"]
  }
}
```

The permission rules matter more in Code Mode. The [permissions docs](https://code.claude.com/docs/en/permissions) name MCP tools as `mcp__<server>__<tool>`. The Code Mode docs say that each tool call inside the script goes through your `deny` rules, `ask` rules and `PreToolUse` hooks. But the auto mode classifier reviews the script once, before it runs. It cannot see values that the script computes at run time, such as a URL taken from an earlier result.

So put strict limits in rules and hooks, not in the classifier. At 12:42 SGT, the EveryInfra MCP `tools/list` showed 12 tools. For reading data, this job needs only three of them: `everyinfra_call_api`, `everyinfra_list_capabilities` and `everyinfra_get_job`. Tools that cause external actions, such as opening a ticket or getting a top-up link, get a deny rule here.

## One call per turn: 30 turns, tens of thousands of characters each

In the first round, we copied what the model does with Code Mode off. We sent one `tools/call` per repository to `everyinfra_call_api` with `{"platform":"github","action":"repository_issues","params":{"url":"https://github.com/<repo>"}}`. We saved every raw result. The screenshot below shows one of them, for Vite at 12:43:37 SGT.

![Screenshot of a real response. At 12:43:37 SGT, a tools/call request goes to api.everyinfra.com/mcp and calls everyinfra_call_api with platform github, action repository_issues and the repository vitejs/vite. The response is HTTP 200 in 0.37 seconds. result.content[0\].text has 83,177 characters and count is 30. The first item is issue 24172, with the author name masked. The last line shows billing with charged true and charged_usd 0.000958.]([https://everyinfra.com/articles/claude-code-code-mode/img-mcp-roundtrip.webp](https://everyinfra.com/articles/claude-code-code-mode/img-mcp-roundtrip.webp?utm_medium=ai_doc&utm_campaign=page_md))

One real MCP round trip: a single repository returned 83,177 characters. The author name is masked. [Screenshot of a real EveryInfra MCP response, 2026-11-22 12:43 SGT](https://api.everyinfra.com/api/v1/social/catalog)

The 30 results came to 2,953,102 characters in total. The median was 84,740 characters. The largest was TanStack/query at 323,135 characters, because some single issue bodies there are very long. The smallest was pmndrs/zustand at 4,538 characters, because it returned only 5 items, 3 of them pull requests.

At 2.69 characters per token, the total is about 1.097 million tokens (estimate). With one call per turn, all of these characters go through the model. They either enter the context directly or go to a file that the model then reads.

![Horizontal bar chart of 30 repositories sorted by MCP result size in characters. TanStack/query is longest at 323,135, then prisma/prisma at 169,622, axios/axios at 156,350 and trpc/trpc at 152,278. The shortest are pmndrs/zustand at 4,538 and pallets/flask at 6,119. A dashed vertical line marks 50,000 characters. 28 bars cross it, and only zustand and flask stay below.](https://everyinfra.com/articles/claude-code-code-mode/fig-03-per-repo-chars-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

Claude Code has two limits for large MCP results. The [MCP output limits section](https://code.claude.com/docs/en/mcp) says that a warning appears when one MCP tool result is above 10,000 tokens. The default maximum is 25,000 tokens, and `MAX_MCP_OUTPUT_TOKENS` changes it. For tools that do not declare their own limit, a text result above 50,000 characters goes to a file, whatever its token count. The conversation then gets a message with the file path.

In our run, 28 of 30 results crossed the 50,000-character line, and about 22 crossed 25,000 tokens (estimate). So with Code Mode off, this job turns into 30 MCP calls, 28 saved files and several Read calls. The [Read tool](https://code.claude.com/docs/en/tools-reference) returns at most 25,000 tokens per call. It refuses a whole file above 256 KB, so the model must read such a file in pages. The 323,135-character file from TanStack/query needs several pages.

With Code Mode off, the model can still run `jq` on the saved files and read less. Bicameral made a related point in a [Reddit reply](https://www.reddit.com/r/ClaudeAI/comments/1xymddk/i_benchmarked_claude_codes_code_mode_across_4/). For file work, Claude already writes shell scripts, so Code Mode saves mostly the fixed cost at session start. The big gap is in MCP calls, because a shell script cannot call MCP tools. Each result below 50,000 characters still enters the context in full.

| Metric | One call per turn (12:43 to 12:51 SGT) | Note |
| --- | --- | --- |
| Repositories / successes | 30 / 30 | 11 of 41 attempts were rate limited and then retried with `retry_after` |
| Total tool output | 2,953,102 characters | Sum of the length of each `result.content[0].text` |
| Tokens | about 1.097 million (estimate) | 2.69 characters per token |
| Results above 50,000 characters | 28 | Character limit from the MCP docs |
| Results above 25,000 tokens (estimate) | 22 | Default token limit from the MCP docs |
| Median API time per call | 0.94 seconds | 30.12 seconds in total |
| API fee | $0.02874 | 30 × $0.000958, sum of `charged_usd` |
| Pull requests in the results | 625 of 849, 73.6% | GitHub counts pull requests as issues |

The [GitHub issues REST docs](https://docs.github.com/en/rest/issues/issues) say that every pull request is an issue, so list endpoints return both. Of our 849 items, 625 were pull requests (73.6%). If you want only user reports, this is data to drop in a script before the model reads anything.

![Stacked bar chart with one row per repository, grey for pull requests and teal for issues, sorted by pull request share. vercel/next.js and fastapi/fastapi have 30 of 30 pull requests. The lowest are colinhacks/zod with 3 of 30 and psf/requests with 4 of 30. pallets/flask returned only 4 items and pmndrs/zustand only 5. In total, 625 of 849 items are pull requests.](https://everyinfra.com/articles/claude-code-code-mode/fig-10-pr-share-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

## A simulated Code Mode style script: run in Node.js, 1,687 characters back

The second round started at 12:51:56 SGT. Code Mode did not turn on, so we wrote a script by hand in the style that the Code Mode docs describe, and ran it in Node.js. Claude did not write this code, and a script that Claude writes could be better or worse. The main part is below, and we kept the full version and its run log. It does four things. It uses a small pool with at most 3 calls in flight and at least 7 seconds between starts.

On `rate_limited`, it waits for the `retry_after` value in the result. It keeps all 30 results in script variables and filters them. Last, it pulls comments for the top 3 matches. The final expression is all that the model sees.

```text
// In Code Mode, callTool is a ready-made function in the session (it calls mcp__everyinfra__everyinfra_call_api).
// In Node.js we replaced it with a small function that calls the MCP endpoint. The rest is unchanged.
const since = Date.now() - 7 * 864e5;
const RX = /regress|breaking|crash|segfault|security|vulnerab|CVE|memory leak|hang|broken|not working|fails?\b/i;

async function api(platform, action, params) {
  for (let i = 0; i < 6; i++) {
    const res = await callTool("everyinfra_call_api", { platform, action, params });
    if (res.isError) {
      const e = res.structuredContent?.error ?? {};
      if (e.code === "rate_limited") { await sleep(((e.retry_after ?? 10) + 2) * 1000); continue; }
      return { error: e.code ?? "error", charged_usd: 0 };
    }
    const j = JSON.parse(res.content[0].text);
    return { results: j.results ?? [], charged_usd: j.billing?.charged_usd ?? 0 };
  }
  return { error: "gave_up", charged_usd: 0 };
}

const pages = await pool(repos, 3, 7000, rp =>
  api("github", "repository_issues", { url: `https://github.com/${rp}` }));
const hits = [];
pages.forEach((p, i) => (p.results || []).forEach(x => {
  if (x.is_pull_request || Date.parse(x.posted_at) < since) return;
  if (!RX.test(x.title + " " + (x.labels || []).join(" "))) return;
  hits.push({ repo: repos[i], number: x.number, title: x.title.slice(0, 90),
              comments: x.comment_count, url: x.url, posted: x.posted_at.slice(0, 10) });
}));
hits.sort((a, b) => b.comments - a.comments);
const top = hits.slice(0, 3);
const threads = await pool(top, 3, 7000, h => api("github", "issue_comments", { url: h.url }));
top.forEach((h, k) => { h.last_comments = (threads[k].results || []).slice(-3)
  .map(c => (c.text || "").replace(/\s+/g, " ").slice(0, 200)); });
({ repos: repos.length, failed: pages.map((p, i) => p.error ? repos[i] : null).filter(Boolean),
   hits: hits.length, top, other_hits: hits.slice(3, 15).map(h => `${h.repo}#${h.number} ${h.title}`) });
```

The script ran for 194 seconds and made 42 calls. 25 calls succeeded. 9 hit the limit of 10 calls per minute, and some of those then succeeded on retry. 8 returned `unavailable`. The failures were the last 5 Python repositories (psf/requests, pydantic, encode/httpx, sqlalchemy and pandas) and the 3 comment calls. All five repositories had worked in the first round, near 12:50 SGT.

Each `unavailable` result had `billing.charged_usd` 0 and `reason` `request_failed_refunded`. Its `structuredContent.error` had `retryable: true` and `retry_after: 60`. Our first script retried only `rate_limited` and treated `unavailable` as final. So those 8 calls went straight into `failed`.

The script read 2,502,282 characters locally for 25 repositories. The object that it returned had 1,687 characters, about 627 tokens (estimate). It held the 10 issues from the last 7 days that matched the rule. The top one by comments was eslint/eslint #21556, with 6 comments.

Others were microsoft/TypeScript #65600 (its title starts with "7.0 regression"), vitest-dev/vitest #11976 (a screenshot assertion fails on Node 27) and jestjs/jest #16565. The `failed` field listed the 5 repositories that the script did not get. With Code Mode on, these 1,687 characters are what the model would read, and they show which 5 repositories to try again and which issues to read.

![Horizontal bar chart on a log scale, each step 10x. One call per turn for 30 repos: 2,953,102 characters, about 1.097 million tokens. One call per turn for the same 25 repos: 2,502,999 characters. The first script returns 1,687 characters, about 627 tokens, which is 0.067% of the per-call volume. The second script returns 908 characters, about 337 tokens.](https://everyinfra.com/articles/claude-code-code-mode/fig-02-context-chars-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

## The second script: retry only the five failures

A common Code Mode pattern is a second script. The first script returns `failed`, the model reads it, and it writes a short script for those items only. In a Claude Code session, variables from one script stay available to the next. The wmedia test says that "variables survive from one script to the next". The 2.1.328 changelog also fixed a bug where top-level variables that a failed script did not set came back as undefined.

At 12:56 SGT, we ran a second script in that style, also in Node.js. It also waits on errors with `retryable: true`, such as `unavailable`, for the `retry_after` time, capped at 60 seconds. It pulls only the 5 failed repositories. Then it merges the matches from both scripts and pulls comments for the top 3.

The second script started at 12:56:18 SGT and ended at 13:02:36 SGT, 378 seconds in total. It made 24 calls. Each of the 5 repositories got 3 tries, with a 60-second wait before each retry. Each of the 3 comment calls also got 3 tries.

All 24 calls returned `unavailable`, and the total `charged_usd` was 0. The script returned 908 characters. `failed` still listed the same 5 repositories, `hits` was 0, and `top` held the 3 merged matches with the most comments. Each `last_comments` array was empty.

All 24 retries returned `unavailable`. These 908 characters show that the retry did not fill the gap and that no comments came back. If the script returned only `top`, the model could read the empty comments as "nobody talks about these issues". So the return value must always carry `failed` and a success count for each step. An empty result and a missing result are different things, and the script must keep them apart.

Also, 378 seconds is not far from the 10-minute limit. With a list twice as long and two 60-second waits per failure, the script would stop before it ends. In that case, run it in the background in auto mode, or let the script return what it has so far.

![Screenshot of a real response. At 12:43:58 SGT, the same tools/call request for lodash/lodash returns HTTP 200 at the JSON-RPC level. The tool result is an error with isError true. The first text block says rate_limited, 10 calls per minute per key, retry in 2 seconds. The second text block says Nothing was charged. structuredContent.error has code rate_limited, reason key_limit, retry_after 2, limit 10, retryable true and max_retries 3.](https://everyinfra.com/articles/claude-code-code-mode/img-rate-limited.webp?utm_medium=ai_doc&utm_campaign=page_md)

The rate limit arrives inside the MCP tool result: HTTP is 200, `isError` is true, `retry_after` tells the script how long to wait, and nothing was charged. [Screenshot of a real EveryInfra MCP response, 2026-11-22 12:43 SGT](https://api.everyinfra.com/api/v1/social/catalog)

## The script filter was wrong, and the model could not see it

A 99.9% cut in context has a cost. The model did not see any of the 2.5 million characters that the script dropped. After the run, we checked each match against the raw first-round results. The rule had a bug. The regex term `hang` (meant for "the app hangs") also matches the four letters inside `change`, `changes` and `changed`.

Five of the 10 matches came from that bug: vitejs/vite #24143 and #24138, eslint/eslint #21556, and vitest-dev/vitest #12022 and #11971. Their titles only contain a word like "change". They are feature requests, docs or build behavior, not regressions. eslint #21556 had the most comments (6), so it was first in the list. The second script then pulled its comments.

The other 5 matches were what the rule was for. microsoft/TypeScript #65600 has "7.0 regression" in its title. vitest-dev/vitest #11976 is a screenshot assertion that fails on Node 27. jestjs/jest #16565 is Jest exiting with code 0 without running tests when watchman fails. reduxjs/redux-toolkit #5618 is a type declaration error under one compiler option. facebook/react #38335 reports a UI crash with memo around a form, still labeled "Status: Unconfirmed".

For the 5 Python repositories that the second script did not get, an offline check on the first-round data finds 2 more. psf/requests #7651 is an auth failure because a digest auth header is not trimmed. pandas-dev/pandas #72256 is a feature idea with the word "crash", so it is also a false positive. Across the newest 30 items of 30 repositories, there were 224 non-PR issues. 96 were opened in the last 7 days. The rule picked 12, and about 6 were real regressions or bug reports.

![Horizontal bar chart of the script's filter funnel. 849 items came back from 30 repositories. 224 are not pull requests. 96 were opened in the last 7 days. 12 matched the rule. 6 are real bug reports after a manual check, shown in teal. The subtitle says that 5 of the 12 matches come from hang inside change.](https://everyinfra.com/articles/claude-code-code-mode/fig-07-filter-funnel-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

With one call per turn, this kind of error is easier to catch. The model reads the text of eslint #21556 and sees a feature request. In Code Mode, the model sees only the titles and comment counts that the script returns. So the result is only as good as the rule.

We made three fixes. First, the regex uses word boundaries (`\bhang(s|ing)?\b`). Second, each match in the return value carries the word that matched, so the model can see the trigger at a glance. Third, the script adds 5 random dropped items to the return value, so the model has a sample to check the rule against.

With all three fixes, we estimate that the return value grows from 1,687 to a little over 2,000 characters (we did not rerun the fixed script). That is still about one thousandth of the per-call volume. The Bicameral benchmark reports a similar risk. In its "read records and judge" task, all 3 wrong answers came from Haiku 5.5. The author thinks the script used the fixed wording of the records to skip repeated parts.

## Side by side: context, turns, time and API fee

The tool output that reaches the model differs by about 1,100 times (2,953,102 characters against 1,687 + 908). Model turns, inferred from each method, are 30 or more against 2 scripts. The API fee and the API time are almost the same. API numbers in the table are measured; model numbers are inferred or estimated.

| Metric | One call per turn | Simulated Code Mode style script | Basis |
| --- | --- | --- | --- |
| Tool requests from the model | 30 MCP calls plus Read calls for saved files | 2 scripts | Inferred from each method, not measured on the model side; Read calls depend on how the model reads |
| Tool output that enters the context | 2,953,102 characters (about 1.1M tokens, estimate) | 1,687 + 908 characters (about 965 tokens, estimate) | Counted from raw results; tokens are estimates |
| Results saved to a file (above 50,000 characters) | 28 | 0 | MCP docs character limit |
| API attempts, with retries | 41 attempts, 30 successes | 42 + 24 attempts, 25 successes | Run logs |
| EveryInfra API fee | $0.02874 | $0.02395 + $0 | Sum of `charged_usd` |
| Charge for failures | 11 rate limited, $0 | 9 rate limited and 32 `unavailable`, $0 | `billing` in each result |

Time needs a closer look. The API itself is fast, with a median of 0.94 seconds per call. Both rounds spent most of their wall-clock time waiting on the rate limit. The first round took about 7.5 minutes and the second took 194 seconds.

We set this test key to 10 calls per minute, and other writing jobs shared it at the same time. With that limit, 30 calls take at least 3 minutes. More parallel calls in the script only hit `rate_limited` sooner.

![Dot plot from 0 to 3 seconds of the 30 successful first-round calls. Most dots sit between 0.8 and 1.1 seconds. The fastest is 0.37 seconds and the slowest is 1.53 seconds. A dashed line marks the median of 0.94 seconds. The subtitle gives a total of 30.12 seconds and says that wall-clock time went to waiting on the limit of 10 calls per minute.](https://everyinfra.com/articles/claude-code-code-mode/fig-09-latency-dist.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

What one call per turn cannot save is model time. Each tool call needs a full model inference. In the [advanced tool use](https://www.anthropic.com/engineering/advanced-tool-use) post, Anthropic says that a five tool workflow means five inference passes. With 30 repositories, that is at least 30 passes, and each one sends a longer conversation than the one before it.

![Timeline from 12:43 to 13:03 SGT with three rows. Top row, one call per turn: 41 attempts, 30 teal dots for successes and 11 grey crosses for rate-limited calls. Middle row, first script: 42 attempts, 25 successes, 9 rate limited and 8 unavailable shown as hollow squares. Bottom row, second script: 24 attempts, all unavailable. No grey mark was charged.](https://everyinfra.com/articles/claude-code-code-mode/fig-04-call-timeline.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

## Cost: the API fee is per call, the model fee depends on what it reads

The EveryInfra side is simple, and it does not depend on Code Mode. `github/repository_issues` costs $0.000958 per call. One check of 30 repositories per day costs $0.02874, or about $0.86 for a 30-day month. Comments for the top 3 matches add $0.002874 per day. The responses state when a failure is free.

Each rate-limited result says "Nothing was charged". Each `unavailable` result has `charged_usd` 0, `reason` `request_failed_refunded` and a refund status of `succeeded`. Across the three rounds, the `charged_usd` values for the two GitHub capabilities add up to $0.05269. That is exactly 55 successes × $0.000958. Every failed or rate-limited call shows `charged_usd` 0.

The model side depends on how many tokens it reads. These are the [Claude API prices](https://platform.claude.com/docs/en/about-claude/pricing) on 2026-11-22. Opus 5.5 costs $4 per million input tokens, $20 per million output tokens and $0.20 per million cache-hit tokens. Sonnet 5.5 costs $2 per million input tokens. Haiku 5.5 costs $0.10 per million input tokens up to 100,000 tokens per request, and $0.50 above that.

If you count one read of the tool output, one call per turn reads about 1.1 million tokens: about $4.39 on Opus 5.5. The script output costs less than one cent. The estimate leaves out resent context (mostly at cache price) and the output tokens of the script itself. On a Claude subscription, you do not pay these amounts directly, but they count toward your usage limits.

![Grouped bar chart on a log scale for one check of 30 repositories. The EveryInfra API fee is $0.0287 for both methods. At the Opus 5.5 base input price, the estimated model input cost is about $4.39 for one call per turn. It is about $0.0039 for the Code Mode style script. The note says the model cost is an estimate for one read, without cache or output.](https://everyinfra.com/articles/claude-code-code-mode/fig-05-cost-share-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

| One check of 30 repositories | One call per turn | Simulated Code Mode style script | Basis |
| --- | --- | --- | --- |
| EveryInfra API fee | $0.02874 | $0.02395 charged (25 repositories succeeded); $0.02874 if all 30 succeed | Catalog price × successes |
| Tool output that the model reads | about 1.097 million tokens | about 965 tokens for both scripts | Estimate, 2.69 characters per token |
| Opus 5.5 input cost, one read | about $4.39 | about $0.0039 | $4 per million tokens |
| Sonnet 5.5 input cost, one read | about $2.19 | about $0.0019 | $2 per million tokens |
| Fits in one session | No, it is above the 1M token window of Opus 5.5 | Yes | Pricing page, 1M token context window |

## Scale it up: every day, 100 and 300 repositories

As a daily morning check, the cost depends on the list length and on the key limit. The API fee grows in a straight line. One `github/repository_issues` call per repository per day costs $0.02874 for 30 repositories, $0.0958 for 100 and $0.2874 for 300. Over a 30-day month, that is about $0.86, $2.87 and $8.62. Comments depend on the number of matches. At 3 per day, they add $0.002874.

The key limit sets the time. Our test key allows 10 calls per minute, so 300 repositories need at least 30 minutes. Account keys have a higher default limit. Our [Claude Code subagents test](/en/blog/claude-code-subagents-tiktok-accounts) measured 60 calls per minute on a normal account key, so 300 repositories take about 5 minutes. Code that Claude waits on stops after 10 minutes in Code Mode. So a 300-repository job must run in the background in auto or bypassPermissions mode (up to 2 hours), or as several scripts of 100 repositories each.

On the model side, one call per turn grows with the list. 30 repositories are already about 1.1 million tokens, and 100 repositories are about 3.7 million. No session can hold that, so the model must rely on saved files, paged reads and many compactions. A Code Mode style script returns the matches, and their size depends on the match count.

A linear estimate from our average (1,687 characters ÷ 25 repositories × 100) gives about 6,700 characters, or about 2,500 tokens, for 100 repositories. At our rate of 12 matches and about 6 real ones per 30 repositories, 100 repositories give about 40 matches and about 20 real ones (estimate).

![Line chart with tokens on a log scale and 30, 100 and 300 repositories on the x axis. Per-call tool output rises from about 1,096,900 tokens to about 3,656,200 and 10,968,700. At 30 repositories it is already above a dashed line for the 1M token window of Opus 5.5. The object that a Code Mode style script returns rises from about 752 to 2,506 and 7,519 tokens. The subtitle says that 100 and 300 are linear estimates from our averages.](https://everyinfra.com/articles/claude-code-code-mode/fig-11-scale-line.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

| List length | API fee per day | API fee per month (30 days) | Minimum time at 10 calls per minute | Minimum time at 60 calls per minute | Per-call tool output (estimate) |
| --- | --- | --- | --- | --- | --- |
| 30 repositories | $0.02874 | $0.86 | 3 minutes | 30 seconds | about 1.1M tokens |
| 100 repositories | $0.0958 | $2.87 | 10 minutes | 100 seconds | about 3.7M tokens |
| 300 repositories | $0.2874 | $8.62 | 30 minutes | 5 minutes | about 11M tokens |

You may ask why we did not call the GitHub REST API directly for GitHub issues. You can. The GitHub [rate limit docs](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api) allow 60 requests per hour without a token and 5,000 per hour with a personal token. The case for EveryInfra is that the same key and MCP tool also reach Reddit, YouTube, X and more (106 platforms in the catalog on 2026-11-22). Fields have the same names across platforms, such as `posted_at` and `comment_count`, and failures are free. If you need only GitHub, your own token is enough.

## Other measurements: Bicameral, wmedia and Flavio Copes

Our numbers come from one job, one set of repositories and one filter. Between 2026-11-13 and 2026-11-18, three other public tests ran the model inside Claude Code. They are good points of comparison.

The [Bicameral benchmark repository](https://github.com/Bicameral-AI/claude-code-mode-benchmark) is the most complete. It has 6 tests and 4 models (Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.2), with two runs per cell and per mode. That is 96 runs on Claude Code 2.1.326, and all numbers come from Claude Code transcripts. The closest test to our job sums 120 records from one MCP tool. Across the four models, processed tokens fell by 62% to 77%. A "read records and judge" test fell by 40% to 68%.

For file work, where Claude already writes scripts, three models fell by 15% to 54%, and Haiku 5.5 used 9% more. Each Code Mode session started about 13,000 tokens smaller. In a reply, the author added cost data. On the MCP summing task, recorded cost fell by 73%. On file work with Opus, it rose by 15%.

The [wmedia test](https://wmedia.es/en/tips/claude-code-code-mode-turn-on) from 2026-11-13 used a different job. It read 40 order JSON files and found the top 3 customers by spend, on Opus 5.5 at medium effort. Both modes made 4 requests. First-request input fell from 36,404 to 22,233 tokens, and total input with cache fell from 150,364 to 94,659. But time went from 15 to 37 seconds. `/context` showed system tools falling from 24.6k to 11.1k tokens, because in Code Mode the model sees only two tools, `REPL` and `Poll`.

[Flavio Copes](https://flaviocopes.com/claude-code-code-mode) tested on 2026-11-18 with an Astro project of 8 Markdown files. A broken-link check went from 35 to 15 seconds. Three independent checks went from 17 to 14 seconds. Timing 100 builds became 101 commands in one script.

![Horizontal bar chart of how much less reaches the model with Code Mode in four measurements. This article, tool output for 30 repos: 99.93% less, in characters. Bicameral, sum 120 records via MCP: 62% to 77% fewer processed tokens. Bicameral, read and judge records: 40% to 68% fewer. wmedia, top 3 from 40 JSON files: 37% fewer total input tokens. The note says the units differ.](https://everyinfra.com/articles/claude-code-code-mode/fig-06-benchmark-compare-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

| Test | Job | Change with Code Mode | Runs | Date |
| --- | --- | --- | --- | --- |
| This article | Issue check of 30 repositories through the EveryInfra MCP | 99.93% fewer characters back to the model (same 25 repositories) | 3 real API rounds; Code Mode not on, script simulated in Node.js | 2026-11-22 |
| Bicameral | Sum 120 records through MCP | 62% to 77% fewer processed tokens | 4 models × 2 runs × 2 modes | 2026-11-17 |
| Bicameral | Read records and judge | 40% to 68% fewer processed tokens | Same | 2026-11-17 |
| Bicameral | Find and change text in files | 15% to 54% fewer on three models, Haiku 9% more | Same | 2026-11-17 |
| wmedia | Top 3 from 40 JSON files | 37% fewer total input tokens, 15 to 37 seconds | 1 each | 2026-11-13 |
| Flavio Copes | Broken-link check | 35 to 15 seconds | 1 each | 2026-11-18 |
| Better Stack | Migration of 166 console calls in 53 files | About 80% faster on average, 28% fewer model round trips, same cost | 3 each | 2026-11-20 |
| Ray Amjad | Issues in a real open source project | About half the input tokens, 71% of the cost | Not stated | 2026-11-16 |

The larger the tool output, the more Code Mode saves. Our 99.9% is higher than the 62% to 77% from Bicameral because we count only tool output that reaches the model. Bicameral counts all processed tokens, including the system prompt, tool definitions and the code itself. With those added back, our cut is below 99.9%, but still above a factor of 100.

## Rate limits, failures and retries: what the script must handle

With one call per turn, the model reads each error and decides what to do. In Code Mode, the script gets the error first. If the script has no rule for it, the model sees only a `failed` list.

The first kind is the rate limit. In the EveryInfra MCP, a rate limit is a tool result with `isError: true`, while the JSON-RPC layer is still HTTP 200. The result has two text blocks and a `structuredContent.error` object. Its fields are `code: "rate_limited"`, `reason: "key_limit"`, `retry_after`, `limit`, `retryable: true` and `max_retries: 3`.

The [MCP tools specification](https://modelcontextprotocol.io/specification/2025-06-18/server/tools) puts tool execution errors in `isError`, not in protocol errors. So a script must check `isError`, not only the HTTP status. Our script waited `retry_after` plus 2 seconds and tried again. Every rate limit in the three rounds succeeded on retry.

The second kind is a temporary outage. Near 12:54 SGT, the 5 Python repositories and the 3 comment calls returned `unavailable` again and again. The fields were `fault: "service"`, `retryable: true` and `retry_after: 60`. The third text block gave next steps. First, send the example request from `structuredContent` once.

If the example also fails, the problem is on the service side, and you ask the user before you open a ticket. Our first script did not retry this kind of error, so it returned a result with 5 gaps. The second script waited 60 seconds per retry, with at most two retries. From 12:56 to 13:02 SGT, all 24 requests for the 5 repositories and the 3 comment threads still returned `unavailable`, with no charge. The script wrote the 5 repositories into `failed`, so the model knew which items were missing and could try again later.

The third kind is a target that does not exist. At 13:02:55 SGT, we requested the repository `everyinfra-test/this-repo-does-not-exist-2026` on purpose. We wanted to see the "not found" response. Instead, we got HTTP 503 with the same `unavailable` code and `recent_failures` 22. The first `next_steps` line said "22 failures in 10 minutes for github/repository_issues; none was charged".

The second line gave a way to tell the cases apart. Send the `example` in the response once, which pulls issues for facebook/react. If the example works, the problem is your target, which may be deleted, private or misspelled. If the example also fails, the problem is on the EveryInfra side, and you ask the user before you open a ticket.

At 13:08:34 SGT we followed that step. The example also returned 503, with no charge, so by that rule the problem was on the service side. A ticket needs the user's consent, and this was a test, so we did not open one. We did not see the "not found" case this time. The table below shows the rule for each case.

We found the fourth kind by accident: a bad parameter. At 13:05:24 SGT, we sent `sort: "top"` to `youtube/comments`. The response was HTTP 422 with `code` `invalid_value`. `allowed` listed `newest` and `popular`, `did_you_mean` was `popular`, and the message said "Nothing was charged".

We sent `popular` instead, and at 13:05:31 SGT the call returned 20 comments for $0.000556. A script handles this kind of error most easily. Read `allowed` or `did_you_mean`, change one parameter and send the call once more. The model does not even need to know.

| Result | Signal in the response | What the script does | Count in this test |
| --- | --- | --- | --- |
| Rate limited | `isError: true`, `code: rate_limited`, `retry_after`, `retryable: true` | Wait `retry_after`, retry up to `max_retries` | 20, all retried with success |
| Temporarily unavailable | HTTP 503 or `isError`, `fault: service`, `retry_after: 60`, an `example` | Wait 60 seconds, retry up to 2 times, then send the `example` once and add the item to `failed` | 34 |
| Bad parameter | HTTP 422, `allowed`, `did_you_mean` | Send once more with the suggested value | 2, fixed on retry |
| Target does not exist | `retryable: false` | Do not retry; put it in the return value | Not seen in this test |

![Horizontal bar chart of every request from 12:43 to 13:08 SGT, grouped by result. 55 successful GitHub requests were charged $0.05269. 6 successful YouTube requests were charged $0.003558. 20 rate_limited, 34 unavailable and 2 invalid_value (422) requests were charged $0.](https://everyinfra.com/articles/claude-code-code-mode/fig-12-error-kinds-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

## Security and audit: key, hooks and sandbox

Keep the key out of the code. Our key exists only in the MCP `headers`, where `${EVERYINFRA_API_KEY}` expands. When the script calls a tool, it never touches the key, and the model never sees it. Do not let the model call the REST API with `fetch` and the key inside the script.

The key would then appear in the code and go into the transcript. The Code Mode docs say that the JavaScript itself and its file, network and MCP calls run outside the [sandbox](https://code.claude.com/docs/en/sandboxing). The sandbox covers only the shell commands that the script starts. To isolate the whole session, use a container or a virtual machine.

Use hooks to see and change the code and its output. To review a script before it runs, add an `ask` rule for `REPL`. A `PreToolUse` [hook](https://code.claude.com/docs/en/hooks) can also read `tool_input.code`. To change script output before the model reads it, write a `PostToolUse` hook that returns a changed `updatedToolOutput`. The docs also say that from v2.1.328, `UserPromptSubmit` hooks no longer receive script output. If you checked output there, move that check to `PostToolUse`.

Audit each call. Each tool call inside the script still goes through permission rules under the usual tool name. So the allow rule for `mcp__everyinfra__everyinfra_call_api` and the deny rules for tickets and top-up links still apply. The [permission modes docs](https://code.claude.com/docs/en/permission-modes) list actions that no mode approves without a prompt, and they prompt inside a script too. On the EveryInfra side, each call has a `request_id`. The call log in the console and the `everyinfra_list_requests` MCP tool both find the charge and any refund by that ID.

## What the videos show that the docs leave out

At 13:02 SGT on 2026-11-22, we searched YouTube for "claude code code mode" with the EveryInfra `youtube/search` capability. We took the top 3 search results. At 13:04 SGT we pulled their English transcripts with `youtube/transcript`, and at 13:05 SGT we pulled the top comments on two of them with `youtube/comments`.

The videos are by [JeredBlu](https://www.youtube.com/watch?v=wSYqwfd5mV0) (2026-11-16), [Better Stack](https://www.youtube.com/watch?v=nraROC2wl8s) (2026-11-20, about 104,000 views) and [Ray Amjad](https://www.youtube.com/watch?v=DRNbxPk9Ab8) (2026-11-16, about 223,000 views).

Check that Code Mode is really on. Ray Amjad asks the model which tools it has, and in Code Mode it names only `REPL` and `Poll`. `Poll` checks on a script that moved to the background. On his first start, Ray Amjad also got a message that Code Mode was not on.

The cause was a UI extension that he had installed, which uses Claude Code hooks. After he turned it off, Code Mode started. JeredBlu's first start also failed, because agent teams were on and his version was older than 2.1.326. So if Code Mode does not start, read the start message for the setting or extension that it names.

Compare the session start with `/context`. JeredBlu ran two sessions side by side in the same repository. The Code Mode session started at 19.6k tokens, and the other at 29.7k. That gap of about 10,000 tokens is close to the 13,000 that Bicameral measured. Then both sessions used a YouTube MCP for the same question. Messages took 44.8k tokens without Code Mode and 23.5k with it.

Press two keys to see the script. Better Stack shows that you press `Ctrl+O` to open the transcript and then `Ctrl+E` to expand one Code row. The docs mention only `Ctrl+O`. Their second finding helps with audits.

Without Code Mode, in all three runs, Claude wrote a Python script that changed files from the shell. `/cost` then showed 0 lines added and 0 removed, because Claude Code saw only a shell command. With Code Mode, the edits went through Claude Code's own Edit tool. `/cost` showed 224 lines added and 171 removed, all 53 files went into file history, and each edit had a diff.

Plan for resume and remote control. In JeredBlu's screenshot, the session says at start that it can resume only with Code Mode on and that Remote Control is not available. If you watch sessions from your phone, decide before you turn it on.

Guardrails are the top worry in the comments. One comment under Ray Amjad's video, with 29 likes, asks how to put guardrails on tool calls now, and whether hooks still work. The docs answer this. Hooks and permission rules still check each call inside the script under the usual tool name. Only the auto mode classifier changes, and it now reviews the whole script once before it runs.

Better Stack shows the risk of that change. A script searches for files and then deletes what it found. The classifier approves the plan, but it never sees which files the script deleted. Their advice is to put the commands that you must block into rules or hooks, and not to rely on auto mode alone.

## Get the model-side numbers yourself: one run on, one run off

This article lacks a model-side measurement. That step needs a logged-in interactive terminal, and you can add it with the public method. The Bicameral benchmark published on 2026-11-17 and the JeredBlu video from 2026-11-16 use the same setup: the same repository folder and the same prompt in two interactive sessions, one started with `CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude` and one with plain `claude`. Both connect to the same EveryInfra MCP with the same allow and deny rules, and the repository list and prompt stay word for word the same, so any gap has a clear cause.

Run `/context` in each session before you start and note the starting size. JeredBlu saw 19.6k tokens with Code Mode and 29.7k without. Then give both sessions the same job, for example "pull the latest issues of these 30 repositories and tell me only the regressions from the last 7 days, sorted by comment count". Run `/context` again at the end and note how much the messages and tool results take. Better Stack also used `/cost` for cost and lines changed. Run each mode at least twice, because the model writes a different script each time. Bicameral ran two runs per cell, 96 in total, and took the numbers from the transcripts that Claude Code saves, not from the screen.

For exact token counts, send the tool results from the transcript to the free token counting endpoint with the model ID that you used. On the Code Mode side, also read the script itself: press `Ctrl+O` for the transcript and `Ctrl+E` to expand the Code row, and check the filter rule. Our `hang` regex that matched `change` is that kind of bug, and the returned result alone does not show it. On the EveryInfra side there is nothing extra to log. Each call in both sessions has a `request_id` and `charged_usd`, the console call log matches them one by one, and the fee should equal the catalog price times the number of successes, with rate-limited and `unavailable` calls at $0. From 2.1.329 (2026-11-19), Code Mode also starts while OpenTelemetry events and metrics are on, and each tool call in a script sends its own event, so teams that log usage with OpenTelemetry can take the per-call records from there.

## When not to use Code Mode

The API already takes a batch. Some EveryInfra capabilities take a list of targets and charge per item. For example, `reddit/posts_batch`, `twitter/posts_batch` and `instagram/profiles_batch` take a `urls` or `usernames` array. One call brings back dozens of results. The script's pool is then not needed, and only the filter is left. `github/repository_issues` takes one repository per call, so this job suits a script.

The result is small. If you check one repository and need a few fields, one call returns a few thousand characters. One call per turn and a script are then the same. In the Bicameral control test with one question and one file, both modes recorded the same cost.

The filter rule is fuzzy. A script can filter only by a rule that you can write down. Whether an issue is a regression often needs a reading of the body, and a regex both misses and over-matches: 5 of our 12 matches came from `hang` inside `change`. For such jobs, let the script do a rough filter and dedupe, and return the titles and the first few hundred characters of each candidate for the model to judge. 12 candidates with 500 characters each are about 6,000 characters, still more than two orders of magnitude below one call per turn (estimate).

You want a human decision in the middle. Once a script runs, the model waits for it to end, so one call per turn suits step-by-step approval better. Also, the Desktop app, the VS Code panel and scheduled `claude -p` jobs cannot use Code Mode today. There, let Claude filter saved MCP results with `jq`, or schedule a script that calls the REST API without the model.

Related articles on this site: [dynamic workflows for Xiaohongshu comments](/en/blog/claude-code-dynamic-workflows-xiaohongshu-comments) send 500 comments to parallel workers; [subagents pull TikTok brand accounts](/en/blog/claude-code-subagents-tiktok-accounts) keep raw data in each subagent's context; the [Responses API WebSocket test](/en/blog/responses-api-websocket-data-tool-latency) saves waiting with a different transport; and the dependency issue check can feed [turning vulnerability advisories into a fix queue](/en/blog/vulnerability-advisory-triage-product). On 2026-10-22, Anthropic published [When to fold subagents into your main agent loop](https://claude.com/resources/articles/building-agents-when-to-fold-subagents-into-your-main-agent-loop), which recommends one model, one context and one tool loop as the default. Code Mode cuts context inside a single loop, so try it before you split work into subagents.

## FAQ

**What is claude code code mode?**

It is an experimental switch in Claude Code from v2.1.323. With it on, the model does not send one tool call at a time.

It writes JavaScript, and the code calls Bash, Read, Edit and MCP tools. Only the return value of the code goes to the model. It is off by default. Start it with `CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude`.

**Can Code Mode call MCP tools?**

Yes. The Code Mode docs say that each tool call in the script goes through permission rules under the usual tool name. That includes MCP names such as `mcp__<server>__<tool>`. Our script handles the real EveryInfra MCP result format (`content`, `isError` and `structuredContent`), but we did not run the model inside Claude Code.

**Code Mode vs MCP: does Code Mode replace MCP?**

They work at different layers. MCP defines how tools are exposed, authenticated and returned. Code Mode changes how the model uses those tools. Your MCP servers do not change. With Code Mode on, their tools become functions that a script can call. [Cloudflare's September 2025 post](https://blog.cloudflare.com/code-mode/) makes the same point: MCP still gives a uniform way to connect, authenticate and document tools. The same idea appeared in Anthropic's November 2025 post [Code execution with MCP](https://www.anthropic.com/engineering/code-execution-with-mcp) and in [programmatic tool calling](https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling) on the Claude API, which runs Python in a sandbox that Anthropic hosts. Code Mode runs the script in your own session.

**How many tokens and how much money does Code Mode save?**

It depends on the job. Jobs with large tool output that needs filtering save the most. For our 30 repositories, characters back to the model fell by 99.9%.

Bicameral's MCP summing test cut processed tokens by 62% to 77% and recorded cost by 73%. File work saves mostly the 13,000 tokens at session start, and its cost can be equal or a little higher. The EveryInfra fee does not change, because it counts successful calls.

**Does Code Mode work with subagents and skills?**

From v2.1.326, it runs with agent teams. Teammates use Code Mode in the default in-process mode, but not in split-pane mode.

In 2.1.329, read-only subagents no longer get `write()` and `edit()`. Subagents keep raw data in another context. Code Mode keeps raw data inside a script. You can use both, because a subagent can also write a script.

## Getting started

1. Create an API key in the [EveryInfra quickstart](/en/docs#quickstart) and store it in `EVERYINFRA_API_KEY`, not in a project file.
1. Run `claude --version`, and run `claude update` if the version is below 2.1.323.
1. Add the remote MCP with the command above (see the [MCP setup page](/en/mcp-server)). Write the allow and deny rules in `~/.claude/settings.json`.
1. Start with `CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude`. Ask which tools it has, or run `/context`: if only `REPL` and `Poll` are left, Code Mode is on.
1. Give it a job with many related calls, such as the latest issues of 30 repositories. Press `Ctrl+O` to see the script. Prices are on the [pricing page](/en/pricing). Each capability page also shows its price, for example [`github/repository_issues`](/en/github-api/repository_issues), [YouTube](/en/youtube-api) and [`youtube/transcript`](/en/youtube-api/transcript).

## References

1. [Code Mode](https://code.claude.com/docs/en/code-mode), Claude Code docs, read Nov 22, 2026
1. [Changelog](https://code.claude.com/docs/en/changelog), Claude Code docs, read Nov 22, 2026
1. [CHANGELOG.md, 2.1.323 to 2.1.330](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md), Anthropic, GitHub, read Nov 22, 2026
1. [@anthropic-ai/claude-code release times](https://registry.npmjs.org/@anthropic-ai/claude-code), npm registry, read Nov 22, 2026
1. [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp), Claude Code docs, read Nov 22, 2026
1. [Tools reference](https://code.claude.com/docs/en/tools-reference), Claude Code docs, read Nov 22, 2026
1. [Configure permissions](https://code.claude.com/docs/en/permissions), Claude Code docs, read Nov 22, 2026
1. [Hooks reference](https://code.claude.com/docs/en/hooks), Claude Code docs, read Nov 22, 2026
1. [Sandboxing](https://code.claude.com/docs/en/sandboxing), Claude Code docs, read Nov 22, 2026
1. [Permission modes](https://code.claude.com/docs/en/permission-modes), Claude Code docs, read Nov 22, 2026
1. [Claude Code settings](https://code.claude.com/docs/en/settings), Claude Code docs, read Nov 22, 2026
1. [Environment variables](https://code.claude.com/docs/en/env-vars), Claude Code docs, read Nov 22, 2026
1. [Managed settings](https://code.claude.com/docs/en/managed-settings), Claude Code docs, read Nov 22, 2026
1. [Manage costs effectively](https://code.claude.com/docs/en/costs), Claude Code docs, read Nov 22, 2026
1. [Context window](https://code.claude.com/docs/en/context-window), Claude Code docs, read Nov 22, 2026
1. [Prompt caching in Claude Code](https://code.claude.com/docs/en/prompt-caching), Claude Code docs, read Nov 22, 2026
1. [Run Claude Code programmatically](https://code.claude.com/docs/en/headless), Claude Code docs, read Nov 22, 2026
1. [Agent teams](https://code.claude.com/docs/en/agent-teams), Claude Code docs, read Nov 22, 2026
1. [Subagents](https://code.claude.com/docs/en/sub-agents), Claude Code docs, read Nov 22, 2026
1. [Interactive mode](https://code.claude.com/docs/en/interactive-mode), Claude Code docs, read Nov 22, 2026
1. [Set up Claude Code](https://code.claude.com/docs/en/setup), Claude Code docs, read Nov 22, 2026
1. [Monitoring (OpenTelemetry)](https://code.claude.com/docs/en/monitoring-usage), Claude Code docs, read Nov 22, 2026
1. [Pricing](https://platform.claude.com/docs/en/about-claude/pricing), Claude Platform docs, read Nov 22, 2026
1. [Glossary](https://platform.claude.com/docs/en/about-claude/glossary), Claude Platform docs, read Nov 22, 2026
1. [Token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting), Claude Platform docs, read Nov 22, 2026
1. [Prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching), Claude Platform docs, read Nov 22, 2026
1. [Programmatic tool calling](https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling), Claude Platform docs, read Nov 22, 2026
1. [Specification 2025-06-18: Tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools), Model Context Protocol, read Nov 22, 2026
1. [claude-code-mode-benchmark](https://github.com/Bicameral-AI/claude-code-mode-benchmark), Bicameral, GitHub, Nov 17, 2026, read Nov 22, 2026
1. [REST API endpoints for issues](https://docs.github.com/en/rest/issues/issues), GitHub Docs, read Nov 22, 2026
1. [Rate limits for the REST API](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api), GitHub Docs, read Nov 22, 2026
1. [Data API catalog](https://api.everyinfra.com/api/v1/social/catalog), EveryInfra, read Nov 22, 2026
1. [Code execution with MCP](https://www.anthropic.com/engineering/code-execution-with-mcp), Anthropic Engineering, Nov 2025, read Nov 22, 2026
1. [Introducing advanced tool use](https://www.anthropic.com/engineering/advanced-tool-use), Anthropic Engineering, read Nov 22, 2026
1. [Building agents: When to fold subagents into your main agent loop](https://claude.com/resources/articles/building-agents-when-to-fold-subagents-into-your-main-agent-loop), Anthropic, Oct 22, 2026, read Nov 22, 2026
1. [Code Mode: the better way to use MCP](https://blog.cloudflare.com/code-mode/), Cloudflare blog, Sep 2025, read Nov 22, 2026
1. [I benchmarked Claude Code's Code Mode across 4 models](https://www.reddit.com/r/ClaudeAI/comments/1xymddk/i_benchmarked_claude_codes_code_mode_across_4/), Reddit r/ClaudeAI, Nov 17, 2026, read Nov 22, 2026
1. [Claude Code Code Mode: how to turn it on](https://wmedia.es/en/tips/claude-code-code-mode-turn-on), wmedia, Nov 13, 2026, read Nov 22, 2026
1. [Claude Code Code Mode](https://flaviocopes.com/claude-code-code-mode), Flavio Copes, Nov 18, 2026, read Nov 22, 2026
1. [Claude Code Finally Got MCP Code Mode (Setup + Test)](https://www.youtube.com/watch?v=wSYqwfd5mV0), JeredBlu, YouTube, Nov 16, 2026, read Nov 22, 2026
1. [I Tested Claude Code's New Code Mode 6 Times](https://www.youtube.com/watch?v=nraROC2wl8s), Better Stack, YouTube, Nov 20, 2026, read Nov 22, 2026
1. [Code Mode Makes Claude Code Smarter & Cheaper](https://www.youtube.com/watch?v=DRNbxPk9Ab8), Ray Amjad, YouTube, Nov 16, 2026, read Nov 22, 2026
