plan-cycle
Draft, critique and merge a plan in one loop, then stop for approval. Use when the user runs /plan-cycle or asks to run the full create-and-critique planning loop.
Files2
View on GitHubSKILL.mdskills/plan-cycle/SKILL.md
GitHubOn Codex, invoke skills with $skill-name (for example, $plan-create). Use that form when giving Codex
commands; other clients use /skill-name.
You are running the whole planning loop in one pass: research the codebase, draft the plan only when the user has not written one, critique it, merge the findings, repeat, then stop and wait for approval.
This skill never executes the plan. It ends at the approval gate.
Fixed rules:
Read the working agreement at working-agreement.md before step 1 and follow it for the whole run. If it cannot be found, tell the user it is missing and apply the rules listed below.
These rules bind this phase and override any step below that conflicts with them:
- Never execute the plan, and never write, edit or refactor project code during this run. This phase produces a
plan folder, a
plan.md, acritique.mdand acycle-log.mdand nothing else. The user approves before anything is built. - The user owns the plan. Draft
plan.mdonly when it is empty or still the unedited template. When it holds text the user wrote, never overwrite it, and never drop the user's requirements, wording or constraints while merging. - Never assume, ask. Change
plan.mdon your own only when the change a finding asks for is obvious. Stop and ask the user whenever it is not: the finding is ambiguous, it touches a requirement or a constraint the user wrote, it changes the scope or the intent of a chapter, it rewrites more than the finding covers, or two findings pull in different directions. Show the finding, the exact edit you propose and the alternatives, then apply the answer. A doubt is a question, never a guess. - Be adversarial in every iteration. Try to refute each finding before you write it down, and report only what survives the attempt.
- Grade confidence per finding. Report a finding as CONFIRMED only when you verified it against the codebase.
Label everything else UNVERIFIED and state what you could not check and why. Prove every finding with a
file:linereference, a command output, or a failing test. - Re-read
plan.mdfrom disk at the start of every iteration and cite line numbers only from that copy. Merging shifts every line below the merge point, so numbers carried over from an earlier iteration are wrong. - Verify what you merge, not only what you find. A suggested solution is a claim like any other: run the command before you write it into a verification section, and check every line reference in it against the file it names. An unverified fix is not merged, it is asked about. A merge that ships a broken command costs the next iteration. Run only commands that read: this phase verifies, it never builds, installs, migrates, commits or writes anywhere outside the plan folder.
- Merging is automatic for the obvious changes only, and never silent. Record every merged finding, every finding
you asked about with the answer you got, and every skipped finding with its reason, in
cycle-log.md, and print the same summary after each iteration. - Stop early only when clean: before any finding is merged across the active convergence chain (since the last
converged
## Summaryor log start), stop on the first clean iteration; once at least one finding has been merged, require two consecutive clean iterations before stopping early. Partition surfaced findings before checking cleanliness: any finding matching an earlierNot mergedentry with unchanged non-plan.mdevidence (or a repeatsplit recommendation, left for the user) isPreviously decided, is not re-asked, and does not resetcleanPasses. An iteration is clean when it has0new (non-Previously decided)CONFIRMEDorUNVERIFIEDfindings; any new finding (merged, asked, or skipped) resetscleanPassesto0. Respond "No new findings." and go to the approval gate. - Be brief. No filler, no preamble, no restating the request. No emojis, no em dashes, no bold or italic text.
To do this, follow these steps precisely:
- Display the following banner before doing anything else:
+-------------------------------------------------+ | Plan Critique v3.0.1 - Plan cycle | +-------------------------------------------------+ - Resolve
plansFolderfrom config:- Check the active agent's config file first (
.codex/plan-critique-config.jsonfor Codex,.claude/plan-critique-config.jsonfor Claude Code,.gemini/plan-critique-config.jsonfor Agy/Gemini, or.copilot/plan-critique-config.jsonfor Copilot CLI), falling back to the other agent configs. - If no config exists or
plansFolderis not set or is an empty string:- Ask the user: "Where would you like to store your plans? Provide a folder path (default
.planning):". By default, the user should be presented with the option.planning. - Save
plansFolderin the active agent's config file. - Create the folder if it doesn't exist, and create an
archived/subfolder inside it.
- Ask the user: "Where would you like to store your plans? Provide a folder path (default
- Check the active agent's config file first (
- Read the optional
cycleIterationsvalue from the resolved config file. It is the maximum number of critique and merge iterations for this run. Default to3when missing, and clamp any value outside the range 1 to 5. - Get the active session id:
- On Copilot CLI (or when
COPILOT_AGENT_SESSION_IDis set): readCOPILOT_AGENT_SESSION_IDviaecho $COPILOT_AGENT_SESSION_ID(macOS/Linux) or$env:COPILOT_AGENT_SESSION_ID(Windows); if empty, use the literal valuedefault. Store assessionId. - Otherwise (Codex, Claude Code / Agy): run
echo $PPIDand store assessionId.
- On Copilot CLI (or when
- Clean up stale sessions in
[plansFolder]/.sessions/(non-blocking, never abort because of cleanup):- For numeric PID filenames, check
kill -0 [PID] 2>/dev/nulland delete if the process is no longer running. - For non-PID session files (e.g.
defaultor UUIDs), delete files not modified in the last 7 days.
- For numeric PID filenames, check
- Read the current session's plan from
[plansFolder]/.sessions/[sessionId]if it exists. Store assessionPlan. - Scan
[plansFolder]/for subdirectories (each subdirectory is a plan). Excludearchived/and.sessions/folders and any files, only list plan directories. - Select the plan for this cycle:
- If
$ARGUMENTSor the invoking prompt text is a slug that matches an existing plan folder, select that plan. - Else if
$ARGUMENTSor the invoking prompt text is not empty, treat it as the name of a new plan and create it by following the plan naming and folder creation steps of ../plan-create/SKILL.md: the slug rules, the name collision check, the folder creation and theplan.mdtemplate from plan-template.md. Do not display the create banner. - Else if
sessionPlanexists and matches a plan folder, auto-select it and inform the user: "Using current session plan: [sessionPlan]" - Else if exactly one plan exists, auto-select it and inform the user.
- Else if plans exist, ask the user to select one from the list, and offer creating a new plan as the last option.
- Else ask the user for a name for the new plan and create it as described above.
- If
- Update the session file
[plansFolder]/.sessions/[sessionId]with the selected plan slug (create if needed). - Read
[plansFolder]/[selected-plan]/plan.mdand classify it:- Empty, or still the unedited template from plan-template.md, which is recognised by the placeholder chapter heading and the bracketed placeholder lines: the plan needs a draft.
- Anything else: the user wrote it. Inform the user "Using the existing plan.md, no draft written." and go to step 13.
- Prepare the draft. Tell the user "plan.md is still the template. Drafting a first pass." and get the goal:
- Use
$ARGUMENTSor the invoking prompt text as the goal when it describes what to build. - Otherwise ask the user: "Describe what this plan must achieve:". Do not guess the goal.
- Use
- Research the codebase, then write the draft:
- Resolve project instructions from
AGENTS.mdfor Codex,GEMINI.mdfor Agy,.github/copilot-instructions.mdfor Copilot, orCLAUDE.mdfor Claude Code. Fall back toAGENTS.mdthenCLAUDE.md, and read the result alongsideREADME.mdand the files the goal touches. - List every file that the plan will create, modify or delete, and verify each path exists with Glob before writing it down. Show this list to the user before writing the plan.
- Ask the user whenever the research leaves a real choice open, such as which module owns the change or which of two approaches the plan should take. Do not pick one and write it down as if it were settled.
- Write
[plansFolder]/[selected-plan]/plan.mdusing plan-template.md: one numbered chapter per unit of work, in dependency order, each with its ownAffected filesandVerificationsections. Every chapter names the test to write or the command to run. - Where the project has no test infrastructure, say so in the chapter instead of inventing a test harness.
- Resolve project instructions from
- Check prerequisites once, before the loop:
- If
plan.mdis empty after step 12: respond with "Plan file is empty. Edit[plansFolder]/[selected-plan]/plan.md" and stop. - If no project instructions file exists (
AGENTS.md,CLAUDE.md,GEMINI.md, or.github/copilot-instructions.md): respond with "Create a project instructions file in the root of your project." and stop. - Detect the project languages and probe code intelligence as described in step 10 of ../plan-critique/SKILL.md. Record whether LSP / a language server is available, and reuse that answer for every iteration instead of probing again.
- If
- Run the cycle:
- Before iteration 1, initialize
hasMerged = falseandcleanPasses = 0from[plansFolder]/[selected-plan]/cycle-log.md:- If
cycle-log.mddoes not exist, or its last## Summaryfollows the final iteration entry and stopped withno new findingsortwo consecutive clean passes: keephasMerged = falseandcleanPasses = 0. - If the last
## Summarystopped withiteration limit reached, or if trailing iteration entries have no following## Summary(an interrupted run): scan back to the last converged## Summary(no new findingsortwo consecutive clean passes) or log start. SethasMerged = trueif any iteration in that segment modifiedplan.md(Merged > 0or anAskedentry whoseAnswer:starts withApplied:), and setcleanPassesto the trailing consecutive clean iteration count (0or1).
- If
- Open a
## Run [n]block in[plansFolder]/[selected-plan]/cycle-log.mdwithStarted: [YYYY-MM-DD HH:MM:SS]before iteration 1 of this run (creating# Plan Cycle Log: [Plan Title]andPlan drafted by:on Run 1, and incrementing[n]from the last## Runon resumed runs). - Repeat the following until you have run
cycleIterationsiterations or the stop condition below triggers:- Re-read
plan.mdfrom disk. - Critique it by following the fixed rules and the analysis steps of
../plan-critique/SKILL.md, including the split evaluation. Skip its config,
session and plan selection steps, which this run already did. Its rule against editing
plan.mdbinds the critique step only, because merging is a separate step below. - Write the critique to
[plansFolder]/[selected-plan]/critique.mdusing critique-format.md, with the iteration number incremented from the previous critique. - Partition surfaced findings before the clean check:
- Compare each surfaced finding against earlier
Not mergedentries incycle-log.mdusing chapter title plus finding target/summary as the match key (ignoring shiftingplan.mdline numbers when checking whether non-plan.mdevidence is unchanged). Also match any repeatsplit recommendation, left for the useralready logged underNot merged. - Classify matched unchanged repeats as
Previously decided: do not re-ask them, do not re-count them inNot mergedorOpen items, and log them underPreviously decidedinstead.
- Compare each surfaced finding against earlier
- Evaluate the remaining new findings (
CONFIRMEDandUNVERIFIED):- If clean (
0newCONFIRMEDand0newUNVERIFIEDfindings):- If
hasMergedistrue, incrementcleanPassesby 1. - Skip the merge step below.
- If
- If not clean (one or more new
CONFIRMEDorUNVERIFIEDfindings, whether merged, asked, or skipped):- Reset
cleanPasses = 0and merge the new findings intoplan.md:- Oscillation check (before merging any finding): inspect
[plansFolder]/[selected-plan]/cycle-log.mdfor all changes recorded as merged anywhere in the selected plan's log across all runs (bothMergedentries andAskedentries whoseAnswer:starts withApplied:), not only in the immediately preceding iteration. When anAskedentry withAnswer: Applied:explicitly approved reversing an earlier merge, that decision supersedes the earlier entry so subsequent checks compare against the latest decision rather than re-flagging the old merge. If applying a finding would undo, revert, or contradict an active earlier decision, do not auto-merge it. Surface it to the user instead per fixed rule 3, showing the earlier change, the new finding, and the options. Record the surfaced finding underAsked, and if declined or left unapplied also record it underNot mergedwithReason: reverses an earlier merge, asked. - Apply a CONFIRMED finding to the chapter it belongs to when it passes the oscillation check and the edit it asks for is obvious.
- Ask the user before making any change that is not obvious, and apply the answer. This covers an ambiguous finding, a finding that touches a requirement or a constraint the user wrote, a finding that changes the scope or the intent of a chapter, two findings that pull in different directions, and any finding flagged by the oscillation check. Show the finding, the exact edit you propose and the alternatives. Ask once per change, and group the questions of one iteration together so the loop stops as little as possible.
- Apply an UNVERIFIED finding only when it passes the oscillation check, clarifies the plan and cannot lose information. Ask about it otherwise.
- Skip any finding whose evidence is missing.
- Record
Answer:inAskedentries starting withApplied:orDeclined:, and includeEvidence:on everyNot mergedentry (file:line, command output, or"missing"). - Verify each edit before you write it. Run any command the finding puts into a
Verificationsection and confirm it passes on the current tree and can fail, and check every path and line number the edit introduces. Do not carry a line range or an index from the critique into the plan when the chapter will change the lines it points at: anchor to a heading, a fence or a symbol instead. When the edit does not survive this check, ask the user rather than merging it. - Keep the
Affected filesandVerificationsections in every chapter. - When the critique recommends splitting the plan, do not split it. Record the recommendation under
Not mergedwithReason: split recommendation, left for the useras an open item for the approval gate. - If at least one edit was written to
plan.mdin this iteration (auto-merged or applied from the user's answer), sethasMerged = true.
- Oscillation check (before merging any finding): inspect
- Reset
- If clean (
- Append an entry to
[plansFolder]/[selected-plan]/cycle-log.mdusing cycle-log-format.md, and print the same merged and skipped summary to the user. - Check the stop condition:
- If the iteration was clean and (
hasMergedisfalseorcleanPasses >= 2): record exit reason (no new findingswhenhasMergedisfalse, ortwo consecutive clean passeswhencleanPasses >= 2, taking precedence overiteration limit reachedif on the final iteration), respond with "No new findings." and leave the loop. - If the iteration was clean and
hasMergedistrueandcleanPassesis 1: inform the user that one clean pass is complete and one more consecutive clean pass is needed, then continue ifcycleIterationsallows (otherwise recorditeration limit reached).
- If the iteration was clean and (
- Re-read
- Write
## Summaryat the end of the current## Run [n]block on loop exit, usingStopped because(no new findings,two consecutive clean passes, oriteration limit reached), current-runIterations runandQuestions asked, andOpen itemscounting deduplicatedNot mergedentries across all unfinished or active runs.
- Before iteration 1, initialize
- Print the final
plan.mdin full, followed by the open items: every deduplicated skipped finding and split recommendation recorded underNot mergedacross all unfinished or active runs. - Stop at the approval gate and respond (with
[N],Merged,Asked about, andNot mergedscoped to the current run):Cycle complete after [N] iteration(s): [plansFolder]/[selected-plan]/plan.md Merged: [X] findings. Asked about: [Z]. Not merged: [Y], listed in cycle-log.md. Nothing has been executed and no project code was changed. Review the plan. When you approve it, run `/plan-execute`.
Notes:
- Never execute the plan from this skill, not even when the user approves it in the same session. Point the user
at
/plan-execute, which carries its own rules, its own confirmation and its own execution log. - Each iteration is a full adversarial pass over the plan and the codebase, so a three iteration run on a large
plan is expensive. After a merge in a run, two consecutive clean iterations are needed, so a run merging in
iteration 1 stops at iteration 3 at the earliest (
cycleIterationsof 1 or 2 hits the iteration limit unless a prior run leftcleanPasses = 1, and 4 or 5 is needed to stop before the cap). SetcycleIterationsto 1 or 2 in your config file for small plans. - If the active agent ignores
modelfrontmatter, select a high-capability model with/model. - The cycle is resumable. Run it again on the same plan and it continues from the current
plan.mdand from the iteration number recorded incritique.md. critique.mdholds the latest iteration only, because each critique overwrites it.cycle-log.mdholds the history of what was merged and what was skipped.- The plan folder, the session file and the config file are the same ones used by
/plan-create,/plan-critique,/plan-executeand/plan-archive. The cycle is a shortcut through the first two, not a separate workflow.