[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F66RB38Q6YV35V4NAKNF6X":3,"skill-same:01M7F66RB38Q6YV35V4NAKNF6X":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7F66RB38Q6YV35V4NAKNF6X","context-budget",null,"What Claude Code loads into context, what survives compaction, what invalidates the prompt cache, and how CLAUDE.md, rules, and auto memory load, for deciding where construct text belongs (session contract, subagent contract, hook context, skill, agent body, output style) and what it costs. Use before adding or growing injected text, changing a contract, adding a SessionStart\u002FSubagentStart\u002FUserPromptSubmit context hook, or switching models or effort mid-session.","carsimax\u002Fconstruct","carsimax","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42248429?v=4","01M7F6660B38RMTKRYJ2DQM39T","Maximiliano Carsi","01M7F6661MDPBN2351WPZNV6CT",1,"MIT","https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcontext-budget\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: context-budget\ndescription: What Claude Code loads into context, what survives compaction, what invalidates the prompt cache, and how CLAUDE.md, rules, and auto memory load, for deciding where construct text belongs (session contract, subagent contract, hook context, skill, agent body, output style) and what it costs. Use before adding or growing injected text, changing a contract, adding a SessionStart\u002FSubagentStart\u002FUserPromptSubmit context hook, or switching models or effort mid-session.\n---\n\n# Context budget in construct\n\nSources (read 2026-10-23): [context window](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fcontext-window.md), [prompt caching](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fprompt-caching.md), [memory](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fmemory.md). Hook output limits: `settings-hooks` skill. Skill loading: `agents-and-skills-authoring` skill.\n\n## Construct's injected text and its budgets\n\n| Text | Channel | Budget (ours) | Hard platform limit |\n| :- | :- | :- | :- |\n| `hooks\u002Fcontract\u002Fsession.md` | `SessionStart` `additionalContext` (`startup\\|resume\\|clear\\|compact`) | 8,000 chars (test) | 10,000 chars per hook output |\n| `hooks\u002Fcontract\u002Fsubagent.md` | `SubagentStart` `additionalContext` | 3,000 bytes (test) | 10,000 chars |\n| feature state | `SessionStart` on `compact\\|resume` | 2,500 chars | 10,000 chars |\n| skill `!` state (`skill-context.mjs`) | skill render | 1,500 chars | large output becomes a file path plus preview |\n| skill bodies | on invocation | keep under 500 lines | 5,000 tokens each survive compaction |\n| skill descriptions | always listed | short, key use first | 1,536 chars each; listing is 1% of the window |\n| agent bodies | the subagent's system prompt | short | combined descriptions > 15,000 tokens warn |\n\nOver 10,000 chars the platform replaces hook output with a file path and a 2,000-char preview: the contract would silently stop being read. The 8,000 test is the margin, not a target.\n\n## What loads when\n\n- Startup: system prompt and tool definitions, output style, then CLAUDE.md levels (managed → user → project → local, concatenated, walk-up from root to cwd), unscoped `.claude\u002Frules\u002F*.md`, auto memory (`MEMORY.md` first 200 lines or 25 KB), MCP tool names, skill descriptions, then hook context.\n- CLAUDE.md is a user message after the system prompt, not part of it; compliance is not guaranteed. That is why construct enforces with hooks and keeps the contract short.\n- A plugin's root `CLAUDE.md` is never loaded. Nested CLAUDE.md files and `paths:` rules load on demand when a matching file is read or edited.\n- Subagents get CLAUDE.md and AGENTS.md but **not** the output style, parent history, or parent auto memory (forks excepted). The subagent contract is the only construct text a subagent is guaranteed to get.\n\n## What survives compaction\n\n- Kept: system prompt, output style.\n- Re-read from disk: project-root CLAUDE.md, unscoped rules, auto memory, the plan-mode plan, up to 5 recently edited files (over 5,000 tokens → path only).\n- Skills: descriptions rebuilt (v2.1.304+); bodies re-attached at **5,000 tokens each, 25,000 total**, oldest dropped. Truncation keeps the start of the file.\n- **Earlier hook context is only summarized.** The documented way to re-inject it is a `SessionStart` hook matching `compact`, which construct uses for the contract and the feature state. Any new context that must survive compaction needs the same matcher.\n- Path-scoped rules and nested CLAUDE.md are not re-injected until a matching file is touched again.\n\n## Prompt cache\n\n- Layers: system prompt + tools → project context (CLAUDE.md, auto memory, unscoped rules) → conversation. Exact-prefix match: a change anywhere recomputes everything after it.\n- **Invalidates**: model switch (including a skill's or command's `model:` frontmatter), effort change on most models (Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1 keep it with an API key or subscription), fast mode on, adding or removing upfront MCP tool definitions, a bare-name deny rule (`Bash`, `mcp__*`) when tool search is off, `\u002Fcompact` (conversation layer), a Claude Code upgrade.\n- **Keeps**: file edits, permission mode changes, output-style changes, skill invocation (unless it sets `model:`), subagent spawn, mid-session CLAUDE.md edits (which also do nothing until `\u002Fclear`, `\u002Fcompact`, or restart), plugin skills\u002Fagents\u002Fhooks\u002Fmonitors changes.\n- Consequence: per-role model routing costs a fresh cache per subagent anyway (a subagent never reads the parent cache), so routing a role to a different model is cheap; switching the **main** model or effort mid-session is not. Never put `model:` in a construct skill's frontmatter.\n- TTL: 5 min default, refreshed on each hit; the main conversation gets 1 h on a Claude subscription. Subagents and workflows: 5 min. Settings: `promptCacheTtl`, `subagentPromptCacheTtl`; agent frontmatter `experimental.cacheTtl`.\n- Check: `\u002Fusage` (`Prompt cache (main)`, v2.1.251+), or `claude -p \"hello\" --output-format json` → `usage.cache_creation`.\n- Hook-context placement in the cache layers is not documented. Inference: it is appended to the conversation, so changing it affects only later turns.\n\n## CLAUDE.md, rules, AGENTS.md, auto memory\n\n- Repository `CLAUDE.md` target: under 200 lines; files over 4 MiB are skipped; `\u003C!-- -->` comments are stripped before injection. `@path` imports (four hops max) do not save context: they load with the importing file.\n- `.claude\u002Frules\u002F*.md`: only the `paths` frontmatter is read; invalid YAML loads the rule unconditionally.\n- AGENTS.md is read only when no CLAUDE.md exists in cwd or above (built-in mod `cc-plugin-agents-md`, v2.1.277+).\n- Auto memory lives in `~\u002F.claude\u002Fprojects\u002F\u003Cproject>\u002Fmemory\u002F` and is separate from Engram. Agent `memory` frontmatter uses its own directory.\n\n## Where new construct text belongs\n\n1. Must always hold → a hook that enforces it, not prose.\n2. Needed every turn by the main thread → the session contract (watch the 8,000 budget).\n3. Needed by every subagent → the subagent contract (watch the 3,000-byte budget).\n4. Needed only for one topic → a skill, rules at the top of the file.\n5. Needed by one role → the agent body.\n6. Tone and reply format → the output style (subagents do not see it).\n\nDiagnose with `\u002Fcontext`, `\u002Fmemory`, `\u002Fdoctor`, and `claude --debug`.\n","# Context budget in construct\n\nSources (read 2026-10-23): [context window](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fcontext-window.md), [prompt caching](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fprompt-caching.md), [memory](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fmemory.md). Hook output limits: `settings-hooks` skill. Skill loading: `agents-and-skills-authoring` skill.\n\n## Construct's injected text and its budgets\n\n| Text | Channel | Budget (ours) | Hard platform limit |\n| :- | :- | :- | :- |\n| `hooks\u002Fcontract\u002Fsession.md` | `SessionStart` `additionalContext` (`startup\\|resume\\|clear\\|compact`) | 8,000 chars (test) | 10,000 chars per hook output |\n| `hooks\u002Fcontract\u002Fsubagent.md` | `SubagentStart` `additionalContext` | 3,000 bytes (test) | 10,000 chars |\n| feature state | `SessionStart` on `compact\\|resume` | 2,500 chars | 10,000 chars |\n| skill `!` state (`skill-context.mjs`) | skill render | 1,500 chars | large output becomes a file path plus preview |\n| skill bodies | on invocation | keep under 500 lines | 5,000 tokens each survive compaction |\n| skill descriptions | always listed | short, key use first | 1,536 chars each; listing is 1% of the window |\n| agent bodies | the subagent's system prompt | short | combined descriptions > 15,000 tokens warn |\n\nOver 10,000 chars the platform replaces hook output with a file path and a 2,000-char preview: the contract would silently stop being read. The 8,000 test is the margin, not a target.\n\n## What loads when\n\n- Startup: system prompt and tool definitions, output style, then CLAUDE.md levels (managed → user → project → local, concatenated, walk-up from root to cwd), unscoped `.claude\u002Frules\u002F*.md`, auto memory (`MEMORY.md` first 200 lines or 25 KB), MCP tool names, skill descriptions, then hook context.\n- CLAUDE.md is a user message after the system prompt, not part of it; compliance is not guaranteed. That is why construct enforces with hooks and keeps the contract short.\n- A plugin's root `CLAUDE.md` is never loaded. Nested CLAUDE.md files and `paths:` rules load on demand when a matching file is read or edited.\n- Subagents get CLAUDE.md and AGENTS.md but **not** the output style, parent history, or parent auto memory (forks excepted). The subagent contract is the only construct text a subagent is guaranteed to get.\n\n## What survives compaction\n\n- Kept: system prompt, output style.\n- Re-read from disk: project-root CLAUDE.md, unscoped rules, auto memory, the plan-mode plan, up to 5 recently edited files (over 5,000 tokens → path only).\n- Skills: descriptions rebuilt (v2.1.304+); bodies re-attached at **5,000 tokens each, 25,000 total**, oldest dropped. Truncation keeps the start of the file.\n- **Earlier hook context is only summarized.** The documented way to re-inject it is a `SessionStart` hook matching `compact`, which construct uses for the contract and the feature state. Any new context that must survive compaction needs the same matcher.\n- Path-scoped rules and nested CLAUDE.md are not re-injected until a matching file is touched again.\n\n## Prompt cache\n\n- Layers: system prompt + tools → project context (CLAUDE.md, auto memory, unscoped rules) → conversation. Exact-prefix match: a change anywhere recomputes everything after it.\n- **Invalidates**: model switch (including a skill's or command's `model:` frontmatter), effort change on most models (Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1 keep it with an API key or subscription), fast mode on, adding or removing upfront MCP tool definitions, a bare-name deny rule (`Bash`, `mcp__*`) when tool search is off, `\u002Fcompact` (conversation layer), a Claude Code upgrade.\n- **Keeps**: file edits, permission mode changes, output-style changes, skill invocation (unless it sets `model:`), subagent spawn, mid-session CLAUDE.md edits (which also do nothing until `\u002Fclear`, `\u002Fcompact`, or restart), plugin skills\u002Fagents\u002Fhooks\u002Fmonitors changes.\n- Consequence: per-role model routing costs a fresh cache per subagent anyway (a subagent never reads the parent cache), so routing a role to a different model is cheap; switching the **main** model or effort mid-session is not. Never put `model:` in a construct skill's frontmatter.\n- TTL: 5 min default, refreshed on each hit; the main conversation gets 1 h on a Claude subscription. Subagents and workflows: 5 min. Settings: `promptCacheTtl`, `subagentPromptCacheTtl`; agent frontmatter `experimental.cacheTtl`.\n- Check: `\u002Fusage` (`Prompt cache (main)`, v2.1.251+), or `claude -p \"hello\" --output-format json` → `usage.cache_creation`.\n- Hook-context placement in the cache layers is not documented. Inference: it is appended to the conversation, so changing it affects only later turns.\n\n## CLAUDE.md, rules, AGENTS.md, auto memory\n\n- Repository `CLAUDE.md` target: under 200 lines; files over 4 MiB are skipped; `\u003C!-- -->` comments are stripped before injection. `@path` imports (four hops max) do not save context: they load with the importing file.\n- `.claude\u002Frules\u002F*.md`: only the `paths` frontmatter is read; invalid YAML loads the rule unconditionally.\n- AGENTS.md is read only when no CLAUDE.md exists in cwd or above (built-in mod `cc-plugin-agents-md`, v2.1.277+).\n- Auto memory lives in `~\u002F.claude\u002Fprojects\u002F\u003Cproject>\u002Fmemory\u002F` and is separate from Engram. Agent `memory` frontmatter uses its own directory.\n\n## Where new construct text belongs\n\n1. Must always hold → a hook that enforces it, not prose.\n2. Needed every turn by the main thread → the session contract (watch the 8,000 budget).\n3. Needed by every subagent → the subagent contract (watch the 3,000-byte budget).\n4. Needed only for one topic → a skill, rules at the top of the file.\n5. Needed by one role → the agent body.\n6. Tone and reply format → the output style (subagents do not see it).\n\nDiagnose with `\u002Fcontext`, `\u002Fmemory`, `\u002Fdoctor`, and `claude --debug`.\n",{"name":5,"description":7},"main","22badcb55851e82eb81a14d18204460bd3881d4a",".claude\u002Fskills\u002Fcontext-budget","https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct","https:\u002F\u002Fgithub.com\u002Fcarsimax","2026-10-30 09:50:40",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add carsimax\u002Fconstruct --skill context-budget",{"tool":36,"command":37},"bunx","bunx skills add carsimax\u002Fconstruct --skill context-budget",{"tool":39,"command":40},"pnpm","pnpm dlx skills add carsimax\u002Fconstruct --skill context-budget","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcontext-budget\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M7F69PT3SMFA4AEETFGW0WFH","workflow","The ADD protocol for every implementation request, feature plan, resume, task sizing, and the closing Risk line.","https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct\u002Fblob\u002Fmain\u002Fplugins\u002Fconstruct\u002Fskills\u002Fworkflow\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7F69J7R3HG57HMVY7QNQNX8","sources","Ground version-dependent code in official documentation. Use when you name a specific uncertainty about a library or framework API, a version-dependent pattern, or a deprecation. Skip when the repository already shows the pattern.","https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct\u002Fblob\u002Fmain\u002Fplugins\u002Fconstruct\u002Fskills\u002Fsources\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7F69CZ1YC0WHK90EV82CB1M","review","Mandatory outside review of high-risk work units, by lens agents the hooks feed and record, plus the dual blind review on request. Trigger: a unit whose Risk names an item is ready to publish, the publication gate denied a push, PR, or release, or the user asks for a review, a dual review, or an adversarial review.","https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct\u002Fblob\u002Fmain\u002Fplugins\u002Fconstruct\u002Fskills\u002Freview\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7F699XTX8F3PNZB0P86XH44","migration","Plan and verify risky migrations and removals. Use when changing a schema or stored data, removing or renaming a public API, flag, config format, or export, replacing a system, or when the task's Risk names item 1 or 3.","https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct\u002Fblob\u002Fmain\u002Fplugins\u002Fconstruct\u002Fskills\u002Fmigration\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7F6953SF387B7GX75V6MXE0","delivery","Plan commits, branches, and pull requests as reviewable units. Use when deciding commit contents, opening or preparing a PR, splitting large work into sub-branches of a feature branch, or preparing a release.","https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct\u002Fblob\u002Fmain\u002Fplugins\u002Fconstruct\u002Fskills\u002Fdelivery\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7F68YK43AQ6BM0KQPN0BVP4","delegation","When and how the ADD orchestrator delegates to construct agents: role mapping, allowed edit surfaces, parallel writers, verifier timing, handoff prompts, and relaying a subagent's blocking question or choice menu. Trigger: deciding to delegate, launching an agent, writing a handoff, or a subagent or tool returns a question, menu, or consent request.","https:\u002F\u002Fgithub.com\u002Fcarsimax\u002Fconstruct\u002Fblob\u002Fmain\u002Fplugins\u002Fconstruct\u002Fskills\u002Fdelegation\u002FSKILL.md",[],[]]