Skip to content

Automatically load @ referenced files in AGENTS.md into context #2225

Closed

Description

@tobias-walle

First of all, thank you for this great project. I really enjoy using it, and it is amazing how fast you improve it!

Claude Code has the very nice feature that you can reference other files using @ in your CLAUDE.md, and it is automatically loaded into the session. This is very helpful to split rules into multiple files or to directly load core files (like the package.json) in every session. With this feature, a minimal instruction file can then look like this:

# Instructions

-  Avoid excessive comments.
-  Prefer a functional approach over classes.
-  Create reusable functions to keep the code clean and readable.

## Relevant Files

-  @./README.md
-  @./package.json
-  @./tsconfig.json
-  @./docs/bun.md

Unfortunately, OpenCode currently doesn't have the same behaviour with AGENTS.md.

It would be great if this could be added and would increase the consistency with the newly added commands feature.

I could also help with a contribution if that would support you.

Activity

  1. rekram1-node commented on Aug 24, 2025

    @rekram1-node
    Collaborator

    I tend to agree, especially to be consistent

  2. mannp commented on Sep 21, 2025

    @mannp

    First of all, thank you for this great project. I really enjoy using it, and it is amazing how fast you improve it!

    I agree, thanks to the devs 👍🏻

    I am struggling to get AGENTS.md loaded into content for the project at all, never mind the referenced files.

    Is just autoloading AGENTS.md already supported?

  3. rekram1-node commented on Sep 21, 2025

    @rekram1-node
    Collaborator

    @mannp AGENTS.md is automatically loaded. Where is the file located?, where are you running opencode?

  4. mannp commented on Sep 21, 2025

    @mannp

    @mannp AGENTS.md is automatically loaded. Where is the file located?, where are you running opencode?

    Hi @rekram1-node it is the root of my project folder where I run opencode. These are the first lines of the file;

    ---
    trigger: always_on
    ---
    
    # 🤖 Agents Configuration - NixOS Configuration Project
    
    ## Overview
    
    This document outlines the AI agents used in this comprehensive NixOS
    configuration flake with custom packages, modules, and development tools. All
    agents must adhere to the development rules and guidelines specified below.
    
    ## 📚 Reference Documentation
    
    - **[README Generator Guide](./docs/guides/readme-generator.md)** - Professional
      README.md generation using Best-README-Template structure  
    .......
    

    I have been using Grok Code Fast 1 model.

    opencode -v
    0.10.4

    
    Edited: removed comments on original op request as they seemed to be confusing to others.
    
  5. rekram1-node commented on Sep 21, 2025

    @rekram1-node
    Collaborator

    I have tried loading roles using mods

    Not really sure what this means

    Edit: mmh this seems it might be a claude thing, maybe 'command' is the opencode option here.

    Not really following here either...

    Are you asking about AGENTS.md? Or slash commands?

  6. mannp commented on Sep 21, 2025

    @mannp

    Are you asking about AGENTS.md? Or slash commands?

    I am asking for the ops request and merely commented that my AGENTS.md isn't loaded on startup.

  7. mlanza commented on Dec 1, 2025

    @mlanza

    Hi team! I wanted to share some observations about how AGENTS.md and instruction files are being loaded that might help inform this feature request.

    I've noticed that while both project and global AGENTS.md files are definitely being read (I can see evidence of their content influencing responses), there seems to be inconsistent behavior with files specified in the instructions property of opencode.json.

    My understanding is that these files are likely provided to the model in some kind of initial brief, but whether the model actually chooses to read their content appears to be left up to its discretion. This creates some uncertainty about what context is actually available.

    I've been experimenting with progressive disclosure - I don't want everything eager-loaded, but I do need a guaranteed minimum amount of context for consistent operations. I've spent several hours trying to tweak configurations to get reliable loading, and while I can always coax the model into reading the intended files, I don't understand why this coaxing is necessary.

    What I'm hoping for is a way to force-feed certain essential rules files into the start of every new session, ensuring a baseline level of context is always available. The @ referencing approach directly in AGENTS.md files could work beautifully for this.

    Thank you for all your hard work on this project - it's improving at an amazing clip!

  8. phall1 commented on Jan 10, 2026

    @phall1

    What would be great is if there was a slash command that just showed you what instruction filed were loaded

  9. gavar commented on Jan 20, 2026

    @gavar

    loading reference files with @ syntax is much needed, the only thing I see is that the IDE does not recognize these as paths and may not refactor correctly if the file is moved. If we can use .md links with spectial prefix like [@filename](./path/to/file)] that would be much better for bigger projects IMO

  10. duckytan commented on Feb 13, 2026

    @duckytan

    补充一个实际使用场景:子项目规则继承

    我有这样一个需求:

    场景:

    • 父项目:my-workspace(包含完整的 AGENTS.md 规则)
    • 子项目:my-workspace/projects/learning-agent(学习项目的专属规则)

    当前问题:
    在子项目创建 CLAUDE.md 时,只能手动复制父项目的规则。如果父项目规则更新,子项目无法自动同步,导致规则不一致。

    期望的解决方案:
    在子项目的 CLAUDE.md 中能够引用父项目的规则文件,例如:

    # 子项目规则
    @../AGENTS.md  <!-- 引用父项目规则 -->
    
    ## 子项目专属规则
    ...

    这样父项目规则更新时,子项目自动生效,无需手动同步。

    这个需求与 Issue #6316(目录自动发现)也高度相关,希望能够优先实现层级规则继承机制。

  11. github-actions commented on Apr 15, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

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