---
name: plan
description: "Execute the implementation planning workflow using the plan template to generate design artifacts."
---
## User Input
You **MUST** consider the user input before proceeding (if not empty).
## Before anything else
This command keeps a run in the idea's record when the akka CLI has one: the
`akka_run_start` MCP tool is available, or the output of `akka specify run start
--help` contains `--station`. A CLI without it predates the idea record. With
such a CLI, say so once and carry this command out as before: skip every step
marked **Idea record**, and open no run.
**Idea record: a console run.** Call the `akka_run_context` MCP tool first when
it is available: it answers `{ console, idea, station, run, spec, topic,
questions, sentBack }`, and `console: true` means the console started this command. Only
without that tool, the console started it when `AKKA_RUN_ID` is set in its
environment, or when the command has no shell to run the akka CLI in. The
console has already opened the run and enforced the rules for it, so in a
console run the run is open from the first step: its id is the `run`
`akka_run_context` answered. Any stop before the normal close, such as a
mode-check refusal, a missing argument, or a check that needs a tool this run
lacks, closes it with `akka_run_close`, that `run`, `outcome: failed` and the
reason. So in a console run: the feature is `akka_run_context`'s `spec` (for
`/akka:discover`, the topic is its `topic`), and the command never searches for
one; skip every step that finds, adopts, starts or links an idea, and never ask
a person a question: wherever this command would ask one, it closes the run with
`outcome: waiting` and `question` set to the question (`--outcome waiting
--question "<question>"` on the CLI); the owner answers in the console, and the
re-run reads the answer from `akka_run_context`'s `questions` (`{station, run,
question, answer}`) and does not ask it again; run the mode check with `--idea`
set to the `idea` `akka_run_context` answered, and skip it when it cannot run
here or no idea is known; open the run by calling `akka_run_start` with
`command` and `args` only, no `idea` and no `station`, and the CLI joins the
console's run; close it as usual; and skip the carry-on step, because the
console moves the idea on. A run with no shell for the akka CLI that
`akka_run_context` answers `console: false` for is not a console run and keeps
no record: open no run, ask nothing about ideas or lanes, and carry the command
out as before the idea record, skipping every step marked **Idea record**.
**Idea record: a station sent back to.** When `akka_run_context` answers
`sentBack` (`{ from, reason, by, at }`), the idea was sent back to this station
from `from`, and `reason` says why. Work on that reason first: read it as the
instruction for this run from `by`, change this station's outputs where the
reason points, and keep what it does not touch. `sentBack` is `null` when no
send-back opened this station's visit.
**Idea record: plan in a console run.** Skip the `.akka/models.md` question and
never write under `.akka/`; say so in one line. Skip the docs refresh and say in
one line that it is left for a laptop run: `/akka:docs` writes under `.akka/`
and needs tools a console run lacks. The modernization baseline question closes
the run `waiting` only when `akka_run_context`'s `questions` holds no answer to
it; on the re-run, use the recorded answer.
**Idea record: find the idea.** On a laptop run, find the feature this command
works on first: call `akka_sdd_list_specs` and identify the target feature as
the first step below does. Its idea is the one in `akka specify idea list
--json` whose `spec` is the feature's folder name (`NNN-name`); an idea is never
found from the git branch. When that idea has `derived: true`, it has no record
yet: adopt it with `akka specify ideas adopt --idea <id>`, then use it. When no
idea has it, read the mode with `akka specify mode`. In À la carte mode, open no
run: say in one line that this run is not recorded, and continue. In Enforced
mode, stop: the project's specs and topics get their ideas once with `akka
specify ideas adopt`, and this command runs after that. Pass the idea's id as
`--idea <id>` to the mode check and `idea` to the run start.
Run `akka specify mode --allows plan`, adding `--idea <id>` when the idea record
found the idea. With a CLI that predates the idea record, add `--as-engine` when
you are carrying this command out as a step of the sequence `/akka:specify`
drives in Enforced mode, rather than because a person invoked it. It exits
non-zero when the project's mode does not permit the command. On a non-zero
exit, print its message verbatim and stop. Do not continue, and do not work
around it. The one exception is a CLI that rejects `--allows` as an unknown
flag: it predates the mode check (older than 3.0.74), so say so and continue
without the check.
With the idea record, Enforced mode runs a station command when the idea's
previous station is done and approved, and the CLI's run start decides;
`/akka:specify` does not drive the sequence. With an older CLI, Enforced mode
gives the sequence to the engine, so a step it sequences is refused to a person
and permitted to the engine. A refusal with a reason of its own, such as
re-running setup, stands either way. The message names the remedy.
**Idea record: open the run.** On a laptop run, call the `akka_run_start` MCP
tool with `station: plan`, `command: /akka:plan`, `idea` set to the idea found
above and `args` set to the user input. Where the tool is not available, run
`akka specify run start --station plan --command /akka:plan --idea <id> --args
"<the user input>" --json`, with the input quoted as one argument. A run is
never started without its idea. It answers JSON: `recorded`, and for a recorded
run its `idea` and `run.id`. Keep both: the last steps use them.
- When it answers `recorded: false`, continue without a run, and say in one line
that this run is not recorded, with its `reason`.
- A refusal by rule is an error whose JSON is `{refused, message, remedy}`,
`refused` naming the rule: `paused`, `limit`, `shipped`, `dropped`,
`approval`, `order`, `no-idea-enforced`, `idea-unresolved` or `console-run`. Print `message` and `remedy` verbatim and stop.
- Any other error, one without `refused` (such as no login), does not stop the
command: continue without a run, and say in one line that this run is not
recorded.
**Idea record: a run that fails is closed too.** Once the run is open, every way
the command ends closes it. When the work fails (a build or tests fail, or a
step stops the command early), call `akka_run_close` with `run`, `outcome:
failed` and `error` set to what failed, in one line, then stop. Where the tool
is not available, run `akka specify run close --run <id> --outcome failed
--error "<what failed>"`. When the person stops the command, close the run with
`outcome: stopped`. This holds in a console run too. The close step below is for
the work's normal end.
## Outline
1. **Setup**: Call the `akka_sdd_list_specs` MCP tool to find the target feature. Then call `akka_sdd_get_template` with template_name="plan" to get the plan template. Identify the feature's spec path (FEATURE_SPEC) and plan destination (FEATURE_DIR/plan.md).
2. **Load context**: Read FEATURE_SPEC and `akka_sdd_constitution`. First fold in answered markers: for each `[NEEDS CLARIFICATION]` marker with a recorded `- Q: … → A: …` answer under `## Clarifications`, integrate the answer into the spec as `/akka:clarify` does and remove the marker. Then, if the spec contains unresolved [NEEDS CLARIFICATION] markers for policy decisions (thresholds, access permissions, retention, sensitive-data rules, approvals), report them, recommend `/akka:clarify`, and stop; do not decide them through research. Load IMPL_PLAN template (already copied). If the project has a `discovery/` folder, read, in each topic folder `discovery/<topic>/` and at the `discovery/` root, `understanding.md` (its Decisions Raised), `behaviour.md` and `system-map.md` (measured figures and Decisions to Force) and `mocks/index.md` (review artifacts), and list the files read on the plan's **Discovery** line. If `.akka/models.md` exists, read it. If FEATURE_DIR/plan.md already exists, read its Decisions Log before writing anything: a row whose status reads `decided <date> by <login>: <answer>` is settled, every section of the new plan (Phase 0 and Phase 1 included) follows its answer, and the row is carried into the new plan unchanged.
3. **Execute plan workflow**: Follow the structure in IMPL_PLAN template to:
- Fill Technical Context (mark unknowns as "NEEDS CLARIFICATION")
- If the spec involves agents or model-generated behavior: check the project's installed Akka SDK version and its local documentation before choosing guardrail, classifier, sanitizer, evaluator, or identity mechanisms. Do not assume features newer than that version and do not upgrade the Akka SDK implicitly; if a required feature needs a newer version, record the upgrade as an explicit decision in research.md.
- Fill Constitution Check section from constitution
- Evaluate gates (ERROR if violations unjustified)
- Phase 0: Generate research.md (resolve all NEEDS CLARIFICATION)
- Phase 1: Map domain concepts to Akka components (Component Architecture table), then generate data-model.md, contracts/, quickstart.md
- Re-evaluate Constitution Check post-design
- Phase 2: Fill Delivery Phases, Review Gates, Baseline, Metrics and Targets, Model Plan and Decisions Log. Without a `discovery/` folder Phase 2 is optional: write in short form only the sections that help this plan, and leave the rest out
4. **Report existing diagrams.** If `FEATURE_DIR/plan-visualize.md` exists, mention in the completion report that it may be stale and suggest running `/akka:visualize` for this feature when the user wants updated diagrams. Leave all diagram files untouched; visualization is optional.
5. **Refresh the docs.** If the project has a `discovery/` folder, run `/akka:docs` (the implementation docs and the Story) before reporting, in this session, so they match what this command wrote, and keep its outcome for the report. If the project has no `discovery/` folder, do not run `/akka:docs`; offer it in the report as an optional next step, and leave `docs/` untouched.
6. **Stop and report**: Planning ends here, after Phase 2 and, in a project with a `discovery/` folder, the docs refresh. Report branch, IMPL_PLAN path, generated artifacts, and any potentially stale diagram paths; without a `discovery/` folder, offer `/akka:docs` as an optional next step.
7. **Close the run**. If a run was opened, call the `akka_run_close` MCP tool with `run` set to its id, `outcome: ok`, and `outputs` set to the files and folders this run wrote, as project-relative paths: `plan.md`, `research.md`, `data-model.md`, `quickstart.md` and `contracts/` under FEATURE_DIR, whichever exist, and `docs/` when the docs refresh ran. A folder ends in `/`. Where the tool is not available, run `akka specify run close --run <id> --outcome ok` with one `--file <path>` for each output. On an error, print its message; the plan already written stands. After the close, run `git status --porcelain -- .akka/record/` and end the final message with one line naming the files it lists, such as "Record files to commit with your work: .akka/record/<id>/…". This command does not commit the record. When git is not available, the line says the record is in `.akka/record/<id>/`.
8. **Carry on or stop.** In a console run, skip this step: the console moves the idea on. If a run was opened, run `akka specify idea next --idea <idea> --from plan --json`, where `<idea>` is the `idea` the run start returned. It answers `{ go, next, reason }`. When `go` is true, carry on into `next.command` in this conversation, following its own instructions. Otherwise stop, print `reason`, and name `next.command` when there is one. Without a run, stop and name the next command.
## Phases
### Phase 0: Outline & Research
1. **Extract unknowns from Technical Context** above:
- For each NEEDS CLARIFICATION → research task
- For each dependency → best practices task
- For each integration → patterns task
2. **Generate and dispatch research agents**:
```text
For each unknown in Technical Context:
Task: "Research {unknown} for {feature context}"
For each technology choice:
Task: "Find best practices for {tech} in {domain}"
```
3. **Consolidate findings** in `research.md` using format:
- Decision: [what was chosen]
- Rationale: [why chosen]
- Alternatives considered: [what else evaluated]
**Output**: research.md with all NEEDS CLARIFICATION resolved
### Phase 1: Design & Contracts
**Prerequisites:** `research.md` complete
1. **Map domain concepts to Akka components** → the Component Architecture table in plan.md:
- Read the "Choosing a component type" section in `akka-context/sdk/components/index.html.md` (first time in session) before mapping
- For each domain concept, process, and query in the spec, choose the component per the decision guide: entity type (Key Value vs Event Sourced), Workflow vs Consumer, whether a View is needed, endpoint type, or a plain domain class instead of a component
- Record every choice in the table with the reason. Where the decision guide names a close alternative (entity type, view vs direct entity read, workflow vs consumer, timed action vs workflow timer), also record the rejected alternative and why it was not chosen
- ERROR if a close-call row lacks the rejected alternative
2. **Extract entities from feature spec** → `data-model.md`:
- Entity name, fields, relationships
- Validation rules from requirements
- State transitions if applicable
3. **Define interface contracts** (if project has external interfaces) → `/contracts/`:
- Identify what interfaces the project exposes to users or other systems
- Document the contract format appropriate for the project type
- Examples: public APIs for libraries, command schemas for CLI tools, endpoints for web services, grammars for parsers, UI contracts for applications
- Skip if project is purely internal (build scripts, one-off tools, etc.)
4. **Agent context update**:
- Agent context files are managed automatically by the Akka CLI when running `akka_sdd_init`. No manual agent context update is needed.
**Output**: Component Architecture table in plan.md, data-model.md, /contracts/*, quickstart.md
### Phase 2: Delivery plan
**Prerequisites:** Phase 1 complete
Phase 2 is required when the project has a `discovery/` folder. Without one, it is optional: write in short form only the sections that help this plan, and skip the mock gate, the baseline stop and the `.akka/models.md` question below, since each relies on discovery.
1. **Delivery Phases** → one `### Phase <n>: <name>` block per phase in plan.md:
- A phase delivers something a person can check: a working slice, a migrated capability, a reviewed design. Order phases so the riskiest assumption is tested earliest.
- Fill every field: goal, steps, parallel with, acceptance test, gate, risk, rollback, size.
- The acceptance test is a check that can fail (a test class, a probe re-run, a comparison against the baseline), never "works as expected".
- Rollback says how to undo the phase without losing earlier phases. For a modernization, name the cutover and how traffic returns to the old system.
- Write the critical path, and which phases can run at the same time.
- Only delivery phases use headings that begin with "Phase". The model plan and the exit conditions read every such heading in plan.md as a phase.
2. **Review Gates** → for each phase that must not start until a person has seen something (screens, a storyboard, a data model, a cutover plan), add a gate row naming the artifact. In a project with a `discovery/` folder, if the spec header reads `**User Interface**: yes`, at least one gate reviews a mock before the first phase that builds the interface. The artifact is registered with `/akka:discover <topic> mock`; if it does not exist yet, say so in the report.
3. **Baseline** → measured values of what is true today, one bullet per metric: `- <metric>: <value> | method: <how measured> | source: <finding or probe result>`.
- Take values from discovery findings or `.akka/discovery/timing.json`. Never write a value nobody measured; put it under Metrics and Targets with how and before which phase it will be measured.
- In a project with a `discovery/` folder, if the spec header reads `**Modernization**: yes`, the Baseline section needs at least one measured value before the plan is complete. If none exists, stop and ask the user how the current system can be measured (`/akka:discover <topic> system` with the timing probe is one way).
- Otherwise write `none: <what was checked>` when there is nothing to compare against.
4. **Metrics and Targets** → each target names the success criterion (SC-nnn) or finding it serves, and how it will be measured.
5. **Model Plan** → a single table with one row per phase and purpose (design, implementation, review, tests, research, visual checks, documentation), and columns Phase, Purpose, Model, Effort, Cost, Speed, Accuracy, Why:
- Every `### Phase <n>` heading has at least one row with a model and an effort. Write the Phase cell as `Phase <n>`.
- If `.akka/models.md` exists, start from its rows and explain any row that differs.
- Choose by what a mistake costs: work whose errors spread (design, data model, review, rules ported from an old system) gets the most accurate model and high effort; work that follows a fixed design (implementation, tests, documentation) gets the balanced model; many small, checkable tasks (screenshots, formatting) get the fastest model and low effort.
- Cost, speed and accuracy are stated relative to the other tiers (lowest, medium, highest). Do not quote prices unless the user gave them.
- Under the table, write the downgrade rule (at 85% of the plan's allowance every sub-agent moves one tier down; the main session is not changed by the AI) and its exceptions, then a rough estimate by phase.
- No subheadings inside this section.
- If the project has a `discovery/` folder and `.akka/models.md` does not exist, ask the user whether to create it from this plan's choices. If yes, call `akka_sdd_get_template` with template_name="models" and write `.akka/models.md`. If the CLI answers that the template is unknown, say plainly that this CLI does not provide the `models` template and that `.akka/models.md` was not created.
6. **Decisions Log** → one row for every choice that changes the plan: every Decisions Raised item in each `understanding.md` under `discovery/`, every Decisions to Force finding in each `behaviour.md` under `discovery/`, and every close call made in this plan. Each row has a recommendation with its reason, an owner (a role), and a status of open, decided with the date, or dropped. Never mark a decision decided unless the user made it. A row decided in the console has the status `decided <date> by <login>: <answer>`: the person named there decided it for its owner. Keep that row, its owner and its status as written, never reopen it, and make the plan follow the answer.
**Output**: Delivery Phases, Review Gates, Baseline, Metrics and Targets, Model Plan and Decisions Log in plan.md
## Key rules
- Use absolute paths
- ERROR on gate failures or unresolved clarifications
## Done When
- [ ] FEATURE_DIR, FEATURE_SPEC, and the plan template were resolved via `akka_sdd_list_specs` and `akka_sdd_get_template`.
- [ ] Technical Context is filled with concrete values; any remaining unknowns are explicitly marked `NEEDS CLARIFICATION`.
- [ ] Constitution Check was filled from `akka_sdd_constitution`, evaluated before Phase 0, and re-evaluated after Phase 1 design — with any violations either resolved or explicitly justified in the Complexity Tracking section.
- [ ] Phase 0 produced `research.md` with every `NEEDS CLARIFICATION` resolved (Decision / Rationale / Alternatives).
- [ ] The Component Architecture table in `plan.md` maps every domain concept, process, and query to a component (or a plain domain class), with close-call rows naming the rejected alternative and why it was not chosen — informed by the "Choosing a component type" section of `akka-context/sdk/components/index.html.md`.
- [ ] Phase 1 produced `data-model.md`, `quickstart.md`, and — if the project exposes external interfaces — `contracts/`.
- [ ] With a `discovery/` folder, Phase 2 filled Delivery Phases (`### Phase <n>: <name>` blocks with goal, steps, parallel with, acceptance test, gate, risk, rollback and size), Review Gates, Baseline (measured values only; at least one for a modernization), Metrics and Targets, the Model Plan table (a model and an effort for every phase, the downgrade rule beneath it) and the Decisions Log. Without one, any Phase 2 section written is in short form.
- [ ] No heading other than a delivery phase begins with "Phase", and the Model Plan section has no subheadings.
- [ ] `FEATURE_DIR/plan.md` was written using the template structure and no gate error was left unresolved.
- [ ] Existing diagrams affected by the source update were reported as potentially stale, with `/akka:visualize` suggested as an optional next step; all diagram files were left untouched.
- [ ] Completion was reported with the branch, plan path, generated artifacts, and the next-command recommendation (`/akka:tasks`).
- [ ] With a `discovery/` folder, `/akka:docs` ran before the report (a console run left it for a laptop run); without one, it was offered as a next step and `docs/` was left untouched.
- [ ] The run was opened with `akka_run_start` after the mode check, against the idea found from its feature, and closed with `akka_run_close` at the end, naming what the plan wrote, or the CLI was reported as predating the idea record.
- [ ] With a run, the command carried on into `next.command` only when `akka specify idea next` answered `go: true`; otherwise it stopped, printed the reason and named the next command.