Skip to content

Add opt-in automatic Codex plan review via Stop hook #267

Closed

Description

@stevensuna

Problem

revdiff-planning automatically reviews Claude Code plans through PreToolUse/ExitPlanMode, but Codex users only have the manual revdiff-plan skill. The Codex README still says Codex lacks hook support, and the manual skill uses best-effort rollout discovery that is ambiguous when several Codex sessions run concurrently.

Codex CLI now supports lifecycle hooks bundled in plugins. Live testing on Codex CLI 0.144.4 confirms that a root Stop hook can return {"decision":"block","reason":"..."} to continue the turn with feedback. Two details differ from the initial design assumptions:

  • permission_mode is the approval policy (bypassPermissions in the tested Plan-mode session), not the collaboration mode, so it cannot gate Plan mode;
  • last_assistant_message is present but null in the tested Stop payload. The same payload provides transcript_path, session_id, and turn_id.

Proposed solution

Extend the existing opt-in plugins/revdiff-planning package without changing the revdiff binary or replacing the manual fallback:

  • keep the current Claude PreToolUse/ExitPlanMode hook unchanged;
  • add a Codex plugin manifest and Codex-specific hook config using Stop;
  • review only complete <proposed_plan> blocks from root Stop events; clarification and normal Build-mode responses have no block and are ignored;
  • prefer a string last_assistant_message; when Codex sends it as null, read only the exact transcript_path whose filename contains the event session_id, then select the final assistant message matching the event turn_id;
  • do not skip stop_hook_active == true, because that is the revised-plan pass after annotation feedback;
  • open the whole plan in revdiff through the existing trusted launcher chain;
  • on a clean review, return {} and let the turn end;
  • on annotations, return decision: "block" with the annotations as the reason so Codex revises the plan and the next Stop reviews the new revision;
  • fail open with a visible warning for malformed or mismatched input, missing revdiff, missing launcher, or overlay failure, so the session cannot be wedged;
  • document Codex marketplace install plus hook trust through /hooks, while keeping /revdiff-plan as the manual fallback and correcting the obsolete no-hook statement.

This remains opt-in because it is packaged as the separate revdiff-planning plugin.

Test plan

Add integration coverage for Claude and Codex payloads: clarification skips, clean plans, bypass approval, annotations and revised-plan loops, null-message exact-turn transcript fallback, missing message/binary, launcher failure, and malformed JSON. Verify the fallback ignores other turns and rejects mismatched sessions. Keep manual skill behavior intact.

Live smoke coverage on Codex 0.144.4 should prove: clean plan opens and quits normally; an annotation blocks the turn, causes a full revision, and opens RevDiff again; Build-mode/non-interactive output is unaffected.

If this direction fits the project, I can send a focused PR with no binary/API changes, changelog edits, or version bump.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions