Agent skill
assembling-context
Use when preparing context for subagent dispatch or managing token budgets. Triggers: 'prepare context for', 'assemble context', 'token budget', 'context package', 'what context does the subagent need'. Also invoked by develop during planning and execution phases.
Install this agent skill to your Project
npx add-skill https://github.com/axiomantic/spellbook/tree/main/skills/assembling-context
SKILL.md
Context Assembly
Invariant Principles
- Tier 1 Never Truncates: Essential context survives any budget pressure
- Budget Before Assembly: Calculate budget FIRST, then select
- Purpose Drives Selection: Design context differs from implementation differs from review
- Recency Over Completeness: Recent feedback beats historical context
- Summarize, Don't Truncate: Intelligent summarization preserves signal
- Integration Points are Tier 1: Interface contracts are essential
Inputs / Outputs
| Input | Required | Description |
|---|---|---|
purpose |
Yes | design, implementation, review, handoff, subagent |
token_budget |
Yes | Maximum tokens available |
source_context |
Yes | Raw context to select from |
| Output | Description |
|---|---|
context_package |
Tiered context ready for injection |
truncation_report |
What was excluded and why |
Context Tiers
<CRITICAL>Over budget: remove Tier 3 first, then Tier 2. Never remove Tier 1.</CRITICAL>
| Tier | Budget | Content | Examples |
|---|---|---|---|
| 1: Essential | 40-60% | Active instructions, user decisions, current artifact, interface contracts, blocking issues | Task spec, APIs, unresolved feedback |
| 2: Supporting | 20-35% | Recent learnings, patterns, prior feedback, success criteria | Last 2-3 iterations, codebase patterns |
| 3: Reference | 10-20% | Historical context, rejected alternatives, verbose docs | Early iterations, full docs (summarize instead) |
Purpose-Specific Packages
| Purpose | Tier 1 Focus | Budget Split | Use With |
|---|---|---|---|
| Design | Requirements, decisions, constraints, integration points | 50/30/20 | brainstorming, writing-plans |
| Implementation | Task spec, acceptance criteria, interfaces, test expectations | 60/25/15 | test-driven-development, executing-plans |
| Review | Code diff, requirements traced, test results | 55/30/15 | code-review, fact-checking |
| Handoff | Current position, pending work, active decisions, blocking issues | 70/20/10 | session boundaries, compaction |
| Subagent | Task, constraints, expected output format | 65/25/10 | dispatching-parallel-agents |
Token Budget
Estimation: tokens ≈ chars / 4 (conservative)
Available: context_window - system_prompt - response_reserve - tool_overhead
Example: 200000 - 8000 - 4000 - 2000 = 186000
Smart Truncation: Never blind head/tail. Preserve structure: intro (30%) + conclusion (20%), mark omitted middle.
Cross-Session Context
| Action | Items |
|---|---|
| Persist | User decisions, validated assumptions, glossary, blocking issues |
| Regenerate | File contents, test results, code patterns (may have changed) |
| Discard | Exploration paths, rejected alternatives, verbose logs |
Handoff format: Position → Pending work → Active decisions → Key learnings → Verification commands
Reasoning Schema
Self-Check
- Calculated token budget explicitly
- Identified Tier 1 for this purpose
- Tier 1 fits within budget
- Smart truncation applied (not blind)
- Integration points included
- Truncation report created
<FINAL_EMPHASIS> Context assembly is invisible infrastructure. Calculate budget. Prioritize by tier. Truncate intelligently. Every token earns its place. </FINAL_EMPHASIS>
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
spellbook-auditing
Meta-audit skill for spellbook development. Spawns parallel subagents to factcheck docs, optimize instructions, find token savings, and identify MCP candidates. Produces actionable report.
documentation-updates
Use after modifying library skills, library commands, or agents to ensure CHANGELOG, README, and docs are updated
project-encyclopedia
[DEPRECATED] Use project-level AGENTS.md files instead. Previously used for first-session codebase onboarding and persistent glossary creation.
reviewing-impl-plans
Use when reviewing implementation plans before execution. Triggers: 'is this plan solid', 'review the plan', 'check before I start building', 'anything missing from this plan', 'will this plan work', 'audit the implementation plan'. NOT for: reviewing design documents (use reviewing-design-docs) or creating plans (use writing-plans).
session-resume
Session resume protocol and session repairs handling. Loaded when spellbook_session_init returns resume_available: true, or when session_init returns a repairs array. Triggers: 'resume', 'continue', 'where were we', session resume, session repairs.
brainstorming
Use when exploring design approaches, generating ideas, or making architectural decisions. Triggers: 'explore options', 'what are the tradeoffs', 'how should I approach', 'let's think through', 'sketch out an approach', 'I need ideas for', 'how would you structure', 'what are my options'. Also invoked by develop when design decisions are needed.
Didn't find tool you were looking for?