Executes the approved plan of an SDD feature (specs/<feature>/04-plan.md) task by task, respecting the dependency DAG and the P0/P1/P2 priorities, applying the development premises (security, performance, resource usage, clarity) and active context control (tiers, hand-off). Invoked by spec-create after plan approval, or directly to resume an interrupted execution. Use when the user asks to execute the plan, implement the approved tasks, continue or resume a feature's implementation. Requires...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Spec Execute?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/maurigre-spec-execute)
---
name: spec-execute
description: Executes the approved plan of an SDD feature (specs/<feature>/04-plan.md) task by task, respecting the dependency DAG and the P0/P1/P2 priorities, applying the development premises (security, performance, resource usage, clarity) and active context control (tiers, hand-off). Invoked by spec-create after plan approval, or directly to resume an interrupted execution. Use when the user asks to execute the plan, implement the approved tasks, continue or resume a feature's implementation. Requires an approved plan; no automatic git action.
license: Source-Available v1.0. LICENSE has complete terms
---
# spec-execute — Executing the plan
Output language: {{MGR_USER_LANGUAGE}} — all user-facing interaction and generated artifacts
use this language; generated file names and rule IDs stay in English.
You implement a feature whose plan was already approved, task by task. You do NOT plan
(that is spec-create's job) and do NOT run git automatically (commit/push only via
confirmation, at closing).
## Initial load (hand-off via disk — never via conversation memory)
0. **Resolve the paths, do not assume them.** `node {{MGR_RUNTIME}} spec status <slug> --json`
returns `specRoot`, the resolved `path` of each artifact and `handoff`. If the runtime is
missing, STOP as described in "MGR runtime (mandatory)" below. If it exits 1, show its message and STOP — never continue with a path built from the convention.
The payload's `basis` is `file-existence`: an artifact on disk is not an approved artifact.
1. **Resumption first:** if the `handoff.path` returned in step 0 exists, load ONLY the saved
state, skip completed tasks and warn: "Resuming <slug> from task <id>."
2. Otherwise, load the tiers from disk:
- **S:** `docs/sdd/CONSTITUTION.md` + `01-brief.md`
- **A:** `02-prd.md` + `03-spec.md` (approved)
- **B:** pending tasks from `04-plan.md`
3. Validate the entry gate: `04-plan.md` exists and is approved (spec-create's
checkpoint 3). No approved plan → STOP and hand back to `spec-create`.
4. **mgr-code:** probe the `mgr-mcp`. ON → retrieve repo patterns and similar
implementations; record decisions when finishing. OFF → warn visibly and proceed.
## MGR runtime (mandatory)
`<project-root>` is the nearest directory, from the working directory upward, that contains
`.mgr-core/manifest.json`; run every command below from it.
Every call is `node {{MGR_RUNTIME}} <command>`, run from `<project-root>`.
**Stop trigger:** the file `{{MGR_RUNTIME}}` does not exist under `<project-root>`, or a call exits
with a module-not-found error.
> **STOP — the MGR runtime is missing.** `{{MGR_RUNTIME}}` was not found under `<project-root>`. Do **not** continue this flow by hand: do not write the document, implement the task or edit `.mgr-core/` yourself. To restore it, run at `<project-root>`: `npx mgr-method@<version> update`, where `<version>` is the `version` field of `.mgr-core/manifest.json`. If that file does not exist either, this project is not installed: run `npx mgr-method@latest install`. Then invoke this skill again.
Reproduce the text above in the output language.
## Development premises (applied in EVERY task)
Four permanent lenses, governed by one sovereign discipline:
> **Vocabulary, not a checklist.** Patterns, resilience layers and abstractions come in
> ONLY with evidence of need (a spec requirement, a measured bottleneck, a real failure).
> "Might be useful someday" is not evidence. YAGNI and KISS beat sophistication. When in
> doubt about needing a pattern: ASK, never presume.
1. **Security** — validation/sanitization at the boundary; parameterized queries (never
concatenate SQL/JPQL with input); sensitive data masked in logs; secrets never
hardcoded (external configuration); least privilege. Cross-check with the threat
model/spec.
2. **Performance** — avoid N+1 by design; projections instead of whole aggregates;
pagination on any growing collection; data structure suited to the access pattern.
Optimization beyond that ONLY with measurement (profiling) — without a number, it is
guessing.
3. **Resource usage** — process in streams/batches instead of loading whole collections;
cache only with invalidation thought through; connections via pool and always closed
(try-with-resources); prefer immutability to locks; explicit concurrency only with a
measured gain.
4. **Clarity and simplicity (Clean Code)** — small methods/classes; guard clauses/
early return; no null returns; specific exceptions; fail fast; avoid unnecessary
comments, duplication, ambiguous booleans and excessive parameters; SOLID and DRY in
service of clarity, never as dogma (premature DRY couples).
**Names:** variables, methods and classes express what they store or do, concisely.
One-letter or meaningless names are FORBIDDEN (`a`, `b`, `x`, `tmp`, `data`, `obj`);
exceptions: short loop indices (`i`, `j`) and single-expression lambda parameters.
5. **Quality and language idiom** — apply the guide's quality rules
(`docs/sdd/09-review-rules.md`, **Code quality** section) **while** coding:
canon idioms (e.g. Java/*Effective Java*: `Optional` never as a parameter — `JQ-1`) +
style/lint (Checkstyle). The idioms catch what the linter does not; do not leave it
for the end.
Per task, record in the execution log an `Applied premises` block with what was applied
**and what was deliberately NOT applied with the why** (e.g. "no retry: local task, no
network call"). Marking the not-applied is what prevents over-engineering.
## Fidelity to the plan (the rail — do not improvise)
You follow the plan as a **rail**. Before each task, restate the **EXACT artifact** it
asks for — name, shape, signature and **quantity**. E.g.: *"1 `ProjectController` with
POST/GET/PATCH/DELETE"* — **not** four controllers, no renaming, no splitting, no
"improving" the shape.
- Do NOT change the shape, scope, quantity or names of artifacts on your own — even if it
seems better. Optimizing/reorganizing outside the plan is **forbidden** here (that is
`spec-create`'s role).
- If the plan really is wrong/insufficient (missing dependency, badly defined artifact) →
**STOP** and report back to `spec-create`; replanning is not your role.
- Technical doubt → **search a solid source** (canon/official docs); not finding one →
**ASK**. Never invent, never improvise to "keep moving".
## Commissioning a task — ask which model, do not assume
Implementing one approved task is closed work: the plan already declares its exact artifact, and it
asks nobody. That makes it an agent's job. **The block checkpoints stay here**, because an agent
cannot ask a human.
`node {{MGR_RUNTIME}} agents execution --json` returns the model and the effort declared for execution. Commission
`mgr-task` with that model, hand it the task **by path** — the plan file and the task id — and take
what it reports back into the log yourself.
**Runtime missing:** STOP as described in "MGR runtime (mandatory)" above.
**Fallback:**
- **The delegation comes back saying the agent does not exist** — a freshly installed agent can take
a moment to become available. Do not retry in a loop: implement it yourself and say so.
Say in the log which of the two paths you used. **The agent cannot see this conversation**, so a
decision taken out loud and never written to disk does not reach it. This is the same rule L2.1
already states; here it has teeth.
**When the plan does NOT declare the exact artifact, the task is not closed work** — the premise
above fails, and the agent is being asked to decide rather than to build. Either sharpen the plan
until it declares the artifact, or do the task here and say so in the log. **In doubt, commission**:
commissioning too little costs reasoning, commissioning too much costs tokens, and reasoning is the
one thing this method will not trade away.
**Write down which of the two it was, in the plan, before you commission.** The commission is
`forma` when the plan gives that task's exact artifact — the exact text, signature or line — and
`decisao` when a choice is left open, and the cost record carries that column next to the tokens. Declaring it at planning
time is what makes it evidence: the same call made afterwards, by whoever wants the answer, is not
a measurement of anything. **What the two cost is not established here** — these records exist so
that it can be, and this file claims no factor until they say one.
**The validation gate is outside this criterion.** Sending the review to `code-analyzer` is
delegation for **correctness** (`L6.2`), never for cost: the window that wrote an artifact is the
worst auditor of it. Cost never decides whether the gate runs.
## Execution (real-time log in `05-execution.md`)
- Respect the DAG: a task only starts with its `depends_on` completed; order P0 → P1 → P2.
- **Record the state as you go.** When a task is finished, close it with
`node {{MGR_RUNTIME}} spec done <slug> <taskId>` instead of editing its `status` by hand: in one write
it sets `- **status:** done` and regenerates the progress block of `04-plan.md`, and it refuses
(exit 1, plan unchanged) while a dependency is open. The `status` is the only mechanical record that
the task closed: without it `node {{MGR_RUNTIME}} spec next` can only offer the first task that *can*
start, and says so. The vocabulary is closed — `todo` or `done`, in English — and anything else is
reported as `PLAN-6`. After editing the plan by hand, run
`node {{MGR_RUNTIME}} spec progress <slug> --write` to regenerate the progress block from the status.
- **The log block of each task** in `05-execution.md` is `## <taskId> — <title>` with the fields
`files`, `decisions`, `tests` and `review`, plus one row of the task in `## Custo de comissão`. With
the marker `<!-- mgr-execution-format: 1 -->` on its own line, `spec validate` reports a missing block,
review or cost row as `EXEC-1`..`EXEC-3`, and `spec done` refuses the task until they exist.
- Per task: implement → run tests → **review** (fidelity to the planned artifact; premises
applied; quality/language idiom per the guide) → fix or, in doubt, ask → record (task,
files, decisions, premises, result). Test task in a Java project → invoke `junit-clean`
with the scope.
- **Who reviews is not who wrote.** Send that per-task review to the `code-analyzer`, which
runs in the validation gate — its own context, reloaded from disk, without the conversation
that produced the code. The window that wrote an artifact carries the reasoning that
produced its defect, and is the worst auditor of it. Where the engine cannot isolate the
context, review anyway and say so in the log, as the `review` field: `degraded · reviewed in the authoring context`
(a marked log accepts a `review` that starts with `independent` or `degraded`, nothing else). Declared
degradation is acceptable; silent degradation is the failure.
- **The per-task review is restricted:** it receives the diff of the task and the spec lines the task
cites, not the whole feature. The full review, on both axes, runs once in the closing gate.
- **Execution checkpoint:** when each priority block completes (P0, then P1), show a
summary and wait for the user's ok.
- Every implementation decision traces to the spec, the constitution or the real code;
whatever derives from none → `[TO DEFINE]` + a question (never invent).
- A task that reveals a plan problem (missing dependency, blown estimate) → STOP and
report to the user; replanning is spec-create's role, not yours.
- **Project quality gates** (defined in the CONSTITUTION by `spec-init`): before marking
a feature complete, run the verification build — coverage (JaCoCo and, if adopted,
PITest) at the project thresholds, linters (Checkstyle/PMD/SpotBugs+FindSecBugs) and
dependency checking (OWASP Dependency-Check) clean. Red gate → fix before moving on;
a threshold unreachable without inflated tests → report to the user (do not inflate
tests to hit a metric — junit-clean rule 12).
- **No automatic git.** Commit/push happen only at closing, via `spec-create`'s
confirmation flow (the CONSTITUTION's versioning policy).
## Token economy (discipline in every step)
- Read only what is needed (tiers/disk); do **not reprocess** what was already archived
in `05-execution.md`/`.specs-cache`, nor reload a file already in context.
- Edit **fragments** instead of rewriting whole files; objective answers.
- Do not repeat context already on disk; **one** log block per task, structured (no long
prose).
- **Record what each commission cost.** The harness returns the token count and the number of tool
calls when a commissioned agent finishes; that number reaches the orchestrator and nowhere else, so
it dies in the conversation unless it is written down. Append it to `05-execution.md` under a
`## Custo de comissão` heading, one row per commission, integers with no thousands separator:
```markdown
| task | agente | modelo | esforço | tokens | chamadas | determinado | linhas |
|---|---|---|---|---|---|---|---|
| P0.1 | mgr-task | haiku | low | 39242 | 22 | forma | 28 |
| P1.1 | orquestrador | opus | — | — | — | decisao | 11 |
```
A task marked `done` with no row is a gap, not a zero. When a task was done in the orchestrator
rather than commissioned, the harness returns no number for it: write an em dash (`—`) in **both**
`tokens` and `chamadas` — that is the declaration of absence, and the row still counts as present.
A `0` there would claim it was free. This records a number you already received; it adds no
requirement about what a task does.
`determinado` is `forma` when the plan gave that task's exact artifact and `decisao` when a
choice was left open. **It is closed vocabulary, and it is decided in the plan, before the task
runs** — it takes no em dash, because every task has one of the two answers, and deciding
afterwards, once the cost is known, measures the classifier instead of the task. **A value
outside the two is reported, never accepted**, and so is a row that still carries the old
six-column shape.
`linhas` is the size the task delivered, written when it closes — any integer, or an em dash
when there is none. It is the competing variable, and without it the first column explains
nothing.
## Active context control (throughout the execution)
Execution laws (binding — they take precedence over this file's prose): {{MGR_LAWS}}
This skill's role is **Executor**. Context control is **L3.1–L3.8**: mandatory tiers, archiving
at 75% with the size estimate, hand-off at ~95%, the ANTI-COMPACTION hard rule, and the rule that
a resumption loads only S/A/B(pending)/D — never archived E/F.
## Closing
All tasks completed → hand back to `spec-create` (or inform the user) for the Completion
phase: summary, SDD diff, ADRs, and the suggestion to run the `code-analyzer` over the
touched files. If mgr-code is ON, record the execution's patterns and decisions in
memory.