codex - ✅(Solved) Fix feat: @include directive for composable AGENTS.md files [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17401Fetched 2026-04-11 06:16:42
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
1
Timeline (top)
labeled ×3commented ×1subscribed ×1unlabeled ×1

Fix Action

Fix / Workaround

Dynamic instruction loading is impossible. As raised in #11838, the model cannot reliably follow "read this file next" directives embedded in instruction text - the CLI, not the model, assembles the system prompt. The workaround is shell-side concatenation (cat file1.md file2.md > AGENTS.md), which is fragile and breaks the declarative model.

  • #11838 - User cannot chain AGENTS.md files; model ignores "read this file next"; requests CLI-level instruction assembly
  • #5983 - Requests --bypass-agents + alternative file loading; shell concatenation acknowledged as janky workaround
  • #3853 - Enterprise request for centralized MDM-managed instruction files outside user home
  • #10067 - Named AGENTS.md variants (--agents review); addresses workflow switching but not modular composition
  • #6149 - Requests ability to point Codex to a specific AGENTS.md path
  • #3540 - Global preamble_path ignored in interactive sessions

PR fix notes

PR #12: feat: fix enforcement for Codex (.codex/config.toml fallback) and Cursor (alwaysApply MDC)

Description (problem / solution / changelog)

What

Fix enforcement for OpenAI Codex and Cursor — the two agents that don't support native @import in their instruction files.

Follow-up to PR #11 (Claude Code + Gemini CLI fixed via @AGENTS_BOOT.md).

Changes

AGENTS.md — Codex (slimmed down)

Short directive to read AGENTS_BOOT.md. The heavy lifting is done by .codex/config.toml.

.codex/config.toml — new file

project_doc_fallback_filenames = ["AGENTS_BOOT.md"]
project_doc_max_bytes = 65536

Codex reads project-scoped .codex/config.toml automatically from the repo root. This tells Codex to also load AGENTS_BOOT.md as a fallback instruction source at each directory level — no inlining, no duplication. AGENTS_BOOT.md is loaded structurally by Codex itself.

.cursorrules — Cursor (legacy)

Deprecation notice pointing to the new MDC file.

.cursor/rules/eacf.mdc — Cursor (modern)

alwaysApply: true + short directive to read AGENTS_BOOT.md. Fires every session.

Agent enforcement matrix (post this PR)

AgentFileMechanismStrength
Claude CodeCLAUDE.md@AGENTS_BOOT.mdNative @import — injected at startup✅ Strong
Gemini CLIGEMINI.md@AGENTS_BOOT.mdNative @import — injected at startup✅ Strong
OpenAI Codex.codex/config.toml fallback + AGENTS.md directiveStructural — Codex loads AGENTS_BOOT.md natively✅ Strong
Cursor (modern).cursor/rules/eacf.mdc (alwaysApply)Always fires, directive to read AGENTS_BOOT.md✅ Medium
Cursor (legacy).cursorrulesCompat only — deprecated⚠️

Single source of truth

AGENTS_BOOT.md — unchanged. All wrappers reference it without duplication.


Proposed by Luna @ ABQ | 17/04/2026

Changed files

  • .codex/config.toml (added, +11/-0)
  • .cursor/rules/eacf.mdc (modified, +2/-9)
  • .cursorrules (modified, +4/-2)
  • AGENTS.md (modified, +6/-3)

Code Example

# AGENTS.md - project root

@docs/coding-standards.md
@docs/security-policy.md
@~/.codex/instructions/rust-conventions.md

## Project-Specific Instructions

- Use `cargo nextest run` for tests.
- Prefer `tracing` over `log` crate.

---

project-root/
  docs/
    coding-standards.md    # shared source of truth
    security-policy.md     # shared source of truth
  AGENTS.md               # @docs/coding-standards.md
  CLAUDE.md               # @docs/coding-standards.md
RAW_BUFFERClick to expand / collapse

What variant of Codex are you using?

CLI

What feature would you like to see?

Add an @path/to/file.md directive to AGENTS.md that the CLI resolves at instruction-assembly time, inlining referenced file content before sending to the model. This enables modular, maintainable instruction sets - and direct interoperability with Claude Code, which already ships this exact syntax in CLAUDE.md.

The problem

Codex's instruction composition is limited to directory-walk layering: one AGENTS.md per directory level, concatenated root-to-cwd. This creates five concrete problems:

No modular reuse across projects. A developer working across 10+ repos with shared conventions must either duplicate content into each repo's AGENTS.md or maintain a single bloated ~/.codex/AGENTS.md that includes everything regardless of relevance.

No team-level instruction ownership. When different teams own different concerns (frontend style, security policy, deployment conventions), there's no way to split these into independently maintained files composed at load time. Everyone edits one file, merge conflicts ensue, instructions drift.

Cross-tool interoperability gap. Claude Code supports @path/to/file.md imports in CLAUDE.md plus an auto-loaded .claude/rules/ directory. Teams using both tools on the same projects must maintain parallel, divergent instruction files. This undermines AGENTS.md's role as an open cross-tool standard under the Linux Foundation / AAIF.

Dynamic instruction loading is impossible. As raised in #11838, the model cannot reliably follow "read this file next" directives embedded in instruction text - the CLI, not the model, assembles the system prompt. The workaround is shell-side concatenation (cat file1.md file2.md > AGENTS.md), which is fragile and breaks the declarative model.

Context budget waste. Without selective composition, users choose between including everything (wasting context on irrelevant instructions and hitting project_doc_max_bytes truncation) or going without project-specific guidance.

Proposed syntax

# AGENTS.md - project root

@docs/coding-standards.md
@docs/security-policy.md
@~/.codex/instructions/rust-conventions.md

## Project-Specific Instructions

- Use `cargo nextest run` for tests.
- Prefer `tracing` over `log` crate.

Resolution rules

  • Relative paths resolve from the directory containing the AGENTS.md
  • ~/ resolves to home directory; ~/.codex/ resolves to $CODEX_HOME
  • Files inlined in declaration order at the position of the @ line
  • Missing files emit a warning to stderr, do not block startup
  • Circular includes detected and rejected
  • Included content counts against project_doc_max_bytes
  • Line must start with @ followed by a file path - no inline usage, no globs

Cross-tool interoperability

With this feature, both tools can reference the same underlying files:

project-root/
  docs/
    coding-standards.md    # shared source of truth
    security-policy.md     # shared source of truth
  AGENTS.md               # @docs/coding-standards.md
  CLAUDE.md               # @docs/coding-standards.md

No duplication, no drift. Same @ syntax, same resolution semantics.

Optional extension: auto-load directory

Lower priority, but a .codex/rules/ directory (analogous to .claude/rules/) where all .md files auto-load alongside AGENTS.md at that directory level would provide zero-configuration composition for teams wanting modular ownership without explicit include lines.

Implementation notes

  • Purely a CLI-side text transformation during instruction assembly. No model changes, no API changes.
  • The @ prefix for file references is established convention in Claude Code, Cursor .mdc files, and others. Same syntax maximizes cross-tool familiarity.
  • Existing project_doc_max_bytes and project_doc_fallback_filenames config keys work as-is. Includes resolve before byte-limit truncation.
  • Skills (introduced April 2026) address reusable workflows but not reusable instructions. Complementary, not competing.

Additional information

Related issues

  • #11838 - User cannot chain AGENTS.md files; model ignores "read this file next"; requests CLI-level instruction assembly
  • #5983 - Requests --bypass-agents + alternative file loading; shell concatenation acknowledged as janky workaround
  • #3853 - Enterprise request for centralized MDM-managed instruction files outside user home
  • #10067 - Named AGENTS.md variants (--agents review); addresses workflow switching but not modular composition
  • #6149 - Requests ability to point Codex to a specific AGENTS.md path
  • #3540 - Global preamble_path ignored in interactive sessions

Cross-ecosystem prior art

  • Claude Code (production): @path/to/file.md imports in CLAUDE.md, .claude/rules/ auto-load directory
  • anthropics/claude-code#13614: Claude Code community requested @include before it shipped - identical pain point
  • Cursor: .mdc rule files with frontmatter-based activation and file references
  • AGENTS.md spec (agents.md, Linux Foundation / AAIF): positions itself as universal cross-tool standard, but modular composition is not yet part of the spec - this feature would be a natural addition

What this unblocks

  • Monorepo teams: shared base instructions with package-level specialization, no duplication
  • Multi-tool teams: single source of truth consumed by both Codex and Claude Code
  • Enterprise: centralized policy files referenced from any project's AGENTS.md
  • Individual developers: language/framework instruction libraries composed per-project
  • Open source maintainers: AGENTS.md that references structured docs already in the repo

extent analysis

TL;DR

Implementing an @path/to/file.md directive in AGENTS.md to enable modular instruction composition and cross-tool interoperability is the most likely fix.

Guidance

  • The proposed syntax allows for relative paths, home directory resolution, and file inlining, which can be used to create modular and maintainable instruction sets.
  • To implement this feature, the CLI would need to be modified to resolve the @ directives at instruction-assembly time, inlining the referenced file content before sending it to the model.
  • The resolution rules, such as relative path resolution and circular include detection, should be implemented to ensure correct and safe inclusion of files.
  • The feature can be tested by creating a sample AGENTS.md file with @ directives and verifying that the included files are correctly inlined and sent to the model.

Example

# AGENTS.md - project root

@docs/coding-standards.md
@docs/security-policy.md
@~/.codex/instructions/rust-conventions.md

## Project-Specific Instructions

- Use `cargo nextest run` for tests.
- Prefer `tracing` over `log` crate.

This example demonstrates how the proposed syntax can be used to include files from different locations and create a modular instruction set.

Notes

The implementation of this feature would require modifications to the CLI, but it would not require any changes to the model or API. The existing project_doc_max_bytes and project_doc_fallback_filenames config keys would still work as-is.

Recommendation

Apply the proposed syntax and resolution rules to enable modular instruction composition and cross-tool interoperability, as it would provide a flexible and maintainable way to manage instructions across different projects and tools.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING