Repository navigation
Description
Summary
The contextcrawler init -g --codex command writes a CONTEXTCRAWLER.md whose prefix rule is too weak to influence Codex CLI's actual shell-command choices. Empirical compliance: 0%.
Reproduction (2026-05-18)
contextcrawler init -g --codex(writes~/.codex/AGENTS.mdwith@~/.codex/CONTEXTCRAWLER.mdreference)- Fresh process:
codex exec --skip-git-repo-check --sandbox read-only 'Show me the recent commit history (last 3 commits, one-line format). Then briefly list what files were modified in the most recent commit.' - Observe shell calls Codex actually issues.
Result
Codex ran:
/bin/zsh -lc 'git log -3 --oneline'← raw, nocontextcrawlerprefix/bin/zsh -lc 'git show --name-only ...'← raw, nocontextcrawlerprefix
Token savings: 0.
Verification it reads the file
A direct prompt — Quote verbatim the rule about shell command prefixes — returned the expected line, confirming the template is loaded. The model knows the rule and chooses not to apply it.
Root cause
hooks/codex/rtk-awareness.md (compiled in as RTK_SLIM_CODEX at src/hooks/init.rs:25) uses single-line advisory wording:
Always prefix shell commands with
contextcrawler.
This loses against Codex's own use shell tool system-prompt guidance. gpt-5.4-mini in particular treats it as soft advice and reaches for the obvious shell form.
Fix (proposed)
Strengthen hooks/codex/rtk-awareness.md with:
- Imperative MUST wording at top
- Concrete WRONG / RIGHT examples covering common commands
- Explicit applies-to command list
- Self-check instruction (before issuing any shell call, check: does it start with
contextcrawler?)
Empirical validation of the fix
Inlined the strengthened block at the top of ~/.codex/AGENTS.md (not the @-import) and re-ran the same prompt. Compliance: 100% (both shell calls now prefixed with contextcrawler). contextcrawler gain --history shows 80%+ savings on the git-log filter.
Scope
- Edit
hooks/codex/rtk-awareness.md(the embedded template) - Update snapshot/exact-match test at
src/hooks/init.rs:3191(assert_eq!(fs::read_to_string(&rtk_md).unwrap(), RTK_SLIM_CODEX)) - No logic changes, no new dependencies
Out of scope (deferred follow-up)
If salience-via-@-import remains the bottleneck under heavier prompts, escalate by inlining a short rule block directly into AGENTS.md (in addition to CONTEXTCRAWLER.md). Requires logic change in run_codex_mode_with_paths() and a separate idempotent block-management path. Not needed yet — the template strengthening alone got 100% on the test case.
Test plan
-
cargo test --allpasses (snapshot/exact-match assertion updated) - Reinstall binary, run
codex execwith the same git-log prompt, confirmcontextcrawlerprefix appears in the shell trace -
contextcrawler gain --historyshows the savings entry
Activity
fix(hooks): strengthen codex prefix rule for actual compliance (theho…