一键导入
nbl-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 职业分类
| name | nbl.subagent-driven-development |
| description | Use when executing implementation plans with independent tasks in the current session |
Execute plan by dispatching fresh subagent per task. Each implementer performs built-in two-stage self-review (spec compliance + code quality) before reporting done. After all tasks complete, perform global two-stage review on all merged code.
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 with built-in two-stage self-review + global review after all tasks = high quality, fast iteration
digraph when_to_use {
"Have implementation plan?" [shape=diamond];
"Tasks mostly independent?" [shape=diamond];
"Stay in this session?" [shape=diamond];
"subagent-driven-development" [shape=box];
"executing-plans" [shape=box];
"Manual execution or brainstorm first" [shape=box];
"Have implementation plan?" -> "Tasks mostly independent?" [label="yes"];
"Have implementation plan?" -> "Manual execution or brainstorm first" [label="no"];
"Tasks mostly independent?" -> "Stay in this session?" [label="yes"];
"Tasks mostly independent?" -> "Manual execution or brainstorm first" [label="no - tightly coupled"];
"Stay in this session?" -> "subagent-driven-development" [label="yes"];
"Stay in this session?" -> "executing-plans" [label="no - parallel session"];
}
vs. Executing Plans (parallel session):
Before any task execution, these gates MUST pass:
GATE 1: Git Worktree Isolation
<NON_NEGOTIABLE>
CRITICAL RULE:
If you are in the primary working tree (
.gitis a directory), regardless of whether you are onmain/masteror already on a development branch, you MUST invokenbl.using-git-worktreesskill via the Skill tool (NOT the built-inEnterWorktreetool) to create an isolated sub-worktree before dispatching any implementer. NO EXCEPTIONS.
NEVER use the built-in
EnterWorktreetool. It bypasses our worktree management conventions and scripts.
Primary working tree is for branch management only. ALL implementation tasks run in isolated sub-worktrees. Never implement directly in primary worktree.
</NON_NEGOTIABLE>
"Error: nbl.subagent-driven-development requires a Git repository. Please run
git initto initialize a repository, then retry."
Typical Usage Pattern (our convention):
User ALWAYS starts Claude Code in the main working tree (primary worktree). The skill creates the isolated worktree, user doesn't manually cd into worktrees to start Claude Code.
FULL Check Process (execute step-by-step, NO shortcuts):
STEP 1: Pre-check - Is this a Git repository?
Execute: git rev-parse --is-inside-work-tree
If NO → STOP, prompt user to initialize Git
If YES → continue to STEP 2
STEP 2: Check if already inside an added worktree:
If .git is a file → INSIDE_ADDED_WORKTREE = YES
If .git is a directory → INSIDE_ADDED_WORKTREE = NO
STEP 3: If INSIDE_ADDED_WORKTREE = YES:
→ GATE 1 PASSED → proceed directly to GATE 2
→ STOP HERE, do NOT create another worktree
STEP 4: If INSIDE_ADDED_WORKTREE = NO (in primary working tree):
Get current branch: CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
If CURRENT_BRANCH is "main" or "master":
1. Auto-create development branch from plan name
2. Checkout new development branch in primary working tree
// CRITICAL: This step executes for BOTH main/master AND development branches!
INVOKE via **Skill tool** (NOT built-in EnterWorktree): `/nbl.using-git-worktrees create <base-name-from-plan>-work --parent feature/<base-name-from-plan>`
// After invocation, you will be inside the newly created worktree
→ GATE 1 PASSED → proceed to GATE 2
MUST create isolated worktree before starting implementation, NO exceptions.
GATE 2: Test-Driven Development
GATE 3: Built-In Two-Stage Self-Review
These gates are NON-NEGOTIABLE. Skip them only if user explicitly overrides.
digraph process {
rankdir=TB;
"Read plan, extract all tasks with full text, note context, create TodoWrite" [shape=box];
"Pre-Check: Is git repository?" [shape=diamond style=filled fillcolor=yellow];
"STOP: Not a git repository" [shape=box style=filled fillcolor=red];
"STEP 2: .git is file or directory?" [shape=diamond style=filled fillcolor=yellow];
"On main/master branch?" [shape=diamond style=filled fillcolor=yellow];
"Auto-create dev branch from plan name" [shape=box];
"INVOKE nbl.using-git-worktrees (MANDATORY)" [shape=box style=filled fillcolor=lightblue];
"In sub-worktree → GATE 1 PASSED" [shape=box style=filled fillcolor=lightgreen];
"GATE 2: TDD mode enabled?" [shape=diamond style=filled fillcolor=yellow];
"More tasks remain?" [shape=diamond];
"Dispatch implementer subagent (with built-in two-stage review)" [shape=box];
"Implementer asks questions?" [shape=diamond];
"Answer questions, provide context" [shape=box];
"Implementer: implement → spec self-check → fix → quality self-check → fix → DONE" [shape=box];
"Mark task complete (TodoWrite + Ledger)" [shape=box];
"Global Stage 1: Spec review (all merged changes)" [shape=box];
"Spec review passes?" [shape=diamond];
"Dispatch fix agent for spec issues" [shape=box];
"Global Stage 2: Code quality review (all merged changes)" [shape=box];
"Quality review passes?" [shape=diamond];
"Dispatch fix agent for quality issues" [shape=box];
"Use nbl.finishing-a-development-branch" [shape=box style=filled fillcolor=lightgreen];
"Read plan, extract all tasks with full text, note context, create TodoWrite" -> "Pre-Check: Is git repository?";
"Pre-Check: Is git repository?" -> "STOP: Not a git repository" [label="no"];
"Pre-Check: Is git repository?" -> "STEP 2: .git is file or directory?" [label="yes"];
"STEP 2: .git is file or directory?" -> "In sub-worktree → GATE 1 PASSED" [label=".git is FILE (already in worktree)"];
"STEP 2: .git is file or directory?" -> "On main/master branch?" [label=".git is DIR (in primary worktree)"];
"On main/master branch?" -> "Auto-create dev branch from plan name" [label="yes → create branch, then MANDATORY invoke"];
"On main/master branch?" -> "INVOKE nbl.using-git-worktrees (MANDATORY)" [label="no → MANDATORY invoke"];
"Auto-create dev branch from plan name" -> "INVOKE nbl.using-git-worktrees (MANDATORY)";
"INVOKE nbl.using-git-worktrees (MANDATORY)" -> "In sub-worktree → GATE 1 PASSED";
"In sub-worktree → GATE 1 PASSED" -> "GATE 2: TDD mode enabled?";
"GATE 2: TDD mode enabled?" -> "More tasks remain?" [label="yes"];
"More tasks remain?" -> "Dispatch implementer subagent (with built-in two-stage review)" [label="yes"];
"Dispatch implementer subagent (with built-in two-stage review)" -> "Implementer asks questions?";
"Implementer asks questions?" -> "Answer questions, provide context" [label="yes"];
"Answer questions, provide context" -> "Dispatch implementer subagent (with built-in two-stage review)";
"Implementer asks questions?" -> "Implementer: implement → spec self-check → fix → quality self-check → fix → DONE" [label="no"];
"Implementer: implement → spec self-check → fix → quality self-check → fix → DONE" -> "Mark task complete (TodoWrite + Ledger)";
"Mark task complete (TodoWrite + Ledger)" -> "More tasks remain?";
"More tasks remain?" -> "Global Stage 1: Spec review (all merged changes)" [label="no"];
"Global Stage 1: Spec review (all merged changes)" -> "Spec review passes?";
"Spec review passes?" -> "Dispatch fix agent for spec issues" [label="no"];
"Dispatch fix agent for spec issues" -> "Global Stage 1: Spec review (all merged changes)";
"Spec review passes?" -> "Global Stage 2: Code quality review (all merged changes)" [label="yes"];
"Global Stage 2: Code quality review (all merged changes)" -> "Quality review passes?";
"Quality review passes?" -> "Dispatch fix agent for quality issues" [label="no"];
"Dispatch fix agent for quality issues" -> "Global Stage 1: Spec review (all merged changes)";
"Quality review passes?" -> "Use nbl.finishing-a-development-branch" [label="yes"];
}
After both reviews pass:
All implementation is complete in the isolated worktree. Enter nbl.finishing-a-development-branch to handle merge and cleanup.
Use the least powerful model that can handle each role to conserve cost and increase speed.
Mechanical implementation tasks (isolated functions, clear specs, 1-2 files): use a fast, cheap model. Most implementation tasks are mechanical when the plan is well-specified.
Integration and judgment tasks (multi-file coordination, pattern matching, debugging): use a standard model.
Architecture, design, and review tasks: use the most capable available model.
Task complexity signals:
Implementer subagents report one of four statuses. Handle each appropriately:
DONE: Implementer completed the work and passed built-in two-stage self-review with all issues fixed. Mark task complete in TodoWrite, and append a line to .nbl/sdd/progress.md (see Durable Progress section below), then proceed to next task.
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 moving on. If they're observations (e.g., "this file is getting large"), note them and mark task complete in TodoWrite, and append to .nbl/sdd/progress.md.
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.
长任务遭遇上下文压缩后,靠 .nbl/sdd/progress.md(git-ignored scratch)恢复执行位置,不信任自己的回忆。
mkdir -p .nbl/sdd && printf '*\n' > .nbl/sdd/.gitignore
该目录自忽略,不污染 git status、不会被误提交。注意:git clean -fdx 会清掉它,可从 git log 重建。
每个 task 的 implementer 自审通过(Stage 1 Spec + Stage 2 Quality 均 PASSED/FIXED)、controller 标完成时,在同一消息里追加一行到 .nbl/sdd/progress.md:
Task N: complete (commits <base7>..<head7>, self-review clean)
<base7> / <head7>:dispatch implementer 之前记录的 BASE 与 implementer 完成后的 HEAD,各取 git rev-parse --short 的 7 位短 SHA。绝不用 HEAD~1——多提交的 task 会静默丢失。self-review clean:对应 implementer 报告里 "Built-in Two-Stage Review Results" 两段均为 PASSED 或 FIXED。skill 启动 / 上下文压缩后恢复时:
cat "$(git rev-parse --show-toplevel)/.nbl/sdd/progress.md"
解析每行 Task N: complete ... 标记为 DONE 跳过,在第一个未标 complete 的 task 恢复执行。以 ledger + git log 为准。
./implementer-prompt.md - Dispatch implementer subagent./spec-reviewer-prompt.md - Dispatch spec compliance reviewer subagent./code-quality-reviewer-prompt.md - Dispatch code quality reviewer subagentYou: I'm using Subagent-Driven Development to execute this plan.
[Read plan file once: docs/nbl/plans/feature-plan.md]
[Extract all 5 tasks with full text and context]
[Create TodoWrite with all tasks]
Task 1: Hook installation script
[Get Task 1 text and context (already extracted)]
[Dispatch implementation subagent with full task text + context]
Implementer: "Before I begin - should the hook be installed at user or system level?"
You: "User level (~/.config/nbl/hooks/)"
Implementer: "Got it. Implementing now..."
[Later] Implementer:
- Implemented install-hook command
- Added tests, 5/5 passing
- **Built-in Two-Stage Review Results:**
- Stage 1 (Spec Compliance): PASSED
- Stage 2 (Code Quality): PASSED
- Committed
[Mark Task 1 complete in TodoWrite, append "Task 1: complete (commits <base7>..<head7>, self-review clean)" to .nbl/sdd/progress.md]
Task 2: Recovery modes
[Get Task 2 text and context (already extracted)]
[Dispatch implementation subagent with full task text + context]
Implementer: [No questions, proceeds]
Implementer:
- Added verify/repair modes
- 8/8 tests passing
- **Built-in Two-Stage Review Results:**
- Stage 1 (Spec Compliance): FIXED - Missing progress reporting, extra --json flag
- Stage 2 (Code Quality): FIXED - Extracted magic number 100 to PROGRESS_INTERVAL constant
- Committed
[Mark Task 2 complete in TodoWrite, append "Task 2: complete (commits <base7>..<head7>, self-review clean)" to .nbl/sdd/progress.md]
...
[After all tasks complete]
[Get BASE_SHA and HEAD_SHA]
[Dispatch global spec reviewer on all changes]
Spec reviewer: ✅ All changes spec compliant
[Dispatch global code quality reviewer on all changes]
Code reviewer: ✅ All changes meet quality standards
[Invoke nbl.finishing-a-development-branch]
Done!
vs. Manual execution:
vs. Executing Plans:
Efficiency gains:
Quality gates:
Efficiency:
Never (NON-NEGOTIABLE):
Never:
If subagent asks questions:
If global reviewer finds issues after all tasks complete:
NON-NEGOTIABLE Requirements:
Supporting skills:
Prompt templates:
./implementer-prompt.md - Implementer with built-in two-stage self-review./spec-reviewer-prompt.md - For final global spec compliance review./code-quality-reviewer-prompt.md - For final global code quality reviewAlternative workflow:
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Use when you have a spec or requirements for a multi-step task, before touching code
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Use when creating new skills, editing existing skills, or verifying skills work before deployment
Use when completing tasks, implementing major features, or before merging to verify work meets requirements