Thank you for your interest in contributing! This guide will help you add new components to the registry and understand the repository structure.
opencode-agents/
โโโ .opencode/
โ โโโ agent/ # Agents
โ โ โโโ openagent.md # Main orchestrator (always default in PRs)
โ โ โโโ opencoder.md # Development specialist
โ โ โโโ subagents/ # Specialized subagents
โ โโโ prompts/ # Prompt library (variants and experiments)
โ โโโ command/ # Slash commands
โ โโโ tool/ # Utility tools
โ โโโ plugin/ # Integrations
โ โโโ context/ # Context files
โโโ evals/
โ โโโ agents/ # Agent test suites
โ โโโ framework/ # Testing framework
โ โโโ results/ # Test results
โโโ scripts/
โ โโโ prompts/ # Prompt management
โ โโโ tests/ # Test utilities
โโโ docs/
โโโ agents/ # Agent documentation
โโโ contributing/ # Contribution guides
โโโ guides/ # User guides
.opencode/agent/ - Main agent prompts (openagent.md, opencoder.md).opencode/agent/subagents/ - Specialized subagents.opencode/prompts/ - Library of prompt variants for different modelsevals/ - Testing framework and test suitesscripts/ - Automation and utility scriptsdocs/ - Documentation and guides.opencode/agent/*.md) - Main AI agents.opencode/agent/subagents/*.md) - Specialized helpers.opencode/command/*.md) - Slash commands.opencode/tool/*/index.ts) - Utility tools.opencode/plugin/*.ts) - Integrations.opencode/context/**/*.md) - Context filesAll markdown files should include YAML frontmatter:
---
description: "Brief description of what this does"
mode: primary # For agents only
temperature: 0.1 # Optional - for agents only
tools: # For agents only
read: true
edit: true
write: true
permissions: # Optional
bash:
"*": "deny"
---
# Component Name
Your component content here...
Required fields:
description - Brief description (all components)Agent-specific fields:
mode - Agent mode (primary, secondary, etc.)model - AI model to usetemperature - Temperature settingtools - Available toolspermissions - Security permissionsInclude JSDoc comments at the top:
/**
* Tool Name
*
* Brief description of what this tool does
*/
export function myTool() {
// Implementation
}
my-new-agent.mdCreate the component file in the appropriate directory:
# Example: Adding a new agent
touch .opencode/agent/my-new-agent.md
Add frontmatter and content following the structure above
Test your component:
# Validate structure
./scripts/registry/validate-component.sh
Update the registry (automatic on merge to main):
# Manual update (optional)
./scripts/registry/register-component.sh
When adding components, they're automatically categorized:
The auto-registration script assigns categories based on component type and location.
Install locally:
# Test the installer
./install.sh --list
Validate structure:
./scripts/registry/validate-component.sh
Test with OpenCode:
opencode --agent your-new-agent
When you submit a PR, GitHub Actions will:
Important: PRs will fail if agents don't use their default prompts. This ensures the main branch stays stable.
OpenCode uses a model-specific prompt library to support different AI models while keeping the main branch stable.
.opencode/
โโโ agent/ # Active prompts (always default in PRs)
โ โโโ openagent.md
โ โโโ opencoder.md
โโโ prompts/ # Prompt library (model-specific variants)
โโโ openagent/
โ โโโ gpt.md # GPT-4 optimized
โ โโโ gemini.md # Gemini optimized
โ โโโ grok.md # Grok optimized
โ โโโ llama.md # Llama/OSS optimized
โ โโโ TEMPLATE.md # Template for new variants
โ โโโ README.md # Capabilities table
โ โโโ results/ # Test results (all variants)
โโโ opencoder/
โโโ ...
**Architecture:**
- Agent files (`.opencode/agent/*.md`) = Canonical defaults
- Prompt variants (`.opencode/prompts/<agent>/<model>.md`) = Model-specific optimizations
# Test a specific variant
./scripts/prompts/test-prompt.sh openagent sonnet-4
# View results
cat .opencode/prompts/openagent/results/sonnet-4-results.json
Copy the template:
cp .opencode/prompts/openagent/TEMPLATE.md .opencode/prompts/openagent/my-variant.md
Edit your variant:
Test it:
./scripts/prompts/test-prompt.sh openagent my-variant
Update the README:
.opencode/prompts/openagent/README.mdSubmit PR:
my-variant.md).opencode/agent/openagent.mdAll PRs must use default prompts. CI automatically validates this.
Before submitting a PR:
# Ensure you're using defaults
./scripts/prompts/validate-pr.sh
# If validation fails, restore defaults
./scripts/prompts/use-prompt.sh openagent default
./scripts/prompts/use-prompt.sh opencoder default
When a variant proves superior:
Verify test results:
cat .opencode/prompts/openagent/results/variant-results.json
Update agent file (canonical default):
cp .opencode/prompts/openagent/variant.md .opencode/agent/openagent.md
Update capabilities table in README
Commit with clear message:
git add .opencode/agent/openagent.md
git commit -m "feat(openagent): promote variant to default - improved X by Y%"
Note: In the new architecture, agent files are the canonical defaults. There are no default.md files in the prompts directory.
Use conventional commits:
feat: add new agent for Xfix: correct issue in Y commanddocs: update Z documentationchore: update dependenciesprompt: add new variant for X modelInclude:
Example:
## What
Adds a new `database-agent` for managing database migrations.
## Why
Automates common database tasks and ensures migration safety.
## How
- Scans migration files
- Validates migration order
- Runs migrations with rollback support
## Testing
- [x] Validated with `./scripts/registry/validate-component.sh`
- [x] Tested with PostgreSQL and MySQL
- [x] Tested rollback scenarios
If your component depends on others, declare them in the registry:
{
"id": "my-component",
"dependencies": ["tool:env", "agent:task-manager"]
}
The installer will automatically install dependencies.
The registry is automatically updated when:
main branch.opencode/ directoryThe GitHub Action:
registry.jsonYou don't need to manually edit registry.json!
any)set -e for error handling# Use the automated system (recommended)
/create-agent my-agent-name
# Or manually follow the development guide
# See: docs/contributing/DEVELOPMENT.md#creating-new-agents
cd evals/framework
npm test -- --agent=my-agent
# Validate structure
./scripts/registry/validate-component.sh
# Ensure using defaults
./scripts/prompts/validate-pr.sh
# Run tests
cd evals/framework && npm test
# List available components
./install.sh --list
# Validate registry
make validate-registry
# Update registry
make update-registry
# Test a prompt variant
./scripts/prompts/test-prompt.sh openagent my-variant
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing! ๐