Deterministic CI preflight for Codex-powered pull request workflows.
codex-context-probe answers a narrow question before you ask Codex to review or
edit a PR:
Which
AGENTS.mdinstructions can each changed file actually see?
It reconstructs Codex instruction discovery for each changed path, produces a context manifest, and fails CI only when objective context problems are found or when you opt into path-scoped contracts.
AGENTS.md linters improve instruction quality. This tool checks instruction visibility.
In a monorepo, a PR can touch services/payments/handler.py while Codex is
started from the wrong directory, a local AGENTS.override.md shadows root
security rules, or a large file gets cut off by the 32 KiB default instruction
budget. Those are not normal markdown quality issues. They are PR-context
preflight issues.
codex-context-probe is designed to run before Codex-powered PR review,
maintainer automation, or release work.
- Reconstructs Codex AGENTS.md discovery:
CODEX_HOMEguidance- project root to target cwd walk
AGENTS.override.mdAGENTS.mdproject_doc_fallback_filenamesproject_doc_max_bytesbudget
- Maps
git diff --name-onlychanged paths to their effective instruction chain. - Emits terminal, JSON, Markdown, and SARIF.
- Writes GitHub Step Summary markdown.
- Reports objective failures:
- instruction truncation or excluded bytes
- ignored project-scoped Codex config keys
- invalid UTF-8 in visible instruction files
- secret-like strings in visible instruction files
- Supports optional
.codex-context.ymlcontracts for path-scoped context tests. - Requires no OpenAI API key for the deterministic path.
By default, content-level checks run only on instruction files that Codex can
actually see for the changed path. Use --scan-shadowed when you also want to
scan shadowed, non-selected instruction files as a broader hygiene check.
pip install "codex-context-probe @ git+https://github.com/part676392/codex-context-probe.git"From source:
git clone https://github.com/part676392/codex-context-probe
cd codex-context-probe
pip install -e .Inspect one working directory:
codex-context-probe inspect . --cwd services/paymentsInspect changed paths in a PR:
codex-context-probe changed . --base origin/main --format markdownCI verification:
codex-context-probe verify . \
--base origin/main \
--format markdown \
--output codex-context-report.md \
--sarif codex-context.sarifTerminal output is intentionally compact so it works in local development and CI logs:
╭─ codex-context-probe changed paths [PASS] ─────────────────────────────╮
│ Project: /repo │
│ Base: origin/main │
│ Changed paths: 1 │
│ Findings: 0 errors, 1 warnings │
╰────────────────────────────────────────────────────────────────────────╯
Changed path context
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ Path ┃ CWD ┃ Included files ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ services/payments/handler.py │ /repo/services/pay… │ AGENTS.md, AGENTS.md │
└──────────────────────────────┴──────────────────────┴──────────────────────┘
Markdown output is designed for PR summaries:
# codex-context-probe changed-path report
- Changed paths: `1`
- Findings: `0` errors, `1` warnings
| Path | CWD | Included instruction files | Bytes | Findings |
|---|---|---|---:|---:|
| `services/payments/handler.py` | `/repo/services/payments` | AGENTS.md<br>AGENTS.md | 612/32768 | 0 errors, 1 warnings |name: Codex context preflight
on:
pull_request:
push:
jobs:
codex-context:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: part676392/codex-context-probe@v0.1.1
with:
base: origin/main
sarif: codex-context.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: codex-context.sarifFor stricter environments, pin third-party actions and this action by commit SHA.
The repository includes its own CI workflow at .github/workflows/ci.yml and a
copyable CI template at docs/github-actions-ci.yml.
Add .codex-context.yml only when you want path-scoped assertions.
contracts:
- id: payments-test-command
paths:
- services/payments/**
assertions:
- type: contains
value: make test-payments
- type: regex
value: Never rotate API keys|Do not rotate API keys
severity: errorContracts apply only to matching changed paths. Without this file, the tool fails only on objective context failures.
Linters ask whether instruction files are well written.
codex-context-probe asks whether the changed files in this PR can see the
right Codex instructions.
It is meant to complement tools such as agnix, ctxlint, agents-lint,
AgentLint, and instrlint, not replace them.
Codex for OSS supports maintainers using Codex for pull request review, maintainer automation, release workflows, and other core OSS work. This project targets the preflight step for that workflow: before Codex reviews a PR, verify that Codex is operating from the intended repository guidance.
MIT