Create the implementation plan for the next phase. The plan file is your entire world: the implementer (a different model with no memory of this session) depends entirely on plan.md for design decisions. Do not implement.
-
Read context from .sdd/{change-name}/exploration.md. If .sdd/{change-name}/prd.md exists, read it too โ PRD is the WHAT/WHY (user perspective), exploration.md is the WHERE (codebase context); the plan combines both into the HOW.
If exploration.md is missing or incomplete, recover via the two-step pattern in _shared/persistence-contract.md. If neither file nor engram has it, return envelope with status: blocked.
-
Create plan file .sdd/{change-name}/plan.md from templates/plan_template.md. Do not omit any section.
-
Deep Interview Phase (MANDATORY)
Complexity check: if exploration.md describes a change touching โค3 files with no cross-layer impact, skip the Deep Interview and proceed to step 4. Document Interview skipped โ simple change (โค3 files, single layer) in ## 4. Clarifications.
Otherwise, conduct an in-depth interview before architecture analysis. Follow the methodology in references/interview_guide.md: 10 dimensions to explore, 5 question filters, iterative loop with minimum 2 rounds.
Key rules:
- Every question must EXPOSE a hidden decision, CHALLENGE assumptions, or FORCE prioritization โ never ask obvious questions.
- Use
AskUserQuestion (up to 4 questions per call, 2-4 options each, recommended option first).
- Record each answer in
## 4. Clarifications as: - **[Dimension]**: Q: <question> โ A: <answer>.
- Do NOT proceed to step 4 until the interview loop has completed.
-
Analyze the requested changes and break them into clear, actionable steps.
-
Team Selection (record only โ do NOT invoke advisors yet)
Adviser coverage rule: for each adviser in the registry (identified by its SKILL.md description frontmatter), evaluate whether the plan's contracts, tasks, or affected layers fall under that adviser's described domain. If the domain overlap is clear, that adviser MUST appear in Team Selection. Skip is allowed only with an explicit rationale that quotes or references the adviser's description frontmatter text โ boilerplate like "not relevant" is rejected by the Detail Quality Gate. Err toward inclusion when the overlap is borderline.
If no advisor skills are listed above, skip steps 5 and 7 and proceed to step 6.
Process:
- Identify which architectural layers are affected.
- Select relevant advisors from the table.
- Document selections in
## Team Selection with reasoning.
Do NOT invoke Task()/Skill() for advisors here โ that's the orchestrator's job.
-
Implementation plan โ files to modify, code sections, new functions/methods/classes, dependencies, data structures, interfaces, configuration changes.
Task format (CRITICAL โ machine-parsed by sdd-implement):
- [ ] TXXX [TAGS]? Description โ file_path
[ ] = incomplete (space inside), [X] = complete (uppercase X only โ [x] is treated as incomplete).
TXXX = T + 3-digit zero-padded number (T001, T002, โฆ), sequential across ALL phases.
[TAGS] optional, e.g. [US1].
- Each task MUST reference its target file path after an em-dash (โ, not hyphen
-).
- See templates/plan_template.md for the full spec with examples.
The format is NOT optional โ sdd-implement parses these markers to track progress, resume across sessions, and execute in batch order.
Batch Assignment Table (MANDATORY)
After all tasks are defined, include a Batch Assignment Table โ the single source of truth for parallelism and execution order. Parallelism is NEVER defined inline in tasks.
| Batch | Tasks | File | Parallel | Depends on |
|-------|-------|------|----------|------------|
| A | T001-T003 | src/User.java | Yes | โ |
| B | T004-T005 | src/Order.java | Yes | โ |
| C | T006 | src/Service.java | No | A, B |
- Group by target file: tasks on the same file belong to the same batch (sequential within the batch).
- Batches on different files with no cross-dependencies can run in parallel (
Parallel=Yes).
- If all batches are sequential, the table still documents execution order.
Detail Quality Gate (self-check before step 7)
Before requesting guidance, verify:
- Task Detail Blocks โ every non-trivial task has a
**Details for TXXX**: block with signatures, types, or schema. Trivial tasks (rename, import-only, config toggle) may omit it.
- Contract Specifications โ if the plan introduces new types/interfaces/schemas, Section 2 has a populated "Contract Specifications" with exact signatures.
- Before/After Analysis โ modification tasks show current โ proposed state in Section 2's "Before/After Analysis".
- Testable Checkpoints โ every phase Checkpoint lists specific verifiable criteria.
- PRD coverage (only when
prd.md exists for this change) โ for every User Story / requirement listed in prd.md, at least one task in plan.md must demonstrably implement it. Walk the PRD top-to-bottom: for each US/requirement, name the TXXX task(s) that cover it. If any US has zero matching tasks, it's a gap โ add the missing task(s) BEFORE continuing. Document the mapping in ## 4. Clarifications as - **PRD coverage**: US1 โ T003,T007 / US2 โ T011 / US3 โ T012-T014. The reviewer will catch the gap if you don't, but late-stage rework is more expensive than fixing it here.
- Adviser coverage โ every installed adviser whose described domain overlaps this plan's contracts or tasks appears in Team Selection, or has an explicit skip rationale that quotes or references the adviser's
description frontmatter text. Boilerplate ("not relevant", "out of scope") without a domain reference fails this check.
If any check fails, fill the missing detail before continuing.
-
Guidance Request
Rule: if Team Selection (step 5) chose any advisors โ return status: guidance_requested. This is the ONLY condition.
In the envelope:
requested_advisors: comma-separated list of all advisor skill names from step 5.
guidance_context: 1-2 sentences per advisor naming what they should focus on (reference task IDs or section names from the plan).
Do NOT request guidance when re-entered with a GUIDANCE: block (skip to step 8) or when step 5 selected zero advisors.
-
Guidance Integration Re-entry (triggered by GUIDANCE: block in launch prompt)
- Read existing
plan.md (do NOT recreate).
- For each advisor entry in the
GUIDANCE: block:
- If the entry has an
engram ID โ call mem_get_observation(id) for full advice.
- If inline text โ read directly.
- Assess each recommendation: relevant to scope? affects task quality?
- Integrate applicable recommendations: update task Detail Blocks, add tasks if a critical gap was identified, revise Before/After Analysis, update Section 2 Contract Specifications.
- Update
## Advice Received: document what was integrated and what was skipped (with rationale).
- Re-run the Detail Quality Gate.
- Return
status: ok (or warning if recommendations could not be fully integrated).
Skip Deep Interview / Team Selection / Guidance Request โ already done. NEVER return status: guidance_requested from a guidance re-entry (would loop infinitely).
Include short code snippets to illustrate patterns, signatures, or structures โ but do NOT implement full solutions. Include a Testing section identifying which unit and integration tests are needed (specify what should be tested and why; don't write the test code).
Save the plan artifact and any general-knowledge discoveries (architecture decisions, conventions) per _shared/persistence-contract.md (Phase Artifact Save Convention + General Knowledge Persistence Mandate). For this phase, title/topic_key is sdd/{change}/plan.