Manage context window, survive compaction, persist state. Use when planning long tasks, coordinating agents, approaching context limits, or when context, compaction, tasks, or persist state are mentioned.
Manages context window by persisting task state and delegating work to survive compaction during complex workflows.
npx claudepluginhub outfitter-dev/outfitterThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/cross-session.mdreferences/delegation-patterns.mdreferences/task-patterns.mdManage your context window, survive compaction, persist state across turns.
<when_to_use>
NOT for: simple single-turn tasks, quick Q&A, tasks completing in one response
</when_to_use>
<problem>Claude Code operates in a ~128K token context window that compacts automatically as it fills. When compaction happens:
What survives:
What disappears:
The consequence: Without explicit state management, you "wake up" after compaction with amnesia — you know what to do, but not what you've done or decided.
</problem> <tasks>Tasks are not just a tracker — they're your persistent memory layer. Use TaskCreate, TaskUpdate, TaskList, and TaskGet to manage state that survives compaction.
| Category | Example |
|---|---|
| Current work | Implementing auth refresh flow (status: in_progress) |
| Completed work | JWT validation logic added to middleware (status: completed) |
| Discovered work | Handle token expiry edge case (status: pending) |
| Key decisions | Embed in task description: "Using RS256 per security review" |
| Agent handoffs | [reviewer] Review auth implementation + metadata: {agentId: "abc123"} |
| Blockers | Create blocker task, use blockedBy field |
Exactly one in_progress at any time. Call TaskUpdate to mark in_progress before starting.
Mark complete immediately. Don't batch completions — TaskUpdate with completed as you finish.
Include agent IDs for resumable sessions in task metadata.
Expand dynamically. TaskCreate as you discover work; don't front-load everything.
Action-oriented subjects. Use verbs: "Implement X", "Fix Y", "Review Z"
pending → in_progress → completed
↓
(blocked → TaskCreate for blocker, add blockedBy)
If blocked, don't mark complete. Create a new task for the blocker and link with addBlockedBy.
As context fills, ensure tasks capture progress. Use TaskUpdate to add details to in_progress task description:
Task: Implementing token refresh
Description:
- Refresh endpoint: POST /api/auth/refresh
- Token rotation: enabled
- Refresh window: 5 minutes before expiry
- Remaining: validation logic
Decisions embedded in completed task descriptions. Current state detailed in active task. Future work queued as pending.
</tasks><pre_compaction>
Run through this when context is filling (you'll notice: slower responses, repetition, degraded reasoning):
Capture progress — What's done? TaskUpdate completed tasks with outcomes in description.
Record decisions — What did you decide? Why? Put in task descriptions.
Note current state — Where exactly are you in the current task? TaskUpdate the in_progress task with specifics.
Queue discovered work — What did you find that needs doing? TaskCreate as pending.
Mark dependencies — What needs what? Use addBlockedBy in TaskUpdate.
Include agent IDs — Any background agents? Record IDs in task metadata.
Bad (state will be lost):
- [x] Research auth approaches
- [ ] Implement auth
- [ ] Test auth
Good (state survives):
- [x] Research auth approaches → middleware + JWT (see src/auth/README.md)
- [ ] [in_progress] Implement JWT refresh flow
- Using jose library (already in deps)
- Endpoint: POST /api/auth/refresh
- Handler started in src/auth/refresh.ts:15
- Remaining: validation logic, token rotation
- [ ] Add refresh flow tests (after impl)
- [ ] [reviewer] Security review auth module (after tests)
</pre_compaction>
<delegation>Main conversation context is precious. Every file you read, every search result, every intermediate thought consumes tokens. Subagents run in isolated contexts — only their final output returns.
If a task can be delegated, delegate it.
Task arrives
├── Exploration/research? → Explore agent (always)
├── Multi-file reading? → Subagent (summarizes for you)
├── Independent subtask? → Background agent
├── Specialized expertise? → Domain agent (reviewer, tester, etc.)
└── Simple, focused, single-file? → Main agent (maybe)
Note: Use
/agentsto see available agents.
Research delegation — Instead of reading 10 files:
{
"description": "Find auth implementation",
"prompt": "Locate authentication-related files, summarize the auth flow",
"subagent_type": "Explore"
}
Main agent receives: concise summary, not 10 file contents.
Parallel review — Instead of sequential analysis:
// Single message, multiple calls, all run_in_background: true
{ "subagent_type": "reviewer", "run_in_background": true, "prompt": "Security review..." }
{ "subagent_type": "analyst", "run_in_background": true, "prompt": "Performance review..." }
Main agent: stays lean, collects results when ready.
Background execution — For independent work:
{
"subagent_type": "tester",
"run_in_background": true,
"prompt": "Run integration tests for auth module"
}
Continue other work; retrieve with TaskOutput later.
Track delegated work in tasks:
[analyst] Research caching strategies (pending, metadata: {taskId: "def456"})
[engineer] Implement cache layer (pending, blockedBy: analyst task)
[reviewer] Review cache implementation (pending, blockedBy: engineer task)
[tester] Validate cache behavior (pending, blockedBy: reviewer task)
When background agents complete, TaskUpdate status and process results.
<cross_session>
For work spanning multiple sessions, use episodic memory MCP server.
Prerequisites: Cross-session patterns require an episodic-memory MCP server to be configured. If unavailable, skip this section — Tasks handle single-session persistence.
At session end or before long pause:
{
"tool": "episodic-memory:save",
"content": {
"task": "Implementing auth refresh flow",
"status": "in_progress",
"completed": ["JWT validation", "Refresh endpoint structure"],
"remaining": ["Token rotation logic", "Tests", "Security review"],
"decisions": {
"library": "jose",
"algorithm": "RS256",
"refresh_window": "5 minutes"
},
"files_modified": ["src/auth/refresh.ts", "src/auth/middleware.ts"],
"next_steps": "Implement token rotation in refresh.ts:42"
}
}
At session start:
{
"tool": "episodic-memory:search",
"query": "auth refresh implementation"
}
Then reconstruct tasks from saved state using TaskCreate.
For single-session work, Tasks alone suffice.
</cross_session>
<workflow>TaskCreate with initial scopeTaskUpdate first task to in_progressTaskUpdate as work progressesTaskCreate for discovered workin_progress task descriptionTaskList to read task state (it persists)in_progress taskTaskUpdate final tasks to complete with outcomes in descriptionALWAYS:
TaskUpdate before significant actionsNEVER:
in_progress tasks simultaneouslyActivates when the user asks about AI prompts, needs prompt templates, wants to search for prompts, or mentions prompts.chat. Use for discovering, retrieving, and improving prompts.
Search, retrieve, and install Agent Skills from the prompts.chat registry using MCP tools. Use when the user asks to find skills, browse skill catalogs, install a skill for Claude, or extend Claude's capabilities with reusable AI agent components.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.