From dx-core
Autonomous execution loop — runs each plan step (implement + test + review + commit internally), with step-fix for failures. Stops after 2 consecutive fix failures on the same step. Use to execute the full plan hands-free.
npx claudepluginhub easingthemes/dx-aem-flow --plugin dx-coreThis skill is limited to using the following tools:
You are a coordinator. You run the step pipeline for each step in implement.md, delegating to skills via the Skill tool.
Executes implementation plans from plan.md files via Superpower Loop phases: task creation, batch execution with verification, git commits. Use after plan ready or on 'execute the plan'.
Executes tech plans via dependency-aware task batching, TDD, incremental commits, section code reviews, and PR creation. Use after planning phases.
Share bugs, ideas, or general feedback.
You are a coordinator. You run the step pipeline for each step in implement.md, delegating to skills via the Skill tool.
After loading implement.md, use TaskList to check for existing tasks from a previous run. If stale tasks exist, cancel them first with TaskUpdate (status: cancelled). Then create a task for each plan step using TaskCreate (e.g., "Step 1: Create dialog XML"). Mark each in_progress when executing, completed when committed. On fix attempts, update the task subject (e.g., "Step 1: Create dialog XML (fix 1)"). On heal cycles, add a task: "Healing: ".
digraph step_all {
"Locate spec dir + check run-state" [shape=box];
"Ensure feature branch" [shape=box];
"Load fix memory" [shape=box];
"Get next pending step" [shape=box];
"All steps done?" [shape=diamond];
"Execute step" [shape=box];
"Step passed?" [shape=diamond];
"Fix attempt" [shape=box];
"Fix succeeded?" [shape=diamond];
"Consecutive failures < 2?" [shape=diamond];
"Invoke step-fix (heal)" [shape=box];
"Heal result?" [shape=diamond];
"Execute corrective steps" [shape=box];
"Corrective step failed after 2 fixes?" [shape=diamond];
"Healing cycle < 2?" [shape=diamond];
"Log progress + track fix patterns" [shape=box];
"Completion summary + log run + promote fixes" [shape=doublecircle];
"STOP: Human intervention needed" [shape=doublecircle];
"Locate spec dir + check run-state" -> "Ensure feature branch";
"Ensure feature branch" -> "Load fix memory";
"Load fix memory" -> "Get next pending step";
"Get next pending step" -> "All steps done?";
"All steps done?" -> "Completion summary + log run + promote fixes" [label="yes"];
"All steps done?" -> "Execute step" [label="no"];
"Execute step" -> "Step passed?";
"Step passed?" -> "Log progress + track fix patterns" [label="yes"];
"Step passed?" -> "Fix attempt" [label="no (blocked)"];
"Fix attempt" -> "Fix succeeded?";
"Fix succeeded?" -> "Log progress + track fix patterns" [label="yes"];
"Fix succeeded?" -> "Consecutive failures < 2?" [label="no"];
"Consecutive failures < 2?" -> "Fix attempt" [label="yes, retry"];
"Consecutive failures < 2?" -> "Invoke step-fix (heal)" [label="no, 2 strikes"];
"Invoke step-fix (heal)" -> "Heal result?";
"Heal result?" -> "Execute corrective steps" [label="healed"];
"Heal result?" -> "STOP: Human intervention needed" [label="unrecoverable"];
"Execute corrective steps" -> "Corrective step failed after 2 fixes?";
"Corrective step failed after 2 fixes?" -> "Log progress + track fix patterns" [label="no, passed"];
"Corrective step failed after 2 fixes?" -> "Healing cycle < 2?" [label="yes, failed"];
"Healing cycle < 2?" -> "Invoke step-fix (heal)" [label="yes, try again"];
"Healing cycle < 2?" -> "STOP: Human intervention needed" [label="no, 2 cycles exhausted"];
"Log progress + track fix patterns" -> "Get next pending step";
}
SPEC_DIR=$(bash .ai/lib/dx-common.sh find-spec-dir $ARGUMENTS)
Maintain run state in $SPEC_DIR/run-state.json:
{
"skill": "dx-step-all",
"ticket": "<id>",
"started": "<ISO-8601>",
"phase": 0,
"step": 0,
"completed_phases": [],
"last_action": "",
"files_modified": []
}
On invocation:
$SPEC_DIR/run-state.jsonstarted < 2 hours ago → ask user: "Previous run found at phase {phase}, step {step}. Resume or start fresh?"started ≥ 2 hours ago → warn: "Stale run state found (started {time}). Starting fresh." Delete run-state.json.During execution: Update run-state.json after each phase/step completion. On completion: Delete run-state.json (clean exit).
Get the plan metadata (step count and status) — do NOT read full implement.md here:
bash .ai/lib/plan-metadata.sh $SPEC_DIR
This outputs a compact summary (~10 tokens/step vs ~200 for full file). Workers (step, step-fix) will read the full implement.md when they need it.
Print: Starting execution: <N> steps total, <M> pending.
Before executing any steps, run the shared branch guard:
bash .ai/lib/ensure-feature-branch.sh $SPEC_DIR
This no-ops if already on feature/* or bugfix/*. Creates a feature branch if on any other branch. The branch name is saved to $SPEC_DIR/.branch.
Print: Branch: <BRANCH> (<BRANCH_ACTION>)
This is a hard gate — never execute steps on a protected branch.
Before entering the execution loop, check if the project has accumulated fix knowledge from previous runs.
If .ai/learning/fixes.md exists:
Known fix patterns for this project: <summary of fixes.md content>Learning: Loaded <N> known fix patterns from previous runs.If it does not exist, skip silently.
Re-read plan metadata to get the latest status (skills update implement.md). Especially important after step-fix creates new steps. Never read full implement.md in the orchestrator — workers handle that.
bash .ai/lib/plan-metadata.sh $SPEC_DIR
Identify the next step with status pending.
Check if any pending or in-progress steps remain.
Invoke Skill(/dx-step) for the current step. dx-step now handles implement + test + review + commit as internal phases — no separate dispatches needed.
Check the result from dx-step:
Error Classification: Before triggering healing, classify the failure using shared/error-handling.md:
Invoke Skill(/dx-step-fix) for the current step.
Track fix attempts per step.
Check the fix result:
Check consecutive fix failure count for this step:
Track healing cycles per step. Max 2 healing cycles per original step.
Invoke Skill(/dx-step-fix) with healing context:
/dx-step-fix <SPEC_DIR> --heal --failure-type step-blocked --blocked-step <N>
dx-step-fix now handles both fix and heal modes internally.
Check the step-fix return:
⚠ Plan modified by heal: <N> corrective step(s) added after Step <blocked-step>.
New steps: <list of step numbers and titles>
Total steps now: <updated total>
Update TaskList to reflect the new steps. Proceed to "Execute corrective steps".Step <N> unrecoverable after 2 fixes + healing. Human intervention needed. Proceed to "STOP: Human intervention needed".Run the normal Execute step → Fix attempt cycle on each new corrective step created by step-fix.
After running the corrective step through the full cycle (including up to 2 fix attempts):
Check the healing cycle count for the original step:
Step <N> blocked after 2 healing cycles. Human intervention needed. Proceed to "STOP: Human intervention needed".After each step cycle, print:
Step <N>/<total> done — <step title>
Track and persist learning signals for each step that completes (or fails):
step_number: which stepstep_title: the step's title from implement.mdfix_attempts: number of fix attempts (0 if none needed)fix_succeeded: how many fix attempts succeededfix_failed: how many fix attempts failedheal_cycles: number of healing cycles invoked (0 if none)heal_succeeded: how many heal cycles succeededheal_failed: how many heal cycles failedfix_types: list of error types encountered (e.g., "compilation", "test-failure", "review-rejection")Persist immediately after each step (not deferred to end-of-run):
mkdir -p .ai/learning/raw
If fix attempts occurred for this step, append one JSONL line per attempt to .ai/learning/raw/fixes.jsonl:
{"timestamp":"<ISO-8601>","ticket":"<id>","step":<N>,"error_type":"<type>","fix_description":"<what was done>","result":"<success|failed>"}
Incremental pattern promotion: After appending, check if any pattern in fixes.jsonl now has 3+ successes and 0 failures. If so, promote it immediately (see "Completion summary + log run + promote fixes" for format). This ensures learning survives even if the run is interrupted.
After all steps are done:
## Execution Complete
**<Title>**
**Steps:** <N>/<N> done (including <H> healing steps)
**Commits:** <N> commits created
**Fix attempts:** <N> total (<M> succeeded, <K> failed)
**Healing cycles:** <N> total (<M> healed, <K> unrecoverable)
### Cross-Repo Note:
<If implement.md has "Other repos required", print:>
> This plan covers **<current repo>** only. Switch to **<other repo(s)>** and run `/dx-req <id>` there to plan and execute those changes.
<Otherwise omit this section.>
### Next steps:
- `/dx-pr` — create pull request
- Review changes with `git log --oneline`
Log run record:
mkdir -p .ai/learning/raw
Append one JSONL line to .ai/learning/raw/runs.jsonl:
{"timestamp":"<ISO-8601>","ticket":"<id>","flow":"step-all","total_steps":<N>,"steps_completed":<N>,"fix_attempts":{"succeeded":<N>,"failed":<N>},"heal_cycles":{"succeeded":<N>,"failed":<N>},"step_titles":["<title1>","<title2>"]}
Use Bash to append — echo '<json>' >> .ai/learning/raw/runs.jsonl
Final promotion sweep:
Run one final pattern promotion check (same logic as incremental promotion in "Log progress + track fix patterns") to catch any patterns that crossed the 3-success threshold during the last step. This is a safety net — most promotions happen incrementally.
Read .ai/learning/raw/fixes.jsonl. Group entries by error_type + fix_description. For each combination with 3+ successes AND 0 failures:
compilation-missing-import).claude/rules/learned-fix-<slug>.md already exists (promoted earlier)# Learned Fix: <error_type>
When encountering: <error_type>
Apply this fix: <fix_description>
Evidence: <N> successful applications across <ticket list>.
Learning: Promoted fix pattern to .claude/rules/learned-fix-<slug>.md — <fix_description>Summary message:
If fix patterns were logged:
Learning: <N> fix patterns logged, <M> promoted to rules.If no fix patterns at all:
Learning: Clean run — no fixes needed.The execution loop has been halted. Either:
Print the blocked step number, the error type, and a summary of what was tried. The user must manually intervene (edit implement.md, fix the environment, or re-plan).
| After Phase | Gate | Fail Action |
|---|---|---|
| Step execution (2a) | Step status is done in implement.md | Enter fix loop (2b-2d) |
| Fix attempt (2d) | Fix count < 2 for this step | If >=2: enter heal cycle (2d-heal) |
| Heal cycle (2d-heal) | Corrective steps added to implement.md | If unrecoverable: STOP with blocked step report |
| All steps complete | No pending or in-progress steps remain | Proceed to build phase |
/dx-step-all 2416553
Reads implement.md from .ai/specs/2416553-add-layout-switcher/, finds 6 pending steps, and runs each through dx-step (which handles implement + test + review + commit internally). Prints progress after each step.
/dx-step-all 2416553
If steps 1-3 are already done, picks up at step 4 and continues. Only pending steps are executed.
When step 3 fails twice, triggers dx-step-fix in heal mode which analyzes the error, creates a corrective step 3a, executes it, then retries step 3. If healing also fails after 2 cycles, stops and reports.
Cause: Steps are marked blocked or in-progress from a previous interrupted run.
Fix: Open implement.md and reset the stuck step's status to pending, then re-run.
Cause: The plan step has incorrect instructions or missing context.
Fix: Let self-healing run (2 fix attempts + 2 heal cycles). If still failing, run /dx-step-fix manually to diagnose, or edit implement.md to fix the step instructions.
Cause: You're on development, main, or master instead of a feature branch.
Fix: The branch guard should auto-create a feature branch. If it fails, manually create one: git checkout -b feature/<id>-<slug>.
Failure: Test passes locally but fails in step execution (timing-dependent assertion) Consecutive failures: 2 Decision: HEAL — test is flaky. Fix: add wait/retry in test assertion.
Failure: Step creates a new utility, but existing utility covers the need
Consecutive failures: 2
Decision: ESCALATE — plan problem, not code problem. Report: "Step 4 violates reuse rule. Existing forms.js:validateField() covers this need."
plan-metadata.sh between steps to get the latest status (skills update implement.md). Especially important after step-fix creates new steps. Never read full implement.md in the orchestrator — workers handle that.This skill uses Skill() tool calls which work on both Claude Code and Copilot CLI.
Copilot CLI / VS Code Chat fallback: If subagent skill invocation fails, run the skills manually in sequence for each plan step:
/dx-step <step-number> — execute a single step (implement + test + review + commit)/dx-step-fix <spec-dir> — attempt repair (up to 2 tries)/dx-step-fix <spec-dir> --heal — diagnose and create corrective stepsimplement.md