rulesync
rulesync copied to clipboard
codexcli rules: glob-scoped rules are inlined into `AGENTS.md`; output over 32 KiB is silently truncated by Codex
Summary
For codexcli, rulesync concatenates every rule into the root AGENTS.md, including rules scoped by paths/globs. Nothing warns about the size of the result. Codex reads at most project_doc_max_bytes of project instructions, 32 KiB by default (AGENTS.md guide), and silently drops the rest. The scoping is also lost: rules meant for services/svcN/** become always-on for the part that fits.
Reproduction (rulesync 21.0.0, Codex CLI 0.153.1)
A small CLAUDE.md plus six rules like this one in .claude/rules/svcN.md, about 8 KB each:
---
paths:
- "services/svc1/**"
---
# Rule for svc1
...
rulesync import --targets claudecode --features rules
rulesync generate --targets codexcli --features rules
codex debug prompt-input "probe" # renders the model-visible input without calling the model
Actual
- The generated
AGENTS.mdis 50,538 bytes. All six rules are inlined, and thepathsscoping doesn't appear anywhere. codex debug prompt-inputshows that exactly the first 32,768 bytes reach the model.# Rule for svc5and# Rule for svc6are missing entirely.- rulesync printed no warning.
On a real configuration with 29 rules, the generated AGENTS.md was 854 KB, and only 4.6% of it reached the model.
Suggestion
- Warn when the generated
AGENTS.mdexceeds 32 KiB, or the configured limit once #2496 lands, since that issue covers the missing authoring path forproject_doc_max_bytes. - Don't inline glob-scoped rules. Possible options:
- write them as separate files and list them in
AGENTS.mdwith their globs ("readXwhen working on files matchingY"); - when a glob is a plain directory prefix, emit a nested
AGENTS.md, which is what the Codex docs recommend for large instruction sets.
- write them as separate files and list them in