Plan Review Iteration
Use Codex CLI to review a completed plan and implement any feedback.
Instructions
- •
Locate the plan: Find the current plan file path from the conversation context, if unable to find a plan ask the user for a file path.
- •
Run Codex review: Execute Codex CLI with JSON output pointing to the plan file:
bashcodex exec --full-auto --json "Review the implementation plan at <PLAN_FILE_PATH> and provide feedback on: 1. SIMPLICITY: Is the implementation as simple as possible? Does it avoid over-engineering, unnecessary abstractions, or premature optimization? 2. ROBUSTNESS: Does it handle errors appropriately? Are edge cases considered? Is it resilient to failures? 3. REUSE: Does the plan leverage existing functions/modules in the codebase, or does it propose writing new code that duplicates existing functionality? Search the codebase for existing implementations before suggesting new code. 4. SECURITY: Are there any potential security concerns? 5. COMPLETENESS: Does it cover all requirements and edge cases? 6. CODE QUALITY: Is the implementation approach sound? Are the patterns appropriate? Be specific about any issues found and suggest concrete improvements."
- •
Extract the session ID: Parse the JSON output for the
thread.startedevent to get thethread_id:json{ "type": "thread.started", "thread_id": "0199a213-81c0-7800-8aa1-bbab2a035a53" }Save this
thread_idfor use in resume commands. - •
Handle timeout with resume: If the command times out (hits the 5 minute bash timeout), resume using the specific session ID:
bashcodex exec resume <THREAD_ID> "Continue the plan review and provide your findings."
Keep resuming until Codex completes its review. Each resume continues from where the previous session left off.
Important: After 3 consecutive timeouts (~15 minutes total), ask the user if they want to continue before resuming again. This prevents runaway sessions and gives the user control over long-running reviews.
- •
Parse the JSON output: Extract the feedback from Codex's structured response.
- •
Present feedback: Summarize Codex's findings for the user.
- •
Implement changes: Update the plan based on Codex's feedback:
- •Simplify over-engineered approaches
- •Improve error handling and robustness
- •Replace new code proposals with references to existing functions where applicable
- •Fix security concerns
- •Address completeness gaps
- •Improve implementation approaches and code quality
- •
Iterate if needed: If significant changes were made, consider running another review pass.
Example
User: "Review the plan with codex"
- •Identify plan file path from conversation (e.g.,
/tmp/plan-abc123.md) - •Run:
codex exec --full-auto --json "Review the implementation plan at /tmp/plan-abc123.md..." - •Extract
thread_idfrom thethread.startedevent (e.g.,"0199a213-81c0-7800-8aa1-bbab2a035a53") - •If timeout occurs, run:
codex exec resume "0199a213-81c0-7800-8aa1-bbab2a035a53" --full-auto --json "Continue the plan review and provide your findings." - •Repeat step 4 until Codex completes (after 3 timeouts, ask user before continuing)
- •Parse JSON output for feedback items
- •Present summary to user
- •Update plan with approved changes
Notes
- •Codex requires being in a git repository
- •
--full-autoallows Codex to explore the codebase - •
--jsonprovides structured JSON Lines output for parsing - •Progress streams to stderr, final output to stdout
- •The
thread_idfrom thethread.startedevent uniquely identifies the session for resume