بنقرة واحدة
subagents-discipline
Core engineering principles for implementation tasks
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Core engineering principles for implementation tasks
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Enforces staged execution discipline on large tasks: a written stage plan, parallel delegation where the runtime supports it, a failable verification check at each stage, and a skeptical self-review before delivery. Trigger when the user explicitly asks ("do this thoroughly", "be systematic", "deep work mode") OR when the task objectively spans multiple files, multiple sources, or multiple sessions. Do NOT trigger on ordinary multi-step requests that a direct attempt handles fine.
Bootstrap project orchestration with beads task tracking.
Create beads from a spec (full decomposition) or from user input (ad-hoc issues). Single entry point for all bead creation.
Dispatch the implementation supervisor for a bead task. Resolves the correct supervisor from the assignee field, checks branch state, and dispatches with full context.
QA finalization gate — validates spec conformity, runs tests/build/lint, produces a structured QA report. Auto-dispatches the supervisor for rework on FAIL. Last gate before human merge.
Code review gate — dispatches the code-reviewer agent to analyze an implementation branch, tracks findings, and auto-dispatches the supervisor for rework when verdict is NEEDS-REWORK.
| name | subagents-discipline |
| description | Core engineering principles for implementation tasks |
Tasks define WHAT to do. Specs define HOW to do it.
This separation is non-negotiable. Tasks contain verifiable acceptance criteria and pointers to specs — never implementation details. Specs contain the technical contract — never project management metadata. When both exist, the spec is the implementation authority; the task is the tracking authority.
This is the highest-priority rule. It overrides any "good idea" you might have.
You MUST execute skill instructions exactly as written. You are NOT allowed to:
isolation: "worktree" to an Agent() call when the skill doesn't mention it)If you believe the instructions are wrong, incomplete, or could be improved — ASK THE USER FIRST. Do not act on your own judgement. The cost of asking is near zero. The cost of a unilateral decision can break the entire workflow.
This applies to:
Violations of this rule are treated as bugs, not as helpful initiative.
Before writing any code, build your full picture by reading three layers — context, contract, and code — in order. Each layer may or may not exist. Use what's available.
bd show {BEAD_ID}
bd comments {BEAD_ID}
Comments may contain investigation findings (INVESTIGATION:), dispatch context (DISPATCH:), root cause analysis, affected files, gotchas. Use this context — don't re-investigate what Sherlock already traced.
Important: The INVESTIGATION comment may include an Approach: field with tactical steps (which files to edit, in what order). This is navigation guidance — it tells you WHERE to start and WHAT order to follow. It does NOT replace the spec's HOW (patterns, interfaces, types). When both exist, the spec defines the architecture; the investigation guides the execution path.
If no comments exist, you have no prior investigation. Proceed to the next layers — they become more important.
The spec or design doc defines how to implement — field names, types, interfaces, architecture decisions. This is your implementation contract.
For epic children (BEAD_ID contains a dot, e.g., BD-001.2):
bd show {EPIC_ID} --json | jq -r '.[0].design // empty'
If a design doc path exists, read it. Match it exactly — same field names, same types, same shapes.
For any bead: check these fields in bd show {BEAD_ID} --json for spec references:
design — one-line pointer to spec section (e.g., "See spec.md § Section 3")external-ref — pipe-separated doc references (e.g., "SPEC §7.4 | PLAN task 06.03")spec-id — PRD reference (e.g., "PRD 9.14")notes — may contain additional contextIf a spec exists, it takes precedence over your own judgement. Follow it. If you believe the spec is wrong, log a DEVIATION: comment explaining why — don't silently diverge.
If no spec or design doc exists, proceed to Layer 3.
When there is no spec defining the HOW, the existing code is your contract. Before implementing:
This is not re-investigating. The investigation found WHERE and WHAT. Code confrontation tells you HOW the codebase expects you to work.
| Context (comments) | Contract (spec) | Code | Approach |
|---|---|---|---|
| Yes | Yes | — | Spec is the contract. Comments guide you to the right files. |
| Yes | No | Read | Follow existing code patterns. Log DECISION: for non-obvious choices. |
| No | Yes | — | Spec is the contract. Find entry points yourself. |
| No | No | Read | Read the bead description and acceptance criteria — that's your minimal spec. Confront the code. Log DECISION: for every choice. |
Before writing code that touches external data (API, database, file, config):
WITHOUT looking first:
Assumed: column is "reference_images"
Reality: column is "reference_image_url"
Result: Query fails
WITH looking first:
Ran: SELECT column_name FROM information_schema.columns WHERE table_name = 'assets';
Saw: reference_image_url
Coded against: reference_image_url
Result: Works
Principle: Optimize for the fastest way to verify your work actually works.
| You built | Fast verification | Slower alternative |
|---|---|---|
| API endpoint | curl the endpoint, check response | Write integration test |
| Database change | Run migration, query the result | Write migration test |
| Frontend component | Load in browser, interact with it | Write component test |
| CLI tool | Run the command, check output | Write unit test |
| Config change | Restart service, verify behavior | N/A — just verify |
Two strategies:
User Journey Tests — Test actual behavior as a user experiences it:
# API: curl with real data
curl -X POST localhost:3000/api/users -d '{"name":"test"}' -H "Content-Type: application/json"
# CLI: run the command
bd create "Test" -d "Testing" && bd list
# Error case: curl with invalid auth
curl -X POST localhost:3000/api/users -H "Authorization: Bearer invalid"
Component Tests — Supplement for regression prevention when fast verification isn't possible:
"Close the Loop" principle: Run the actual thing. Verify it works. Check error cases.
Good: "Curled endpoint with invalid auth, got 401 as expected" Bad: "Wrote tests, they compile"
Before claiming you can't fully test:
During implementation, log every non-trivial decision and any deviation from the spec/design doc as bead comments. This creates a traceable decision trail that the QA agent and humans can review.
When you choose between alternatives, pick a pattern, or make a non-obvious choice:
bd comments add {BEAD_ID} "DECISION: [what you chose] instead of [alternative] because [reason]"
Examples:
DECISION: Used Strategy pattern instead of switch/case because the spec lists 5+ payment providers and more will be addedDECISION: Stored session in Redis instead of memory because the spec requires horizontal scalingDECISION: Used batch insert instead of individual inserts because the dataset exceeds 1000 rowsWhen you implement something differently from what the spec/design doc defined — always log why:
bd comments add {BEAD_ID} "DEVIATION: Spec said [X], implemented [Y] because [reason]"
Examples:
DEVIATION: Spec said use REST endpoint, implemented WebSocket because the data requires real-time pushDEVIATION: Spec defined field as 'user_id: string', implemented as 'user_id: number' because the DB schema uses integer PKsDEVIATION: Spec included pagination, deferred to separate task because it requires a new dependencyBefore marking the bead as in-review, you MUST leave a structured completion comment summarizing what was done. This is consumed by the code-reviewer agent and the orchestrator to understand the scope of changes without reading every diff.
bd comments add {BEAD_ID} "COMPLETED:
Summary: [1-2 sentences describing what was implemented/fixed]
Files changed: [list of files modified, created, or deleted]
Decisions: [count of DECISION comments logged, or 'none']
Deviations: [count of DEVIATION comments logged, or 'none — implemented as spec']
Tests: [what was tested and how — functional verification, unit tests, etc.]"
Then record the canonical implementation state (enforced by the SubagentStop hook — skipping this blocks the workflow):
bd set-state {BEAD_ID} impl=done --reason "Implementation completed on branch {branch-name}"
Neither step is optional. Every implementation task must have both the COMPLETED comment and impl=done state before marking in-review.
Your job ends at in-review. After pushing and marking the bead in-review with needs-review label, stop. Do NOT run bd close.
Closing beads is the user's decision after review and QA gates pass. This is non-negotiable.
When you catch yourself thinking: