Path-aware dynamic rule loading for better code-quality control

Resolved 💬 1 comment Opened Apr 9, 2026 by garizs Closed Apr 9, 2026

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.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗