agentleFS
golid-aigolid-ai/golid/.cursor/rules/plan-execution-loop.mdc

golid / rules

Cursor rule40 starsChanged 6 months agoMITView on GitHub

Execute a docs/plans/*.md slice with subagent implement → evidence-based audit → fix until 90+ — invoke manually when running a plan

  • Deletes or force-pushes

The file

We split this plan-execution-loop.mdc into the rules it gives an agent

9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Parent agent (re-audit dispatch): Do not paste prior grades into the prompt.

    line 67
  2. Distinctive:

    Read plan slice before dispatching — do not dump whole plan into subagent

    line 71
  3. Very specific:

    Run scripts/check_spec_drift.sh origin/main before commit when handler/service touched

    line 74
  4. Distinctive:

    Commit per slice or logical batch after PASS.

    line 75
  5. Very specific:

    Update docs/plans/*.md Progress table after each PASS

    line 76
  6. Very specific:

    Before commit on backend slices: spec sync or [skip-spec(module): reason].

    line 90
  7. Very specific:

    When running two or more plans concurrently (each with its own execution loop), do not share one working tree.

    line 100
  8. Distinctive:

    After each pick: build + test.

    line 119
  9. Very specific:

    Run full verification on parent: check_spec_drift.sh, npm run typecheck, go test ./...

    line 120

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
plan-execution-loop.mdc
---
description: Execute a docs/plans/*.md slice with subagent implement → evidence-based audit → fix until 90+ — invoke manually when running a plan
alwaysApply: false
---

# Plan Execution Loop

> **Thesis:** One plan slice at a time — implement, evidence-based audit (≥90/100, file:line proof required), fix, re-audit — then next slice. Parent agent orchestrates; subagents implement and audit.
>
> **Invoke when:** User says "run the plan", "execute slice X", or points at `docs/plans/*.md` for implementation.

## Per-slice loop (do not skip)

```
1. IMPLEMENT — Task subagent: read plan slice only; implement; run verification commands; update Progress row
2. AUDIT   — Task subagent (readonly): grade /100 vs slice acceptance with file:line evidence; PASS only if ≥90 and every criterion has proof
3. FIX     — if FAIL: Task subagent applies audit fix list; no scope creep
4. RE-AUDIT — repeat 2–3 until ≥90 with full evidence
5. NEXT SLICE — only after current slice PASS
```

## Subagent prompts must include

- Exact slice ID and file path to plan section
- Acceptance criteria from plan (copy verbatim)
- Verification commands (`npm run test:coverage`, `check_spec_drift.sh`, etc.)
- Forbidden scope (other slices, unrelated refactors)
- Evidence rule: every deduction needs `path:line` citation; every PASS criterion needs `path:line` proof or automatic FAIL
- **Fresh grade (audit dispatches only):** grade the artifact **as it exists now** — start at 100, deduct only for **current** gaps with `path:line` proof. Do not reward "improvement since last pass", prior fix lists, or Progress table history. Parent must not anchor with prior scores (see Re-audit below).
- "Return: grade, PASS/FAIL, evidence table, fix list, files changed, blockers"

## Evidence-based audit (mandatory)

Audit subagents grade **evidence**, not vibes. A numeric score without citations is invalid.

**For every deduction** — cite `path:line` (or `path:line-line` for a range) showing the gap. Example: `-5 Scope: backend/internal/handler/foo.go:42 — touches bar.go, outside slice file list`.

**For every slice acceptance criterion** — cite `path:line` (or command output) proving it is met. If the auditor cannot find proof after reading the diff and running verification commands, that criterion is **automatic FAIL** regardless of the running score.

**Score math:**

- Start at 100.
- Deduct per finding with cited evidence only — no uncited deductions.
- Uncited "looks good" claims do not count toward PASS.
- Final grade = 100 minus cited deductions. If any acceptance criterion lacks proof → **FAIL** even when grade ≥90.

**Required audit return format:**

```
Grade: NN/100 — PASS | FAIL
Acceptance evidence:
  - [criterion verbatim]: path:line — one-line proof
Deductions:
  - [-N Dimension]: path:line — finding
Fix list: (ordered, only if FAIL)
Blockers: (only if FAIL)
```

Parent agent: reject audit output missing the evidence table or with blank acceptance proofs — re-dispatch audit with "evidence required" before FIX or NEXT SLICE.

### Re-audit — avoid accumulation bias

Fix loops invite **score drift** when auditors see prior grades and nudge scores up. Re-audits grade the **current artifact only**, not deltas from the last grade.

**Audit subagent (re-audit):** Same rubric as pass 1. No prior scores or fix-list history in context. Fixed issues = no deduction, not bonus points. No `path:line` proof → criterion fails.

**Parent agent (re-audit dispatch):** Do not paste prior grades into the prompt. Reject audits that cite "pass N fixed X" without re-verifying X in the current file.

## Parent agent responsibilities

- Read plan slice before dispatching — do not dump whole plan into subagent
- Reject audit subagent output without file:line evidence — re-dispatch, do not accept inflated scores
- On re-audit dispatch: omit prior pass scores from the prompt; reject grade inflation without cited gap closure (see Re-audit — accumulation bias)
- Run `scripts/check_spec_drift.sh origin/main` before commit when handler/service touched
- Commit per slice or logical batch after PASS; never commit with audit below 90 or missing evidence
- Update `docs/plans/*.md` Progress table after each PASS

## Audit dimensions (default weights)

| Dimension | What to check | Evidence required |
|-----------|---------------|-------------------|
| Completeness | All deliverables in slice scope | `path:line` per deliverable, or FAIL |
| Accuracy | Paths, commands, plan citations match repo | `path:line` or command output |
| Acceptance | Slice-specific gates met | `path:line` or test output per criterion |
| Scope | No slice creep; spec sync if required | `path:line` for out-of-scope edits, or `rg`/diff showing clean scope |
| Verification | Commands run, exit 0 | Paste exit code + relevant output snippet |

## Contract closeout (from `slice-and-ship`)

Before commit on backend slices: spec sync or `[skip-spec(module): reason]`; run `check_spec_drift.sh`.

## Parallel slices within one plan

Independent slices (e.g. B4a ∥ B4b ∥ B4c) may run as parallel **implement** subagents in the **same working tree** when they touch disjoint files. Each slice still gets its own **audit → fix → re-audit** loop before merge.

Pre-flight: `rg` plan slice file lists — if two slices touch the same file, run them sequentially.

## Multiple plans in parallel (worktrees required)

When running **two or more plans** concurrently (each with its own execution loop), **do not share one working tree.** Each plan gets isolated git state — same rules as `parallel-subagents` "When subagents will commit code".

```
Parent branch (e.g. steve-dev)
├── worktree: ../golid-plan-a  →  branch plan/a-short-name  →  docs/plans/foo.md loop
└── worktree: ../golid-plan-b  →  branch plan/b-short-name  →  docs/plans/bar.md loop
```

**Setup (parent agent):**

```bash
git worktree add -b plan/<name> ../golid-<name> HEAD
# Dispatch plan execution loop subagent with working_directory = that worktree path
```

**Land back on parent branch:**

1. Pre-flight: `rg` both plans for overlapping file paths — resolve or serialize conflicting plans
2. Cherry-pick **one commit at a time** from each plan branch (smaller/additive plan first) — see `parallel-subagents` cherry-pick loop
3. After each pick: build + test; fix conflicts before next pick
4. Run full verification on parent: `check_spec_drift.sh`, `npm run typecheck`, `go test ./...`
5. `git worktree remove` + `git branch -D plan/<name>` when landed

**Forbidden on parent repo while worktrees run:** `git reset --hard`, `git clean -fd`, `git checkout --force` — can destroy uncommitted work in sibling worktrees.

## Anti-patterns

| Bad | Good |
|-----|------|
| Implement B4a–c in one pass | B4a PASS → then B4b |
| Two plans editing same branch simultaneously | One worktree per plan |
| Bulk cherry-pick plan commits | One commit at a time |
| Audit whole plan at end | Audit each slice before next |
| Skip audit because "tests pass" | Audit grades behavior + docs + scope |
| Commit at 82/100 | Fix loop until ≥90 |
| Grade 92 with no file:line citations | Reject output; re-audit with evidence |
| "Criterion met" without path:line proof | Automatic FAIL for that criterion |
| Vague deductions ("could be cleaner") | Cited finding or no deduction |
| Re-audit prompt includes prior scores or sympathy grading | Fresh grade from 100; re-verify fixes at `path:line` only |

## Related

- `slice-and-ship` — slice definition, contract closeout
- `audit-bugs` — finding citation standard (`path:line` or `rg` count)
- `git-commits` — `check_spec_drift.sh` before commit; parallel shared-file exception
- `parallel-subagents` — worktree isolation, cherry-pick order, shared-file pre-flight

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.