From skillz
Design context management for coding agents: sub-agent decomposition, context resets, progressive disclosure hierarchies, and artifact handoffs. Use when agents lose coherence on long tasks, when context windows fill up, when you need to decompose complex workflows into isolated subtasks, or when setting up sub-agent patterns. Use this skill whenever the user mentions context windows, sub-agents, context management, agent memory, or long-running agent tasks. Part of the harness engineering workflow; start with `harness-audit` for overall assessment.
How this skill is triggered — by the user, by Claude, or both
Slash command
/skillz:context-architectureThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Design how a coding agent manages its context window across tasks of varying complexity.
Design how a coding agent manages its context window across tasks of varying complexity.
Context is finite and degrades with noise. Every token in the context window competes for attention. The goal is to keep the agent's working context focused on the current subtask while preserving access to broader knowledge on demand.
Not every task needs context architecture. Match the strategy to the task:
| Task Type | Strategy |
|---|---|
| Single file edit, quick question | No special management needed |
| Multi-file feature, moderate complexity | Progressive disclosure + sub-agents for research |
| Large refactor, cross-cutting changes | Sub-agent decomposition with clear boundaries |
| Long-running development (hours/days) | Context resets with structured handoffs |
| Multi-step pipeline (plan → build → review) | Multi-agent with isolated contexts (see multi-agent-design) |
Structure information so agents load it when needed, not upfront.
Map each piece of information to a level:
Always in context:
- Build/test commands
- Hard rules (3-5 lines)
- Architecture overview pointing to docs
On-demand reference:
- docs/api-design.md → read when modifying API endpoints
- docs/data-model.md → read when changing schemas
- docs/testing.md → read when writing tests
Executable knowledge:
- scripts/check-deps.sh → run to verify dependency graph
- scripts/db-status.sh → run to check migration state
Reference docs from the root instruction file with clear triggers: "Read docs/api-design.md before modifying any endpoint."
Use sub-agents (forked contexts) to isolate discrete subtasks. The parent agent dispatches work and receives compacted results, keeping its own context clean.
Each sub-agent gets:
The parent agent receives:
Sub-agents act as context firewalls. Intermediate noise (file contents, search results, false starts) stays inside the sub-agent. Only the distilled result crosses back to the parent.
Parent context:
"Implement the payment refund feature"
→ spawns research sub-agent
← receives: "Payments are in src/payments/, use PaymentService.refund().
The refund flow requires: 1) validate order status, 2) call Stripe API,
3) update order record. See src/payments/service.py:142."
→ spawns implementation sub-agent with the research summary
← receives: "Implemented refund endpoint. Files changed: [list].
Needs review: error handling for partial refunds."
The parent never loaded the dozens of files the research agent read.
For long-running tasks (multi-hour sessions, multi-day projects), context degrades even with sub-agents. The working context accumulates stale state, abandoned approaches, and resolved discussions.
A context reset is only useful if the new context starts with the right information. Write a handoff artifact before resetting:
## Handoff: [Task Name]
### Completed
- [What was done, with file paths]
### Current State
- [What's working, what's broken, what's partially implemented]
### Next Steps
- [What remains, in priority order]
### Decisions Made
- [Key decisions and why, so the new context doesn't relitigate them]
### Known Issues
- [Bugs, edge cases, or concerns discovered but not yet addressed]
The new context starts with: root instructions + handoff artifact + relevant file contents.
Some agent systems offer context compaction (summarizing the conversation). This preserves continuity but doesn't give a clean slate. Use compaction for minor cleanups; use full resets when the context is significantly polluted.
| Approach | When to Use |
|---|---|
| Compaction | Moderate noise, still on the same subtask |
| Full reset + handoff | Switching phases, severe quality degradation, accumulated stale context |
context: fork in skillscontext: fork run in isolated context automatically.cursor/rules/)harness-audit — diagnose context issues before designing solutionsmulti-agent-design — when context isolation leads to a full multi-agent architecturewrite-agent-instructions — progressive disclosure requires well-structured root instructionsnpx claudepluginhub zmackie/skillz --plugin skillzGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.