Skip to content
Back to skills

Review Codex

ASecurity

Auto-detect what was built, write a Codex adversarial prompt, dispatch Codex directly via `codex exec`, then verify results when complete

  • 11 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
ai-agentspythonrustgobashgitapidocumentation

Works with

  • terminal
  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 24, 2026

npx -y skills add haterade22/TAOM --skill review-codex --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Review Codex?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Review Codex
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/haterade22-review-codex/badge)](https://www.skillsdirectory.com/skills/haterade22-review-codex)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: review-codex
description: Auto-detect what was built, write a Codex adversarial prompt, dispatch Codex directly via `codex exec`, then verify results when complete
argument-hint: "[optional: feature-name or path-to-review.md]"
---

# Codex Adversarial Review Pipeline

Codex cost is not a constraint, so do not hedge on it; the consent gate stays (Mike, 2026-08-01). `/deep-review` Step 0 says when his word covers a pass.

Handles the full Codex review lifecycle automatically — Claude dispatches Codex directly via the local `codex` CLI (no terminal hand-off to the user). Detects what needs reviewing from context.

**Argument handling:**
- No argument: auto-detect from git what was changed, write prompt, dispatch
- Feature name (no `.md`): write prompt for that feature, dispatch
- Path to `.md` file: verify that existing Codex review, implement fixes
- If a `codex-adversarial-*.md` file was recently created in `docs/reviews/raw/`, ask user if they want to verify it

## Codex CLI invocation contract (added 2026-05-25)

Claude has direct access to Codex via the `codex` binary (`C:\Users\mikew\AppData\Roaming\npm\codex.cmd` on Windows, `codex` on POSIX). Dispatch is a **Bash call from inside this skill** — the user does NOT open a separate terminal.

**Required pre-flight (Phase 2 only — once per skill invocation):**
```bash
codex login status
```
Expect `Logged in using ChatGPT` (or equivalent). If not logged in, stop the skill and surface the message — the user must run `codex login` themselves (interactive browser flow).

**Dispatch command (Phase 2e):**
```bash
cd "<repo-root>" && codex exec -c model_reasoning_effort="<level>" -c project_doc_max_bytes=65536 - < "<prompt-file-path>" > "<output-file-path>" 2>&1
```
- `codex exec -` reads the prompt from stdin (avoids argv length limits for large prompts).
- Output (stdout + stderr) goes to `docs/reviews/raw/codex-adversarial-{feature}-{date}.md`.
- Wrap with `run_in_background: true` on the Bash tool call. Run time follows the effort passed on that dispatch: `ultra` or `max` usually takes 10-45 minutes (review 95, `ultra`, about 30 minutes for a 12-file changeset), `xhigh` and `high` less (no measured window yet: say "shorter than the ultra window" until one is recorded). The harness notifies when the background job completes.
- The model comes from the repo's `.codex/config.toml` (`model = "gpt-6-astra"`), and so does the default effort (`model_reasoning_effort = "ultra"`, set 2026-09-11, which is the ceiling: every dispatch overrides it with a level of its own, next bullet; the ladder this CLI reports for the model is low, medium, high, xhigh, max, ultra, read from `~/.codex/models_cache.json`, and `ultra` is its top; the pin was `gpt-5.6-sol` at `max` from 2026-09-05), but ONLY on a machine whose `~/.codex/config.toml` trusts this checkout path (`[projects.'E:\repos\TAOM'] trust_level = "trusted"`). Until 2026-09-05 the user config trusted the old `c:\users\mikew\source\repos\taom` path only, so the repo pin was inert and `codex doctor` reported `MCP servers 0`; after trusting the path it reports 3. On a new laptop, add the trust entry first, then `codex doctor` must show `MCP servers 3`. Do NOT override the model unless the user asks.
- **Reasoning effort is the session's call** (Mike, 2026-09-28). The config's `ultra` is a ceiling, not a requirement: pass `-c model_reasoning_effort="<level>"` on every dispatch, sized to the review. `ultra` or `max` for a first pass over a large or risky change (engine patches, native or save-data paths, many files); `xhigh` for a mid-size change; `high` for a focused pass over a few fixes from an earlier review. Name the level and the reason in the one-line dispatch message.
- **Reviewing a worktree: dispatch from the worktree itself.** Its project config loads there as it does in the main checkout (EMPIRICAL 2026-09-28: `codex doctor` run in `E:\repos\taom-creature-bandits` reports model `gpt-6-astra` and `MCP servers 3`, the same as the main checkout), and the `workspace-write` sandbox then covers only the worktree, not the main tree where other sessions may be editing. /improve dispatches from the main checkout on purpose: its generated prompt forbids every edit (`tools/improve_ctl.py` codex-prompt) and its output lives outside the tree. Either way the output header's `model:` and `reasoning effort:` lines confirm what ran.
- Codex reads project rules from `AGENTS.md`, truncated at `project_doc_max_bytes` (default 32768). AGENTS.md stays under 8,192 bytes (`tools/reviewctl.py` fails it above that), so it fits; TAOM's detailed review rules (Critical Rules, "Non-Negotiable ADR Rules", commit conventions) live in `.ai/review-reference.md`, which AGENTS.md "Start here" tells Codex to read. Keep passing `-c project_doc_max_bytes=65536` as margin: the project `.codex/config.toml` also sets the key, but a project config is read only when the checkout path is trusted in `~/.codex/config.toml` (see the model bullet above). Confirm with `codex debug prompt-input "hi"` (no API call): the rendered input must contain AGENTS.md's "Evidence, never invention" rule. The project-declared `filesystem`/`git`/`ilspy` MCP servers load under the same trust rule, and the filesystem server now also reaches the live `TAOM_Map` and `LOTRLOME_Armory` ModuleData.

**When the background job notifies completion:**
1. Read the output file. Confirm it's a real Codex review (starts with review structure, not an error message).
2. If the output starts with `Error:` / `panic:` / login failure / empty file, fall back to manual dispatch by telling the user the failure mode.
3. Otherwise, proceed to Phase 3 (verify findings).

## Phase 1: Detect What to Review

### If no argument provided:

1. Run `git diff --name-only HEAD` and `git diff --name-only HEAD~3..HEAD` to find recently changed `.cs`, `.xml` and `.xslt` files
2. Group changed files by feature directory (e.g., `Main/Features/SettlementGuards/` → SettlementGuards)
3. Check `docs/reviews/raw/` for any `codex-adversarial-*.md` file modified in the last hour
   - If found: go to **Phase 3** (verify that review)
   - If not found: go to **Phase 2** (write prompt for the most-changed feature)

### If argument is a feature name:
Go to **Phase 2** with that feature.

### If argument is a `.md` path:
Go to **Phase 3** with that file.

## Phase 2: Write Codex Prompt

### 2a: Gather feature files

Find all files for the feature:
- `Main/Features/{feature}/` — all .cs files (services, hooks, models, UI, IoC)
- `TAOM.Tests/Features/{feature}/` — all test files
- `Main/_Module/ModuleData/` — any config files (JSON, XML) used by the feature
- `Main/Adapters/` — any adapters used by this feature (grep for feature-related types)
- `docs/features/{feature}.md` — feature documentation if it exists
- Check `Main/SubModule.cs` and `Main/IoC.cs` for registration lines

Count files, identify GameModel overrides, Harmony patches, config files, and test coverage.

### 2b: Identify vanilla targets

For each Harmony patch, identify the vanilla class and method being patched.
For each GameModel, identify the vanilla base class being overridden.
Name each target type in the prompt and tell Codex to read it from the installed DLLs through its ilspy server; the dump at `E:\Decompiled_Bannerlord\` is for browsing only.

### 2c: Identify Known Suspects

Run a quick analysis of the feature for likely issues:
- Check all config files for kingdom/culture IDs — do they match the cheatsheet?
- Check all Harmony patches for fail-safe defaults (`?? true` vs `?? false`)
- Check for dead code (methods defined but never called)
- Check for convention consistency with other TAOM features
- Check any reflection usage for correct field/type targets
- Check for stale state across lifecycle boundaries
- **Entity state matrix for OnGameLoaded behaviors:** If the feature has an `OnGameLoadedEvent` handler that mutates Hero/Settlement state, enumerate all possible entity states (recruited, traveling, dead, prisoner, fugitive) and check whether the mutation is guarded for each. This is a HIGH-priority suspect — Review #23 found a ship-blocking bug from this pattern.
- **Idempotent vs destructive operations:** If the feature copies a behavior pattern from another feature (e.g., "run same logic on new game and load"), check whether the operation is idempotent. Destructive operations (moving heroes, changing state) need stricter guards on the load path than their new-game counterparts.

List 3-6 Known Suspects with specific hypotheses for Codex to CONFIRM or DISPUTE.

### 2d: Write the prompt

Use flat formatting — NO indented continuation lines (triggers backslash-escape prompt). Use `--` not `—`.

The prompt must include:

1. Feature description (1-2 lines)
2. The TAOM ID CHEATSHEET block from [references/prompt-fixed.md](references/prompt-fixed.md), as written there
3. READ FIRST section (feature docs, config files)
4. Known Suspects section (from 2c)
5. File lists grouped by category
6. REQUIRED SECTIONS with feature-specific questions:
   - VANILLA CODE (decompile targets, paste as code blocks)
   - Feature-specific deep analysis (concrete scenarios)
   - CONFIG CROSS-REFERENCE
   - FINDINGS OR OBSERVATIONS
7. QUALITY GATES
8. The Prior review lessons block from [references/prompt-fixed.md](references/prompt-fixed.md), as written there
9. Output: return the full report as your FINAL MESSAGE. The dispatcher redirects stdout into docs/reviews/raw/codex-adversarial-{feature}-{date}.md; tell Codex NOT to write that path itself (2026-09-13: it assembled its report into the same file the transcript was streaming into and the transcript won; the report had to be rebuilt from its part files).

### 2e: Dispatch Codex directly

1. **Write the prompt to disk** at `docs/reviews/codex-adversarial-{feature}-{date}.prompt.md` so it's reviewable + reusable.
2. **Pre-flight Codex auth** — run `codex login status` once. If not `Logged in`, stop and tell the user to `codex login`.
3. **Dispatch via Bash** in background:
   ```
   Bash tool call:
     command: cd "<repo-root>" && mkdir -p docs/reviews/raw && codex exec -c model_reasoning_effort="<level>" -c project_doc_max_bytes=65536 - < "docs/reviews/codex-adversarial-{feature}-{date}.prompt.md" > "docs/reviews/raw/codex-adversarial-{feature}-{date}.md" 2>&1
     run_in_background: true
     timeout: 7200000  (an unattended run, such as `claude -p` or a cloud session, stops a background command at its timeout, 2 h at most; an interactive session has no limit; the harness notifies when Codex finishes)
   ```
4. **Tell the user once** what was dispatched: feature name, prompt path, output path, the reasoning level chosen and the one-line reason, and the expected window for that level (dispatch contract above). Do NOT poll the background job: the harness sends a notification when the job actually completes.
5. **Continue with other work or stop**. When the background notification arrives, automatically proceed to Phase 3 by reading the output file. Do NOT re-prompt the user to "run /review-codex again" — Claude continues the lifecycle itself.

Fallback path (only if direct dispatch fails — `codex` binary missing, auth expired, sandbox refuses):

```
Tell the user:
  Direct Codex dispatch failed: <exact error from Bash output>.
  Manual fallback (<level> is the reasoning effort chosen for this review):
    1. Open a terminal
    2. cd <repo-root>
    3. mkdir -p docs/reviews/raw && codex exec -c model_reasoning_effort="<level>" -c project_doc_max_bytes=65536 - < "docs/reviews/codex-adversarial-{feature}-{date}.prompt.md" > "docs/reviews/raw/codex-adversarial-{feature}-{date}.md"
    4. When done, re-invoke /review-codex with the .md file path as argument
```

## Phase 3: Verify Codex Review

Read process docs first: `docs/reviews/REVIEW-GUIDE.md` "Codex Failure Patterns". Do not read `docs/reviews/REVIEW-LOG.md`; grep it for the feature name.

### 3a: Read the Review

Read the Codex review file. Identify:
- Total findings and severities
- Known Suspects section (highest priority if present)
- Whether code blocks from both codebases are present (quality indicator)
- Whether config was cross-referenced (quality indicator)

### 3b: Verify Each Finding

**A Codex finding is a hypothesis, not a verdict** (per `.claude/rules/evidence-over-claims.md`). Verify EVERY finding against the TAOM source and decompiled vanilla BEFORE implementing it: re-read the actual code, don't act on the reviewer's confidence. This skill auto-implements confirmed findings, so an unverified finding becomes an unverified change.

For EACH finding:

**Read the TAOM source.** Does the code do what Codex claims?

**Verify "missing" claims.** Grep the codebase — don't trust "I didn't find it."

**Decompile vanilla targets.** For Harmony/GameModel findings, use `pwsh tools/taom-src.ps1 path <Type>`; the dump at `E:\Decompiled_Bannerlord\` is for browsing and can lag an engine bump.

**Check donor-comparison fairness.** Ported references may target an older Bannerlord — flag API differences.

**Check what Codex missed:**
- Config ID consistency (kingdom/culture IDs match cheatsheet?)
- Cross-config coverage: when a feature reads config A and config B, every entry in A has its entry in B (every CC culture in cultures.json has at least one career in taom_careers.xml)
- Fail-safe defaults (`?? true` vs `?? false`)
- No-op code paths
- Dead config values
- Stale state across lifecycle boundaries
- **OnGameLoaded entity state matrix**: If the feature mutates Hero/Settlement state on load, verify all entity states are guarded (recruited, traveling, dead, prisoner, fugitive). This is a HIGH-priority check — Review #23 found a load-path teleport bug from this exact gap.

### 3c: Verify Known Suspects

If the review has Known Suspects with CONFIRMED/DISPUTED verdicts:
- Verify each independently by reading source
- Codex has been wrong about these before

### 3d: Produce Assessment

Output table:

| # | Codex Severity | Your Severity | Agree? | Reason |
|---|---------------|--------------|--------|--------|

Then categorize:
- **Confirmed bugs** — file, line, what to change, why
- **False positives** — why Codex was wrong
- **Design questions** — need user input
- **Things Codex missed** — additional bugs found

### 3e: Root Cause Analysis — Why Did We Miss This?

For EACH confirmed bug that Codex found, answer:

**What category?** (pick one)
- Config ID mismatch — wrong kingdom/culture/troop/settlement ID in config
- Missing vanilla gate — didn't check what vanilla does before overriding
- Stale state / lifecycle — cache, flag, or reference survives past its intended scope
- Dead / no-op code — code exists but does nothing in all cases
- Convention inconsistency — pattern used differently than rest of codebase
- Reflection target wrong — field/property on wrong type or wrong name
- Missing null guard — didn't handle the null/empty/missing case
- Logic error — wrong formula, wrong condition, wrong comparison
- Other — describe

**Why did Claude miss it during implementation?**
- Didn't decompile vanilla target before writing the patch/model
- Didn't cross-reference config IDs against source-of-truth files
- Didn't trace the full lifecycle (init → runtime → save/load → cleanup)
- Didn't enumerate all entity states for a load-path mutation (see csharp-architecture.md "Entity State Matrix")
- Assumed an API worked a certain way without verifying
- Copied a pattern from another feature without checking if it fits (idempotent vs destructive)
- Other — describe

**Preventive action:** For each root cause, add ONE of:
- A new unit test that would catch this category of bug
- A config validation test that cross-references IDs at test time
- A note in `docs/reviews/REVIEW-GUIDE.md` as a new check item
- A rule in `.claude/rules/` if it's a recurring pattern
- A `### <rule>` entry in the matching category file under `docs/reviews/lessons/` (index: `docs/reviews/LESSONS-LEARNED.md`) — **mandatory for any systemic finding.** Shape: `### rule` → `**Why missed:**` → `**Prevent:**` → `**Source:**`. This is the always-consulted master record (indexed from the harness `MEMORY.md`); read the matching category file before the next review of that subsystem.

Do NOT skip this step. The point is not just to fix bugs — it's to make the same category of bug impossible in future features. Output the analysis as:

| # | Bug | Category | Why Missed | Preventive Action |
|---|-----|----------|-----------|-------------------|

### 3f: Implement Confirmed Fixes

For each confirmed bug:
1. Make the code change
2. `dotnet build TAOM.Tests -p:DisableModuleCopy=true -p:ModuleId=`: must compile
3. Run the tests of the changed type: `python tools/graphify_taom.py tests "<changed type or file>"` prints the `dotnet test --filter` line (after `refresh --if-stale`: a stale graph misses a new test file). They must pass
4. Update tests if behavior changed
5. Add any preventive tests identified in 3e

After the last fix, run the full suite once: `dotnet test TAOM.Tests -p:DisableModuleCopy=true -p:ModuleId=` must pass (both flags on both commands, or the build deploys into the game install), and the Python suite when a tool changed (`/verify` Steps 2 and 2b). Skip this run only when `/ship` Phase 4 runs `/verify` next.

### 3h: Update the Codex lessons (`.ai/review-reference.md`)

Codex reads the "Lessons From Prior Reviews" section of `.ai/review-reference.md`, which AGENTS.md
"Start here" sends every reviewer to. Add a line there only for a new false-positive pattern or a
missed category (a bug Codex missed that Claude caught). Harvest any durable pattern into
`docs/reviews/lessons/<category>.md` too. `docs/reviews/codex-track-record.md` is frozen: do not add
an essay to it. In an `/improve` run the review lead lists these instead of writing them, and the
orchestrator consolidates them once at wrap-up.

### 3i: Update Review Log

1. Add entry to `docs/reviews/REVIEW-LOG.md`
2. Update metrics
3. Add new failure patterns to `docs/reviews/REVIEW-GUIDE.md` if discovered
4. Include the root cause table from 3e in the review log entry

## Rules

- NEVER implement a fix without reading the source file first
- NEVER agree with a Codex finding just because it sounds plausible — verify
- Decompile vanilla targets for ALL Harmony patch and GameModel findings
- Config cross-reference is mandatory, not optional
- When in doubt about design intent, flag for user input rather than guessing
- Build and run the changed type's tests after EVERY fix; the full suite once after the last (3f)
- Flat formatting in prompts — no indented continuation lines

Files in this skill

  • SKILL.md17.9 KB
  • references/prompt-fixed.md1.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.