Skip to main content

Codex CLI Integration

Rafter’s Codex CLI integration installs the same four skills as Claude Code, plus PreToolUse/PostToolUse hooks in .codex/hooks.json and an AGENTS.md instruction block.

Hooks

PreToolUse / PostToolUse entries in .codex/hooks.json, matched on Bash|apply_patch. Enforced before every matched tool call.

Skills

Four skills installed to ~/.agents/skills/: rafter, rafter-secure-design, rafter-code-review, rafter-skill-review.

Setup

1. Install Rafter CLI

2. Initialize Local Security

Rafter detects Codex CLI via ~/.codex and writes: With --local, skills and hooks land under <cwd>/.agents/ and <cwd>/.codex/, and the instruction block is written to <cwd>/AGENTS.md instead (shared with Windsurf, if that’s also installed). To install all detected integrations at once:
--all does not install the git pre-commit hook. Run rafter agent install-hook separately — see Advanced Usage below.

3. Restart Codex CLI

Restart Codex CLI to load the newly installed hooks and skills.

Skill Location

After initialization:

Hooks

.codex/hooks.json gets PreToolUse and PostToolUse entries matched on Bash|apply_patch — Codex’s shell and file-edit tools. Codex also documents PreToolUse firing for MCP tool calls (patterns like mcp__<server>__<tool>); if you wire up an MCP server alongside these hooks, add a matcher for it yourself. The PreToolUse hook checks a Bash command against command policy, and an apply_patch against the same write checks as a file write: every path in the patch’s *** Add File:, *** Update File:, *** Delete File: and *** Move to: headers is checked against the guard on ~/.rafter/, and the patch text is scanned for secrets. When it has no objection it returns no decision, so Codex’s own approval settings apply. As with the other platforms, the PreToolUse hook denies a command that would otherwise require approval rather than prompting — the deny reason tells you to run it with rafter agent exec '<command>' at an interactive terminal.

Usage

Backend Scanning

Trigger a security scan of your repository:
Or use the rafter scan alias:
Backend scanning requires a Rafter API key. Set it via export RAFTER_API_KEY="your-key" or pass --api-key. A project .env file cannot set RAFTER_API_KEY — the CLI ignores RAFTER_* values from .env as of 0.10.6.

Local Security

These commands work locally without an API key:
rafter agent scan still works but is deprecated — it will be removed in a future major version. Use rafter secrets instead.

Skill Auditing

Treat third-party extension ecosystems as hostile by default. There have been reports of malware distributed via skill marketplaces, using social-engineering instructions to run obfuscated shell commands.
Before installing any third-party skill:
This runs a deterministic pass — secrets, high-risk shell patterns, obfuscation signals, suspicious files, external URLs — and prints a structured report. Exit code 0 means that pass found nothing; it does not mean the skill is safe. rafter agent audit-skill still works but is deprecated in favor of rafter skill review, and prints a warning pointing at the replacement.

Configuration

Command Policy

Examples use the Node CLI’s camelCase keys; the Python CLI uses snake_case. See the key casing note.
A small set of catastrophic patterns — rm -rf /, fork bombs, disk wipes, reverse shells — is always blocked regardless of mode; commandPolicy.blockedPatterns / requireApproval are the configurable layer above that floor.

View Configuration

Monitoring

View Agent Activity

rafter agent audit has no --json flag. The underlying log is newline-delimited JSON at ~/.rafter/audit.jsonl if you need it machine-readable; --share produces a redacted excerpt for an issue report, and --verify checks the log’s tamper-detection hash chain.

Troubleshooting

  1. Check that the integration is installed:
    For Codex, verify checks that the skill is installed at ~/.agents/skills/rafter/SKILL.md. Check the hook entries directly (step 3).
  2. Verify skills are installed: ls ~/.agents/skills/rafter/
  3. Verify hooks are installed: cat ~/.codex/hooks.json
  4. Re-run: rafter agent init --with-codex
  5. Restart Codex CLI
Ensure ~/.codex exists, then run: rafter agent init --with-codex

Advanced Usage

Pre-Commit Hook

rafter agent init (with or without --all) does not install a git hook:
The hook runs rafter secrets --staged --quiet and blocks the commit on any finding, or if the staged diff can’t be read at all.

What’s Next?

Secret Scanning

28 secret patterns detected

Command Execution

Risk-assessed command validation

Command Reference

Full CLI reference