context-window.md +17 −7
91 tokens: 2400,91 tokens: 2400,
92 color: '#8A8880',92 color: '#8A8880',
93 vis: 'brief',93 vis: 'brief',
94 restoredAfterCompact: true,
94 desc: 'Main auth file. You see "Read auth.ts" in your terminal, but the 2,400 tokens of file content only Claude sees.',95 desc: 'Main auth file. You see "Read auth.ts" in your terminal, but the 2,400 tokens of file content only Claude sees.',
95 tip: 'File reads dominate context usage. Be specific in prompts ("fix the bug in auth.ts") so Claude reads fewer files. For research-heavy tasks, use a subagent.',96 tip: 'File reads dominate context usage. Be specific in prompts ("fix the bug in auth.ts") so Claude reads fewer files. For research-heavy tasks, use a subagent.',
96 link: null97 link: null
101 tokens: 1100,102 tokens: 1100,
102 color: '#8A8880',103 color: '#8A8880',
103 vis: 'brief',104 vis: 'brief',
105 restoredAfterCompact: true,
104 desc: 'Following imports to the token module. Shown as a one-liner in your terminal.',106 desc: 'Following imports to the token module. Shown as a one-liner in your terminal.',
105 link: null107 link: null
106 }, {108 }, {
110 tokens: 380,112 tokens: 380,
111 color: '#4A9B8E',113 color: '#4A9B8E',
112 vis: 'brief',114 vis: 'brief',
115 restoredAfterCompact: true,
113 desc: 'This rule in `.claude/rules/` has a `paths:` pattern matching `src/api/**`. It loaded automatically when Claude read a file in that directory. You see "Loaded .claude/rules/api-conventions.md" in your terminal, but not the rule content.',116 desc: 'This rule in `.claude/rules/` has a `paths:` pattern matching `src/api/**`. It loaded automatically when Claude read a file in that directory. You see "Loaded .claude/rules/api-conventions.md" in your terminal, but not the rule content.',
114 link: '/en/memory#path-specific-rules'117 link: '/en/memory#path-specific-rules'
115 }, {118 }, {
119 tokens: 1800,122 tokens: 1800,
120 color: '#8A8880',123 color: '#8A8880',
121 vis: 'brief',124 vis: 'brief',
125 restoredAfterCompact: true,
122 desc: 'Tracing the auth flow deeper.',126 desc: 'Tracing the auth flow deeper.',
123 link: null127 link: null
124 }, {128 }, {
128 tokens: 1600,132 tokens: 1600,
129 color: '#8A8880',133 color: '#8A8880',
130 vis: 'brief',134 vis: 'brief',
135 restoredAfterCompact: true,
131 desc: 'Checking existing tests for expected behavior.',136 desc: 'Checking existing tests for expected behavior.',
132 link: null137 link: null
133 }, {138 }, {
137 tokens: 290,142 tokens: 290,
138 color: '#4A9B8E',143 color: '#4A9B8E',
139 vis: 'brief',144 vis: 'brief',
145 restoredAfterCompact: true,
140 desc: 'Another path-scoped rule, this one matching `*.test.ts` files. Triggered when Claude read auth.test.ts. Shown as a one-line "Loaded" notice.',146 desc: 'Another path-scoped rule, this one matching `*.test.ts` files. Triggered when Claude read auth.test.ts. Shown as a one-line "Loaded" notice.',
141 link: '/en/memory#path-specific-rules'147 link: '/en/memory#path-specific-rules'
142 }, {148 }, {
335 tokens: 620,341 tokens: 620,
336 color: '#558A42',342 color: '#558A42',
337 vis: 'brief',343 vis: 'brief',
338344 desc: 'You invoked a skill that has `disable-model-invocation: true`. Its description was not in the skill index at startup, so it cost zero context until this moment. Now the full skill content loads and Claude follows its instructions to stage, commit, and push your changes.', restoredAfterCompact: true,
345 desc: 'You invoked a skill that has `disable-model-invocation: true`. Its description was not in the skill index at startup, so it cost zero context until this moment. Now the full skill content loads and Claude follows its instructions to stage, commit, and push your changes. After `/compact`, Claude Code re-injects the body of each skill you invoked, capped at 5,000 tokens per skill.',
339 tip: 'Set `disable-model-invocation: true` on skills with side effects like committing, deploying, or sending messages. They stay out of context entirely until you need them.',346 tip: 'Set `disable-model-invocation: true` on skills with side effects like committing, deploying, or sending messages. They stay out of context entirely until you need them.',
340 link: '/en/skills#control-who-invokes-a-skill'347 link: '/en/skills#control-who-invokes-a-skill'
341 }, {}, {348 }, {}, {
531 }538 }
532 {}539 {}
533 const autoLoads = nonCompact.filter(e => e.kind === 'auto' && e.t < STARTUP_END && !e.noSurviveCompact);540 const autoLoads = nonCompact.filter(e => e.kind === 'auto' && e.t < STARTUP_END && !e.noSurviveCompact);
541 const restored = nonCompact.filter(e => e.restoredAfterCompact);
534 const summarized = nonCompact.filter(e => e.t >= STARTUP_END && e.kind !== 'sub');542 const summarized = nonCompact.filter(e => e.t >= STARTUP_END && e.kind !== 'sub');
535 const sumTokens = summarized.reduce((s, e) => s + e.tokens, 0);543 const sumTokens = summarized.reduce((s, e) => s + e.tokens, 0);
536 const summaryBlock = {544 const summaryBlock = {
540 tokens: Math.round(sumTokens * 0.12),548 tokens: Math.round(sumTokens * 0.12),
541 color: '#A09E96',549 color: '#A09E96',
542 vis: 'hidden',550 vis: 'hidden',
543551 desc: `All ${summarized.length} conversation events condensed into one structured summary. The summary keeps: your requests and intent, key technical concepts, files examined or modified with important code snippets, errors and how they were fixed, pending tasks, and current work. It replaces the verbatim conversation: full tool outputs and intermediate reasoning are gone. Claude can still reference the work but won't have the exact code it read earlier.`, desc: `All ${summarized.length} conversation events condensed into one structured summary. The summary keeps: your requests and intent, key technical concepts, files examined or modified with important code snippets, errors and how they were fixed, pending tasks, and current work. It replaces the verbatim conversation: full tool outputs and intermediate reasoning are gone. Claude Code re-reads the files modified most recently and re-injects the skills you invoked, listed below. Claude can still reference the rest of the work but won't have the exact content.`,
544 link: '/en/how-claude-code-works#the-context-window'552 link: '/en/how-claude-code-works#the-context-window'
545 };553 };
546 return {554 return {
547555 visible: [...autoLoads, summaryBlock], visible: [...autoLoads, summaryBlock, ...restored],
548 preCompactTotal: nonCompact.reduce((s, e) => s + e.tokens, 0)556 preCompactTotal: nonCompact.reduce((s, e) => s + e.tokens, 0)
549 };557 };
550 }, [preCompactVisible, isCompacted]);558 }, [preCompactVisible, isCompacted]);
617 if (detailRef.current) detailRef.current.scrollTop = 0;625 if (detailRef.current) detailRef.current.scrollTop = 0;
618 }, [hovEvent]);626 }, [hovEvent]);
619 const focusT = hovEvent ? hovEvent.t : time;627 const focusT = hovEvent ? hovEvent.t : time;
620628 const takeaway = isCompacted ? 'Compaction replaces the conversation with a structured summary. System prompt, CLAUDE.md, memory, and MCP tools reload automatically. The skill listing is the one exception. Only skills you actually invoked are preserved.' : focusT < STARTUP_END ? 'A lot loads before you type anything. CLAUDE.md, memory, skills, and MCP tools are all in context before your first prompt.' : focusT < 0.28 ? "Your prompt is tiny compared to what's already loaded. Most of Claude's context is project knowledge, not your words." : focusT < 0.50 ? 'Each file Claude reads grows the context. Path-scoped rules load automatically alongside matching files.' : focusT < 0.71 ? 'Hooks fire automatically on tool events. Output reaches Claude via additionalContext JSON. Exit code 2 surfaces stderr to Claude. Plain stdout on exit 0 goes to the debug log, not the transcript.' : focusT < 0.79 ? 'Follow-up questions keep building on the same context. Everything from earlier is still there.' : focusT < 0.87 ? "The subagent works in its own separate context window. None of its file reads touch yours. Only the final summary comes back." : focusT < 0.88 ? 'Bang commands run in your shell and prefix the output to your next message. Useful for grounding Claude in command results without it running them.' : focusT < 0.90 ? 'User-only skills stay out of context entirely until you invoke them. The skill index at startup only lists skills Claude can call on its own.' : '/compact summarizes the conversation to free space while keeping key information. In a real session, run it when context starts affecting performance or before a long new task.'; const takeaway = isCompacted ? 'Compaction replaces the conversation with a structured summary. System prompt, CLAUDE.md, memory, and MCP tools reload automatically. Claude Code also re-reads up to five of the files modified most recently, reloads the rules that match them, and re-injects the skills you invoked. The skill listing does not reload.' : focusT < STARTUP_END ? 'A lot loads before you type anything. CLAUDE.md, memory, skills, and MCP tools are all in context before your first prompt.' : focusT < 0.28 ? "Your prompt is tiny compared to what's already loaded. Most of Claude's context is project knowledge, not your words." : focusT < 0.50 ? 'Each file Claude reads grows the context. Path-scoped rules load automatically alongside matching files.' : focusT < 0.71 ? 'Hooks fire automatically on tool events. Output reaches Claude via additionalContext JSON. Exit code 2 surfaces stderr to Claude. Plain stdout on exit 0 goes to the debug log, not the transcript.' : focusT < 0.79 ? 'Follow-up questions keep building on the same context. Everything from earlier is still there.' : focusT < 0.87 ? "The subagent works in its own separate context window. None of its file reads touch yours. Only the final summary comes back." : focusT < 0.88 ? 'Bang commands run in your shell and prefix the output to your next message. Useful for grounding Claude in command results without it running them.' : focusT < 0.90 ? 'User-only skills stay out of context entirely until you invoke them. The skill index at startup only lists skills Claude can call on its own.' : '/compact summarizes the conversation to free space while keeping key information. In a real session, run it when context starts affecting performance or before a long new task.';
621629 const terminalView = isCompacted ? 'A "Conversation compacted" message. The summarization happens silently.' : focusT < STARTUP_END ? 'The input box, waiting for your first message. Everything above loads silently before you type anything.' : focusT < 0.28 ? 'Your prompt. Claude hasn\'t started working yet.' : focusT < 0.52 ? 'Your prompt and "Reading files...". Rules show as one-line "Loaded" notices, not their content.' : focusT < 0.72 ? "Claude's response and file diffs. Hooks fire silently. Tool output like npm test shows as a brief summary, not the full content." : focusT < 0.79 ? 'Your follow-up prompt.' : focusT < 0.86 ? "A brief notice that a subagent is working, then its result. You don't see the subagent's individual file reads." : focusT < 0.90 ? "Claude's response, your git status output, and the commit-push skill running." : 'Your full conversation. /compact is available to run.'; const terminalView = isCompacted ? 'A "Conversation compacted" message, then a one-line "Read auth.ts" for each re-read file and "Skills restored (commit-push)". The rules show as "Loaded" lines on Claude\'s next turn. None of the content itself appears.' : focusT < STARTUP_END ? 'The input box, waiting for your first message. Everything above loads silently before you type anything.' : focusT < 0.28 ? 'Your prompt. Claude hasn\'t started working yet.' : focusT < 0.52 ? 'Your prompt and "Reading files...". Rules show as one-line "Loaded" notices, not their content.' : focusT < 0.72 ? "Claude's response and file diffs. Hooks fire silently. Tool output like npm test shows as a brief summary, not the full content." : focusT < 0.79 ? 'Your follow-up prompt.' : focusT < 0.86 ? "A brief notice that a subagent is working, then its result. You don't see the subagent's individual file reads." : focusT < 0.90 ? "Claude's response, your git status output, and the commit-push skill running." : 'Your full conversation. /compact is available to run.';
622 const mono = 'var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)';630 const mono = 'var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)';
623 const renderWithCode = s => s.split('`').map((part, i) => i % 2 === 1 ? <code key={i} style={{631 const renderWithCode = s => s.split('`').map((part, i) => i % 2 === 1 ? <code key={i} style={{
624 fontFamily: mono,632 fontFamily: mono,
944 lineHeight: 1.5,952 lineHeight: 1.5,
945 marginTop: 4953 marginTop: 4
946 }}>954 }}>
947955 This is what's left in context: startup content, which lives outside the message history and reloads after compaction, plus a structured summary of the entire conversation. Skill descriptions don't reload. This is what's left in context: startup content, which lives outside the message history and reloads after compaction, a structured summary of the entire conversation, the files modified most recently, which Claude Code re-reads along with the rules that match them, and the body of each skill you invoked. Skill descriptions don't reload.
948 </div>956 </div>
949 </div>}957 </div>}
950 {time > 0 && visible.length > 0 && <div style={{958 {time > 0 && visible.length > 0 && <div style={{
967 const enteringSubagent = isSub && prevKind !== 'sub';975 const enteringSubagent = isSub && prevKind !== 'sub';
968 const leavingSubagent = prevKind === 'sub' && !isSub;976 const leavingSubagent = prevKind === 'sub' && !isSub;
969 let showPhase = null;977 let showPhase = null;
970978 if (evt.kind === 'user' && prevKind !== 'user') showPhase = 'You'; else if (evt.kind === 'claude' && prevKind === 'user') showPhase = 'Claude works'; else if (evt.label === 'Conversation summary') showPhase = 'Summarized by /compact'; if (isCompacted && evt.restoredAfterCompact) {
979 if (prevKind === 'compact') showPhase = 'Restored after /compact';
980 } else if (evt.kind === 'user' && prevKind !== 'user') showPhase = 'You'; else if (evt.kind === 'claude' && prevKind === 'user') showPhase = 'Claude works'; else if (evt.label === 'Conversation summary') showPhase = 'Summarized by /compact';
971 const isNewRow = isCompacted && !(evt.kind === 'auto' && evt.t < STARTUP_END);981 const isNewRow = isCompacted && !(evt.kind === 'auto' && evt.t < STARTUP_END);
972 return <div key={evt.label + evt.t} className={isNewRow ? 'cw-compacted-row' : ''} style={isNewRow ? {982 return <div key={evt.label + evt.t} className={isNewRow ? 'cw-compacted-row' : ''} style={isNewRow ? {
973 animationDelay: `${i * 60}ms`983 animationDelay: `${i * 60}ms`