Skip to content

Import/reference support #11

Open
Open

Description

@jsit

With this feature, paths can be listed within a rules file to specify dependencies.

  • These referenced files get added to context whenever the rules file is in context
  • Both relative and absolute paths are supported
  • Example: If naming-conventions.mdc mentions @personality.mdc, the personality file gets included whenever the naming conventions file is
  • Dependencies can't be removed from context independently -- @personality.mdc can't be removed from context until naming-conventions.mdc is removed.

Prior art

Activity

  1. joserprieto commented on Aug 20, 2025

    @joserprieto

    Great timing! Just posted about a similar modular approach on LinkedIn.

    I've been using this pattern with Claude Code for months - the import functionality is a game changer for maintaining complex contexts.

    Happy to share implementation patterns and real-world usage examples.

    LinkedIn post:

    https://www.linkedin.com/posts/joserprieto_manage-claudes-memory-activity-7364033253990719490-944Y

  2. PaulRBerg commented on Oct 3, 2025

    @PaulRBerg

    Until OpenAI adds this (super important) feature to AGENTS.md and Codex CLI, you can use my Python script to flatten Markdown files that use Claude’s @foo.md file-reference syntax:

    https://gist.github.com/PaulRBerg/3c78def758cec459b987f6968c8e018d

  3. allenhutchison commented on Oct 31, 2025

    @allenhutchison

    I'm a maintainer on Gemini CLI. We're exploring the option of making AGENTS.md our standard context file but we have an import feature with @ style references in GEMINI.md. I'd love to see an equivalent reference feature added to the AGENTS.md standard. This would make it much easier for us to support AGENTS.md by default. Issue in our repo that is tracking this: google-gemini/gemini-cli#12345

  4. joserprieto commented on Nov 13, 2025

    @joserprieto

    There are workarounds to achieve include-like functionality with AGENTS.md:

    1. File references in AGENTS.md
    ## Core Context
    You MUST read the following files:
    - @./core-conventions.md
    - @./domain-rules.md
    1. Directory-based isolation
      /project
        /.ai/AGENTS.md          # Generic instructions
        /contexts/backend/AGENTS.md  # Backend-specific
        /contexts/frontend/AGENTS.md # Frontend-specific
    

    Navigate agents to specific directories; their AGENTS.md is loaded automatically.

    Not perfect, but functional with most agents.

  5. illeatmyhat commented on Nov 20, 2025

    @illeatmyhat

    I'm primarily interested in this feature being standardized in order to support LLM-driven dynamic rewriting of files imported by the AGENTS.md.
    AGENTS.md files are currently hand-written, but LLMs have a tendency to collapse large volumes of text. To support maintaining both domains (strict adherence to a hand-written policy and general advice produced by an LLM), references to other files are needed, so that the LLM can freely mess up specific imported segments but not affect others.

  6. Wolfe-Jam commented on Dec 30, 2025

    @Wolfe-Jam
  7. codethief commented on Mar 10, 2026

    @codethief

    @PaulRBerg Regarding the screenshot you posted: Note that Claude Code does not naively inject the referenced file's content in-place but it probably appends the files to the context with appropriate delimiters and labeling. Otherwise, the examples from https://code.claude.com/docs/en/common-workflows#reference-files-and-directories that include inline references would not work as expected.

    You can reference multiple files in a single message (for example, “@file1.js and @file2.js”)

    Here, @file1.js and @file2.js in CLAUDE.md likely induces a prompt like

    --- BEGINNING of file: CLAUDE.md ---
    […]
    @file1.js and @file2.js
    […]
    --- END of file: CLAUDE.md ---
    
    --- BEGINNING of file: file1.js ---
    <file contents>
    --- END of file: file1.js --
    
    --- BEGINNING of file: file2.js ---
    <file contents>
    --- END of file: file2.js --
    
  8. Pjrich1313 commented on Mar 10, 2026

    @Pjrich1313
  9. ysysimon commented on Mar 19, 2026

    @ysysimon

    Has this feature not been standardized yet?

    It seems very useful for partial overrides. A common use case would be developer-private agent instructions, similar to how projects often use .env plus .env.production / .env.local style layering.

    For example, a repository may want to keep a shared AGENTS.md, while individual developers may want to append or override only a small subset of instructions for their own machine, shell, or workflow, without replacing the entire file.

    @-style references (or any equivalent modular include / layering mechanism) seem like a very natural solution for this. Is there already a plan to make this part of the standard, rather than something only supported by specific implementations?

  10. MisaoDev commented on May 5, 2026

    @MisaoDev

    I was already using this with CLAUDE.md and to my surprise it's not standard for AGENTS.md. This is an extremely useful feature for local overrides and to keep your context organized.

  11. Aric5301 commented on Oct 20, 2026

    @Aric5301

    Hi @romainhuet @dkundel, following up on this since it's been open for over a year and keeps coming up (#9 and #71 both reference it).

    Several AGENTS.md consumers already implement @path imports in practice: Claude Code, OpenCode, Amp, and Zed. Others, like Codex, don't document any import mechanism: per the Codex docs, AGENTS.md files are concatenated as-is, so @ references aren't expanded. That means a repo that relies on imports today gets different context depending on which agent reads it, which undercuts the cross-tool goal of the format.

    Now that the project has a Technical Charter under AAIF, could you share whether import/reference support is on the roadmap for the spec? In particular:

    • Is there an agreed direction on syntax (@path vs. something else) and semantics (inline vs. appended, relative path base, recursion limits)?
    • Where are spec changes like this being discussed and decided now?

    @allenhutchison, is this still blocking Gemini CLI from defaulting to AGENTS.md (google-gemini/gemini-cli#12345)? A concrete implementer requirement would help scope it.

  12. Pjrich1313 commented on Oct 21, 2026

    @Pjrich1313
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions