Skip to content

Review gate setup writes to temp dir, but Stop hook reads from persistent dir #59

@xinnyu

Description

@xinnyu

Bug

/codex:setup --enable-review-gate appears to succeed, but the Stop hook never enforces the gate.

Root cause

resolveStateDir() in scripts/lib/state.mjs (L29-44) picks the state directory based on CLAUDE_PLUGIN_DATA:

const pluginDataDir = process.env[PLUGIN_DATA_ENV];
const stateRoot = pluginDataDir
  ? path.join(pluginDataDir, "state")
  : FALLBACK_STATE_ROOT_DIR;  // os.tmpdir() + "codex-companion"

The setup command runs via Bash (invoked by Claude), where CLAUDE_PLUGIN_DATA is not set → writes stopReviewGate: true to the temp directory.

The Stop hook runs via Claude Code's hook system, where CLAUDE_PLUGIN_DATA is set → reads from the persistent plugin data directory, which still has the default stopReviewGate: false.

Evidence

# Temp dir (written by setup) — gate enabled
/var/folders/.../codex-companion/feat-emoji-<hash>/state.json
→ { "config": { "stopReviewGate": true } }

# Persistent dir (read by hook) — gate still disabled
~/.claude/plugins/data/codex-openai-codex/state/feat-emoji-<hash>/state.json
→ { "config": { "stopReviewGate": false } }

Suggested fix

The setup subcommand in codex-companion.mjs should resolve the persistent plugin data directory the same way hooks do. Options:

  1. Have the skill pass CLAUDE_PLUGIN_DATA as an env var when invoking the setup Bash command.
  2. Have codex-companion.mjs setup detect ~/.claude/plugins/data/codex-openai-codex/ as a fallback when CLAUDE_PLUGIN_DATA is unset.
  3. Write to both directories during setup so either reader finds the correct value.

Environment

  • Claude Code (CLI)
  • codex-plugin-cc v1.0.1
  • codex-cli 0.117.0
  • macOS Darwin 25.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions