{"schemaVersion":"1.0","publication":{"slug":"pivot-claude-code","name":"Claude Code Review","description":"Workflows, releases, and field notes for Anthropic's coding agent.","audience":"Developers and teams adopting Claude Code.","geography":null},"edition":{"id":"299b20e8-0293-44da-8731-ac2e7e4e675c","date":"2026-11-04","status":"locked","createdAt":"2026-11-03T00:47:49.390Z","storyCount":3,"newsletterSubject":"Claude Code cuts long-session lag 35%, Cursor users told to check for a leaked key, edits now locked to your project"},"updatedAt":"2026-11-04T20:24:29.358Z","stories":[{"id":"f1399db0-fc07-4153-b732-b7a015471605","title":"Cursor Users Who Installed Claude Code on Oct 29 Should Check for an Attacker's Key","dek":"An extension is an add-on to your editor and a marketplace is its built-in add-on store; uninstalling the tampered build leaves behind the login key and startup entries it added to your computer.","bodyMd":"Two tampered builds of the `anthropic.claude-code` extension, 2.1.312 and 2.1.313, were served from Cursor's extension marketplace on October 29. Cursor says they were live for roughly 11 hours, from about 2:27 AM to 1:35 PM PDT, and that at most 5,000 users received them. Cursor users with automatic extension updates on could have received the build without any action. Microsoft Threat Intelligence published its analysis of the build on October 31.\n\nTwo terms used below: `authorized_keys` is the file (`~/.ssh/authorized_keys`) that lists the SSH public keys allowed to log in to your account without a password, and `svc-telemetry` is the comment label on the attacker's key that the loader added to it.\n\nThe attacker prepended a JavaScript loader to `extension.js` and left the real code intact. It runs when the extension loads, before the extension's own code and with no prompt, so you do not need to start a Claude Code session. According to Microsoft Threat Intelligence, Phorion and OpenSourceMalware, the loader collects hostname, username, OS, Git email and the names (not values) of up to 40 environment variables containing strings such as KEY, TOKEN, SECRET or AWS. It then appends an Ed25519 public key commented `svc-telemetry` to `~/.ssh/authorized_keys`, tries to enable SSH, and opens a reverse tunnel to 134.209.82[.]225.\n\nThe cleanup problem is where it writes. Persistence sits outside the extension folder: a LaunchAgent at `~/Library/LaunchAgents/com.apple.sysmond.plist` on macOS, an `@reboot` crontab entry on Linux, and a SysMon scheduled task or `sysmon.cmd` in the Startup folder on Windows. Supporting files include `~/.config/.smt` and `.smtk`. Removing or updating the extension leaves all of it in place, and Microsoft says Cursor's takedown of the attacker's server does not remove what is already on a device.\n\nFor triage, check `authorized_keys` for the `svc-telemetry` line, but Microsoft's guidance is to confirm the key against the published fingerprint rather than its label. Phorion's advisory lists that fingerprint, and a Medium analysis of the build adds that the label is a free-text comment anyone with access can edit. Microsoft also advises preserving the package, SSH files and startup configuration before cleanup, isolating machines that show loader execution, and rotating credentials and revoking sessions from a known-clean device. Phorion's cleanup order is to kill the retry loop and any `ssh` or `autossh` processes, remove the persistence, delete the key line and `/tmp/.stk_` files, confirm Remote Login is off on macOS, and rotate credentials if SSH was enabled or an inbound login is suspected. A login from 127.0.0.1 using that key means someone came back through the tunnel.\n\nActual remote access was probably limited. Cursor said errors in the malicious code blocked the SSH step on most macOS and Windows hosts. Phorion found that coding errors likely blocked remote access on many affected systems: on macOS the loader ran `systemsetup -getremotelogin` without admin rights, and on Windows it relied on `/bin/sh`. Key planting, persistence and the host report still went ahead. Cursor's listed hashes cover only macOS Apple silicon and Windows x64 packages, though the loader contains a Linux branch.\n\nAnthropic's Felix Rieseberg wrote that \"it wasn't a compromise of Anthropic's systems or employee laptops\" and that a malicious actor used access to Cursor's marketplace to publish the copy. Anthropic says the npm package and its official channels were unaffected, and Cursor has said it found no other tampered extensions. How the attacker obtained publishing access is still unexplained. Security researcher Kevin Beaumont, by contrast, calls it a compromise of Anthropic's verified account and says the replacement release does not undo what the earlier build installed.\n\nFor teams on Cursor, Microsoft points to the editor's hardening guidance: restrict extensions to approved publishers and set an installation cooldown that delays newly published versions.","status":"published","storyType":"news","category":"Ecosystem","clusterKey":"claude-code-extension-ssh-backdoor-cursor-marketplace","slug":"check-authorized-keys-for-a-svc-telemetry-key-if-cursor-updated-claude-c-f1399d","url":"https://claudecodereview.ai/a/check-authorized-keys-for-a-svc-telemetry-key-if-cursor-updated-claude-c-f1399d/","relayUrl":"https://relaygrid.com/publications/pivot-claude-code/stories/f1399db0-fc07-4153-b732-b7a015471605","role":"lead","position":0,"imageStatus":"ready","imageUrl":"https://media.pivotnews.ai/brands/claude-code-review/articles/check-authorized-keys-for-a-svc-telemetry-key-if-cursor-updated-claude-c-f1399d/0748d1d315752ecd-c0f03986da69938d/web_hero.webp","imageAlt":"A row of horizontal file lines with one specific line lifted out of the sequence to indicate an unauthorized entry.","createdAt":"2026-11-02T22:41:19.833Z","updatedAt":"2026-11-04T20:24:29.358Z","sources":[{"role":"primary","title":"Tampered Claude Code extension in Cursor marketplace planted SSH backdoor","url":"https://pivotnews.ai/build/tampered-claude-code-extension-in-cursor-marketplace","sourceName":"Pivot News","author":null,"publishedAt":"2026-10-31T06:21:15Z"},{"role":"supporting","title":"A Backdoored Claude Code Extension Shipped Through Cursor’s Marketplace. Here’s What to Check","url":"https://medium.com/@oleg.a.ivanchenko/a-backdoored-claude-code-extension-shipped-through-cursors-marketplace-here-s-what-to-check-ba86366885da?source=rss------claude_code-5","sourceName":"Oleg Ivanchenko","author":"Oleg Ivanchenko","publishedAt":"2026-10-31T14:53:44Z"},{"role":"supporting","title":"Pulled Claude Code 2.1.313 extension carried a backdoor, Phorion says","url":"https://pivotnews.ai/security/pulled-claude-code-2-1-313-extension-carried-a-backdoor","sourceName":"Pivot News","author":null,"publishedAt":"2026-10-31T10:07:07Z"},{"role":"supporting","title":"Cursor says trojanized Claude Code extension planted SSH backdoors","url":"https://pivotnews.ai/security/cursor-says-trojanized-claude-code-extension-planted-ssh","sourceName":"Pivot News","author":null,"publishedAt":"2026-10-31T08:21:05Z"},{"role":"supporting","title":"Claude Code extension carried an SSH backdoor, security researcher says","url":"https://pivotnews.ai/security/claude-code-extension-carried-an-ssh-backdoor-security","sourceName":"Pivot News","author":null,"publishedAt":"2026-10-31T02:21:20Z"},{"role":"supporting","title":"Beaumont says backdoored Claude Code extension hit developer machines","url":"https://pivotnews.ai/security/beaumont-says-backdoored-claude-code-extension-hit","sourceName":"Pivot News","author":null,"publishedAt":"2026-10-31T01:21:57Z"},{"role":"supporting","title":"Malicious Claude Code extension reached up to 5,000 Cursor users","url":"https://pivotnews.ai/security/malicious-claude-code-extension-reached-up-to-5-000-cursor","sourceName":"Pivot News","author":null,"publishedAt":"2026-10-31T01:21:41Z"},{"role":"supporting","title":"Claude Code Extension Compromise: Check Your Marketplace, Not Just Your Model","url":"https://open.spotify.com/episode/6BwvgiUg5VP104lRAHQTx7","sourceName":"Claude Code Cast","author":"Claude Code Cast","publishedAt":"2026-10-30T15:34:00Z"}]},{"id":"a1b3be8d-cbd4-4d4a-8d51-3799ce3d3138","title":"Claude Code Starts Replies 35% Sooner in Very Long Chats","dek":"Anthropic's message threads stop Claude Code resending the whole conversation each turn, but token use stays the same.","bodyMd":"Anthropic introduced message threads on 2 November as part of the Claude Messages API, and the feature is on by default for most Claude Code users. Instead of resending the full conversation with every request, an agent sends only what changed since the last turn. Anthropic reports a 35% reduction in median time-to-first-token for large requests, according to ZDNET.\n\nThe gain concentrates in sessions with a context of 500,000 to 1 million tokens. Computer-using agents benefit as well: screenshots \"stay with the thread instead of being re-uploaded on every turn,\" per Anthropic's blog post as quoted by ZDNET. API users can switch the feature on with the `thread` parameter on their requests.\n\nZDNET ran the numbers against its own Claude Code logs. Roughly 980 turns recorded before the feature arrived showed Claude typically starting a response about 3 seconds after a mid-task request at contexts of 500,000 tokens and up. Busy evenings produced 100 to 225 model calls over four hours. Applying Anthropic's 35% figure, ZDNET estimates a saving of 2 to 4 minutes per four-hour session. The 35% is Anthropic's own measurement, and the minutes are a quick projection built on that number rather than a measured result.\n\nCost does not move. The model still processes the full conversation on every turn, so token usage is unchanged, and rate limits are the same. Message threads can be combined with prompt caching, which is the feature that actually lowers spend by avoiding repeated processing of the same prompt.\n\nThere are limits. One-off requests see no improvement. Any conversation that pauses for more than 5 minutes between turns sends the full message contents again. Message threads also do not replace context management or compaction, and a larger context still carries a greater risk that the model loses track of its task.","status":"published","storyType":"news","category":"Release","clusterKey":"claude-code-message-threads","slug":"get-faster-replies-in-long-sessions-now-that-message-threads-stop-resend-a1b3be","url":"https://claudecodereview.ai/a/get-faster-replies-in-long-sessions-now-that-message-threads-stop-resend-a1b3be/","relayUrl":"https://relaygrid.com/publications/pivot-claude-code/stories/a1b3be8d-cbd4-4d4a-8d51-3799ce3d3138","role":"item","position":1,"imageStatus":"ready","imageUrl":"https://media.pivotnews.ai/brands/claude-code-review/articles/get-faster-replies-in-long-sessions-now-that-message-threads-stop-resend-a1b3be/6cc22d7cd68f8a92-d1d1cae4efc1544a/web_hero.webp","imageAlt":"A long, continuous document scroll splitting into individual segments, with one segment lifted away from the stack to illustrate sending only updated message turns.","createdAt":"2026-11-03T20:49:41.104Z","updatedAt":"2026-11-04T19:40:03.743Z","sources":[{"role":"primary","title":"Is Claude Code truly faster with message threads? I did the math on my logs - ZDNET","url":"https://zdnet.com/innovation/claude-code-message-threads-speed-test","sourceName":"\"when:7d \"Claude Code\" Anthropic\" - Google News","author":"\"when:7d \"Claude Code\" Anthropic\" - Google News","publishedAt":"2026-11-03T13:11:36Z"},{"role":"supporting","title":"Claude Code now can chat with different sessions???","url":"https://reddit.com/r/ClaudeCode/comments/1xmwrug/claude_code_now_can_chat_with_different_sessions","sourceName":"/u/Ok-Patient116","author":"/u/Ok-Patient116","publishedAt":"2026-11-03T15:59:13Z"},{"role":"supporting","title":"Anthropic speeds up Claude Code with message threads. But your token bill stays the same. - The New Stack","url":"https://thenewstack.io/anthropic-claude-message-threads","sourceName":"\"when:7d \"Claude Code\" Anthropic\" - Google News","author":"\"when:7d \"Claude Code\" Anthropic\" - Google News","publishedAt":"2026-11-03T13:50:46Z"}]},{"id":"a8deb3ca-a79e-49cd-8bff-4d115c4288e7","title":"Claude Code Adds a Setting to Block Edits Outside Your Project","dek":"A new setting makes Claude Code's file-editing tools refuse to touch paths outside the folders the session is working in, whichever permission mode is active.","bodyMd":"Claude Code 2.1.314 adds a setting called `permissions.blockWritesOutsideWorkingDirectories`; the GitHub release is dated 2026-10-30. With it, the Write, Edit and NotebookEdit tools refuse paths outside the working directories, the folders the session is working in. The release notes say this holds in every permission mode.\n\nThat last clause is the point: the release notes do not carve out any mode, so the refusal is not tied to the mode a session happens to be in.\n\nThe setting sits under `permissions` in Claude Code's settings. The Claude Agent SDK for TypeScript, version 0.3.314, also adds `permissions.blockWritesOutsideWorkingDirectories` to its `Settings` type. That release is at parity with Claude Code 2.1.314 and updates with `npm install @anthropic-ai/claude-agent-sdk@0.3.314` (yarn, pnpm and bun work as well).\n\nThe scope is narrow. The setting names three file-writing tools: Write, Edit and NotebookEdit. The release notes do not mention shell commands.\n\nOther changes in the same release touch the same area. Claude's file tools now ask before editing the local copy of your organization's server-managed settings, as they already do for your own settings files. A settings file left out with `--setting-sources` no longer supplies some settings, such as auto mode rules and saved permission consents. Sandbox protections now apply to a worktree entered by `claude -p --resume` or `--continue`.\n\nThe release also adds idle compaction to VS Code and Claude Desktop's Code tab. A conversation of 200K+ tokens left idle is summarized, and the summary is used on your next message if the prompt cache has expired.","status":"published","storyType":"news","category":"Release","clusterKey":"block-writes-outside-working-directories-setting","slug":"stop-write-and-edit-from-touching-files-outside-your-project-in-every-pe-a8deb3","url":"https://claudecodereview.ai/a/stop-write-and-edit-from-touching-files-outside-your-project-in-every-pe-a8deb3/","relayUrl":"https://relaygrid.com/publications/pivot-claude-code/stories/a8deb3ca-a79e-49cd-8bff-4d115c4288e7","role":"item","position":2,"imageStatus":"ready","imageUrl":"https://media.pivotnews.ai/brands/claude-code-review/articles/stop-write-and-edit-from-touching-files-outside-your-project-in-every-pe-a8deb3/7a1c5d208892d2f6-61ba405a5cbc4ed8/web_hero.webp","imageAlt":"A diagram shows three rectangular blocks inside a larger container, with an external line being blocked from entering the container's perimeter.","createdAt":"2026-11-03T00:15:08.332Z","updatedAt":"2026-11-04T19:44:23.483Z","sources":[{"role":"primary","title":"Claude Code v2.1.314","url":"https://github.com/anthropics/claude-code/releases/tag/v2.1.314","sourceName":"Anthropic","author":"Anthropic","publishedAt":"2026-10-30T01:06:26Z"},{"role":"supporting","title":"2.1.314","url":"https://code.claude.com/docs/en/changelog#2-1-314","sourceName":"Claude Code changelog","author":"Claude Code changelog","publishedAt":"2026-10-30T01:16:56Z"},{"role":"supporting","title":"Claude Agent SDK for TypeScript v0.3.314","url":"https://github.com/anthropics/claude-agent-sdk-typescript/releases/tag/v0.3.314","sourceName":"Anthropic","author":"Anthropic","publishedAt":"2026-10-30T01:05:35Z"}]}],"tips":[{"id":"c2c400d8-1f06-47b3-8d67-3fa31b8d2401","title":"az-brake Makes Claude Code Ask Before About 50 Types of Billable Azure Resources","dek":"A chat \"yes\" to a cost plan let a storage account through with no real control, so the az-brake plugin adds an approval prompt before billable Azure commands, though if the plugin hits an error it lets the command run without asking instead of blocking it.","bodyMd":"Approving a cost plan in chat does not tie that approval to the commands that follow. In one test, Claude Code and its user agreed a plan for an Azure storage account, then Claude Code created a resource group and the account. Nothing went wrong, but the same \"yes\" would have covered a bigger SKU or a second account.\n\nBudget alerts do not close the gap. They react to usage records, and hours after the test the subscription showed no usage rows for the new storage account. The check has to run before the command.\n\n**What az-brake does**\n\naz-brake is a Claude Code plugin built on a PreToolUse hook, which runs before every shell command. When an Azure CLI command looks billable, the hook answers \"ask\" and Claude Code shows its normal approval prompt. The prompt names the resource type being created, plus the name, size, SKU and location flags when the command has them. In a chained command (`a && b && c`), every billable step is listed.\n\nIt never shows a price, because the hook cannot see your rates, discounts or reservations.\n\n**Install**\n\nRun `/plugin install az-brake --marketplace thisismairaj/az-brake` inside Claude Code. The package is also on npm as `az-brake`. It needs Node 20 or newer on your PATH and has nothing to configure.\n\n**What it asks about, and what passes**\n\n- About 50 resource types prompt: virtual machines and scale sets, disks, storage accounts, AKS clusters and node pools, SQL databases, PostgreSQL and MySQL flexible servers, Cosmos DB, Redis, web and function apps, Databricks workspaces, Log Analytics, public IPs, gateways and load balancers, and more.\n- Starting, resuming, scaling or resizing those resources also prompts.\n- Commands that can create anything, such as deployments, `az stack create`, `az resource create` and `az rest --method put`, prompt too. The prompt says it cannot see what the template contains.\n- Reads, `list`, `show`, deletes, `az login`, resource groups and virtual networks run without a prompt. So does a `--what-if` run, and so do `az group create` and `az sql server create`, which are free on their own.\n\nThe short pass list is deliberate. A hook that asks too often gets switched off.\n\n**Limits**\n\nThe hook fails open: if the plugin hits an internal error, it lets the Azure command run without asking you instead of blocking it, on the reasoning that a brake that jams gets uninstalled. It is a speed bump, not a security boundary. It reads command text, so it does not catch `bash -c \"az vm create ...\"`, Terraform, the portal, or anything typed by hand.\n\nIts developer ran 95 unit cases and checked each command path against the installed Azure CLI. Ten paths turned out to live in CLI extensions. Headless `claude -p` runs in dontAsk and bypassPermissions modes blocked an `az storage account create` command, while a free `az group exists` passed. The interactive approval dialog, the PowerShell path, machines without Git Bash, and macOS and Linux are not yet verified. It was built and tested on Windows only.","category":"Workflow","slug":"az-brake-makes-claude-code-ask-before-about-50-types-of-billable-azure-r-c2c400","url":"https://claudecodereview.ai/a/az-brake-makes-claude-code-ask-before-about-50-types-of-billable-azure-r-c2c400/","relayUrl":"https://relaygrid.com/publications/pivot-claude-code/stories/c2c400d8-1f06-47b3-8d67-3fa31b8d2401","imageUrl":null,"imageAlt":null,"createdAt":"2026-11-19T04:42:58.750Z"},{"id":"0cad986f-60d8-4568-8c8e-1a80359bfb24","title":"Write a Handoff Note Before Closing Claude Code So Tomorrow's Session Starts With Evidence","dek":"A short note covering goal, state, checks and next step lets a fresh session pick up unfinished work without treating yesterday's guesses as facts.","bodyMd":"Before you end a complicated session, ask Claude Code for a short handoff note. It gives the next session a route back into the work: where things stand, what the evidence says, and the next thing to check. Without it, the first task of the day is often reconstructing the last task of yesterday.\n\n**Try the built-in options first.** Claude Code already saves CLI conversations. Anthropic's session documentation lists `claude --continue` for the most recent session in the current directory and `claude --resume` for a session picker. If you are continuing the same task, start there.\n\nA handoff note earns its place when you want a concise review of unfinished work, a fresh conversation, or a teammate to take over. It does not transfer a running process, restore an environment, or replace the conversation history. `HANDOFF.md` is only a filename you choose, with no automatic loading, so you have to ask Claude Code to read it.\n\n**What the note should answer.** Six short sections:\n\n1. **Goal:** the behavior the user should get, including the awkward case.\n2. **Current state:** working directory, branch, revision, relevant files and uncommitted changes.\n3. **Decisions:** what was chosen and why, with a pointer to the requirement or discussion.\n4. **Checks:** the exact command, the observed result, and which version of the code was checked.\n5. **Open questions:** assumptions, blockers and work that has not been tested.\n6. **Next step:** one concrete action and the check that will show whether it helped.\n\n**How to use it.**\n\n1. While the session can still inspect the work, ask Claude Code to draft the note. Adapt the filename if your project already has a handoff convention.\n2. Review the draft and correct anything vague or wrong. Replace \"tests pass\" with the actual command and what it covered.\n3. Ask Claude Code to save the agreed note.\n4. In the next session, in the right project, ask it to read the note and identify the current state and its first verification step before editing.\n\n**Make the note earn your trust.** If the branch changed overnight, reconcile it. A test that ran before the latest edit describes the earlier state. If the note names a file that is missing, investigate. Check that any referenced process is still running and the environment is available, since \"server started\" does not survive a shutdown.\n\n**Where it lives.** A personal scratch note can stay local. A team handoff may belong in a ticket or a reviewed repository file. Link to approved evidence rather than pasting private logs or credentials. For parallel tasks, use separate notes so two sessions are not rewriting the same status.\n\n**Keep it out of permanent instructions.** Anthropic's memory documentation separates persistent project instructions from auto memory. Put stable conventions in the project's instruction files, use the handoff for the current task's changing state, and retire it when the task is done. Lasting architectural decisions belong in a decision record that the note links to.\n\n**Limits.** This is a proposed workflow, not a tested guarantee that Claude Code will follow every line, and no speedup has been measured. Keep your normal permissions and checks. To test it, pause one small local task, then see whether a fresh session finds the right files, keeps the known limitation, and separates passed checks from work not run.","category":"Workflow","slug":"write-a-handoff-note-before-closing-claude-code-so-tomorrow-s-session-st-0cad98","url":"https://claudecodereview.ai/a/write-a-handoff-note-before-closing-claude-code-so-tomorrow-s-session-st-0cad98/","relayUrl":"https://relaygrid.com/publications/pivot-claude-code/stories/0cad986f-60d8-4568-8c8e-1a80359bfb24","imageUrl":null,"imageAlt":null,"createdAt":"2026-11-19T04:41:01.222Z"},{"id":"3f33bc2f-7cb9-4cf6-8522-bd4525e7a25a","title":"Claude Code Lets You Save a Commit Prompt as a One-File Shortcut","dek":"A slash command, a saved prompt you run by typing a slash and its name, drafts a commit message in a fixed format from your staged changes and takes extra instructions each time.","bodyMd":"If you keep pasting `git status`, the staged diff and \"write a conventional commit, then wait\" into Claude Code, the prompt can live in a slash command instead. A slash command is a saved prompt you run by typing a slash and its name, and it is just a markdown file in your project. A conventional commit is a commit message that follows a fixed format, `type(scope): summary`, so history is easy to read and parse. The file name becomes the command, and `$ARGUMENTS` lets you add instructions each time.\n\n**The file**\n\nSave this as `.claude/commands/commit.md`:\n\n```\n---\ndescription: \"Draft a conventional commit for staged changes\"\nargument-hint: \"[stage | extra instructions]\"\n---\nWrite a conventional commit for the currently staged changes only.\n\n1. Run `git diff --cached` and `git status -sb`. If nothing is staged, stop and say so. Do not stage files yourself unless I passed `stage` as an argument.\n2. Propose a single commit message: `type(scope): summary` plus an optional body.\n3. Use one of feat, fix, docs, refactor, test, chore, perf, or ci.\n4. Do not add `Co-Authored-By` or other AI attribution unless I ask.\n5. If I passed arguments (`$ARGUMENTS`), treat them as extra instructions (for example `stage` or a scope hint).\n6. Show the message and wait for me to confirm before running `git commit`. Never push.\n```\n\n**Using it**\n\nRun `/commit` to draft a message for what is already staged, or `/commit stage` to let Claude Code stage files first. Claude Code injects the file as the prompt and replaces `$ARGUMENTS` with whatever you type after the command. A scope hint works the same way.\n\nKeeping \"wait for confirm\" and \"never push\" inside the command reduces unattended commits. If you want a harder guard, pair it with an \"ask\" permission rule for `git commit`.\n\n**Sharing and variations**\n\nCommit the command file so every teammate gets the same workflow. If you need several separate values, use `$1` and `$2` positional placeholders instead of `$ARGUMENTS`.","category":"Workflow","slug":"claude-code-lets-you-save-a-commit-prompt-as-a-one-file-shortcut-3f33bc","url":"https://claudecodereview.ai/a/claude-code-lets-you-save-a-commit-prompt-as-a-one-file-shortcut-3f33bc/","relayUrl":"https://relaygrid.com/publications/pivot-claude-code/stories/3f33bc2f-7cb9-4cf6-8522-bd4525e7a25a","imageUrl":null,"imageAlt":null,"createdAt":"2026-11-19T04:40:07.341Z"},{"id":"2709258f-7db4-4690-88d9-417bb07f2634","title":"Cut Tokens (Billing Units) in Claude Code: 18 Fixes, Starting With Clearing Chat History Between Tasks","dek":"Most tokens go to the conversation history Claude Code re-sends on every turn, so the biggest savings come from shrinking that history and sending routine work to cheaper models.","bodyMd":"A guide built from Claude Code's cost, caching and model docs lists 18 ways to cut token use. Its premise: most tokens are not your prompts. Claude Code sends the full conversation (system prompt, CLAUDE.md, every message, file read and test log) with each request, and every tool call is another request. The prompt cache, which bills repeated history at a lower rate, softens this, but a thousand turns still add up.\n\n**The changes with the clearest steps**\n\n1. **Clear between tasks.** `/clear` starts empty and costs nothing. Name the session so you can return: `/clear oauth-migration`, then `/resume oauth-migration`. `/compact` summarizes instead, but it has to read the whole conversation, so compacting a big context is itself a big request.\n2. **Lower the auto-compact window.** Sessions on current models compact at about 967K tokens by default. Run `/autocompact 200k` for the current model, set `\"autoCompactWindow\": 200000` in `~/.claude/settings.json` for every model, or launch with `claude --autocompact 300k`. `/autocompact auto` restores the default. Accepted sizes run from 100K to 1M.\n3. **Compact at a break, with a focus line.** Example: `/compact Focus on the auth refactor: files changed, failing tests, and the decision to keep JWT refresh in middleware`. Compact before you step away: after a break longer than the cache lifetime, the same compact reprocesses everything at full price.\n4. **Put compact instructions in CLAUDE.md.** Add a \"Compact instructions\" section, for example: \"When compacting, keep test output, code changes, file paths touched and open TODOs. Drop exploration notes.\"\n5. **Run codebase search on Haiku.** The built-in Explore subagent uses your main model. Create `.claude/agents/Explore.md` with frontmatter `name: Explore`, a description, `model: haiku` and `tools: Read, Grep, Glob`. On list prices, Claude Haiku 5.5 is $0.10 per million input tokens and $0.50 output, against $4 and $20 for Claude Opus 5.5. Haiku 5.5 bills $0.50 input once a prompt passes 100,000 tokens, so keep exploration scoped.\n6. **Route by job.** `/model opusplan` uses Claude Opus 5.5 in plan mode and Claude Sonnet 5.5 for execution. Sonnet lists at $2 input and $10 output. Each model has its own cache, so plan once per task.\n7. **Use an advisor.** `/model sonnet` then `/advisor opus` lets the main model consult a stronger one at decision points. `/advisor off` for small tasks. Each advisor call reads the full transcript uncached, so it suits long multi-step work.\n8. **Shrink CLAUDE.md.** The docs suggest under 200 lines. In one practitioner's measurement, a 129,349-character file made a trivial Haiku request read 125,424 tokens, against 28,952 in an empty directory. Imports do not reduce cost, because imported files load with the parent. Path-scoped rules do: put them in `.claude/rules/api.md` with `paths: [\"src/api/*.ts\"]`. Subagents can skip the file with `omitClaudeMd: true`. A short file that maps the project still helps: one iOS test dropped from about 100K to about 70K tokens with a root CLAUDE.md.\n9. **Move procedures into skills.** A skill body loads only when used. Add `disable-model-invocation: true` to skills you only want to run by hand.\n10. **Replace.claudeignore.** The permissions docs say it has no effect. Use Read deny rules in `.claude/settings.json`, such as `\"Read(./coverage/*)\"` and `\"Read(*.min.js)\"`. Claude applies them to Grep and Glob on a best-effort basis.\n11. **Trim test output with a hook.** The costs page includes a PreToolUse hook that appends `2>&1 | tail -n 100` to `npm test`, `pytest` or `go test`. Verify it with `/hooks`.\n12. **Send verbose work to a subagent** and ask for a short report. Subagents still spend their own tokens, so this only saves total tokens when the subagent is cheap and lean.\n13. **Cut MCP overhead.** Prefer CLIs like `gh`, `aws` and `gcloud`. MCP output warns at 10,000 tokens and caps at 25,000. Use `/context` to see what is eating space, then `/mcp disable sentry`. Do it at session start: connecting or removing a server invalidates the cache.\n14. **Protect the cache.** On Opus 5.5 and Sonnet 5.5 a cache hit costs 0.05x base input. On Sonnet 5.5 that is $0.10 per million tokens against $2.50 for a five-minute write. Switching models, turning on fast mode, changing MCP servers or plugins, compacting and upgrading Claude Code break it. Editing source files, changing permission mode, invoking skills and spawning subagents do not. API-key users can set `\"promptCacheTtl\": \"1h\"`, but one-hour writes cost 2x base instead of 1.25x.\n15. **Treat effort as a dial.** Medium is already the default on the current models. Use `/effort low` for renames and one-line edits, and `/effort status` to check. Typing `ultrathink` in a prompt raises one turn only.\n16. **Plan first and name the files.** `/plan add rate limiting to POST /api/login in src/api/auth.ts using the existing redis client in src/lib/redis.ts. Done means a test that sends 6 requests and gets 429 on the 6th.` Press Esc when it drifts and `/rewind` to a checkpoint.\n17. **Measure first.** `/context` shows what fills the window and `/usage` shows session tokens and cache stats. When the footer shows \"f to fix\", press `f` to apply the recommendations. Anthropic's own enterprise figure is about $13 per developer per active day.\n18. **Cap scripted runs.** `claude -p \"triage this issue\" --max-budget-usd 0.50`, `--max-turns 3`, and `--bare` to skip auto-discovery of hooks, skills, MCP servers and CLAUDE.md. Stop forgotten `/loop` tasks, or set `\"idleCompaction\": false`.\n\n**Where not to save**\n\nKeep Haiku off architecture, security review and tricky concurrency. Do not lower effort on bug fixes in existing code, and do not compact mid-debug when the error trail is the evidence. Deny reads on generated output only, never source, tests or lockfiles. Run tests in the main session before committing instead of trusting a subagent's summary. Agent teams are a poor place to save: the docs estimate about 7x more tokens than a standard session when teammates run in plan mode.\n\nFor a one-day start, run `/context` and `/usage`, set `/autocompact 200k`, add compact instructions, cut CLAUDE.md under 200 lines, and create the Haiku Explore agent.","category":"Workflow","slug":"cut-tokens-billing-units-in-claude-code-18-fixes-starting-with-clearing-270925","url":"https://claudecodereview.ai/a/cut-tokens-billing-units-in-claude-code-18-fixes-starting-with-clearing-270925/","relayUrl":"https://relaygrid.com/publications/pivot-claude-code/stories/2709258f-7db4-4690-88d9-417bb07f2634","imageUrl":"https://media.pivotnews.ai/brands/claude-code-review/articles/cut-tokens-billing-units-in-claude-code-18-fixes-starting-with-clearing-270925/ed13af64116c6652-c3b39bf7c4daa62d/web_hero.webp","imageAlt":"A vertical chain of 18 blocks with one block near the top detached and floating to the side, highlighted in clay-orange.","createdAt":"2026-11-19T01:27:13.583Z"},{"id":"259168be-e366-4ece-972a-42b284954e5d","title":"Catch Claude Code Saying \"Fixed\" When Nothing Ran After the Edit","dek":"A small script that runs when Claude Code tries to end its turn sends the agent back once if it claims success without a test or build; tested by re-running it against the developer's 3,977 saved past turns, it blocked 2 of the 406 that ended in a success claim.","bodyMd":"Claude Code sometimes edits a file and ends the turn with \"fixed\" or \"tests pass\" when nothing ran after that edit. A Stop hook called claude-code-claim-check (MIT license, plain Python, no dependencies) is built to catch that. A Stop hook is a script that runs when Claude Code tries to end its turn. The repo is at github.com/Balance0014/claude-code-claim-check.\n\n**How it works**\n\nWhen Claude Code tries to end a turn, the hook reads the session transcript. If the last message claims success and no test, build or command ran after the last code edit, it sends Claude Code back once with a short note: run the check, or say it isn't verified.\n\n**Try it before installing**\n\nThe repo includes a replay command, which re-runs the hook over your saved past sessions. Run it over your own session logs first to see what the hook would have blocked, before you install anything.\n\n**Why the tuning matters**\n\nIts developer re-ran 3,977 saved past turns through the hook, 406 of which ended in something like done, fixed, deployed or tests pass. The first version would have blocked 86 of them. Almost all were fine: Claude Code had run the tests a turn or two earlier and was wrapping up. After the fix, the same 406 claims produce 2 blocks, and one is the exact case the hook was built for: \"fixed\" right after an edit with nothing run since.\n\nLessons from getting it wrong:\n\n- Quoted text and code blocks have to be ignored, because Claude Code quotes the user back often.\n- Plans are not claims. \"Once tests pass I'll tag the release\" does not say tests passed.\n- The hook blocks once and never twice in a row, since repeated blocks can trap the agent in a loop and burn tokens.\n- \"That function isn't used anywhere\" after a single grep is its own failure. The hook now wants two different kinds of lookup before it accepts a not-found.\n\n**Known gap**\n\nThe hook cannot cheaply catch a test that runs and passes but never touches the code that just changed.","category":"Workflow","slug":"catch-claude-code-saying-fixed-when-nothing-ran-after-the-edit-259168","url":"https://claudecodereview.ai/a/catch-claude-code-saying-fixed-when-nothing-ran-after-the-edit-259168/","relayUrl":"https://relaygrid.com/publications/pivot-claude-code/stories/259168be-e366-4ece-972a-42b284954e5d","imageUrl":"https://media.pivotnews.ai/brands/claude-code-review/articles/catch-claude-code-saying-fixed-when-nothing-ran-after-the-edit-259168/1e940951b8d6d9e1-309392540b98220f/web_hero.webp","imageAlt":"A diagram shows a branching structure ending in 406 items, with two items isolated and lifted away from the rest.","createdAt":"2026-11-19T01:15:33.807Z"}]}