Extend agent discovery to the .agents/ directory standard
The
.agents/directory is becoming an open standard for agent-based tools. This plugin lets OpenCode read commands and agents from~/.agents/and.agents/directories, enabling interoperability with other harnesses and cleaner project organization.
OpenCode natively reads from .opencode/ and ~/.config/opencode/. This plugin adds .agents/ as an additional discovery source without overwriting or conflicting with existing config. It merges discovered entries into the OpenCode configuration during session startup.
src/index.ts
├── fallbackSanitization()
├── parseMarkdown()
├── scanDirectory()
├── findProjectDirs()
└── config hook
└── scans ~/.agents/ + .agents/ tree
└── merges commands + agents into cfg
- Discovers command and agent markdown files from
~/.agents/and.agents/directories - Supports
command/,commands/,agent/, andagents/subdirectory naming - Respects existing
.opencode/entries — plugin entries never overwrite native config - Walks up the directory tree from the project root to find parent
.agents/directories - YAML frontmatter support for metadata in markdown files
Add the plugin to opencode.json or opencode.jsonc:
{
"plugin": ["@capybearista/opencode-agents-loader@latest"]
}You can also install it through the CLI:
opencode plugin -g @capybearista/opencode-agents-loader@latest # global install
opencode plugin @capybearista/opencode-agents-loader@latest # project-local installSimply run the following command while no active OpenCode sessions are running:
rm -rf ~/.cache/opencode/packages/'opencode-agents-loader@latest'/The next time you open OpenCode, the new version will be installed!
Create markdown files with YAML frontmatter:
---
name: "My Command"
description: "Does something useful"
---
# Command Body
This is the command content that the agent will process.Place command markdown files in command/ or commands/ subdirectories:
~/.agents/
commands/
hello.md
git/
status.md
.agents/
commands/
project-specific-prompt.md
Place agent markdown files in agent/ or agents/ subdirectories:
~/.agents/
agents/
reviewer.md
architect.md
.agents/
agents/
project-expert.md
Existing config entries from .opencode/ directories always take precedence over .agents/ entries. The plugin only injects entries that do not already exist.
Within .agents/ directories, the closest directory to your project wins. Precedence (highest to lowest):
.opencode/(project-local).agents/closest to project root.agents/parent directories (walking up the tree)~/.config/opencode/(global)~/.agents/(global)
This plugin requires no manual configuration. It works automatically by reading from .agents/ directories.
- If commands or agents don't appear, verify your files end in
.mdand include valid YAML frontmatter - Confirm the directory naming is
commands/orcommand/,agents/oragent/ .opencode/entries always take priority—remove or rename conflicts there first
This package lives in the opencode-plugins monorepo.
- Run
bun run build,bun run typecheck,bun run lint, andbun testbefore opening a PR. - Keep the plugin focused on agent/command discovery from
.agents/directories. - Prefer small, direct changes.
Please open an issue or check for existing ones before creating a pull request.