Captain your AI with Scrolls, Rules, and Crew - a unified prompt management system for OpenCode.
opencode-captain is a plugin that manages three types of prompt templates:
| Type | Trigger | Behavior | Use Case |
|---|---|---|---|
| Scrolls | //name in messages |
Expand on demand, toast notification | Dynamic workflows, review checklists |
| Rules | Automatic | Silent injection into system prompt | Coding standards, style guides |
| Crew | Config hook | Register as OpenCode agents | Custom agents, specialists, delegates |
Review this auth system like //linus-torvalds and think about it //5-approaches
@backend/auth/service.go
The plugin automatically:
- Detects the
//linus-torvaldsand//5-approachesmentions - Expands them into full content wrapped in
<workflow>tags - Injects any matching rules silently into the system prompt
- Registers crew members as available agents
Scrolls are triggered explicitly with //name syntax in your messages.
| Location | Scope | Priority |
|---|---|---|
.opencode/scrolls/ |
Project | Highest |
.opencode/workflows/ |
Project | Highest |
.opencode/commands/ |
Project | Highest |
~/.config/opencode/scrolls/ |
Global | Lower |
~/.config/opencode/workflows/ |
Global | Lower |
~/.config/opencode/commands/ |
Global | Lower |
Project scrolls override global ones with the same name.
~/.config/opencode/scrolls/my-scroll.md -> //my-scroll
---
description: "Short description of what this scroll does"
shortcuts: [ms, my-s]
tags: [review, check, analyze]
automention: true
onlyFor: [oracle, frontend]
spawnFor: [frontend:expanded]
include: [docs/api-guide.md, shared/common-rules.md]
---
# My Custom Scroll
Instructions for the AI to follow when this scroll is mentioned.
## Step 1
Do this thing...| Field | Type | Description |
|---|---|---|
description |
string | Short description shown in catalog |
shortcuts / aliases |
array | Alternative names to trigger this scroll |
tags |
array | Keywords for auto-suggestion matching |
automention |
true / expanded / false |
Auto-suggestion mode (default: true) |
scrollInScroll |
true / hints / false |
Nested scroll expansion mode (default: false) |
expand |
true / false |
Expand full content on mention or inject hint (default: true) |
onlyFor |
array | Limit visibility to specific agents |
spawnFor |
array | Inject when agent spawns (e.g., [frontend:expanded]) |
include |
array | Files to merge before scroll content (see File Inclusion) |
| Tool | Description |
|---|---|
list_workflows |
List all available scrolls |
fetch_scroll |
Fetch a scroll's content (auto-executes on_load tools) |
get_workflow |
[Deprecated] Alias for fetch_scroll |
create_workflow |
Create a new scroll |
edit_workflow |
Edit an existing scroll |
rename_workflow |
Rename a scroll |
delete_workflow |
Delete a scroll |
reload_workflows |
Reload scrolls from disk |
expand_workflows |
Manually expand //mentions in text |
Rules are automatically injected into the system prompt based on the active agent. They run silently without toast notifications.
| Location | Scope |
|---|---|
.opencode/rules/ |
Project |
.opencode/creeds/ |
Project |
.opencode/code/ |
Project |
~/.config/opencode/rules/ |
Global |
~/.config/opencode/creeds/ |
Global |
~/.config/opencode/code/ |
Global |
~/.config/opencode/rules/typescript-style.md
---
description: "TypeScript coding standards"
onlyFor: [frontend, oracle]
---
# TypeScript Style Guide
- Use `const` over `let` where possible
- Prefer explicit return types on functions
- Use strict null checks| Field | Type | Description |
|---|---|---|
description |
string | Short description |
onlyFor |
array | Only inject for these agents (empty = all agents) |
| Tool | Description |
|---|---|
list_rules |
List all available rules |
get_rule |
Get a specific rule's content |
create_rule |
Create a new rule |
edit_rule |
Edit an existing rule |
delete_rule |
Delete a rule |
reload_rules |
Reload rules from disk |
- On every message, the plugin checks the active agent
- Rules with matching
onlyFor(or noonlyFor) are collected - Rule content is injected into the system prompt
- No toast notification - completely silent
Example: A typescript-style rule with onlyFor: [frontend] only injects when the frontend agent is active.
Crew members are markdown files that define custom agents. They're registered with OpenCode via the config hook and can be invoked using the Task tool.
| Location | Scope |
|---|---|
.opencode/crew/ |
Project |
.opencode/agents/ |
Project |
.opencode/mates/ |
Project |
~/.config/opencode/crew/ |
Global |
~/.config/opencode/agents/ |
Global |
~/.config/opencode/mates/ |
Global |
~/.config/opencode/crew/code-reviewer.md
---
description: "Expert code reviewer"
model: claude-3-opus
temperature: 0.3
tools: [read, glob, grep]
mode: subagent
onlyFor: [oracle]
---
You are an expert code reviewer. Analyze code for:
- Code quality and best practices
- Potential bugs and edge cases
- Performance considerations
- Security vulnerabilities
Be thorough but concise. Provide actionable feedback.| Field | Type | Description |
|---|---|---|
description |
string | Short description shown in agent list |
model |
string | Model to use (e.g., claude-3-opus, gpt-4) |
temperature |
number | Temperature setting (0-1) |
tools |
array | Tools to enable for this agent |
mode |
agent / subagent |
Top-level agent or delegated subagent (default: subagent) |
onlyFor |
array | Only visible to these parent agents |
| Tool | Description |
|---|---|
list_crew |
List all crew members |
get_crew |
Get a crew member's definition |
create_crew |
Add a new crew member |
edit_crew |
Edit a crew member |
delete_crew |
Remove a crew member |
reload_crew |
Reload crew from disk |
- On plugin load, crew files are parsed from
crew/,agents/, ormates/folders - Each crew member is converted to an AgentConfig
- Crew is registered with OpenCode via the
confighook - Agents become available for invocation via the Task tool
Example: Create a frontend-expert crew member, then delegate to it:
Task(agent="frontend-expert", prompt="Review this React component")
Scrolls can include external files that get merged before the scroll content:
---
include: [docs/api-guide.md, shared/security-rules.md]
---
# My Scroll
This content comes after the included files.Path resolution:
- Project-relative:
docs/api-guide.md→<project>/docs/api-guide.md - Scroll-relative:
./sibling.mdor../shared/file.md - Absolute:
C:\Users\shared\file.mdor/home/user/file.md
Cross-platform: Both Windows (\) and Unix (/) path separators work.
Behavior:
- Included files are merged in order, separated by
--- - Missing files produce warnings but don't crash
- Inclusion happens at load time, not runtime
Scrolls with automention enabled are suggested based on message content:
| Mode | Behavior |
|---|---|
automention: true |
AI fetches and applies automatically if relevant |
automention: expanded |
Content injected directly (no fetch needed) |
automention: false |
No auto-suggestion |
Tags support groups, OR alternatives, and phrase matching:
tags: [commit, [staged, changes], patchnote|patchlog]| Tag Type | Example | Triggers When |
|---|---|---|
| Single | commit |
Word present (needs >=2 singles) |
| Group (AND) | [staged, changes] |
ALL words present (triggers immediately) |
| OR | patchnote|patchlog |
ANY word matches |
Scrolls can auto-inject when specific agents spawn:
spawnFor: [frontend:expanded, oracle]Repeated mentions become references:
- First
//linus-torvalds-> full expansion - Second
//linus-torvalds->[use_workflow:linus-torvalds-abc1]
Scrolls can reference other scrolls:
scrollInScroll: trueFor large scrolls, use expand: false to reduce context bloat:
---
expand: false
---When expand: false is set:
- Instead of injecting full
<workflow>content - Injects a hint:
[//name → call fetch_scroll("name") to read] - AI fetches content on-demand when needed
Global toggle: Set expandScrolls: false in captain.json to make all scrolls hint-only by default.
Precedence: Both scroll.expand AND config.expandScrolls must be true for full expansion.
Add to your opencode.json:
{
"plugin": ["opencode-captain"]
}Or for local development:
cd ~/.config/opencode/plugin/opencode-captain
bun install
bun run buildConfig file: ~/.config/opencode/captain.json
{
"deduplicateSameMessage": true,
"maxNestingDepth": 3,
"expandScrolls": true
}| Option | Type | Default | Description |
|---|---|---|---|
deduplicateSameMessage |
boolean | true |
Replace duplicate mentions with references |
maxNestingDepth |
number | 3 |
Max depth for nested scroll expansion |
expandScrolls |
boolean | true |
Global toggle for scroll expansion (when false, all scrolls inject hints) |
All legacy terminology still works:
| Legacy | Current | Status |
|---|---|---|
Order |
Scroll |
✅ Alias |
orders/ |
scrolls/ |
✅ Both recognized |
orderInOrder |
scrollInScroll |
✅ Both parsed |
spawnAt |
spawnFor |
✅ Both parsed |
expandOrders |
expandScrolls |
✅ Both work |
All existing workflow files work as-is. No migration required.
MIT