agents.md icon indicating copy to clipboard operation
agents.md copied to clipboard

Import/reference support

Open jsit opened this issue 4 months ago • 5 comments

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

  • Claude Code's imports: https://docs.anthropic.com/en/docs/claude-code/memory#claude-md-imports
  • Cursor's file references: https://docs.cursor.com/en/context/rules#rule-anatomy
  • Zed's includes: https://zed.dev/docs/ai/text-threads#slash-commands-in-rules
  • Amp Code's includes: https://ampcode.com/manual#AGENTS.md

jsit avatar Aug 20 '25 12:08 jsit

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

joserprieto avatar Aug 20 '25 20:08 joserprieto

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

PaulRBerg avatar Oct 03 '25 18:10 PaulRBerg

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: https://github.com/google-gemini/gemini-cli/issues/12345

allenhutchison avatar Oct 31 '25 16:10 allenhutchison

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.

joserprieto avatar Nov 13 '25 15:11 joserprieto

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.

illeatmyhat avatar Nov 20 '25 18:11 illeatmyhat