claude-code - 💡(How to fix) Fix /branch causes massive context inflation — 6% to 73% after single message [4 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45419Fetched 2026-04-09 08:05:51
View on GitHub
Comments
4
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
commented ×4closed ×1
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I searched existing issues and found no duplicates
  • I am using the latest version of Claude Code

What's Wrong?

After using /branch to create a branch from a conversation at 6% context (59.7k/1M tokens), the new branch shows 73% context (735k/1M tokens) after sending a single short message.

The system/tools/memory/skills categories remain identical between parent and branch — the entire inflation is in the Messages category:

  • Before branch: Messages = 40.5k tokens (4.0%)
  • After branch + 1 message: Messages = 715.6k tokens (71.6%)

That's ~675k tokens appearing from nowhere. One short message cannot account for this.

Steps to Reproduce

  1. Have a conversation at ~6% context usage (59.7k tokens)
  2. Run /context to confirm usage
  3. Run /branch
  4. Send one short message in the new branch
  5. Run /context again

Expected Behavior

Context usage in the branch should be roughly the same as the parent session plus the new message/response — maybe 7-8%, not 73%.

Actual Behavior

Context jumps from 6% (59.7k) to 73% (735k). The Messages category inflates from 40.5k to 715.6k tokens.

All non-message categories are identical between parent and branch:

  • System prompt: 6.5k (0.6%)
  • System tools: 7.9k (0.8%)
  • MCP tools: ~2.2k (0.2%)
  • Memory files: 2.9k (0.3%)
  • Skills: 1.2k (0.1%)
  • Autocompact buffer: 21k (2.1%)

Only Messages inflates: 40.5k → 715.6k. This suggests /branch is either duplicating/expanding message history without compaction, or the token counter is miscalculating after a branch.

Screenshots

Will attach /context screenshots (before and after) in comments.

Claude Model

Opus 4.6 (1M context)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.96

Platform

Anthropic API

Operating System

macOS (Darwin 24.6.0)

Terminal/Shell

zsh

Additional Information

This is distinct from the general token consumption issues (#41930, #40524, #41607) — those are about cache invalidation and compaction bugs. This is specifically about /branch inflating the Messages token count by ~18x immediately.

extent analysis

TL;DR

The issue can be mitigated by investigating the /branch command's behavior and its impact on message history compaction.

Guidance

  • Verify that the /branch command is correctly implemented and does not inadvertently duplicate or expand message history without compaction.
  • Check the token counter's calculation after a branch is created to ensure it accurately reflects the new context usage.
  • Investigate if there are any known issues or bugs related to the /branch command and context usage in the Claude Code version 2.1.96.
  • Compare the behavior of the /branch command with other similar commands to identify any inconsistencies.

Example

No code snippet is provided as the issue does not contain sufficient information to create a relevant example.

Notes

The issue seems to be specific to the /branch command and its interaction with message history and context usage. Further investigation is needed to determine the root cause of the problem.

Recommendation

Apply workaround: Investigate and potentially modify the /branch command to correctly handle message history compaction and token counting to prevent context usage inflation.

FAIL-SAFE: Given the lack of information about the internal implementation of the /branch command and the Claude Code, the above guidance is provided with the assumption that the issue is related to the command's behavior and its impact on context usage.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING