Skip to content

feat(opencode): load .opencode/AGENTS.md instructions#12096

Open
skabillium wants to merge 6 commits intoanomalyco:devfrom
skabillium:feat/local-agents-md
Open

feat(opencode): load .opencode/AGENTS.md instructions#12096
skabillium wants to merge 6 commits intoanomalyco:devfrom
skabillium:feat/local-agents-md

Conversation

@skabillium
Copy link
Copy Markdown

@skabillium skabillium commented Feb 4, 2026

What does this PR do?

Closes #11454

Adds support for loading project rules from .opencode/AGENTS.md in addition to the existing local rule-file resolution.

  • Local rule discovery still traverses upward to find the first matching rule file among AGENTS.md, CLAUDE.md, and (deprecated) CONTEXT.md.
  • Any .opencode/AGENTS.md files found via upward traversal are loaded in addition to the local rule file above.
  • Documentation is updated to reflect .opencode/AGENTS.md and the local precedence behavior.

Why?

Allows projects to keep OpenCode-specific instructions in a dedicated .opencode/ folder without replacing existing AGENTS.md/CLAUDE.md usage.

How did you verify your code works?

  • Added tests for loading both AGENTS.md + .opencode/AGENTS.md, and for loading only .opencode/AGENTS.md when AGENTS.md is absent.
  • Ran: bun test test/session/instruction.test.ts (from packages/opencode)
  • Ran the project locally to verify

Notes

  • Only affects project-local rule loading; global rule precedence is unchanged.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 4, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 4, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

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`)
1. **Local files** by traversing up from the current directory (`AGENTS.md`, `CLAUDE.md`, `CONTEXT.md`) plus `.opencode/AGENTS.md`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer not documenting CONTEXT.md it is deprecated and will be removed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rekram1-node sure, should I remove other mentions of it in the file?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Support .opencode/AGENTS.md for environment-specific instructions

2 participants