Skip to content

docs: clarify that project and global AGENTS.md files are combined, not overridden #9282

Closed as not planned

Description

@alanpog

The Rules documentation has an ambiguous "Precedence" section that can mislead users.

Current text

When opencode starts, it looks for rule files in this order:

  1. Local files by traversing up from the current directory (AGENTS.md, CLAUDE.md, or CONTEXT.md)
  2. Global file at ~/.config/opencode/AGENTS.md
  3. Claude Code file at ~/.claude/CLAUDE.md (unless disabled)

The first matching file wins in each category.

Problem

The phrase "first matching file wins" suggests only one file is loaded total. Combined with the "Global" section saying users can put "personal rules" there, users may believe:

  • Having a project-level AGENTS.md will override their global one
  • They need to choose between project or global rules

Actual behavior

Looking at packages/opencode/src/session/system.ts, both local AND global files are loaded and combined:

  1. Local category: first filename found wins (AGENTS.md > CLAUDE.md > CONTEXT.md)
  2. Global category: first filename found wins (~/.config/opencode/AGENTS.md > ~/.claude/CLAUDE.md)
  3. Both categories are combined — files are concatenated with newlines in the system prompt

Suggested fix

Clarify that:

  • "First wins" applies to filename variants within each category, not across categories
  • Both project-level and global rules are loaded together
  • The order in the prompt is: project rules first, then global rules

Activity

  1. berenar commented on Jan 18, 2026

    @berenar
    Contributor

    Agree, it's not clear

  2. mrclrchtr commented on Jan 25, 2026

    @mrclrchtr

    Yes, please update the docs - I also can't figure out exactly whether the CLAUDE.md pattern from claude code is used with “loading subdir CLAUDE.md files when working with files in the directory”. That would be super interesting!

  3. added a commit that references this issue on Feb 19, 2026
    807acb5
  4. jstasiak commented on Feb 19, 2026

    @jstasiak

    #14330 addresses this problem.

  5. ggbondg commented on Mar 18, 2026

    @ggbondg

    agree +1, if conflict, project rules should override the global rule.

  6. github-actions commented on Jul 6, 2026

    @github-actions
    Contributor

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

  7. xmontero commented on Aug 5, 2026

    @xmontero

    I can't get why this has been marked as "not planned".

    a) Shoudn't the documentation reflect the actual behaviour?
    b) Is the public documentation also versioned in git?
    c) May we open an issue on the documentation repo if it exists, link to there and change the tag from "not planned" to "see there in the other place"?

    PD:
    xref'd here #9287 (comment)

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