Implementation plan executor

From SkillPanel/maister · View interactive version

Implementation plan executor is an AI agent skill from the GitHub repository SkillPanel/maister. Execute implementation plans by delegating each task group to task-group-implementer subagent. Main agent coordinates prepares context, invokes subagent, processes output, marks checkboxes, updates work-log. Uses lazy standards loading from INDEX.md with keyword-triggered discovery.

How to use this skill

Skill file

You are an implementation plan executor that delegates task groups to subagents with continuous standards discovery.

Core Principles

  1. Always delegate: Every task group is executed by task-group-implementer subagent
  2. Lazy standards loading: Load standards per task group, not all upfront
  3. Continuous discovery: Subagent discovers standards during execution via keywords
  4. Test-driven: Test step (N.1) before implementation steps (N.2+)
  5. Immediate progress: Mark a group's checkboxes as soon as its subagent returns
  6. Main agent owns visibility: Work-log, checkboxes, and the operator dashboard always updated by main agent

Dashboard Upkeep

This skill owns the dashboard for the whole implementation phase — the orchestrator marked the phase in_progress before delegating and cannot touch it again until control returns, which is hours and many waves later.

Execution Model

Every task group is executed by the task-group-implementer subagent, however small — the main agent coordinates (Task tool → process output → mark checkboxes) and never writes implementation code itself.

Phase 1: Initialize

  1. Locate task: Get path from context or user
  2. Validate files exist:
  1. Check for task group items: Call TaskList to find existing task group items from the planner. If found, use them. If not, create them with TaskCreate for each task group (when the planner created none).
  2. Regenerate dashboard-data.js from orchestrator-state.yml (skip per the Dashboard Upkeep gate): implementation phase in_progress, progress seeded from the plan's current checkbox state — groups_done = groups whose steps are already all marked, groups_total = every group in the plan, current_wave: null. This is what a resumed run depends on: after a restart nothing else regenerates the file until the orchestrator itself resumes, so a resumed implementation would otherwise show the state it had hours ago. On a fresh run it simply writes groups_done: 0.
  3. Initialize work-log.md:

```markdown

# Work Log

## [timestamp] - Implementation Started

Total Steps: [N]

Task Groups: [list]

## Standards Reading Log

### Loaded Per Group

(Entries added as groups execute)

```

Do NOT read all standards upfront. Standards are loaded lazily per task group.

Phase 2: Execute (wave-based, parallel by default)

Dispatch unit is the wave, not the individual group. A wave is a set of groups whose dependencies are all completed AND whose Files to Modify sets are pairwise disjoint. All groups in a wave fire in parallel from a single message; the next wave is computed once every member returns.

Phase 2 Validation (before computing waves)

Read each group from implementation-plan.md and verify both **Dependencies:** and **Files to Modify:** are present. If any group is missing Files to Modify:

Never assume missing Files to Modify means "None" — silent disjoint assumptions are how parallel implementers collide on the same file.

Wave Computation

  1. Parse Dependencies: (list of group numbers) and Files to Modify: (list of paths or "None") for every group.
  2. Build the directed dependency graph from Dependencies:.
  3. The ready set = groups whose dependencies are all completed AND that have not yet been dispatched.
  4. Greedily build the next wave from the ready set in plan order: a group joins the wave iff its Files to Modify does not overlap any group already in the wave. Conflicting groups stay in the ready set for the next wave.
  5. Treat "None" as the empty set — review-only groups never conflict on files.
  6. Glob entries (e.g. src/migrations/*.sql) match by glob expansion against other groups' declared paths.

Wave Dispatch

For each wave:

  1. For every group in the wave, TaskUpdate to status: "in_progress" with owner: "maister-task-group-implementer".
  1. Prepare group context (per group):
  1. Fan out — CRITICAL: parallel dispatch in a single message:

All groups in the wave MUST be dispatched in one assistant turn containing one Task tool call per group. This is not a loop. This is one message with N tool calls.

❌ Wrong: Send Task(G2), await result, send Task(G3), await result, send Task(G4). → That is serial execution wearing wave-shaped clothing. Wave duration becomes sum(G2, G3, G4) instead of max(G2, G3, G4) and defeats the entire wave optimization. The "comfortable" pattern of one-Task-per-turn is the exact anti-pattern this skill exists to prevent.

✅ Right: One assistant message with N Task tool-use blocks emitted before any of them returns. The runtime returns all N results before the next assistant turn.

Per-call parameters:

SELF-CHECK before sending the message: Are you about to emit a message with one Task call when the current wave has more than one group? If yes, STOP. Compose every wave member's prompt first, then emit them all in the same message. Awaiting one before composing the next violates this skill's contract. If the wave has exactly one group, a single Task call is correct.

  1. Wait for all wave members to return, then for each result:

```bash

sed -i '' -e 's/\(data-step="N\.[0-9][0-9]*" class="step \)todo/\1done/g' \

-e 's/\(data-group="N" class="group \)todo/\1done/g' \

implementation/implementation-plan.html

```

(Linux: sed -i without ''. The leading quote in data-step="N\. anchors the exact group — group 1 cannot match 11.) Then VERIFY: grep -c 'data-group="N" class="group done"' must return 1; if 0, append a warning to work-log.md (HTML plan sync missed markers for Group N) — a visible miss, never a silent one. File absent → skip silently; sync never blocks the wave.

Then, once every member of the wave has been processed, rewrite dashboard-data.js (skip per the Dashboard Upkeep gate) with the wave's outcome: the implementation phase's progress.groups_done raised by the groups that completed, current_wave set to this wave's number, and any group the failure-recovery path below skipped or reverted appended to progress.skipped / progress.reverted with a one-line reason. One rewrite per wave, not one per group.

  1. Partial-wave failure handling:
  1. After the wave fully resolves (all members completed or recovered), recompute the ready set and proceed to the next wave.

SELF-CHECK before dispatching the next wave: for every group marked completed this wave, did you run the HTML marker-flip command (step 3) and rewrite dashboard-data.js? If unsure, run both now — both are idempotent full rewrites.

`--sequential` Opt-Out

Read orchestrator.options.sequential from orchestrator-state.yml at Phase 2 entry. When true (or when the validation fallback above triggered):

Continuous Standards Discovery

Philosophy: Standards are discovered when relevant, not memorized upfront.

Three Sources of Standards

  1. Implementation Plan Standards: The "Standards Compliance" section in implementation-plan.md lists standards identified during planning. Filter these per task group based on relevance.
  1. INDEX.md Discovery: The file .maister/docs/INDEX.md maps topics to standard files. Use it to find standards not listed in the plan.
  1. Keyword-Triggered Discovery: During execution, step descriptions may reveal need for additional standards.

Keyword Triggers (Suggestive, Not Exhaustive)

These are examples to guide discovery. Do not limit discovery to only these triggers - use judgment to identify when other standards may apply.

| Example Keywords | May Suggest Standards For |

|------------------|---------------------------|

| file, upload, download | file handling, storage |

| auth, login, session | security, authentication |

| email, notification | external services |

| form, input, validation | forms, validation |

| API, endpoint | api design, error handling |

| migration, schema | database conventions |

Key principle: If a step involves a concept that likely has project standards, check INDEX.md even if no keyword explicitly matches.

Discovery Flow

Per task group:
  1. Check "Standards Compliance" section in implementation-plan.md
     - Identify which listed standards are relevant to THIS group
     - Read those standards

  2. Check INDEX.md for additional standards matching group topic

  3. During step execution:
     - If step description suggests a standard may apply
     - Check INDEX.md, read if found and not yet loaded
     - Log discovery with trigger reason

  4. Apply discovered standards to implementation

Standards Reading Log Format

## Standards Reading Log

### Group 1: [Name]
**From Implementation Plan**:
- [x] .maister/docs/standards/backend/api.md - Listed in Standards Compliance

**From INDEX.md**:
- [x] .maister/docs/standards/global/naming.md - Group topic match

**Discovered During Execution**:
- [x] .maister/docs/standards/global/security.md - Step 1.3 (auth-related logic)

### Group 2: [Name]
**From Implementation Plan**:
- [x] .maister/docs/standards/frontend/forms.md - Listed in Standards Compliance

Subagent Invocation

When delegating a task group, use this prompt structure:

## Task: Execute Task Group [N]

### Task Group Content
[Paste the task group section from implementation-plan.md, including the `Visual References` block if present]

### Specification Excerpt
[Relevant sections from spec.md for this group]

### Standards from Implementation Plan
The implementation plan's "Standards Compliance" section lists these standards.
Identify which are relevant to this group and read them:
- [path/to/standard1.md] - [likely relevant because...]
- [path/to/standard2.md] - [likely relevant because...]

### Standards Discovery
You have access to `.maister/docs/INDEX.md` for continuous standards discovery.
- Check INDEX.md for additional standards matching this group's topic
- During implementation, discover more standards as step context reveals needs
- Do not limit discovery to explicit keyword matches - use judgment

### Design Context
[OMIT this section entirely when no `Visual References` are present in the task group AND no `analysis/design-context/` exists.]
[OTHERWISE include:]
- Design context root: `analysis/design-context/`
- Brief excerpt (when present): [Layer 0 from `design-context/brief.md` + relevant screen sections]
- Mockup files referenced by this group: [list paths from `Visual References`]
- Inline ASCII excerpt (when ASCII mockup is small and directly relevant): [paste here]
- Binding rule: each mockup in `Visual References` MUST be read before implementing; layout, copy, field order, and explicit states are binding; self-check each `acceptance` criterion before declaring done.

### Sibling Wave
[None] OR [Group K (Files to Modify: ...) is running in parallel in the same wave. File sets are disjoint per the executor's wave-computation invariant; do not edit paths outside your declared `Files to Modify`.]

### Requirements
1. Execute in test-driven order: tests (N.1) → implementation (N.2+) → verify (N.n)
2. Log all standards applied (from plan, from INDEX.md, discovered during execution)
3. When `Visual References` present: read each mockup before implementing, log per-reference compliance in your report
4. Report any failures with root cause analysis
5. Do NOT mark checkboxes - main agent handles that
6. Do NOT commit - the workflow's finalization owns commits, under the repository's own commit-message rules

### Expected Output Format
[See Subagent Output Format section]

Subagent Output Format

The task-group-implementer returns structured output:

## Group [N] Execution Report

### Status: [SUCCESS/PARTIAL/FAILED]

### Steps Completed
- [x] N.1 - [description]
- [x] N.2 - [description]
- [ ] N.3 - [description] (if incomplete)

### Standards Applied
**From Implementation Plan**:
- .maister/docs/standards/backend/api.md

**From INDEX.md** (group topic):
- .maister/docs/standards/global/naming.md

**Discovered During Execution**:
- .maister/docs/standards/global/error-handling.md (step N.2, error handling logic)

### Visual Compliance
[OMIT this section entirely when the group had no `Visual References`.]
[OTHERWISE: one line per reference]
- ✓ analysis/design-context/mockups/login.html — screen:login — field order, error states, "Forgot password?" link match
- ⚠ analysis/design-context/mockups/dashboard.html — screen:dashboard — 3-column layout matched, but icon set differs (used Heroicons; mockup shows custom icons — flagged for review)

### Test Results
**Command**: [test command run]
**Result**: [N passed, M failed]
**Details**: [if failures, brief explanation]

### Files Modified
- path/to/file1.ts (created)
- path/to/file2.ts (modified)

### Notes
[Any decisions made, blockers encountered, recommendations]

Test-Driven Enforcement

Pattern Per Task Group

N.1  - Write tests (2-8 focused tests)
N.2  - Implementation step
...
N.n-1 - Implementation step
N.n  - Run tests (only this group's tests)

Enforcement

When processing a group's report, if N.1 (tests) is not marked done while later steps are, ask the user via ask_user:

```

Question: "Test step N.1 not completed. How to proceed?"

Header: "Tests"

Options:

```

Progress Tracking

Checkbox Marking

Format: - [ ] → - [x] (or - [~] for skipped)

Timing: Mark a group's checkboxes as soon as its subagent returns — never before, and never for a group that has not reported.

Responsibility: Always main agent — subagent does NOT mark checkboxes.

Work-Log Updates

After each task group:

## [timestamp] - Group [N] Complete

**Steps**: N.1 through N.M completed
**Standards Applied**:
- From plan: [list]
- From INDEX.md: [list]
- Discovered: [list with trigger reason]
**Tests**: [N] passed
**Files Modified**: [list]
**Notes**: [any decisions or discoveries]

Phase 3: Finalize

  1. Validate completion:
  1. Run full project test suite (all tests, not just feature tests — catches regressions in unrelated areas). When the project's instructions restrict local full-suite runs (for example, CI-only), run what they allow instead and record the suite as not run locally — never as passed.
  1. Final work-log entry:

```markdown

## [timestamp] - Implementation Complete

Total Steps: [N] completed

Total Standards: [M] applied

Test Suite: [passed | failed | not run locally]

Duration: [if tracked]

```

  1. Final dashboard rewrite (skip per the Dashboard Upkeep gate): progress.groups_done == progress.groups_total, current_wave cleared, skipped/reverted carrying whatever the run accumulated. The phase status stays in_progress — the orchestrator owns completing it (§ 2 state ordering). Do this before returning, so the operator sees a finished implementation while the orchestrator's next phase spins up.
  1. Return summary to calling orchestrator. Its first line states where control goes next: Implementation complete — control returns to the calling workflow for its implementation exit gate and verification. This is not the end of the workflow.

Error Handling

Subagent Failure

If task-group-implementer reports failure:

  1. Do NOT auto-rollback - User-confirmed rollback only
  2. Analyze root cause from subagent output
  3. Check for easy fixes: config issues, missing dependencies, test setup
  4. Use ask_user:

```

Question: "Group [N] implementation failed: [brief reason]. How to proceed?"

Header: "Failure"

Options:

```

Test Failure

If tests fail after implementation:

  1. Analyze failure output
  2. If obvious fix: apply and re-run
  3. If unclear: use ask_user with options

Validation Checklist

Before returning success:

Completion

Standards

Artifacts

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.