一键导入
loop
Orchestrate the full feature workflow loop by detecting artifact state and routing through review, implementation, audit, and follow-up steps.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Orchestrate the full feature workflow loop by detecting artifact state and routing through review, implementation, audit, and follow-up steps.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Validate workflow markdown documents such as plans, reviews, implementation reports, and audits against the required format contract.
Master workflow orchestrating feature planning, review, implementation, audit, and retrospectives. Entry point for feature development lifecycle.
Audit a feature implementation against its approved plan and implementation report, then produce the architect verdict and follow-up direction.
Create a feature-specific context document and save it under the feature contexts directory for later planning, review, or implementation work.
Create a feature document covering business context and initial architecture for a new feature using the PM and Architect workflow.
Execute a review-approved feature plan and produce or refine the implementation report for that feature.
| name | loop |
| description | Orchestrate the full feature workflow loop by detecting artifact state and routing through review, implementation, audit, and follow-up steps. |
| applyTo | [] |
Purpose: Orchestrate the full plan loop from any checkpoint. Detects current state from artifacts and runs the appropriate next steps via subagents.
No arguments (auto-detect from chat):
/loop — infer FEATURE_ID and plan-slug from chat history, auto-detect artifact stateWith FEATURE_ID:
/loop feat-2026-01-xxx — auto-detect plan-slug from dir, auto-detect state/loop feat-2026-01-xxx 1-plan-slug — explicit feature + planReference by artifact:
/loop plan — reference current plan from chat (infer feature + slug)/loop R{n} — reference review round (e.g. loop R2 → find review.md round 2, infer feature + plan)/loop I{n} — reference impl round (e.g. loop I1 → find implementation.md round 1, infer feature + plan)Entry point override (optional, rarely used):
/loop feat-2026-01-xxx from review — force start from review/loop feat-2026-01-xxx from implement — force from implementation/loop feat-2026-01-xxx from audit — force from audit/loop feat-2026-01-xxx from fix — force from post-audit fixYou are the Architect orchestrator (architect.md). Job: detect artifact state, route to next step, spawn subagents, continue loop.
Parse user input intelligently:
Before feature-id extraction, handle standalone fix aliases.
fixes, treat it as the standalone fixes workspacefixes {plan-slug} or fixes/{plan-slug}, resolve:
.pythia/workflows/fixes.pythia/workflows/fixes/fixes.md.pythia/workflows/fixes/plans/.pythia/workflows/fixes/reports/fixes is provided without a plan slug, ask the user for the plan slug or list available fixesfeature-dirNo arguments → Search chat history for FEATURE_ID and plan-slug
Reference by artifact → Parse and infer feature context
plan → Search chat for "plan" mentions, infer FEATURE_ID and slugR{n} → Search chat for review round reference, extract feature-dir from path, count existing review rounds to verifyI{n} → Search chat for impl reference, extract feature-dir, verify round existsWith explicit FEATURE_ID → Validate and proceed
{feature-dir}/plans/ and pick latest/defaultfrom provided → proceed to auto-detectionRead artifact files to determine lifecycle position:
1. Does plans/{plan-slug}.plan.md exist?
NO → EXIT: "Plan not found. Use /plan skill first."
2. Does reports/{plan-slug}.review.md exist with Verdict: ready?
NO → ENTRY: review
3. Does reports/{plan-slug}.implementation.md exist?
NO → ENTRY: implement
4. Does reports/{plan-slug}.audit.md exist?
NO → ENTRY: audit
5. Read last **Verdict**: line in audit.md
ready → DONE
needs-fixes → ENTRY: fix (needs-fixes)
plan-fix → ENTRY: fix (plan-fix)
re-plan → ENTRY: re-plan
One subagent per role, one at a time. Wait for completion before next.
Orchestrator MUST NOT create or edit role artifacts meant for subagents: reports/{plan-slug}.review.md, reports/{plan-slug}.implementation.md, or reports/{plan-slug}.audit.md. The orchestrator only reads them, routes, and (for plan-fix only) patches plans/{plan-slug}.plan.md. Skipping a real subagent handoff and writing those files in the orchestrator context is incorrect.
Workflow-doc validation (orchestrator-owned): After any subagent (Reviewer / Developer / Audit) writes or materially updates a workflow Markdown artifact, or after the orchestrator saves plans/{plan-slug}.plan.md in ENTRY: fix (plan-fix), the orchestrator must run workflow-doc validation before routing onward: spawn a Validator subagent using the handoff prompt in /validate skill § Validator subagent (delegation) (absolute validate skill path + absolute artifact path), or use inline fallback per that skill and state so. Exit 0 required before parsing verdicts or entering the next ENTRY. This satisfies the child-skill validation requirement so Reviewer/Developer/Audit subagents may skip nested Validator when the orchestrator documents the run.
Concrete tooling (orchestrator — if “Validator subagent” is unclear): Use a separate delegated task (e.g. Cursor Task) so validation does not run inside the orchestrator thread — commonly subagent_type="generalPurpose" or another short, shell-capable one-shot type your host documents. Put only the filled handoff prompt from /validate skill § Validator subagent in that task (two absolute paths); do not paste ENTRY routing notes, parsed verdicts, or the workflow artifact body — only validation instructions.
PostToolUse hook nudges: After subagents save workflow artifacts, post.js may emit pythia-nudge: lines on stderr (plan → review, review → replan/implement, implementation → audit, audit verdict routing). Treat these as hints; State Detection above and artifact files remain authoritative. Reconcile nudges before routing. Hooks do not replace Validator exit 0 — see hook-integration.md.
ENTRY: review → Spawn Reviewer subagent (full procedure: ### ENTRY: review below)
review.mdENTRY: implement → Spawn Developer subagent
ENTRY: audit → Spawn fresh Architect subagent (independent of Developer)
ENTRY: fix (needs-fixes) → Spawn Developer subagent (refinement mode)
ENTRY: fix (plan-fix) → Orchestrator (current context)
ENTRY: re-plan → Report BLOCKED
/replan skill for scope decisions| Status | Action |
|---|---|
ready | DONE — report success, commit message, artifact paths |
needs-fixes ≥ 2 | STUCK — manual fix needed |
plan-fix ≥ 2 | ESCALATE → re-plan |
re-plan | BLOCKED — user decision required |
| Review ≥ 2 | DEADLOCKED — user decision required |
See also: /replan skill, /plan skill
1. Spawn Reviewer subagent (separate context — do not perform the review in the orchestrator thread).
The orchestrator MUST NOT write or edit reports/{plan-slug}.review.md.
2. Pass a self-contained prompt so the subagent does not depend on hidden chat state. Use this
template (substitute {feature-dir}, {plan-slug}, {R-next} after counting existing ## … R… headers):
Prompt: "You are the Reviewer subagent, not the loop orchestrator.
Handoff: Architect orchestrator started ENTRY: review for this feature/plan.
Feature directory: {feature-dir}
Plan slug: {plan-slug}
Next review round: {R-next} (append only; new ## {plan-slug} R{R-next} block at EOF per review format).
Read:
- plans/{plan-slug}.plan.md
- Related contexts under contexts/ as mandatory per [/review skill](../review/SKILL.md)
Write/update:
- reports/{plan-slug}.review.md (Navigation + Retrospective + new round; follow review-format.md)
Produce Verdict: ready or needs-revision in the new round (per review-format.md).
Follow [/review skill](../review/SKILL.md) and [reviewer.md](../../agents/reviewer.md) in full.
Do NOT implement code, do NOT patch the plan, do NOT run later loop steps (implement/audit)."
3. Wait for the subagent to finish.
3b. Workflow-doc validation: Validator subagent (or inline fallback per [/validate skill](../validate/SKILL.md)) for `reports/{plan-slug}.review.md`. Exit `0` required.
4. Verify reports/{plan-slug}.review.md exists and the latest round contains an explicit verdict
line the orchestrator can parse (Verdict: ready | needs-revision).
5. Route: ready → ENTRY: implement | needs-revision → if review rounds < max: [/replan](../replan/SKILL.md)
path per workflow (user or authorized replan) then re-enter ENTRY: review; if at max rounds → DEADLOCKED exit.
1. Spawn Developer subagent
Prompt: "You are the Developer. Execute plan {plan-slug} for feature {feature-dir}.
Plan: plans/{plan-slug}.plan.md. Review: reports/{plan-slug}.review.md.
Write implementation report to reports/{plan-slug}.implementation.md.
Follow the [/implement skill](../implement/SKILL.md)."
Wait.
1b. Workflow-doc validation: Validator subagent (or inline fallback per [/validate skill](../validate/SKILL.md)) for `reports/{plan-slug}.implementation.md`. Exit `0` required.
2. Verify reports/{plan-slug}.implementation.md was written (check file exists and is non-empty).
→ ENTRY: audit
1. Spawn fresh Architect subagent
Prompt: "You are the Architect auditor. Audit implementation of plan {plan-slug} for {feature-dir}.
Plan: plans/{plan-slug}.plan.md. Implementation: reports/{plan-slug}.implementation.md.
Write audit to reports/{plan-slug}.audit.md.
If verdict ≠ ready, write problems to notes/{plan-slug}.problems.md.
Follow the [/audit skill](../audit/SKILL.md).
Do NOT continue the loop — only audit and write artifacts."
Wait.
1b. Workflow-doc validation: Validator subagent (or inline fallback per [/validate skill](../validate/SKILL.md)) for `reports/{plan-slug}.audit.md`. Exit `0` required.
2. Read reports/{plan-slug}.audit.md — find verdict.
→ route by verdict (see Post-audit routing below)
iteration_count += 1
If iteration_count > 2:
EXIT STUCK: "Needs-fixes loop exceeded 2 iterations. Manual intervention required."
Report: last audit verdict, path to problems.md, recommended next step.
1. Spawn Developer subagent (refinement mode)
Prompt: "You are the Developer in REFINEMENT mode for plan {plan-slug}, feature {feature-dir}.
Read:
- plans/{plan-slug}.plan.md
- reports/{plan-slug}.implementation.md (last round)
- notes/{plan-slug}.problems.md (audit findings)
Perform the minimal fix for each issue in problems.md.
Append all work to the last Implementation Round's Out-of-Plan Work.
Do not create a new implementation round.
Follow the [/implement skill](../implement/SKILL.md) (refinement mode)."
Wait.
1b. Workflow-doc validation: Validator subagent (or inline fallback per [/validate skill](../validate/SKILL.md)) for `reports/{plan-slug}.implementation.md`. Exit `0` required.
2. → ENTRY: audit (fresh re-audit)
[Orchestrator — current context]
1. Read notes/{plan-slug}.problems.md.
2. Read plans/{plan-slug}.plan.md.
3. For each problem marked as `plan error`:
- Amend the affected step in the plan.
- Add version marker: **Amended**: v{N} (A{audit-round})
- Increment metadata Version.
- Add revision log entry (trigger: Audit A{audit-round}).
4. Save updated plan to plans/{plan-slug}.plan.md.
4b. Workflow-doc validation: Validator subagent (or inline fallback per [/validate skill](../validate/SKILL.md)) for `plans/{plan-slug}.plan.md`. Exit `0` required.
5. Spawn Developer subagent (full re-implement of affected steps)
Prompt: "You are the Developer. Re-execute the plan for {plan-slug}, feature {feature-dir}.
The plan was patched (plan-fix). Start a new implementation round.
Plan: plans/{plan-slug}.plan.md. Focus on steps marked **Amended**.
Follow the [/implement skill](../implement/SKILL.md)."
Wait.
6. → ENTRY: audit (fresh re-audit)
Note: if this second audit produces plan-fix again → escalate to ENTRY: re-plan.
[Stop auto-continuation — require user decision]
Report to user:
"Audit verdict is `re-plan`. This requires scope and architectural decisions.
Please review:
- reports/{plan-slug}.audit.md
- notes/{plan-slug}.problems.md
Then use [/replan skill](../replan/SKILL.md) to revise the plan,
followed by [/review skill](../review/SKILL.md) and then [/implement skill](../implement/SKILL.md)."
Do not auto-spawn Reviewer or Architect for replan — scope decisions require user input.
Exception: if user explicitly said \"loop with re-plan authority\" or \"auto full loop\":
Architect (current context) uses [/replan skill](../replan/SKILL.md) (Trigger 2) and patches plan.
→ ENTRY: review (full review cycle via [/review](../review/SKILL.md))
→ ENTRY: implement (via [/implement](../implement/SKILL.md))
→ ENTRY: audit (via [/audit](../audit/SKILL.md))
If result is still not ready → EXIT BLOCKED.
| Verdict | Route |
|---|---|
ready | → EXIT DONE |
needs-fixes | → ENTRY: fix (needs-fixes) |
plan-fix | → ENTRY: fix (plan-fix) |
re-plan | → ENTRY: re-plan |
| Condition | Message |
|---|---|
ready | DONE — report final status, commit message from audit.md, and artifact paths |
needs-fixes ≥ 2 | STUCK — report last problems.md path + "Manual fix needed" |
plan-fix → second audit ≠ ready | ESCALATING — auto-route to re-plan (if authorized) or report |
re-plan from audit | BLOCKED — report, require user input |
| Review ≥ 2 rounds + needs-revision | DEADLOCKED — report, require user input |
The orchestrator tracks iteration counts in memory (not in files) for the current run:
needs_fixes_iterations: incremented each time fix (needs-fixes) runsplan_fix_done: boolean, set when fix (plan-fix) runs oncereview_rounds: read from review file (count ## {plan-slug} R{n} headers)After each subagent completes, report its result briefly before continuing:
## Loop iteration {n}
**Step**: {step name}
**Subagent**: {role}
**Result**: {artifact written, verdict if applicable}
**Next**: {what the orchestrator will do next}
On exit:
## Loop complete
**Final status**: {DONE | STUCK | BLOCKED | DEADLOCKED | ESCALATING}
**Verdict**: {last audit verdict}
**Artifact**: {feature-dir}/reports/{plan-slug}.audit.md
**Problems** (if any): {feature-dir}/notes/{plan-slug}.problems.md
**Commit message** (if ready): [from audit.md]
**Iterations**: review={n}, implement={n}, audit={n}, fix={n}