subagents
Tool for searching, listing, and fetching subagents from the local filesystem. Allows browsing available subagents, searching by keywords, and retrieving full definitions from $HOME/.config/opencode/agents/.
SKILL.md
| Name | subagents |
| Description | Tool for searching, listing, and fetching subagents from the local filesystem. Allows browsing available subagents, searching by keywords, and retrieving full definitions from $HOME/.config/opencode/agents/. |
name: subagents description: Tool for searching, listing, and fetching subagents from the local filesystem. Allows browsing available subagents, searching by keywords, and retrieving full definitions from $HOME/.config/opencode/agents/.
Subagents Local Catalog Tool
Manage and access subagents from the local filesystem. Scans $HOME/.config/opencode/agents/ for agent definitions and provides browsing, searching, and fetching capabilities.
The Job
- Receive user request for subagent operations (list, search, fetch)
- Scan local filesystem for agent definitions
- Parse YAML frontmatter and extract metadata
- Filter and format results as requested
- Return formatted results to the user
Important: All operations use local filesystem access - no network requests required.
Step 1: Parse User Request
Identify the operation type:
- list: Show all categories and their subagents
- search <query>: Find subagents matching keywords in name or description
- fetch <name>: Get the full markdown content for a specific subagent
Step 2: Scan Local Agent Directory
- Check for agents directory: Use glob with absolute path:
globwithpath="$HOME/.config/opencode/agents"andpattern="*.md" - Handle missing directory: If no agents found, provide helpful setup instructions
- Parse agent files: For each .md file found, use read to extract:
- YAML frontmatter (name, description, tools, category)
- Filename for categorization (backend-, frontend-, devops- prefixes)
Frontmatter Extraction Pattern
Use read to get file contents, then parse YAML between --- markers:
---
name: backend-developer
description: Senior backend engineer for scalable APIs
tools: postgresql_execute_query, jira_search_issues
---
Categorization Logic
Extract category from filename prefixes:
backend-*→ Backend Developmentfrontend-*→ Frontend Developmentdevops-*→ DevOps & Infrastructureqa-*→ Quality & Testingsecurity-*→ Securitydata-*→ Data & Analyticsui-*→ UI/UX Designmobile-*→ Mobile Developmentcloud-*→ Cloud & Platformdocs-*→ Documentation- Other → General
Step 3: Process Request
For List Operation
- Collect all agent files using glob
- Group by category using filename prefix logic
- Format organized list by categories:
## Backend Development
- backend-developer: Senior backend engineer for scalable APIs
- database-architect: Database design and optimization expert
## Frontend Development
- frontend-developer: React/Vue/Angular specialist
- ui-designer: User interface and experience designer
...
For Search Operation
- Use grep to search agent files for keywords in:
- Names (filename and frontmatter name field)
- Descriptions (frontmatter description field)
- Tools (frontmatter tools field)
- Return matches with category context:
Found 3 matching subagents:
## Security-Related Subagents
- security-engineer (Infrastructure): Security specialist for cloud infrastructure
- security-auditor (Quality): Security vulnerability assessment expert
- backend-security (Backend): API security and authentication specialist
For Fetch Operation
- Find exact match for requested name using glob pattern
*{name}*.md - Use read to return full file content including frontmatter and body
- If not found, suggest similar names using partial matches
Output Format
- Use markdown formatting for readability
- Include category names for organization
- Show brief descriptions in lists
- Return full content for fetches
- Include tool lists for context
Error Handling
No Agents Directory Found
❌ No subagents found in $HOME/.config/opencode/agents/
To set up subagents:
1. Create the directory: mkdir -p $HOME/.config/opencode/agents
2. Add agent definition files as .md files with YAML frontmatter
3. Example agent file:
---
name: backend-developer
description: Senior backend engineer for scalable APIs
tools: postgresql_execute_query, jira_search_issues
---
# Backend Developer
Expert in building scalable backend systems...
No Search Results
❌ No subagents found matching "keyword"
💡 Try these alternatives:
- Search for different keywords
- Use `/subagents list` to see all available agents
- Check for typos in your search query
Agent Not Found for Fetch
❌ Subagent "agent-name" not found
💡 Did you mean:
- similar-agent-name (Backend Development)
- agent-name-alt (Infrastructure)
Use `/subagents list` to see all available agents.
Examples
List all subagents:
## Backend Development
- backend-developer: Senior backend engineer for scalable APIs
Tools: postgresql_execute_query, jira_search_issues
- database-architect: Database design and optimization expert
Tools: postgresql_execute_query
## Frontend Development
- frontend-developer: React/Vue/Angular specialist
Tools: chrome_click, chrome_fill, playwright_browser_evaluate
Search for "security":
Found 3 matching subagents:
## Security-Related Subagents
- security-engineer (Infrastructure): Security specialist for cloud infrastructure
File: security-engineer.md
Tools: jira_search_issues, bash
- security-auditor (Quality): Security vulnerability assessment expert
File: qa-security-auditor.md
Tools: jira_search_issues, grep
Fetch backend-developer:
# Backend Developer
---
name: backend-developer
description: Senior backend engineer for scalable APIs
tools: postgresql_execute_query, jira_search_issues
category: backend
---
## Overview
Expert in building scalable backend systems with focus on API design, database architecture, and performance optimization.
## Capabilities
- Database design and optimization
- API development and documentation
- Performance troubleshooting
- Security best practices
- System architecture design
## Tools Available
- PostgreSQL database operations
- Jira issue tracking and management
- Code review and analysis
- Deployment automation
## Usage
Perfect for tasks involving backend development, database work, and API design.
File Structure Requirements
Agents should be stored as .md files in $HOME/.config/opencode/agents/ with:
-
YAML Frontmatter with required fields:
name: Human-readable agent namedescription: Brief description of capabilitiestools: Comma-separated list of available toolscategory(optional): Override auto-categorization
-
Filename following naming convention:
- Use hyphens for spaces:
backend-developer.md - Include category prefix for auto-categorization:
backend-,frontend-, etc.
- Use hyphens for spaces:
-
Markdown Body with sections like:
- Overview
- Capabilities
- Usage examples
- Tool documentation