subagent-usage
Skill4 starsChanged 7 months agoMITView on GitHub
When to use subagents, how many, context hygiene, worktree isolation patterns
- Deletes or force-pushes
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- sefaertunc/anthropic-watchedited, first seen Apr 30, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- sefaertunc/anthropic-watch★ 199% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-routingSkill
- backend-conventionsSkill
- claude-md-maintenanceSkill
- coding-principlesSkill
- context-managementSkill
- coordinator-modeSkill
- frontend-design-systemSkill
- git-conventionsSkill
- memory-architectureSkill
- planning-with-filesSkill
- project-patternsSkill
- prompt-engineeringSkill
- review-and-handoffSkill
- security-checklistSkill
- testingSkill
- verificationSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 12 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
Read 10 test files to understand patterns (consumes context)
- Distinctive: line 42
Write new tests (uses that context)
- Distinctive: line 54
Parallel: when tasks are independent.
- Distinctive: line 55
Run test-writer and code-simplifier on different parts of the code simultaneously
- Distinctive: line 56
Run build-validator while continuing implementation
- Distinctive: line 58
Sequential: when tasks depend on each other.
- Distinctive: line 59
Run code-simplifier first, then test-writer on the simplified code
- Distinctive: line 60
Run security-reviewer first, then fix the issues it found
- Distinctive: line 62
Don't spawn more than 2-3 parallel subagents.
- Very specific: line 85
Run worclaude doctor to diagnose.
- Very specific: line 91
If you invoke claude --worktree directly (not via an agent), no preamble runs — sync the worktree manually before doing real work:
- Distinctive: line 102
If the agent breaks something, it's isolated
- Very specific: line 116
Test all three scenarios: fresh (no .claude/), existing (.claude/ but no meta), upgrade (meta exists).
- Distinctive: line 126
Don't use subagents for tasks that require judgment about the overall session direction.
- Distinctive: line 130
If a subagent fails, don't automatically retry.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Subagent Usage
What Subagents Are
Subagents are separate Claude instances spawned from your main session. They have their own context window, execute independently, and return results to the main session. Your main context stays clean.
When Subagents Help
Tasks that benefit from subagents:
- Testing: writing tests for code you just implemented (test-writer agent)
- Code review: reviewing your own changes for quality (code-simplifier agent)
- Research: reading many files to answer a specific question
- Parallel work: running verification while you continue designing
- Build validation: checking that everything compiles and passes (build-validator)
- File generation: creating boilerplate, configs, or template files
The common thread: these tasks require context (reading files, understanding code) but that context doesn't need to persist in your main session.
When NOT to Use Subagents
- Tasks requiring back-and-forth with the user (subagents can't interact with users)
- Tasks where the result needs deep integration with your current reasoning
- Very small tasks (the overhead of spawning isn't worth it)
- Tasks that depend on conversation history the subagent doesn't have
Context Hygiene
Your main session has limited context. Every file you read, every long output you generate, consumes context. Subagents let you offload this:
Instead of:
- Read 10 test files to understand patterns (consumes context)
- Write new tests (uses that context)
- Continue main work (context is now polluted with test details)
Do:
- Spawn test-writer subagent with: "write tests for src/merger.js following patterns in tests/core/"
- Continue main work while subagent works
- Subagent returns: "wrote 3 test files, all passing"
- Main context stays clean
Parallel vs Sequential Subagents
Parallel: when tasks are independent.
- Run test-writer and code-simplifier on different parts of the code simultaneously
- Run build-validator while continuing implementation
Sequential: when tasks depend on each other.
- Run code-simplifier first, then test-writer on the simplified code
- Run security-reviewer first, then fix the issues it found
Don't spawn more than 2-3 parallel subagents. Each consumes resources and coordination overhead grows.
Worktree Isolation
Some agents use git worktree to make changes without affecting your working tree:
How it works:
- Agent creates a worktree based on
origin/HEAD(see gotcha below) - Makes changes in the worktree (isolated from your files)
- Commits changes
- You merge or cherry-pick the results
Agents with worktree isolation: code-simplifier, test-writer, verify-app, bug-fixer, refactorer, doc-writer.
Base-branch gotcha
Both claude --worktree and the Agent isolation: "worktree" option create the
worktree from origin/HEAD, not your current branch. If your working branch is
ahead of whatever origin/HEAD points to (typically origin/main), the worktree
will miss those commits.
Run worclaude doctor to diagnose. Fix locally with git remote set-head origin
<your-branch> (reversible via --auto or main). The bundled bug-fixer,
verify-app, and test-writer agents include a freshness preamble that resets
their worktree to match the parent's current branch automatically; other worktree
agents do not.
If you invoke claude --worktree directly (not via an agent), no preamble runs
— sync the worktree manually before doing real work:
cd .claude/worktrees/<name>
git fetch origin && git reset --hard origin/<your-working-branch>Benefits:
- Agent's changes don't conflict with your uncommitted work
- You can review agent changes before merging
- If the agent breaks something, it's isolated
Giving Subagents Good Instructions
Subagents start with zero context. They don't know what you've been doing. Give them:
- The specific task: "Write unit tests for the merge function in src/core/merger.js"
- Where to look: "Follow patterns from tests/core/detector.test.js"
- Constraints: "Use Vitest, not Jest. Mock fs-extra, not the actual filesystem."
- Success criteria: "All tests should pass. Cover happy path, error cases, and the three-way merge edge case."
Bad instruction: "Write some tests" Good instruction: "Write unit tests for detectScenario() in src/core/detector.js. Test all three scenarios: fresh (no .claude/), existing (.claude/ but no meta), upgrade (meta exists). Mock the filesystem. Use Vitest."
Gotchas
- Subagents don't see your uncommitted changes unless they share the same working directory. If you need them to see your changes, commit first or use the same worktree.
- Subagent output is returned to your context. If a subagent generates a huge report, that report consumes your context. Ask for concise results.
- Don't use subagents for tasks that require judgment about the overall session direction. They lack the conversational context to make those calls.
- Worktree-based agents need a clean git state to create the worktree. Commit or stash before spawning them.
- If a subagent fails, don't automatically retry. Understand why it failed first. The same instructions will produce the same failure.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

