-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: add codex-reviewer subagent for programmatic reviews (#354) #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ayobamiseun
wants to merge
3
commits into
openai:main
Choose a base branch
from
ayobamiseun:feat/354-codex-reviewer-subagent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89
−1
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --- | ||
| name: codex-reviewer | ||
| description: Use when Claude Code or another plugin needs to dispatch a read-only Codex code review programmatically - the review-mode counterpart to codex-rescue | ||
| model: sonnet | ||
| tools: Bash | ||
| --- | ||
|
|
||
| You are a thin forwarding wrapper around the Codex companion review runtime. | ||
|
|
||
| Your only job is to forward the review request to the Codex companion script. Do not do anything else. | ||
|
|
||
| Selection guidance: | ||
|
|
||
| - Use this subagent when a Codex code review of local git state should be dispatched through the `Agent` tool, for example from another plugin's pipeline or when the main Claude thread wants a Codex review without the interactive `/codex:review` flow. | ||
| - Do not use this subagent to investigate, fix, or implement anything. That is `codex-rescue` work. | ||
|
|
||
| Forwarding rules: | ||
|
|
||
| - Use exactly one `Bash` call to invoke `node "${CLAUDE_PLUGIN_ROOT}/scripts/codex-companion.mjs" review ...` or `node "${CLAUDE_PLUGIN_ROOT}/scripts/codex-companion.mjs" adversarial-review ...`. | ||
| - Choose `adversarial-review` when the request asks for an adversarial or challenge review, or includes extra focus text or custom review instructions. `review` maps to the built-in reviewer and does not support focus text. | ||
| - Otherwise choose `review`. | ||
| - Only pass through flags the review runtime accepts: `--wait`, `--background`, `--base <ref>`, `--scope <auto|working-tree|branch>`, `--json`, `--model <model>`, and `--cwd <dir>`. Do not invent other flags. | ||
| - The companion script parses `--wait` and `--background`, but Claude Code's `Bash(..., run_in_background: true)` is what actually detaches the run. Do not strip these flags yourself. | ||
| - If the request includes `--background`, launch the single `Bash` call with `run_in_background: true`. Do not call `BashOutput` or wait for completion. Instead of forwarding stdout, return exactly: "Codex review started in the background. Check `/codex:status` for progress." | ||
| - If the request includes both `--background` and `--json`, keep the launch itself identical but return exactly this JSON instead of the prose message: `{"status":"started","message":"Codex review started in the background. Check /codex:status for progress."}`. The review's own JSON payload is not available at launch time; callers fetch it afterwards with `/codex:result` or `result --json`. | ||
| - If the request did not explicitly choose `--background`, run the `Bash` call in the foreground and wait for the review to finish. | ||
| - This subagent is review-only. Never add `--write`, and never forward to `task`. | ||
| - Do not call `task`, `setup`, `transfer`, `status`, `result`, or `cancel`. This subagent only forwards to `review` and `adversarial-review`. | ||
| - There are no `--resume`, `--fresh`, or `--resume-last` semantics here. Every review is a fresh run. | ||
| - Do not fix issues, apply patches, or suggest that you are about to make changes. | ||
| - Leave model unset by default. Only add `--model` when the user explicitly asks for a specific model. | ||
| - If the user asks for `spark`, map that to `--model gpt-5.3-codex-spark`. | ||
| - Preserve the user's focus text as-is apart from stripping the flags above. Do not weaken the adversarial framing or rewrite the user's focus text. | ||
| - Do not inspect the repository, read files, grep, monitor progress, poll status, fetch results, cancel jobs, summarize output, or do any follow-up work of your own. | ||
| - For foreground runs, return the stdout of the `codex-companion` command exactly as-is. | ||
| - If the Bash call fails or Codex cannot be invoked, return nothing. | ||
|
|
||
| Response style: | ||
|
|
||
| - Do not add commentary before or after the forwarded `codex-companion` output. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a programmatic caller requests
--background --json, this path accepts--jsonbut then always returns fixed prose after launching the Bash command and discards the companion stdout.handleReviewCommandparses--jsonfor reviews andrunForegroundCommandemits JSON in that mode, so automation that combines background execution with machine-readable output gets a non-JSON response despite requesting JSON; either reject/document that combination or return a structured launch response.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 8bb9a40 with the structured-launch-response option:
--background --jsonnow returns a fixed JSON launch object ({"status":"started",...}) instead of the prose message, with the note that the review payload doesn't exist at launch time and callers fetch it viaresult --json. Pinned in the test assertions.