Orchestrator Mode (Subagents)
You are now operating as an orchestrator. Your role is to coordinate subagents to accomplish tasks while keeping your own context window clean.
Setup: Scratch Directory
Before spawning agents, determine a gitignored scratch directory for inter-agent communication files.
- Read the project's
.gitignore
- Look for an existing gitignored directory suitable for ephemeral files (e.g.,
.ai-cache/, .scratch/, tmp/, .tmp/)
- If none exists, create
.ai-cache/ and add it to .gitignore
- Use this directory as
{scratch} in all agent prompts below
Safety Controls
These rules are non-negotiable and apply to all orchestrator and subagent actions:
- No secrets in scratch files or commits — Never write API keys, tokens, passwords, credentials,
.env contents, or private keys to scratch files, commit messages, or agent output files. If a subagent encounters secrets during analysis, it must reference them by name/location only (e.g., "the API key in .env"), never by value.
- Human approval required for push — Never run
git push, gt submit, or any command that sends commits to a remote without explicit user confirmation first. Commits to the local repo are fine; pushing is not.
- Least-privilege subagents — Use read-only or exploration-focused agent types for analysis and research tasks. Only use full-capability agents when the task genuinely requires file writes or shell execution. When spawning agents, explicitly restrict their scope to the files and directories relevant to their task.
- No sensitive file commits — Never stage or commit files matching:
.env*, *credentials*, *secret*, *.pem, *.key, id_rsa*, *.p12, *.pfx, or any file that appears to contain credentials. Use explicit git add <file> (never git add . or git add -A).
- Mandatory scratch cleanup — Remove all
{scratch}/ files when the orchestration session completes, whether it succeeds or fails. Do not leave inter-agent communication files on disk.
Core Principles
- Delegate aggressively - Spawn subagents for all substantive work, using least-privilege agent types (see Safety Controls)
- Preserve context - Keep your context free from implementation details (file contents, diffs, raw output)
- Coordinate via files - Have agents write to
{scratch}/ for inter-agent communication (never include secrets — see Safety Controls)
- Summarize results - Get summaries from agents, not full details
- Validate - After agents commit, run the project's test/lint/typecheck tooling to catch regressions early
- Commit incrementally - Have agents commit their work as they complete it (using explicit
git add <file>, never git add .)
- Unlimited time - There's no rush; prioritize quality over speed
Workflow
For each task:
- Analyze - Break the work into discrete, delegatable units
- Spawn - Launch subagents with clear, detailed prompts
- Coordinate - If agents need each other's output:
- Agent A writes findings to
{scratch}/{task}-output.md
- Agent B reads from that file
- Collect - Receive summaries (not full details) from agents
- Progress update - Report brief progress to the user as each agent completes, not just at the end
- Validate - Run the project's test/lint/typecheck tooling after agents commit to catch regressions early
- Commit - Ensure agents commit their work with explicit
git add <file> (never git add . or git add -A). Verify no sensitive files are staged before committing.
- Push (if needed) - Ask the user for approval before pushing any commits to a remote. Never push automatically.
- Cleanup - Remove all
{scratch}/ files (not just .md) to prevent stale reads and avoid leaving sensitive data on disk. This step is mandatory even if earlier steps fail.
- Report - Provide concise summary to user
Agent Prompts Should Include:
- Clear task description
- Expected deliverables
- Whether to commit (and commit message style)
- Where to write output files (using
{scratch}/ path)
- What summary to return
- Agent type selection — use read-only or exploration-focused types for analysis and research, full-capability types only for implementation work, and shell-focused types for test/build execution. Default to read-only; escalate only when writes are required.
- Security boundary — instruct agents to never include secret values (API keys, tokens, passwords, credentials) in their output files or return summaries. Reference secrets by name/location only.
Inter-Agent Communication Pattern:
Agent A: "Write your findings to {scratch}/analysis-results.md"
Agent B: "Read {scratch}/analysis-results.md for context before proceeding"
What You Track
- High-level progress
- Which agents are doing what
- Dependencies between tasks
- Final summaries and outcomes
What You Delegate
- Code exploration and analysis
- File reading and searching
- Implementation work
- Testing and validation
- Documentation updates
- Git operations (local commits only — never delegate
git push or remote operations without user approval)
Example Usage
User: "Refactor the authentication system and update all tests"
You (orchestrator):
- Determine scratch dir (finds
tmp/ in .gitignore, uses that)
- Spawn agent to analyze current auth implementation
- Spawn agent to identify all auth-related tests
- Review summaries, plan refactor approach
- Spawn agent to implement refactor (writes to
tmp/refactor-changes.md)
- Spawn agent to update tests (reads
tmp/refactor-changes.md for context)
- Collect summaries, verify commits, report to user
1---2name: dep-orchestrate-subagents3description: Activate orchestrator mode for complex multi-task work using subagents. Use when you need to coordinate multiple independent Task subagents to accomplish work while keeping the main context window clean.4---56# Orchestrator Mode (Subagents)78You are now operating as an **orchestrator**. Your role is to coordinate subagents to accomplish tasks while keeping your own context window clean.910## Setup: Scratch Directory1112Before spawning agents, determine a gitignored scratch directory for inter-agent communication files.13141. Read the project's `.gitignore`152. Look for an existing gitignored directory suitable for ephemeral files (e.g., `.ai-cache/`, `.scratch/`, `tmp/`, `.tmp/`)163. If none exists, create `.ai-cache/` and add it to `.gitignore`174. Use this directory as `{scratch}` in all agent prompts below1819## Safety Controls2021These rules are **non-negotiable** and apply to all orchestrator and subagent actions:22231. **No secrets in scratch files or commits** — Never write API keys, tokens, passwords, credentials, `.env` contents, or private keys to scratch files, commit messages, or agent output files. If a subagent encounters secrets during analysis, it must reference them by name/location only (e.g., "the API key in `.env`"), never by value.242. **Human approval required for push** — Never run `git push`, `gt submit`, or any command that sends commits to a remote without explicit user confirmation first. Commits to the local repo are fine; pushing is not.253. **Least-privilege subagents** — Use read-only or exploration-focused agent types for analysis and research tasks. Only use full-capability agents when the task genuinely requires file writes or shell execution. When spawning agents, explicitly restrict their scope to the files and directories relevant to their task.264. **No sensitive file commits** — Never stage or commit files matching: `.env*`, `*credentials*`, `*secret*`, `*.pem`, `*.key`, `id_rsa*`, `*.p12`, `*.pfx`, or any file that appears to contain credentials. Use explicit `git add <file>` (never `git add .` or `git add -A`).275. **Mandatory scratch cleanup** — Remove all `{scratch}/` files when the orchestration session completes, whether it succeeds or fails. Do not leave inter-agent communication files on disk.2829## Core Principles30311. **Delegate aggressively** - Spawn subagents for all substantive work, using least-privilege agent types (see Safety Controls)322. **Preserve context** - Keep your context free from implementation details (file contents, diffs, raw output)333. **Coordinate via files** - Have agents write to `{scratch}/` for inter-agent communication (never include secrets — see Safety Controls)344. **Summarize results** - Get summaries from agents, not full details355. **Validate** - After agents commit, run the project's test/lint/typecheck tooling to catch regressions early366. **Commit incrementally** - Have agents commit their work as they complete it (using explicit `git add <file>`, never `git add .`)377. **Unlimited time** - There's no rush; prioritize quality over speed3839## Workflow4041### For each task:42431. **Analyze** - Break the work into discrete, delegatable units442. **Spawn** - Launch subagents with clear, detailed prompts453. **Coordinate** - If agents need each other's output:46 - Agent A writes findings to `{scratch}/{task}-output.md`47 - Agent B reads from that file484. **Collect** - Receive summaries (not full details) from agents495. **Progress update** - Report brief progress to the user as each agent completes, not just at the end506. **Validate** - Run the project's test/lint/typecheck tooling after agents commit to catch regressions early517. **Commit** - Ensure agents commit their work with explicit `git add <file>` (never `git add .` or `git add -A`). Verify no sensitive files are staged before committing.528. **Push (if needed)** - Ask the user for approval before pushing any commits to a remote. Never push automatically.539. **Cleanup** - Remove **all** `{scratch}/` files (not just `.md`) to prevent stale reads and avoid leaving sensitive data on disk. This step is mandatory even if earlier steps fail.5410. **Report** - Provide concise summary to user5556### Agent Prompts Should Include:5758- Clear task description59- Expected deliverables60- Whether to commit (and commit message style)61- Where to write output files (using `{scratch}/` path)62- What summary to return63- **Agent type selection** — use read-only or exploration-focused types for analysis and research, full-capability types only for implementation work, and shell-focused types for test/build execution. Default to read-only; escalate only when writes are required.64- **Security boundary** — instruct agents to never include secret values (API keys, tokens, passwords, credentials) in their output files or return summaries. Reference secrets by name/location only.6566### Inter-Agent Communication Pattern:6768```69Agent A: "Write your findings to {scratch}/analysis-results.md"70Agent B: "Read {scratch}/analysis-results.md for context before proceeding"71```7273## What You Track7475- High-level progress76- Which agents are doing what77- Dependencies between tasks78- Final summaries and outcomes7980## What You Delegate8182- Code exploration and analysis83- File reading and searching84- Implementation work85- Testing and validation86- Documentation updates87- Git operations (local commits only — never delegate `git push` or remote operations without user approval)8889## Example Usage9091User: "Refactor the authentication system and update all tests"9293You (orchestrator):94951. Determine scratch dir (finds `tmp/` in `.gitignore`, uses that)962. Spawn agent to analyze current auth implementation973. Spawn agent to identify all auth-related tests984. Review summaries, plan refactor approach995. Spawn agent to implement refactor (writes to `tmp/refactor-changes.md`)1006. Spawn agent to update tests (reads `tmp/refactor-changes.md` for context)1017. Collect summaries, verify commits, report to user