agentleFS
wesammustafawesammustafa/opencode-primer/docs/agents.md

opencode-primer

AGENTS.md397 starsChanged 5 months agoMITView on GitHub

Custom agents let you bake a role, model choice, and permission profile into a markdown file. They show up in the Tab cycle (primary) or as @mentions (subagent). Five OpenCode-built-in agents you should know: Hit Tab to cycle primaries. Use @<name> in your prompt to invoke a subagent. Two locations, same format: 🆕 File-based agent loading is GA as of v1.16. Scaffold one interactively with opencode agent create (it prompts for location, description, mode, and permissions), or just write the…

  • Deletes or force-pushes
  • Commits and pushes
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

We split this agents.md into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Only description is effectively required — mode is optional and defaults to all.

    line 75
  2. Distinctive:

    Use this to keep an agent productive (no constant prompting for safe reads) while still gating destructive commands.

    line 131
  3. Very specific:

    Read-only, cheap model — @scout-replacement scoped to a specific knowledge area.

    line 215

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
agents.md

Agents — Custom Agents & Subagents

Custom agents let you bake a role, model choice, and permission profile into a markdown file. They show up in the Tab cycle (primary) or as @mentions (subagent).

The agent zoo

Five OpenCode-built-in agents you should know:

NameModeToolsReach for it when…
buildprimary (default)AllDefault daily-driver — implementation, refactors
planprimaryedit & bash set to "ask"Read-only-ish analysis — exploration, design
generalsubagentAll minus todowriteBig sub-tasks you want isolated from main context
exploresubagentread, grep, glob, list"Where is X?" code search
scoutsubagentwebfetch, websearch, + read toolsExternal docs and dependency research

Hit Tab to cycle primaries. Use @<name> in your prompt to invoke a subagent.

Custom agents — file format

Two locations, same format:

ScopePath
Project.opencode/agents/<name>.md
Global~/.config/opencode/agents/<name>.md

🆕 File-based agent loading is GA as of v1.16. Scaffold one interactively with opencode agent create (it prompts for location, description, mode, and permissions), or just write the markdown by hand.

---
description: Senior frontend engineer — Tailwind + React + TypeScript expert
mode: all
model: anthropic/claude-sonnet-5
temperature: 0.2
permission:
  edit: allow
  bash:
    "*": "ask"
    "pnpm test*": "allow"
    "pnpm lint*": "allow"
    "git status*": "allow"
  webfetch: deny
tools:
  websearch: false
---

You are a senior frontend engineer. Specifics:
- Use Tailwind for styling. Reach for CSS modules only when Tailwind can't express it.
- Components are TypeScript with named exports and explicit Props types.
- Tests use Vitest + @testing-library/react.
- Match existing patterns in `src/components/Button/` for new components.

Frontmatter keys

Verified against the config JSON schema's AgentConfig:

KeyTypePurpose
descriptionstringShown in /agents and surfaced to the LLM
modeprimary | subagent | allHow the agent can be invoked
modelprovider/model-idPer-agent model override
temperature · top_pnumberSampling controls
permissionobjectPer-tool allow/ask/deny (see below)
toolsobjectDeprecated — prefer permission. Boolean per tool — {"websearch": false}
prompt (JSON form only)stringSystem prompt; alternative to markdown body
stepsnumberMax agentic iterations before a forced text-only response
maxStepsnumberDeprecated — use steps.
disablebooleanDisable an agent entirely
hiddenbooleanHide from the UI but keep available
colorstringUI accent color
variant · optionsstring · objectModel variant + per-provider options

Only description is effectively required — mode is optional and defaults to all.

Filename → agent name

The filename (minus .md) becomes the agent name. security-auditor.md → @security-auditor.

Naming rules: lowercase, alphanumeric, hyphens. No spaces, no underscores.

Mode reference

modeWhere it appearsUse when
primaryTab cycle alongside build/planA persistent role you'll inhabit for hours
subagent@<name> mentions, task toolA focused helper for a specific sub-task
allBothYou want flexibility (most custom agents)

Permission model

Permission keys (verified against PermissionConfig in the config JSON schema):

KeyTools / behavior gated
readread tool
editwrite, edit, apply_patch
bashshell — supports glob-pattern overrides
glob · grep · listsearch and listing
taskspawning subagents
todowritethe in-session todo list
questionthe question tool
external_directoryfiles outside the project root
webfetch · websearchnetwork access
lsplanguage server tools
skillagent skill loading
doom_looprunaway-loop safeguards

Three values everywhere: "allow" (no prompt) · "ask" (prompt user) · "deny" (block).

Glob-pattern bash

The bash key can be a single value or a glob-map. Order matters: rules are matched in order and the last matching rule wins, so put the catch-all * first and the more specific overrides after it.

{
  "permission": {
    "bash": {
      "*": "ask",
      "git status*": "allow",
      "git diff*": "allow",
      "pnpm test*": "allow",
      "git push --force*": "deny",
      "rm -rf*": "deny"
    }
  }
}

Use this to keep an agent productive (no constant prompting for safe reads) while still gating destructive commands.

Choosing a model per agent

{
  "agent": {
    "explore":      { "model": "opencode/qwen3.6-plus" },
    "scout":        { "model": "opencode/qwen3.6-plus" },
    "plan":         { "model": "opencode/claude-opus-4-8" },
    "build":        { "model": "opencode/claude-sonnet-4-6" },
    "deep-thinker": { "model": "openai/gpt-5", "options": { "reasoningEffort": "high" } }
  }
}

If unspecified:

  • Primary agents inherit the global model.
  • Subagents inherit the model from whatever agent invoked them.

Tools per agent

⚠️ The tools map is deprecated in favor of the permission field (set a tool to "deny" to disable it). It still works and remains the simplest way to gate MCP tools by glob, but prefer permission for new configs.

The tools map enables/disables individual tools by name, including MCP tools (use glob patterns):

{
  "agent": {
    "doc-writer": {
      "tools": {
        "bash": false,
        "edit": true,
        "websearch": false,
        "github_*": false
      }
    }
  }
}

Note: tools is independent from permission. A tool can be enabled but still require "ask" per the permission map.

Patterns

Read-only reviewer

A subagent that reviews diffs but never writes. See specialized-agents/system-prompts/code-reviewer-prompt.md for the full prompt.

---
description: Reviews code without modifying files
mode: subagent
permission:
  edit: deny
  bash:
    "*": "ask"
    "git diff*": "allow"
---

Specialist primary

A daily-driver agent with a baked-in role. Different model, different prompt, different defaults.

---
description: Backend engineer — TypeScript, Postgres, REST
mode: primary
model: anthropic/claude-sonnet-5
permission:
  bash:
    "*": "ask"
    "pnpm test*": "allow"
    "pnpm typecheck*": "allow"
    "psql*": "deny"
---

You're a backend engineer working on this monorepo's API…

Cheap research subagent

Read-only, cheap model — @scout-replacement scoped to a specific knowledge area.

---
description: Looks up React Router v7 patterns and idioms
mode: subagent
model: opencode/qwen3.6-plus
permission:
  edit: deny
  bash: deny
---

Drop-in specialists

This repo ships 7 production-ready prompts in specialized-agents/ — backend, frontend, code reviewer, security reviewer, tech lead, database, and UX. Copy any of them to .opencode/agents/<name>.md to use as a starting point.

📚 Full agent reference: opencode.ai/docs/agents.


Last reviewed: 2026-07-05 · Canonical source: opencode.ai/docs/agents.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.