subagent-driven-development
Use when executing implementation plans with independent tasks in the current session
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Use when executing implementation plans with independent tasks in the current session
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use when asked to grab, take, or work on a tracked implementation issue.
Test-driven development with a red-green-refactor loop. Use when building features or fixing bugs test-first.
Use when you have a spec or requirements for a multi-step task, before touching code
| name | subagent-driven-development |
| description | Use when executing implementation plans with independent tasks in the current session |
Execute a plan by dispatching a fresh implementer subagent per task, a task review (spec compliance + code quality) after each task, and a broad whole-branch review at the end.
Why subagents: You delegate tasks to specialized agents with isolated context. By precisely crafting their instructions and context, you ensure they stay focused and succeed at their task. They should never inherit your session's context or history — you construct exactly what they need. This also preserves your own context for coordination work.
Core principle: Fresh subagent per task + task review (spec + quality) + broad final review = high quality, fast iteration
Narration: between tool calls, narrate at most one short line — the ledger and the tool results carry the record.
Pacing: Pacing is owned by the enclosing workflow. When run inside Sage's issue-implementation workflow, follow the selected HITL/AFK mode there; per-task commits always apply, while human gates may be deferred in AFK mode until final PR-readiness approval. Independent of pacing, these situations are escalation triggers — raise them with your human partner when they occur: a BLOCKED status you cannot resolve, ambiguity that genuinely prevents progress, or all tasks complete.
Work through these questions in order:
writing-plans skill) or brainstorm the design before executing anything.What this buys you:
Setup (once):
git worktree add; jj: jj workspace add).Per task:
git rev-parse HEAD before dispatch; jj: the working-copy parent, jj --no-pager log -r @-, because jj commit keeps the working copy's change ID on the completed commit — if the working copy already contains task work, record its parent, not @.)<workdir>/task-N-brief.md).git diff -U10 BASE..HEAD; jj: jj diff --git --context 10 --from BASE --to @) — redirected to a uniquely named file, and dispatch a task reviewer subagent using task-reviewer-prompt.md.After all tasks:
git diff -U10 BRANCH_BASE..HEAD; jj: jj diff --git --context 10 --from BRANCH_BASE --to @ — plus the commit list: git: git log --oneline BRANCH_BASE..HEAD; jj: jj --no-pager log -r 'BRANCH_BASE..@'), the plan's requirements and global constraints, and the ledger's accumulated Minor-findings list so it can triage which must be fixed before merge. Ask for the same Critical/Important/Minor severity categories and an overall verdict.Dispatch every worker with the subagent tool. Its fields:
task — the full prompt (composed from the templates in this skill)label — a short name for logs, e.g. task-3-implementer, task-3-reviewersystem_prompt — optional; use only when the role needs standing rules the task text shouldn't carrychild.tools — the child's tool policychild.model / child.provider — model overridesThe subagent tool is blocking and defaults to a read-only tool policy; implementer and reviewer children need an explicit child.tools policy that permits editing. Since dispatch is blocking, subagents run one at a time — which is what you want; parallel implementers conflict.
Async vs. blocking dispatch: "async dispatch" (as issue-implementation mandates) means fire-with-a-complete-prompt and non-interactive execution — the worker cannot converse with you mid-run. When the available subagent tool is blocking, the same discipline applies: compose a complete initial prompt and do no mid-run steering. Questions from a worker arrive only as a NEEDS_CONTEXT return; answer them by re-dispatching with the answer added to the prompt.
Before dispatching Task 1, scan the plan once for conflicts:
Present everything you find to your human partner as one batched question — each finding beside the plan text that mandates it, asking which governs — before execution begins, not one interrupt per discovery mid-plan. If the scan is clean, proceed without comment. The review loop remains the net for conflicts that only emerge from implementation.
Use the least powerful model that can handle each role to conserve cost and increase speed. Select it with the child.model (and, where relevant, child.provider) override on the dispatch.
Mechanical implementation tasks (isolated functions, clear specs, 1-2 files): use a fast, cheap tier. Most implementation tasks are mechanical when the plan is well-specified.
Integration and judgment tasks (multi-file coordination, pattern matching, debugging): use a standard tier.
Architecture and design tasks: use the most capable available tier. The final whole-branch review is one of these — dispatch it on the most capable available model, not the session default.
Review tasks: choose the model with the same judgment, scaled to the diff's size, complexity, and risk. A small mechanical diff does not need the most capable model; a subtle concurrency change does.
Always set child.model explicitly when dispatching a subagent. An omitted model inherits your session's model — often the most capable and most expensive — which silently defeats this section.
Turn count beats token price. Wall-clock and context cost scale with how many turns a subagent takes, and the cheapest models routinely take 2-3x the turns on multi-step work — costing more overall. Use a mid-tier model as the floor for reviewers and for implementers working from prose descriptions. When the task's plan text contains the complete code to write, the implementation is transcription plus testing: use the cheapest tier for that implementer. Single-file mechanical fixes also take the cheapest tier.
Task complexity signals (implementation tasks):
Implementer subagents report one of four statuses. Handle each appropriately:
DONE: Write the review diff file — a unified diff from BASE to the current tip with ~10 lines of context (git: git diff -U10 BASE..HEAD; jj: jj diff --git --context 10 --from BASE --to @) redirected to a uniquely named file (BASE is the revision you recorded before dispatching the implementer — never assume the task produced a single commit; deriving the diff from only the last commit silently drops all but the last commit of a multi-commit task). Then dispatch the task reviewer with that file path.
DONE_WITH_CONCERNS: The implementer completed the work but flagged doubts. Read the concerns before proceeding. If the concerns are about correctness or scope, address them before review. If they're observations (e.g., "this file is getting large"), note them and proceed to review.
NEEDS_CONTEXT: The implementer needs information that wasn't provided. Provide the missing context and re-dispatch.
BLOCKED: The implementer cannot complete the task. Assess the blocker:
Never ignore an escalation or force the same model to retry without changes. If the implementer said it's stuck, something needs to change.
The task reviewer may report "⚠️ Cannot verify from diff" items — requirements that live in unchanged code or span tasks. These do not block the rest of the review, but you must resolve each one yourself before marking the task complete: you hold the plan and cross-task context the reviewer lacks. If you confirm an item is a real gap, treat it as a failed spec review — send it back to the implementer and re-review.
Per-task reviews are task-scoped gates. The broad review happens once, at the final whole-branch review. When you fill a reviewer template:
git log --oneline BASE..HEAD; jj: jj --no-pager log -r 'BASE..@'), a stat summary (git: git diff --stat BASE..HEAD; jj: jj diff --stat --from BASE --to @), and the full diff with ~10 lines of context (git: git diff -U10 BASE..HEAD; jj: jj diff --git --context 10 --from BASE --to @) into one uniquely named file per review (a re-review after fixes gets a fresh, distinctly named file). The output never enters your own context, and the reviewer sees the commit list, stat summary, and full diff in one Read call. Use the BASE you recorded before dispatching the implementer — never just the parent of the latest change, which silently truncates multi-commit tasks.@, and name the path in the final review dispatch, so the final reviewer reads one file instead of re-deriving the branch diff itself.Everything you paste into a dispatch prompt — and everything a subagent prints back — stays resident in your context for the rest of the session and is re-read on every later turn. Hand artifacts over as files:
<workdir>/task-N-brief.md) without routing the text through your own context (a small shell extraction or a cheap subagent can do the copy). Compose the dispatch so the brief stays the single source of requirements. Your dispatch should contain: (1) one line on where this task fits in the project; (2) the brief path, introduced as "read this first — it is your requirements, with the exact values to use verbatim"; (3) interfaces and decisions from earlier tasks that the brief cannot know; (4) your resolution of any ambiguity you noticed in the brief; (5) the report-file path and report contract. Exact values (numbers, magic strings, signatures, test cases) appear only in the brief.…/task-N-brief.md → report …/task-N-report.md) and put it in the dispatch prompt. The implementer writes the full report there and returns only status, commits, a one-line test summary, and concerns.Conversation memory does not survive compaction. In real sessions, controllers that lost their place have re-dispatched entire completed task sequences — the single most expensive failure observed. Track progress in a ledger file, not only in conversation.
<workdir>/progress.md.Task N: complete (changes <base>..<head>, review clean).git log --oneline; jj: jj --no-pager log) over your own recollection.You: I'm using Subagent-Driven Development to execute this plan.
[Read plan file once: docs/plans/feature-plan.md]
[Initialize the progress ledger with all tasks]
Task 1: Hook installation script
[Record BASE; write task-1 brief file; dispatch implementer with brief + report paths + context]
Implementer: Status: NEEDS_CONTEXT — should the hook be installed at user or system level?
[Re-dispatch with the answer added to the prompt: "Install at user level (~/.config/hooks/)"]
Implementer:
- Implemented install-hook command
- Added tests, 5/5 passing
- Self-review: Found I missed --force flag, added it
- Committed (project convention)
[Write diff file from BASE..@; dispatch task reviewer with its path]
Task reviewer: Spec ✅ - all requirements met, nothing extra.
Strengths: Good test coverage, clean. Issues: None. Task quality: Approved.
[Mark Task 1 complete in the ledger]
Task 2: Recovery modes
[Record BASE; write task-2 brief file; dispatch implementer with brief + report paths + context]
Implementer: [No questions, proceeds]
Implementer:
- Added verify/repair modes
- 8/8 tests passing
- Self-review: All good
- Committed
[Write diff file; dispatch task reviewer with its path]
Task reviewer: Spec ❌:
- Missing: Progress reporting (spec says "report every 100 items")
- Extra: Added --json flag (not requested)
Issues (Important): Magic number (100)
[Dispatch fix subagent with all findings]
Fixer: Removed --json flag, added progress reporting, extracted PROGRESS_INTERVAL constant
[Regenerate diff file; task reviewer reviews again]
Task reviewer: Spec ✅. Task quality: Approved.
[Mark Task 2 complete in the ledger]
...
[After all tasks]
[Dispatch final whole-branch reviewer with the branch diff file]
Final reviewer: All requirements met, ready to merge
Done — report completion to the enclosing workflow.
vs. Manual execution:
Efficiency gains:
Quality gates:
Cost:
Never:
git worktree add; jj: jj workspace add)git diff -U10 BASE..HEAD; jj: jj diff --git --context 10 --from BASE --to @) and name the path in the promptIf subagent asks questions:
If reviewer finds issues:
If subagent fails task:
Related skills in this pack:
Before starting: work in an isolated workspace, not directly on the main branch/bookmark — create one with the project's VCS (git: git worktree add; jj: jj workspace add).
After the final review passes: report completion to the enclosing workflow or your human partner; integration (merge, PR, cleanup) is their call.