跳到正文
FunCoding

subagent

Delegate bounded specialist work to builtin or custom subagents via single-agent, parallel, forked-context, worktree-isolated, or Intercom-coordinated background runs, and manage or control running subagents. Apply proactively whenever parallel codebase discovery, independent fresh-context review, isolated bug diagnosis, multi-writer worktrees, custom agent management, or background child control adds speed or isolation while keeping the parent session in control.

Star
886
最近提交
2026年12月1日

packages/subagents/skills/subagent/SKILL.md

在 GitHub 上查看

Subagent

This skill is for the main parent orchestrator only. Do not inject or follow it inside spawned child subagents: the parent owns delegation, orchestration, review fanout, and writer launches, while child subagents execute concrete role-specific tasks without delegating further.

Use bounded specialist delegation when isolation, parallelism, or specialist expertise adds value. Keep interactive, exploratory, conceptual, and conversation-led work inline. For multi-round independent work, coordinate children from codemode and continue from their completion notices.

When to use

  • Parallel codebase discovery: combine codebase-locator, codebase-analyzer, and codebase-pattern-finder in fresh context to map files, execution paths, and conventions concurrently.
  • Local research mining: pair codebase-research-locator with codebase-research-analyzer to surface prior decisions in research/ and specs/.
  • External research: use codebase-online-researcher for authoritative web sources and docs.
  • Debug and fix: use debugger for actual failures needing reproduction, root-cause diagnosis, and a validated patch.
  • Refinement: use code-simplifier to clean up recently changed code without altering observable behavior.
  • Adversarial review: compose fresh read-only specialists (codebase-analyzer, codebase-pattern-finder, debugger inspect-only, codebase-online-researcher) — there is no generic reviewer agent.
  • Run control and authoring: wait on, inspect, pause, quit, or resume background children, or create/update custom project or user agents.

Use the subagent(...) tool for execution, management, status, and control. If the user supplies a URL, issue, PR, plan, file, or screenshot, read or fetch it first and pass the scope explicitly to each fresh-context child.

Builtin Agents

Precedence by parsed runtime name: project (.atomic/agents/**, .agents/**, .pi/agents/**) → user (~/.atomic/agent/agents/**, ~/.agents/**, ~/.pi/agent/agents/**) → builtin.

AgentPurposeRoleNotes
codebase-locatorMap files, tests, and configsRead-onlyCategorized file map; no analysis.
codebase-analyzerTrace how code works (file:line)Read-onlyExplains mechanics; does not critique unless asked.
codebase-pattern-finderSurface existing patterns/conventionsRead-onlyReturns snippets with file:line refs.
codebase-research-locatorDiscover prior research/ & specs/Read-onlySorts by recency and flags supersession.
codebase-research-analyzerExtract active constraints from prior docsRead-onlyFilters for what still applies today.
codebase-online-researcherAuthoritative web researchRead-onlyReturns cited findings.
code-simplifierClean up recent editsWriterPreserves all observable behavior.
debuggerReproduce, diagnose, and fix failuresWriterHas tdd, agent-browser, agent-desktop, herdr, and tmux skills plus qlty, how, why, show-me, no-comments, intercom, contact_supervisor, and todo; inspect-only requires explicit instruction.
workerImplement normal tasks/handoffsWriterDefaults to forked context; has tdd, agent-browser, agent-desktop, herdr, and tmux skills plus qlty, no-comments, intercom, contact_supervisor, and todo.

Each builtin defaults to model: "auto", with no pinned fallback chain (uses your configured default model at its default thinking level, else the launching session's model). Concrete model overrides run as named and fall back only to the agent's own fallbackModels. Inspect effective config with subagent({ action: "get", agent: "debugger" }) or customize persistently under subagents.agentOverrides in ~/.atomic/agent/settings.json or .atomic/settings.json.

Every builtin agent declares intercom for live coordination with the supervisor and same-group peers; debugger and worker also declare contact_supervisor. Parent tool restrictions and disabled Intercom still apply.

Prompting specialist subagents

Write each child prompt as a compact contract covering Goal, Context/evidence, Success criteria, Hard constraints (true invariants only, such as "inspect and report only; do not edit"), Validation, Output, and Stop rules. Avoid duplicating the agent's own system prompt or over-specifying every tool call.

Running subagents

Single, parallel, forked, and worktree runs

// Single background child
subagent({ agent: "codebase-analyzer", task: "Trace token verification with file:line refs." })

// Parallel independent batch (distinct output paths; use outputMode: "file-only" for large reports)
subagent({
  tasks: [
    { agent: "codebase-locator", task: "Map auth files", output: "auth-files.md", progress: true },
    { agent: "codebase-pattern-finder", task: "Find API-key validation patterns" }
  ],
  concurrency: 2,
  context: "fresh"
})

// Multiple concurrent writers isolated into temporary worktrees (requires clean git tree)
subagent({
  tasks: [
    { agent: "debugger", task: "Fix failing test in package A" },
    { agent: "code-simplifier", task: "Clean up recent changes in package B" }
  ],
  worktree: true
})
  • Context mode: use context: "fork" when a writer needs the settled parent conversation (reuses prompt cache on the same model/thinking level); use context: "fresh" for independent reviews and discovery so children do not inherit parent conclusions.
  • Single-threaded writes: keep one writer per working copy, or isolate concurrent writers with worktree: true or named worktree: { branch, base?, path? }.
  • Progress files: progress: true tracks a child's progress.md under isolated artifact storage without writing into cwd (distinct from includeProgress: true, which returns runtime telemetry).
  • Non-interactive launches: settle user questions in the parent first (using ask_user_question when available) and pass concrete decisions to the child.

Background launches, waits, and control

Every subagent runs in the background and returns a launch receipt (taskId, childId, intercomTarget) once admitted. Continue independent parent work while children run, and wait only when the next step depends on a child's result:

subagent({ action: "wait", id: taskId })
subagent({ action: "status", id: taskId })
subagent({ action: "pause", id: taskId })          // stop now, hold queued messages until resume
subagent({ action: "quit", id: taskId })           // stop gracefully; stays resumable
subagent({ action: "resume", id: taskId, message: "Focus on the failing test first." })
  • A launch receipt or an ended wait (timeout or Esc) never means the child stopped — do not relaunch duplicates; wait on the same taskId or continue from its completion notice.
  • pause and quit (and all: true) leave children resumable under the same ID, Intercom name, and group. Completed, failed, and interrupted children are also resumable; children cancelled for good or gone after restart cannot be resumed (launch a fresh child with handoff context instead). kill and interrupt were removed; use quit.
  • Intervene only on real needs_attention control signals or user direction — silence during long tests or reasoning is normal. Override thresholds with control: { needsAttentionAfterMs, notifyOn } for legitimately quiet runs.

Intercom and peer coordination

All builtin specialists declare intercom; debugger and worker also declare contact_supervisor when Atomic's Intercom bridge is active (always respecting parent tool restrictions).

  • Default to peer-to-peer (swarm) coordination: children in the same parallel batch or named group share an Intercom group. Siblings discover each other with intercom({ action: "list" }) and send/ask directly to exchange file paths, reproductions, ownership claims, and evidence-backed challenges rather than routing through the supervisor.
  • Escalate decisions upward: reserve contact_supervisor (need_decision, interview_request, progress_update) for supervisor decisions; answer inbound asks with intercom({ action: "reply", message }).
  • Group isolation & scale: use group: true for a private batch group or a named group across launches. Only the parent launches children; to scale past 1000 concurrent children, raise parallel.maxTasks, parallel.concurrency, and parallel.runningCapacity.
  • Noninteractive children: intercom ask cannot revive a terminated child; use subagent({ action: "resume", id, message }) or a fresh launch.

Managing custom agents

Create, inspect, update, or delete user/project agents via subagent({ action: "list" | "get" | "create" | "update" | "delete", ... }). Optional package metadata registers the runtime name as {package}.{name}. Prefer subagents.agentOverrides for small tweaks to builtins.

Key constraints

  • One-level delegation: children can call only list, get, status, and wait; launches and run controls (pause, resume, quit) are refused inside any child.
  • Forked history: forking requires at least one settled parent turn and carries the parent's sent project context and skills while still enforcing the child's own tool policy.

Bundled reference

  • references/orchestration-patterns.md — parallel research/context-build/cleanup recipes, the parent-led Clarify → Discover → Implement → Review loop, review-round caps, suffix-first reasoning levels (model:effort), and common error remedies. Read when running multi-phase orchestration or troubleshooting subagent errors.

相似的 Skill

ask-matt

MAmattpocock/skills336k近 7 天新增 4,217 个 star

chief-of-staff

MAmattpocock/skills336k近 7 天新增 4,217 个 star

setup-matt-pocock-skills

MAmattpocock/skills336k近 7 天新增 4,217 个 star

subagent-driven-development

OBobra/superpowers331k近 7 天新增 5,030 个 star

autonomous-loops

AFaffaan-m/ECC314k近 7 天新增 3,503 个 star

agent-eval

AFaffaan-m/ECC314k近 7 天新增 3,503 个 star