Skip to content

[FEATURE]: Make .opencode/AGENTS.md the standard location for project instructions #48601

Open

Description

@collinsezedike
  • I have verified this feature I'm about to request hasn't been suggested before.

Every other piece of project-local OpenCode configuration lives inside .opencode/: custom agents at .opencode/agent/, commands at .opencode/command/, plus skills/, plugins/, themes/, and tool/. Project instructions are the one exception still forced to sit at the repository root instead of inside that existing convention, in packages/opencode/src/session/instruction.ts, instructionFiles only ever looks at AGENTS.md/CLAUDE.md next to the project root.

Make .opencode/AGENTS.md the standard location OpenCode looks for first, with the current root-level AGENTS.md treated as the fallback for projects that haven't adopted the new location, not the other way around. This matters because project instructions frequently carry content someone doesn't want in a shared repository, ported personal preferences, working notes, disclosure-sensitive decisions, and putting the standard location inside the directory OpenCode already treats as its own local config namespace means a project's existing .opencode/.gitignore can cover it the same way it already covers other local-only OpenCode state. Right now the only way to keep a root AGENTS.md untracked is a workaround entirely outside OpenCode, a global git excludes file, or editing that repo's own .gitignore, which is awkward for anyone only contributing to a project rather than owning it.

If both .opencode/AGENTS.md and a root AGENTS.md exist, both should be loaded and concatenated as instructions rather than one silently winning. A root AGENTS.md is often also carrying OpenCode's own /init-generated codebase analysis, which is a different kind of content from hand-maintained or ported instructions and there's no reason a project can't have both, one for machine-generated codebase context, one for the standard-location instructions, at the same time.

For every existing project with only a root AGENTS.md and no .opencode/AGENTS.md, behavior is unchanged, current root-level discovery keeps working exactly as it does today.

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed request, @collinsezedike! In short, you'd like OpenCode to also load project instructions from .opencode/AGENTS.md, together with any root AGENTS.md, so local-only instructions can sit in the .opencode/ directory and be gitignored there. Maintainers will consider it.

    One note: the file you mention (packages/opencode/src/session/instruction.ts) is from OpenCode v1 (opencode-ai, 0.x/1.x). In v2 (@opencode/cli, 2.x), instruction loading is in packages/core/src/config/plugin/instruction.ts. It works the same way: it collects AGENTS.md files walking up from your working directory to the project root.

    In the meantime, v2 can do this through config. It reads .opencode/opencode.json as project config, and the instructions setting takes paths relative to the project:

    {
      "$schema": "https://opencode.ai/config.json",
      "instructions": [".opencode/AGENTS.md"]
    }

    With that, .opencode/AGENTS.md is loaded in addition to any root AGENTS.md. Both files can be listed in .opencode/.gitignore, or in the repo's own .git/info/exclude, which is per-clone and never committed, so it also works when you only contribute to a project.

    I couldn't search for related issues this time, so I can't confirm whether this has been suggested before.

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