Skip to content

Feature: Add --agents flag to switch between named AGENTS.md variants #10067

Closed as not planned

Description

@lexobe

Summary

Add a --agents <name> CLI flag that allows users to switch between different named AGENTS.md files by name, e.g.:

codex --agents review "Review this PR"
codex --agents refactor "Clean up this module"
codex --agents debug "Find the root cause"

This would resolve to a file named AGENTS.<name>.md (or similar convention) in the standard discovery locations, rather than requiring the user to specify a full file path.

Motivation

Currently, Codex has a single AGENTS.md per directory level. There is no way to maintain multiple instruction sets for different workflows within the same project without renaming files or manipulating the filesystem each time.

Real-world use cases:

  • Code review vs. code generation: A reviewer agent needs different instructions (focus on bugs, security, style) than a feature-building agent (focus on patterns, tests, architecture).
  • Debugging vs. refactoring: Different tasks benefit from different system prompts — a debug agent should be methodical and trace-oriented, while a refactor agent should focus on readability and design patterns.
  • Team roles: Different team members may want different instruction sets — a frontend dev and a backend dev working on the same monorepo need different context.
  • CI/CD pipelines: Different pipeline stages (lint, review, generate tests) each need tailored instructions.

Proposed Behavior

File naming convention

AGENTS.md              # default (no --agents flag)
AGENTS.review.md       # codex --agents review
AGENTS.refactor.md     # codex --agents refactor
AGENTS.debug.md        # codex --agents debug

Discovery

Same directory-traversal logic as today, but at each level look for AGENTS.<name>.md (and AGENTS.<name>.override.md) instead of AGENTS.md:

  1. Global: ~/.codex/AGENTS.<name>.override.md → ~/.codex/AGENTS.<name>.md
  2. Project: Git root → CWD, checking AGENTS.<name>.override.md → AGENTS.<name>.md
  3. Fallback: If no named variant is found at a given level, optionally fall back to the plain AGENTS.md at that level (configurable behavior).

Examples

# Use the "review" instruction set
codex --agents review "Check this PR for security issues"

# Use the "refactor" instruction set
codex --agents refactor "Simplify the authentication module"

# Default behavior (unchanged, no flag)
codex "Implement the new feature"

# In non-interactive mode
codex exec --agents review -q "List all potential bugs" --json

Edge cases

  • Named file not found at any level → clear error: No AGENTS.review.md found in discovery path. Available variants: review, debug, refactor
  • List available variants: codex --list-agents could scan discovery paths and list all AGENTS.*.md files
  • Empty named file → skip silently (consistent with current behavior)

Why Not Just Use --profile?

Profiles (--profile <name>) already exist but control model and config settings (model name, reasoning effort, sandbox mode, etc.). Agent instructions are a separate concern — you may want the same model config but different instructions, or vice versa. Coupling them forces unnecessary duplication.

That said, profiles could also support an agents key:

[profiles.review]
model = "o3"
agents = "review"  # automatically implies --agents review

[profiles.quick-review]
model = "gpt-5-mini"
agents = "review"  # same instructions, cheaper model

Alternatives Considered

  • --agents-file <path>: Too low-level; forces users to manage paths rather than names. Doesn't integrate with the existing discovery hierarchy.
  • Symlinks / file renaming: Fragile, error-prone, no discoverability.
  • project_doc_fallback_filenames: Only controls fallback filenames, doesn't support explicit selection.
  • CODEX_HOME switching: Overkill — changes all global config just to swap instructions.

Related Issues

Activity

  1. added
    enhancement
    CLI
    on Jan 28, 2026
  2. changed the title [-]Feature: Add --agents-file CLI flag to explicitly specify AGENTS.md file path[/-] [+]Feature: Add --agents flag to switch between named AGENTS.md variants[/+] on Jan 28, 2026
  3. etraut-openai commented on Jan 28, 2026

    @etraut-openai
    Contributor

    Have you explored using skills for your use case? I think it mostly addresses what you're looking for with existing functionality.

  4. evsukof commented on Feb 16, 2026

    @evsukof

    Hi, I have a similar pain point and support the request from @lexobe . Having --agents would be highly beneficial for creating workflows.

  5. kquinsland01 commented on Feb 23, 2026

    @kquinsland01

    Have you explored using skills for your use case? I think it mostly addresses what you're looking for with existing functionality.

    I have. Skills can approximate some aspects of this request but not others. Now that sub-agents are a bit less experimental with codex, I would really like to be able to do something like this:

    .
    └── .codex/
        └── agents/
            ├── test-writer/
            │   ├── AGENTS.md    # Everything that only this sub-agent should know
            │   └── codex.toml     # Has the `model_reasoning_effort` and other settings as currently supported
            └── documetntarian/ ##
                ├── AGENTS.md   
                └── codex.toml
    

    Then in my root/main/core (whatever you want to call it) AGENTS.md I can issue instructions akin to "review instructions in PROBLEM.md, use the documentarian sub-agent to help find and surface the appropriate documentation to understand the APIs and how they relate to the problem. Use the test-writer sub-agent to draft tests that use the targeted API as the spec/problem necessitate..."

  6. added
    TUI
    and removed
    CLI
    on Apr 2, 2026
  7. isCopyman commented on Apr 12, 2026

    @isCopyman

    claude --agent can directly switch roles and configurations

  8. MemoAsh commented on Jul 4, 2026

    @MemoAsh

    I think skills cover the "named workflow" part of this better than more AGENTS.*.md variants, but only if the repo keeps a clean split:

    • AGENTS.md: stable repo-wide constraints and commands
    • skills/<workflow>/SKILL.md: task procedure, trigger, stop conditions, output shape
    • skills/<workflow>/verification.md: what must be checked before the agent says it is done

    For the examples in this issue:

    • review becomes a review skill
    • debug becomes a reproduction/root-cause skill
    • refactor becomes a scoped refactor skill

    The missing piece is often not the skill file itself, but a small verification contract. Without that, a "review" skill and a "debug" skill still degrade into long prompts.

    I put together a tiny example repo showing this structure with a PR-review workflow and a safe-edit workflow:

    https://github.com/MemoAsh/agent-workflow-pack

    The pattern is intentionally simple: background rules in AGENTS.md, task behavior in SKILL.md, and completion criteria in verification.md.

  9. etraut-openai commented on Oct 12, 2026

    @etraut-openai
    Contributor

    You can use skills to provide task-specific instructions, and you can invoke skills using @ or $.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions