Skip to content

Commit eec73c4

Browse files
authored
Merge pull request #159 from zevorn/codex/gen-plan-learning-mode
[codex] add coach mode to gen-plan
2 parents e045999 + 63a7701 commit eec73c4

6 files changed

Lines changed: 239 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Requires [codex CLI](https://github.com/openai/codex) for review. See the full [
5757
```bash
5858
/humanize:gen-plan --input .humanize/explore/<run-id>/final-idea.md --output docs/plan.md
5959
```
60+
Add `--coach` to run mandatory short-answer stage quizzes after each planning stage. Normal plan decision questions stay separate; quiz mismatches are treated as design drift, AI design correction, or background gaps before the agent expands the next planning layer.
6061

6162
4. **Refine an annotated plan** before implementation when reviewers add comments (`CMT:` ... `ENDCMT`, `<cmt>` ... `</cmt>`, or `<comment>` ... `</comment>`):
6263
```bash

commands/gen-plan.md

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: "Generate implementation plan from draft document"
3-
argument-hint: "--input <path/to/draft.md> --output <path/to/plan.md> [--auto-start-rlcr-if-converged] [--discussion|--direct]"
3+
argument-hint: "--input <path/to/draft.md> --output <path/to/plan.md> [--auto-start-rlcr-if-converged] [--discussion|--direct] [--coach]"
44
allowed-tools:
55
- "Bash(${CLAUDE_PLUGIN_ROOT}/scripts/validate-gen-plan-io.sh:*)"
66
- "Bash(${CLAUDE_PLUGIN_ROOT}/scripts/ask-codex.sh:*)"
@@ -33,7 +33,7 @@ This command transforms a user's draft document into a well-structured implement
3333

3434
> **Sequential Execution Constraint**: All phases below MUST execute strictly in order. Do NOT parallelize tool calls across different phases. Each phase must fully complete before the next one begins.
3535
36-
1. **Execution Mode Setup**: Parse optional behaviors from command arguments
36+
1. **Execution Mode Setup**: Parse optional behaviors from command arguments, including coach mode
3737
2. **Load Project Config**: Resolve merged Humanize config defaults for `alternative_plan_language` and `gen_plan_mode`
3838
3. **IO Validation**: Validate input and output paths
3939
4. **Relevance Check**: Verify draft is relevant to the repository
@@ -44,6 +44,8 @@ This command transforms a user's draft document into a well-structured implement
4444
9. **Final Plan Generation**: Generate the converged structured plan.md with task routing tags
4545
10. **Write and Complete**: Write output file, optionally write translated language variant, optionally auto-start implementation, and report results
4646

47+
When `--coach` is enabled, run mandatory stage quizzes after each completed planning stage. Normal human decision questions still happen when the plan needs a user choice, but those decision questions do not count as coach quizzes. Coach quizzes are inserted during plan generation, not deferred to a final review, and test whether the human's understanding is aligned with the agent's current plan.
48+
4749
---
4850

4951
## Phase 0: Execution Mode Setup
@@ -53,10 +55,80 @@ Parse `$ARGUMENTS` and set:
5355
- `AUTO_START_RLCR_IF_CONVERGED=false` otherwise
5456
- `GEN_PLAN_MODE_DISCUSSION=true` if `--discussion` is present
5557
- `GEN_PLAN_MODE_DIRECT=true` if `--direct` is present
58+
- `COACH_MODE=true` if `--coach` is present
59+
- `COACH_MODE=false` otherwise
5660
- If both `--discussion` and `--direct` are present simultaneously, report error "Cannot use --discussion and --direct together" and stop
5761

5862
`AUTO_START_RLCR_IF_CONVERGED=true` allows skipping manual plan review and starting implementation immediately (by invoking `/humanize:start-rlcr-loop <output-plan-path>`), but only when `GEN_PLAN_MODE=discussion`, plan convergence is achieved, and no pending user decisions remain. In `direct` mode this condition is never satisfied.
5963

64+
Initialize coach-mode state:
65+
- `COACH_CHECK_STATUS=not_enabled` when `COACH_MODE=false`
66+
- `COACH_CHECK_STATUS=pending` when `COACH_MODE=true`
67+
- `COACH_CHECK_COUNT=0`
68+
- `COACH_CHECK_SUMMARY=""`
69+
- `COACH_MAINLINE_LEDGER=[]`
70+
71+
### Coach Mode Protocol
72+
73+
When `COACH_MODE=true`, insert a mandatory stage quiz after each completed planning stage and before expanding from one planning layer to the next. Each quiz gate MUST use AskUserQuestion and MUST include:
74+
75+
1. **Stage explanation**: 3-5 concise bullets explaining what was completed, what plan state now exists, and why it matters.
76+
2. **Decision separation**: ask normal plan decision questions separately from coach quizzes. Decision questions resolve product/design choices and may use options; they do not satisfy the stage quiz requirement.
77+
3. **Stage quiz**: ask at least one short-answer or free-form quiz question that the human must answer in their own words. Do not use multiple-choice, yes/no, or "continue" confirmation as the quiz, unless the interface has no free-form input path; if forced to use choices, ask the human to type the reasoning before continuing.
78+
4. **Coach question ladder**: choose quiz questions only from these categories, in this order when more than one category applies:
79+
- **Memory**: ask the user to restate or identify a design decision from their own draft or prior clarification. This checks whether the user remembers what they already designed; do not challenge correctness in this category.
80+
- **Self-check**: ask the user to inspect the candidate plan/design and confirm whether it matches their intent, constraints, risks, and acceptance criteria. This checks whether the design direction is correct or needs revision.
81+
- **Education**: explain background knowledge, repository context, or technical tradeoffs that may be obvious to the agent but not to the user, then ask whether the explanation is understood before relying on it.
82+
5. **Grading and remediation**: grade the answer against the stage's current plan state, explain any mismatch, and remediate according to the category-specific standards below.
83+
6. **Confirmation**: continue only after the quiz answer is aligned, or after remediation/revision resolves the mismatch.
84+
85+
Do NOT continue to the next planning layer until the stage quiz has been answered and graded. If the user asks a follow-up question, answer it directly, inspect the repository when codebase facts matter, update the explanation if needed, and then ask a new stage quiz on the same mainline point. If the user challenges the direction, update the candidate plan state, rerun the relevant analysis, and repeat the quiz gate for the revised stage.
86+
87+
If confirmation cannot be obtained, set `COACH_CHECK_STATUS=blocked`, write the unresolved decision or comprehension blocker into `## Pending User Decisions`, report the blocker, and stop instead of producing a deeper plan.
88+
89+
### Coach Answer Interpretation Standards
90+
91+
Incorrect, surprising, or non-confirming answers are first-class gen-plan quality signals. Interpret them by category:
92+
93+
- **Memory mismatch**: treat this as possible design intent drift, not as a simple recall failure. Pause expansion, ask whether the original draft decision has changed or should remain authoritative, update the candidate plan source of truth or `## Pending User Decisions`, and rerun the affected analysis before proceeding.
94+
- **Self-check rejection**: treat this as evidence that the AI candidate plan/design is wrong, incomplete, or misaligned with the user's intent. Revise the candidate plan, record the correction, and rerun the relevant analysis or convergence step before asking for confirmation again.
95+
- **Education gap**: treat this as a prerequisite background/context gap. Provide a concise explanation tied to the repository or technical tradeoff, ask for explicit confirmation, and do not rely on that concept in deeper plan content until it is understood. If the gap remains unresolved, set `COACH_CHECK_STATUS=blocked`, record it as a blocker, and do not auto-start implementation.
96+
97+
The plan is not coach-confirmed until each triggered category has been handled according to its standard. Do not collapse these signals into a generic wrong answer.
98+
99+
### Coach Questioning Style
100+
101+
- Ask one quiz question at a time.
102+
- Use the Memory -> Self-check -> Education order when a checkpoint needs multiple quiz questions. Skip categories that do not apply; never invent busywork to fill all three.
103+
- Walk the plan's decision tree in dependency order. Resolve prerequisite understanding before downstream implementation details.
104+
- Provide the expected answer and concise rationale only after the user answers or asks for help, so the exchange remains a real quiz rather than a disguised explanation.
105+
- If a question can be answered by inspecting the repository, inspect the repository instead of asking the user. Ask the human only about comprehension, judgment, priority, or unresolved tradeoffs.
106+
- Do not use rapid Q&A. Do not substitute multiple-choice, yes/no, or "continue" prompts for the mandatory stage quiz. Avoid trivia; every quiz must test alignment with the current plan's goal, risks, approach, scope, acceptance criteria, dependencies, or task sequence.
107+
108+
### Coach Ledger
109+
110+
Maintain `COACH_MAINLINE_LEDGER` as the plan develops. Each entry should capture a mainline topic, the checkpoint where it was introduced, its question category (`Memory`, `Self-check`, or `Education`), its outcome (`confirmed`, `design_intent_drift`, `ai_design_correction`, `background_gap`, or `blocked`), its dependencies, the user's decision or confirmation, and whether it is confirmed or blocked.
111+
112+
During later checkpoints, reference earlier ledger entries only when current plan content depends on them, and connect those prior decisions to the current mainline logic. Do not add unrelated historical checks just to increase difficulty.
113+
114+
### Overall Human Acceptance
115+
116+
Checkpoint D MUST perform overall human acceptance for the full plan logic before Phase 7 writes the final plan:
117+
118+
- Summarize the plan's mainline from goal to implementation sequence.
119+
- Summarize what the user has already confirmed and any topics that required explanation or revision.
120+
- Ask whether the user understands and accepts the overall plan direction, not merely whether the last checkpoint is complete.
121+
- If the user asks follow-up questions during this acceptance, answer them and repeat the acceptance confirmation before proceeding.
122+
123+
Run these checkpoints:
124+
125+
- **Checkpoint A - First-pass analysis**: After Phase 3 and before Phase 4, explain Codex Analysis v1, then quiz the user on the highest-risk assumption and whether any `QUESTIONS_FOR_USER` item blocks candidate planning.
126+
- **Checkpoint B - Candidate plan**: After Phase 4 and before Phase 5 (or before Phase 6 in direct mode), explain the proposed scope, path boundaries, dependencies, and risks, then quiz the user on the main implementation mechanism or affected components.
127+
- **Checkpoint C - Convergence rounds**: After each Phase 5 convergence round and before running another round or declaring convergence, explain material changes, resolved disagreements, and remaining disagreements, then quiz the user on the delta and whether any item should be reopened.
128+
- **Checkpoint D - Finalization gate**: After Phase 6 and before Phase 7, summarize the final plan direction, unresolved decisions, and acceptance-criteria shape. Perform a final stage quiz on the plan's mainline and ask for overall human acceptance before writing the plan.
129+
130+
After each passed checkpoint, increment `COACH_CHECK_COUNT`, update `COACH_MAINLINE_LEDGER`, and append concise checkpoint notes to `COACH_CHECK_SUMMARY` for Phase 8 reporting. When all required checkpoints have passed, set `COACH_CHECK_STATUS=passed`. When `COACH_MODE=false`, skip this protocol completely.
131+
60132
---
61133

62134
## Phase 0.5: Load Project Config
@@ -211,6 +283,8 @@ If `ask-codex.sh` fails (missing Codex CLI, timeout, or runtime error), use AskU
211283
- Retry with updated Codex settings/environment
212284
- Continue with Claude-only planning (explicitly note reduced cross-review confidence in plan output)
213285

286+
If `COACH_MODE=true`, run Checkpoint A before entering Phase 4.
287+
214288
---
215289

216290
## Phase 4: Claude Candidate Plan (v1)
@@ -250,6 +324,8 @@ Use the Task tool with `subagent_type: "Explore"` to investigate:
250324
- Existing patterns and conventions
251325
- Dependencies and integrations
252326

327+
If `COACH_MODE=true`, run Checkpoint B before entering Phase 5. In direct mode, run Checkpoint B before entering Phase 6.
328+
253329
---
254330

255331
## Phase 5: Iterative Convergence Loop (Claude <-> Second Codex)
@@ -288,6 +364,7 @@ After Claude candidate plan v1 is ready, run iterative challenge/refine rounds w
288364
- Resolution status (`resolved` or `needs_user_decision`)
289365
- Round-to-round delta
290366
- Do NOT use `deferred` as a convergence status. If the selected resolution defers work, it is `resolved` only after the candidate plan records a `DEC-*` decision with a non-`PENDING` `Decision Status`, links that decision to a `FUT-*` item under `## Future Work / Out of Scope`, and ensures the deferred work is not represented as a current-scope AC/task. If that DEC/FUT linkage is missing or the decision needs human input, mark the topic `needs_user_decision`.
367+
- If `COACH_MODE=true`, run Checkpoint C before starting another convergence round or declaring convergence
291368
292369
### Loop Termination Rules
293370
@@ -316,7 +393,7 @@ Decide if manual review can be skipped:
316393
- Else if `AUTO_START_RLCR_IF_CONVERGED=true` **and** `PLAN_CONVERGENCE_STATUS=converged`, set `HUMAN_REVIEW_REQUIRED=false`
317394
- Otherwise set `HUMAN_REVIEW_REQUIRED=true`
318395
319-
Do not skip Step 1.5. If `HUMAN_REVIEW_REQUIRED=false`, run Step 1.5 first, then skip Step 2-4 and continue directly to Phase 7.
396+
Do not skip Step 1.5. If `HUMAN_REVIEW_REQUIRED=false`, run Step 1.5 first, then skip Step 2-4. Then run Checkpoint D if `COACH_MODE=true`; otherwise continue directly to Phase 7.
320397
321398
### Step 1.5: Consolidate Pending User Decisions (runs unconditionally)
322399
@@ -376,6 +453,8 @@ For each unresolved disagreement, present:
376453

377454
If the user does not decide immediately, keep the item in the plan as `PENDING` under a dedicated user-decision section.
378455

456+
If `COACH_MODE=true`, run Checkpoint D after all required issue and disagreement handling is complete. Do not enter Phase 7 until `COACH_CHECK_STATUS=passed`.
457+
379458
---
380459

381460
## Phase 7: Final Plan Generation
@@ -635,14 +714,15 @@ If all of the following are true:
635714
- `GEN_PLAN_MODE=discussion`
636715
- There are no pending decisions with status `PENDING`
637716
- Every convergence topic whose resolution defers work has a resolved `DEC-*` plus linked `FUT-*` entry; no deferred-work resolution exists only in the convergence matrix
717+
- `COACH_MODE=false` or `COACH_CHECK_STATUS=passed`
638718
639719
Then start work immediately by running:
640720
641721
```bash
642722
/humanize:start-rlcr-loop --skip-quiz <output-plan-path>
643723
```
644724
645-
The `--skip-quiz` flag is passed because the user has already demonstrated understanding of the plan through the gen-plan convergence discussion.
725+
The `--skip-quiz` flag is passed because the user has already demonstrated understanding of the plan through the gen-plan convergence discussion and, when requested, coach checkpoints.
646726
647727
If the command invocation is not available in this context, fall back to the setup script:
648728
@@ -663,6 +743,7 @@ Report to the user:
663743
- Summary of what was included
664744
- Number of acceptance criteria defined
665745
- Number of convergence rounds executed
746+
- Coach mode status, including checkpoint count, confirmed mainline decisions, and blocked items if applicable
666747
- Number of unresolved user decisions (if any)
667748
- Whether language was unified (if applicable)
668749
- Whether direct work start was attempted, and its result
@@ -675,6 +756,13 @@ If issues arise during plan generation that require user input:
675756
- Use AskUserQuestion to clarify
676757
- Document any user decisions in the plan's context
677758
759+
If coach confirmation fails or remains ambiguous:
760+
- Stop before expanding the next planning layer
761+
- Explain which checkpoint is blocked
762+
- Summarize the explanation or revision that was attempted
763+
- Record the blocker in `## Pending User Decisions`
764+
- Tell the user they can rerun without `--coach` only if they intentionally want to skip plan-time coaching checks
765+
678766
If auto-start mode is enabled but convergence conditions are not met:
679767
- Explain why direct start was skipped
680768
- Tell the user to either resolve pending decisions or run `/humanize:start-rlcr-loop <plan.md>` manually

docs/usage.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ OPTIONS:
160160
(discussion mode only; ignored in --direct)
161161
--discussion Use discussion mode (iterative Claude/Codex convergence rounds)
162162
--direct Use direct mode (skip convergence rounds, proceed immediately to plan)
163+
--coach
164+
Run mandatory short-answer stage quizzes before expanding each planning layer
163165
-h, --help Show help message
164166
```
165167

@@ -170,8 +172,9 @@ Workflow:
170172
2. Checks if draft is relevant to the repository
171173
3. Analyzes draft for clarity, consistency, completeness, and functionality
172174
4. Engages user to resolve any issues found
173-
5. Generates a structured plan.md with acceptance criteria
174-
6. Optionally starts `/humanize:start-rlcr-loop` if `--auto-start-rlcr-if-converged` conditions are met
175+
5. When `--coach` is enabled, runs mandatory stage quizzes after each planning stage; normal plan decision questions stay separate, and quiz mismatches become design drift, AI design corrections, or background gaps before overall acceptance
176+
6. Generates a structured plan.md with acceptance criteria
177+
7. Optionally starts `/humanize:start-rlcr-loop` if `--auto-start-rlcr-if-converged` conditions are met
175178

176179
If reviewers later annotate the generated plan with comment blocks, run
177180
`/humanize:refine-plan --input <plan.md>` before starting or resuming implementation.

scripts/validate-gen-plan-io.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
set -e
1515

1616
usage() {
17-
echo "Usage: $0 --input <path/to/draft.md> --output <path/to/plan.md> [--auto-start-rlcr-if-converged] [--discussion|--direct]"
17+
echo "Usage: $0 --input <path/to/draft.md> --output <path/to/plan.md> [--auto-start-rlcr-if-converged] [--discussion|--direct] [--coach]"
1818
echo ""
1919
echo "Options:"
2020
echo " --input Path to the input draft file (required)"
2121
echo " --output Path to the output plan file (required)"
2222
echo " --auto-start-rlcr-if-converged Enable direct RLCR start after converged planning (discussion mode only)"
2323
echo " --discussion Use discussion mode (iterative Claude/Codex convergence rounds)"
2424
echo " --direct Use direct mode (skip convergence rounds, proceed immediately to plan)"
25+
echo " --coach Run mandatory short-answer stage quizzes during plan generation"
2526
echo " -h, --help Show this help message"
2627
exit 6
2728
}
@@ -31,6 +32,7 @@ OUTPUT_FILE=""
3132
AUTO_START_RLCR_IF_CONVERGED="false"
3233
GEN_PLAN_MODE_DISCUSSION="false"
3334
GEN_PLAN_MODE_DIRECT="false"
35+
COACH_MODE="false"
3436

3537
# Parse arguments
3638
while [[ $# -gt 0 ]]; do
@@ -63,6 +65,10 @@ while [[ $# -gt 0 ]]; do
6365
GEN_PLAN_MODE_DIRECT="true"
6466
shift
6567
;;
68+
--coach)
69+
COACH_MODE="true"
70+
shift
71+
;;
6672
-h|--help)
6773
usage
6874
;;
@@ -157,6 +163,7 @@ INPUT_LINE_COUNT=$(wc -l < "$INPUT_FILE" | tr -d ' ')
157163
echo "VALIDATION_SUCCESS"
158164
echo "Input file: $INPUT_FILE ($INPUT_LINE_COUNT lines)"
159165
echo "Output target: $OUTPUT_FILE"
166+
echo "Coach mode: $COACH_MODE"
160167
echo "IO validation passed."
161168

162169
# Locate template file using CLAUDE_PLUGIN_ROOT (set by Claude Code plugin system)

0 commit comments

Comments
 (0)