17 KiB
Plan Handoff
This file contains post-plan-writing instructions: document review, post-generation options, and issue creation. Load it after the plan file has been written and the confidence check (5.3.1-5.3.7) is complete.
5.3.8 Document Review
Format gate. This phase runs only when OUTPUT_FORMAT=md (resolved in SKILL.md Phase 0.0). ce-doc-review's mutation mechanics are markdown-specific — its walkthrough applies gated_auto/manual fixes as "single-file markdown changes" via the platform's edit tool, and its Append-to-Open-Questions flow inserts ##/### markdown headings (see references/walkthrough.md and references/open-questions-defer.md in the ce-doc-review skill). Running those mutators against an HTML artifact would produce malformed output. Until ce-doc-review gains HTML-aware mutation, HTML plans skip this phase entirely.
When OUTPUT_FORMAT=html: Skip the ce-doc-review invocation. Capture a synthetic "skipped" envelope so the menu summary line in 5.4 can name the limitation explicitly:
fixes_applied = 0proposed_fixes_count = 0,decisions_count = 0,fyi_count = 0skipped_reason = "output_format_html"
Then proceed directly to Final Checks (5.3.9). Do not block on this — the confidence check at 5.3 already strengthened the plan. Free-form requests for review in the post-generation menu will be declined for HTML runs with a prompt to switch to output:md (see 5.4); review is not available for HTML plans until ce-doc-review gains HTML-aware mutation.
When OUTPUT_FORMAT=md: Run the ce-doc-review skill with mode:headless on the plan file. Pass mode:headless <plan-path> as the skill arguments. When this step is reached for a markdown plan, it is mandatory — do not skip it because the confidence check already ran. The two tools catch different classes of issues.
Headless is the default at this phase because most users want to start work after planning, not adjudicate every reviewer concern up front. Headless applies safe_auto fixes silently and returns structured findings text — no walkthrough, no per-finding routing, no blocking prompts. The post-generation menu (see 5.4) offers Run deeper doc review as a first-class option so users can opt into the full interactive walkthrough when they want it.
The confidence check and ce-doc-review are complementary:
- The confidence check strengthens rationale, sequencing, risk treatment, and grounding
- Document-review checks coherence, feasibility, scope alignment, and surfaces role-specific issues
Capture the headless envelope so it can drive the contextual summary above the post-generation menu:
- The number of fixes auto-applied
- The count of remaining findings, broken out by user-facing bucket (proposed fixes, decisions, FYI observations)
- The severity breakdown of decisions and proposed fixes (specifically the P0/P1 count, since those benefit from explicit user attention)
When ce-doc-review returns "Review complete", proceed to Final Checks.
Pipeline mode: Pipeline runs (LFG or any disable-model-invocation context) force OUTPUT_FORMAT=md at Phase 0.0, so the format gate above never selects the HTML skip path in pipeline mode. Pipeline runs always invoke ce-doc-review with mode:headless and the plan path — the headless mode is identical to the interactive default at this phase. No further routing is offered in pipeline mode; the caller decides what to do with the returned findings. Address any P0/P1 findings before returning control to the caller.
5.3.9 Final Checks and Cleanup
Before proceeding to post-generation options:
- Confirm the plan is stronger in specific ways, not merely longer
- Confirm the planning boundary is intact
- Confirm origin decisions were preserved when an origin document exists
If artifact-backed mode was used:
- Clean up the temporary scratch directory after the plan is safely updated
- If cleanup is not practical on the current platform, note where the artifacts were left
Format-specific composition. When OUTPUT_FORMAT=html (resolved in SKILL.md Phase 0.0), the plan is written as a single self-contained .html file — there is no markdown sibling. Read references/html-rendering.md for composition rules: invariants, precedence stack, format principles, agent-consumability rules, and the post-compose audit. The .html file is the artifact downstream consumers (ce-work, human readers) read. ce-doc-review is not a current HTML consumer — its mutation mechanics are markdown-only today, and HTML plans skip the 5.3.8 doc-review pass until that gap closes.
When OUTPUT_FORMAT=md, write the markdown directly per references/markdown-rendering.md. No HTML is composed.
After all mutations in this run have settled (initial write, deepening synthesis, ce-doc-review safe_auto fixes when OUTPUT_FORMAT=md, HITL Proof resync if any), the artifact at its single path reflects the final state. HTML runs skip the ce-doc-review autofix step (see 5.3.8 format gate).
5.4 Post-Generation Options
Pipeline mode: If invoked from an automated workflow such as LFG or any disable-model-invocation context, skip the interactive menu below and return control to the caller immediately. The plan file has already been written, the confidence check has already run, and ce-doc-review has already run — the caller (e.g., lfg) determines the next step.
Path format: Use absolute paths for chat-output file references — relative paths are not auto-linked as clickable in most terminals.
Summary line above the menu (always): Print a single concise line summarizing the headless review state — e.g., Doc review applied 3 fixes. 2 decisions, 1 proposed fix, 4 FYI observations remain (1 at P1). When no fixes were applied and no findings remain, print Doc review clean — no fixes needed. When the envelope carries skipped_reason: output_format_html (HTML run, per Phase 5.3.8 format gate), print Doc review skipped — ce-doc-review is markdown-only today; the HTML plan was not reviewed. so the user knows the autofix pass did not run on this artifact. This line establishes what the autofix pass did (or didn't) so the user has the context to choose between the menu options below.
Question: "Plan ready at <absolute path to plan>. What would you like to do next?"
Options:
- Start
/ce-work(recommended) - Begin implementing this plan in the current session - Run deeper doc review - Walk through the remaining findings interactively (full ce-doc-review walkthrough)
- Create Issue - Create a tracked issue from this plan in your configured issue tracker (GitHub or Linear)
- Open in Proof (web app) — review and comment to iterate with the agent - Open the doc in Every's Proof editor, iterate with the agent via comments, or copy a link to share with others. Render only when
OUTPUT_FORMAT=md. - Open in browser - Open the HTML plan file locally for review and sharing. Render only when
OUTPUT_FORMAT=html. - Done for now - Pause; the plan file is saved and can be resumed later
Option 4 format-keyed label. Under exclusive output mode, the plan exists as exactly one artifact — .md or .html, never both. Render the option 4 label matching the produced format. Proof operates on markdown plans (it ingests the .md source and rewrites markdown), so it does not apply to HTML runs; the browser option opens the local .html file directly. /ce-work remains the recommended option in both modes — ce-work reads either format (see the ce-work skill's plan-input handling).
Menu rendering: The menu has 5 options, which exceeds the AskUserQuestion 4-option cap. Per the AGENTS.md narrow exception for legitimate option overflow, render this menu as a numbered list in chat with the hint "Pick a number or describe what you want." rather than trimming to fit the cap. Each option is a distinct destination/workflow and none are removable without losing real user choice (deeper review, issue creation, Proof, ce-work, and pause are each separately requested in practice). On platforms where blocking question tools have no option cap (e.g., Codex request_user_input, Pi ask_user), use the platform's blocking tool with all 5 options. When the platform's blocking tool is unavailable or errors (e.g., Codex edit modes where request_user_input is not exposed, or ask_user returns no match), fall back to the same numbered-list-in-chat rendering with the "Pick a number or describe what you want." hint — the same fallback the AskUserQuestion overflow path uses. Never silently skip the question.
Hide Run deeper doc review when no actionable findings remain or doc review was skipped. Show option 2 only when the headless envelope reports proposed_fixes_count + decisions_count > 0 — i.e., at least one gated_auto or manual finding at confidence anchor 75 or 100. Drop the option in any other case, including FYI-only state. FYI observations (anchor 50) do not enter ce-doc-review's interactive routing question or walkthrough — that flow is gated to actionable findings — so a Run deeper doc review option that only has FYIs to show is a dead-end: ce-doc-review would re-dispatch the persona team, find the same FYIs, skip the routing question, and fall through to the terminal question with nothing to walk through. The user paid the dispatch cost for no engagement surface. Also drop option 2 when the envelope carries skipped_reason: output_format_html — ce-doc-review's mutation mechanics are markdown-only today (see Phase 5.3.8 format gate), so a Run deeper doc review option on an HTML plan would route into the same markdown-oriented walkthrough the gate exists to prevent. When option 2 is dropped, the menu becomes 4 options (1, 3, 4, 5 above), falls back to AskUserQuestion on Claude Code, and renumbers 1-4 in display so users see a clean sequence. The summary line above the menu still names the FYI count when present (Doc review applied 3 fixes. 2 FYI observations remain.) so the user sees what was found, even though there is no menu action attached to it — the FYIs are visible in the headless envelope text the menu rendered alongside.
Based on selection (the bare per-option routing is also stated inline in the SKILL.md so it cannot be missed when this reference is not loaded; the elaborate sub-flows below are the reason this reference still exists):
-
Start
/ce-work-> Invoke thece-workskill via the platform's skill-invocation primitive (Skillin Claude Code,Skillin Codex, the equivalent on Gemini/Pi), passing the plan path as the skill argument. Do not merely tell the user to type/ce-work— fire the invocation now so the plan executes in this session. -
Run deeper doc review -> Re-invoke the
ce-doc-reviewskill on the plan path withoutmode:headlessso the interactive routing question and walkthrough fire. The headless pass already appliedsafe_autofixes and recorded its findings in the session, so the interactive pass picks up where headless stopped — its R29 suppression rule prevents prior-round Skipped/Deferred entries from re-raising. After it returns, re-render this menu with the refreshed counts so the user can pick what to do next. -
Create Issue -> Follow the Issue Creation section below
-
Open in Proof (web app) — review and comment to iterate with the agent -> Load the
ce-proofskill in HITL-review mode with:- source file:
docs/plans/<plan_filename>.md - doc title:
Plan: <plan title from frontmatter> - identity:
ai:compound-engineering/Compound Engineering - recommended next step:
/ce-work(shown in the ce-proof skill's final terminal output)
Follow
references/hitl-review.mdin the ce-proof skill. It uploads the plan, prompts the user for review in Proof's web UI, ingests filtered comment threads, applies agreed edits through the current Proof edit APIs, replies/resolves in-thread, and syncs the final markdown back to the plan file atomically on proceed.Note: the Proof flow only runs when
OUTPUT_FORMAT=md(the menu only renders this option then). Proof ingests markdown; HTML plans use the local browser option instead.When the ce-proof skill returns:
status: proceededwithlocalSynced: true-> the plan on disk now reflects the review. Re-runce-doc-reviewon the updated plan before re-rendering the menu — HITL can materially rewrite the plan body, so the prior ce-doc-review pass no longer covers the current file and section 5.3.8 requires a review before any handoff option is offered. Then return to the post-generation options with the refreshed residual findings.status: proceededwithlocalSynced: false-> the reviewed version lives in Proof atdocUrlbut the local copy is stale. Offer to pull the Proof doc tolocalPathusing the ce-proof skill's Pull workflow. If the pull happened, re-runce-doc-reviewon the pulled file before re-rendering the options (same 5.3.8 rationale — the local plan was materially updated by the pull). If the pull was declined, include a one-line note above the menu that<localPath>is stale vs. Proof — otherwiseStart /ce-workorCreate Issuewill silently use the pre-review copy.status: done_for_now-> the plan on disk may be stale if the user edited in Proof before leaving. Offer to pull the Proof doc tolocalPathso the local plan file stays in sync. If the pull happened, re-runce-doc-reviewon the pulled file before re-rendering the options (same 5.3.8 rationale). If the pull was declined, include the stale-local note above the menu.done_for_nowmeans the user stopped the HITL loop — it does not mean they ended the whole plan session; they may still want to start work or create an issue.status: aborted-> fall back to the options without changes.
If the initial upload fails (network error, Proof API down), retry once after a short wait. If it still fails, tell the user the upload didn't succeed and briefly explain why, then return to the options — don't leave them wondering why the option did nothing.
- source file:
-
Open in browser -> Display the absolute path to the
.htmlplan file so the user can open it locally. Where the platform exposes a browser-opening primitive (e.g.,openon macOS,xdg-openon Linux,starton Windows), the agent may invoke it directly; otherwise print the absolute path and let the user open it. After the path is displayed (or the browser is opened), return to the post-generation options so the user can pick a follow-up action. -
Done for now -> Display a brief confirmation that the plan file is saved and end the turn. Do not start follow-up work without an explicit further user prompt.
-
Free-form prompts that target the findings (e.g., the user types "review", "walk through", "deep review" instead of picking a numbered option) -> route as if they had picked
Run deeper doc review. Do not loop back to the menu without firing the deeper review. Exception: when the envelope carriesskipped_reason: output_format_html, do not fire ce-doc-review — instead, reply once withce-doc-review is markdown-only today; the HTML plan can't be reviewed without HTML-aware mutation support. Switch to /ce-plan output:md to regenerate as markdown if you want a review pass.and loop back to the menu. -
Other free-form input -> Accept revisions to the plan and loop back to options.
Issue Creation
When the user selects "Create Issue", detect their project tracker:
-
Read
AGENTS.md(orCLAUDE.mdfor compatibility) at the repo root and look forproject_tracker: githuborproject_tracker: linear. -
If
project_tracker: github:gh issue create --title "<type>: <title>" --body-file <plan_path> -
If
project_tracker: linear:linear issue create --title "<title>" --description "$(cat <plan_path>)" -
If no tracker is configured, ask the user which tracker they use with the platform's blocking question tool:
AskUserQuestionin Claude Code (callToolSearchwithselect:AskUserQuestionfirst if its schema isn't loaded),request_user_inputin Codex,ask_userin Gemini,ask_userin Pi (requires thepi-ask-userextension). Fall back to asking in chat only when no blocking tool exists or the call errors (e.g., Codex edit modes) — not because a schema load is required. Never silently skip. Options:GitHub,Linear,Skip. Then:- Proceed with the chosen tracker's command above
- Offer to persist the choice by adding
project_tracker: <value>toAGENTS.md, where<value>is the lowercase tracker key (githuborlinear) — not the display label — so future runs match the detector in step 1 and skip this prompt - If
Skip, return to the options without creating an issue
-
If the detected tracker's CLI is not installed or not authenticated, surface a clear error (e.g., "
ghCLI not found — install it or create the issue manually") and return to the options.
After issue creation:
- Display the issue URL
- Ask whether to proceed to
/ce-workusing the platform's blocking question tool