Context Budget Skill
Purpose: Manage LLM context window as a finite resource. Ensure the right agents and skills are loaded for each task while preventing context overflow.
Overview
LLM context windows have hard token limits. Loading all 19 agents and 27 skills simultaneously consumes context that should be reserved for the actual work. This skill implements intelligent selective loading to maximize usable context for code and reasoning.
How It Works
1. Domain Detection
At the start of each task, analyze the user request to identify which domains are involved:
User: "Add JWT authentication to the API"
→ Detected domains: security, backend, testing
→ Load: security-reviewer, backend-specialist, tdd-guide
→ Load: security-practices, api-patterns, testing-patterns
2. Selective Loading
Consult engine/loading-rules.json to determine which agents and skills to load:
- Always loaded (core):
rules.md, manifest.json, workflow-state.json
- Session context:
session-context.md, session-state.json
- Domain-specific: Only agents/skills matching detected domains
3. Budget Limits
| Resource |
Default Limit |
Rationale |
| Agents per session |
4 |
Each agent ~200-500 tokens of context |
| Skills per session |
6 |
Each skill ~200-800 tokens of context |
| Maximum loaded context |
~30% of window |
Reserve 70% for code and reasoning |
4. Overflow Prevention
When approaching context limits:
- Warn: Alert that context is nearing capacity
- Compact: Apply
strategic-compact skill to summarize completed work
- Unload: Release agents/skills no longer needed for current phase
- Persist: Save important context to
session-state.json before compaction
Task-Based Loading Profiles
| Task Type |
Agents Loaded |
Skills Loaded |
| Security audit |
security-reviewer, architect |
security-practices, architecture |
| Feature build |
planner, architect, tdd-guide |
plan-writing, testing-patterns, clean-code |
| Bug fix |
build-error-resolver |
debugging-strategies |
| Sprint planning |
sprint-orchestrator, planner |
plan-writing, brainstorming |
| Code review |
code-reviewer, security-reviewer |
clean-code, security-practices |
| Deployment |
devops-engineer, reliability-engineer |
deployment-procedures, docker-patterns |
Integration
- Triggered at session start by reading
engine/loading-rules.json
- Enforced by
reliability-engineer agent
- Monitored throughout session lifecycle
- Compaction delegated to
strategic-compact skill
1---2name: context-budget3description: Context window budget management and selective capability loading for LLM token optimization.4---56# Context Budget Skill78> **Purpose**: Manage LLM context window as a finite resource. Ensure the right agents and skills are loaded for each task while preventing context overflow.910---1112## Overview1314LLM context windows have hard token limits. Loading all 19 agents and 27 skills simultaneously consumes context that should be reserved for the actual work. This skill implements intelligent selective loading to maximize usable context for code and reasoning.1516---1718## How It Works1920### 1. Domain Detection2122At the start of each task, analyze the user request to identify which domains are involved:2324```25User: "Add JWT authentication to the API"26→ Detected domains: security, backend, testing27→ Load: security-reviewer, backend-specialist, tdd-guide28→ Load: security-practices, api-patterns, testing-patterns29```3031### 2. Selective Loading3233Consult `engine/loading-rules.json` to determine which agents and skills to load:3435- **Always loaded** (core): `rules.md`, `manifest.json`, `workflow-state.json`36- **Session context**: `session-context.md`, `session-state.json`37- **Domain-specific**: Only agents/skills matching detected domains3839### 3. Budget Limits4041| Resource | Default Limit | Rationale |42|:---------|:-------------|:----------|43| Agents per session | 4 | Each agent ~200-500 tokens of context |44| Skills per session | 6 | Each skill ~200-800 tokens of context |45| Maximum loaded context | ~30% of window | Reserve 70% for code and reasoning |4647### 4. Overflow Prevention4849When approaching context limits:50511. **Warn**: Alert that context is nearing capacity522. **Compact**: Apply `strategic-compact` skill to summarize completed work533. **Unload**: Release agents/skills no longer needed for current phase544. **Persist**: Save important context to `session-state.json` before compaction5556---5758## Task-Based Loading Profiles5960| Task Type | Agents Loaded | Skills Loaded |61|:----------|:-------------|:-------------|62| **Security audit** | security-reviewer, architect | security-practices, architecture |63| **Feature build** | planner, architect, tdd-guide | plan-writing, testing-patterns, clean-code |64| **Bug fix** | build-error-resolver | debugging-strategies |65| **Sprint planning** | sprint-orchestrator, planner | plan-writing, brainstorming |66| **Code review** | code-reviewer, security-reviewer | clean-code, security-practices |67| **Deployment** | devops-engineer, reliability-engineer | deployment-procedures, docker-patterns |6869---7071## Integration7273- Triggered at session start by reading `engine/loading-rules.json`74- Enforced by `reliability-engineer` agent75- Monitored throughout session lifecycle76- Compaction delegated to `strategic-compact` skill