codex - 💡(How to fix) Fix Path-aware dynamic rule loading for better code-quality control [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#17239Fetched 2026-04-10 03:43:32
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3closed ×1commented ×1

Root Cause

  • A single top-level AGENTS.md becomes too large, too generic, and eventually too weak.
  • Nested AGENTS.md only help if I launch Codex from the “right” directory or if the current discovery model happens to include them.
  • Workflow skills / prompts / local conventions are not strong enough for strict code-quality control, because they still depend on the model consistently selecting and following them.
  • Post-hoc quality gates are useful, but they only catch violations after the agent has already produced low-quality code. That means repeated repair cycles, wasted tokens, and extra review time.
RAW_BUFFERClick to expand / collapse

What variant of Codex are you using?

CLI

What feature would you like to see?

I would like Codex to support some form of path-aware dynamic rule loading so that project-specific coding rules can be applied based on the files or modules actually being worked on, instead of relying on one large static AGENTS.md loaded from the current working directory path.

I am intentionally describing the behavioral outcome, not insisting on one specific implementation.

Possible implementation paths could include any of the following:

  • dynamically loading nested AGENTS.md / project docs when relevant files are read or edited
  • allowing AGENTS.md to include other rule files conditionally
  • a native pre-turn context hook
  • an MCP-based rules provider that Codex can query for the current task / target paths
  • another mechanism that gives the same end result

The core need is this:

As a developer, I need Codex to apply the right architectural and code-quality rules for the specific part of the codebase being modified, without requiring me to put everything into one giant prompt file and without relying on the model to manually “remember” to fetch the right rules.

Why this matters

Right now, controlling agent code quality in larger repos is difficult:

  • A single top-level AGENTS.md becomes too large, too generic, and eventually too weak.
  • Nested AGENTS.md only help if I launch Codex from the “right” directory or if the current discovery model happens to include them.
  • Workflow skills / prompts / local conventions are not strong enough for strict code-quality control, because they still depend on the model consistently selecting and following them.
  • Post-hoc quality gates are useful, but they only catch violations after the agent has already produced low-quality code. That means repeated repair cycles, wasted tokens, and extra review time.

In practice, this makes it hard to enforce different rules for different modules, for example:

  • runtime gameplay code vs domain logic
  • tests vs production code
  • bootstrap/orchestration code vs presentation code
  • backend vs frontend in mixed repos
  • generated or vendor areas vs authored code

The developer experience problem

This is not just about convenience. It is about reliable quality control.

When the agent does not receive the right scoped rules at the right time:

  • architecture boundaries are violated more often
  • style and naming conventions drift
  • repetitive cleanup is required after nearly every change
  • trust in the agent drops, because output quality becomes inconsistent

That forces developers into one of two bad options:

  1. keep all rules in one large prompt file and hope the model follows them, or
  2. constantly restate local rules manually during the session

Neither scales well.

What would count as success

Any solution would help if it makes the following possible:

  • Codex can determine that a task is touching files in a specific module / subtree / file class.
  • Codex automatically gets the rules relevant to that scope.
  • The loaded scoped rules are visible or inspectable so the user can verify what context was active.
  • The mechanism works in long-running sessions and does not depend entirely on the model voluntarily remembering to retrieve rules.
  • The feature supports real-world repos with multiple architectural zones and different quality standards per zone.

Example

If I start Codex at repo root and later the task shifts to files under something like:

  • Assets/Scripts/Runtime/Placement/**
  • Assets/Scripts/Domain/**
  • Assets/Tests/**

then Codex should be able to load the relevant rules for those zones automatically or through a first-class built-in mechanism, without requiring me to restart the session from another directory or manually paste rules again.

Why I’m opening this even though related issues exist

I know there are nearby requests such as:

  • nested AGENTS.md on demand
  • include files in AGENTS.md
  • stronger local developer instruction files
  • dynamic pre-turn hooks

Those are all related, but this request is specifically about the higher-level product need:

developers need a reliable way to scope code-quality and architectural rules to the part of the repo the agent is actually working on.

I do not care whether the solution looks like Cursor Rules, nested AGENTS, hooks, MCP, or something else. I care about being able to control agent code quality reliably in a large codebase.

Additional information

Related issues:

  • #8559 File-specific rules (closed as not planned)
  • #12115 Dynamically loading nested AGENTS.md
  • #6038 Ability to include files in AGENTS.md
  • #12926 developer_instructions_file
  • #14814 native pre-turn dynamic context hook

My request is not “please clone Cursor exactly”. My request is: please provide a first-class Codex mechanism that achieves the same practical outcome for scoped code-quality guidance.

extent analysis

TL;DR

Implement a path-aware dynamic rule loading mechanism to apply project-specific coding rules based on the files or modules being worked on.

Guidance

  • Investigate the feasibility of dynamically loading nested AGENTS.md files when relevant files are read or edited.
  • Explore the possibility of allowing AGENTS.md to include other rule files conditionally.
  • Consider implementing a native pre-turn context hook or an MCP-based rules provider to query for the current task/target paths.
  • Evaluate the potential of using a different mechanism that achieves the same end result, such as a first-class Codex mechanism for scoped code-quality guidance.

Example

No specific code snippet is provided, as the issue focuses on the behavioral outcome rather than a specific implementation.

Notes

The solution should prioritize reliability and scalability, ensuring that the mechanism works in long-running sessions and does not depend entirely on the model voluntarily remembering to retrieve rules.

Recommendation

Apply a workaround by using a combination of existing features, such as nested AGENTS.md files and include files in AGENTS.md, until a native path-aware dynamic rule loading mechanism is implemented. This approach allows for some level of scoped code-quality guidance, although it may not be as seamless or efficient as a first-class Codex mechanism.

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