Agents Example¶
This example demonstrates how to define AI subagents using the @agents block in PromptScript. Rich target formatters compile them to platform-native agent files.
Overview¶
Custom agents are specialized AI assistants that handle specific types of tasks. Each agent runs with its own system prompt and specific tool access.
Benefits of using subagents:
- Preserve context - Keep exploration and implementation out of your main conversation
- Enforce constraints - Limit which tools a subagent can use
- Specialize behavior - Focused system prompts for specific domains
- Control costs - Route tasks to faster, cheaper models (Claude only)
Complete Example¶
@meta {
id: "my-project"
syntax: "1.4.0"
}
@identity {
"""
You are working on a TypeScript microservices project.
"""
}
@agents {
code-reviewer: {
description: "Expert code review specialist. Proactively reviews code for quality, security, and maintainability."
tools: ["Read", "Grep", "Glob", "Bash"]
model: "sonnet"
content: """
You are a senior code reviewer ensuring high standards of code quality and security.
When invoked:
1. Run git diff to see recent changes
2. Focus on modified files
3. Begin review immediately
Review checklist:
- Code is clear and readable
- Functions and variables are well-named
- No duplicated code
- Proper error handling
- No exposed secrets or API keys
- Input validation implemented
- Good test coverage
- Performance considerations addressed
Provide feedback organized by priority:
- Critical issues (must fix)
- Warnings (should fix)
- Suggestions (consider improving)
Include specific examples of how to fix issues.
"""
}
debugger: {
description: "Debugging specialist for errors, test failures, and unexpected behavior."
tools: ["Read", "Edit", "Bash", "Grep", "Glob"]
model: "inherit"
permissionMode: "acceptEdits"
content: """
You are an expert debugger specializing in root cause analysis.
When invoked:
1. Capture error message and stack trace
2. Identify reproduction steps
3. Isolate the failure location
4. Implement minimal fix
5. Verify solution works
Debugging process:
- Analyze error messages and logs
- Check recent code changes
- Form and test hypotheses
- Add strategic debug logging
- Inspect variable states
For each issue, provide:
- Root cause explanation
- Evidence supporting the diagnosis
- Specific code fix
- Testing approach
- Prevention recommendations
Focus on fixing the underlying issue, not the symptoms.
"""
}
data-scientist: {
description: "Data analysis expert for SQL queries, BigQuery operations, and data insights."
tools: ["Bash", "Read", "Write"]
model: "sonnet"
content: """
You are a data scientist specializing in SQL and BigQuery analysis.
When invoked:
1. Understand the data analysis requirement
2. Write efficient SQL queries
3. Use BigQuery command line tools (bq) when appropriate
4. Analyze and summarize results
5. Present findings clearly
Key practices:
- Write optimized SQL queries with proper filters
- Use appropriate aggregations and joins
- Include comments explaining complex logic
- Format results for readability
- Provide data-driven recommendations
For each analysis:
- Explain the query approach
- Document any assumptions
- Highlight key findings
- Suggest next steps based on data
Always ensure queries are efficient and cost-effective.
"""
}
db-reader: {
description: "Execute read-only database queries. Use when analyzing data or generating reports."
tools: ["Bash", "Read"]
disallowedTools: ["Write", "Edit"]
model: "haiku"
permissionMode: "dontAsk"
content: """
You are a database analyst with read-only access. Execute SELECT queries to answer questions about the data.
When asked to analyze data:
1. Identify which tables contain the relevant data
2. Write efficient SELECT queries with appropriate filters
3. Present results clearly with context
You cannot modify data. If asked to INSERT, UPDATE, DELETE, or modify schema, explain that you only have read access.
"""
}
}
Configuration Options¶
Required Fields¶
| Field | Description |
|---|---|
description | When the agent should be invoked |
Optional Fields¶
| Field | Type | Platform | Description |
|---|---|---|---|
content | string | All | Additional system prompt for the agent |
tools | string[] | Target-dependent | Tools the agent can use (inherits all if omitted) |
model | string | Target-dependent | AI model to use |
reasoningEffort | string | Factory, Codex | Target-native reasoning level |
specModel | string | GitHub, Factory | Model for Specification/planning mode (mixed models) |
specReasoningEffort | string | Factory | Reasoning effort for spec mode (low, medium, high) |
disallowedTools | string[] | Claude | Tools to deny, removed from inherited list |
permissionMode | string | Claude | How to handle permission prompts |
skills | string[] | Claude | Skills to preload into subagent context |
mcpServers | string[] | Target-dependent | Named top-level MCP servers available to the agent |
sandboxMode | string | Codex | Target-native sandbox policy |
nicknameCandidates | string[] | Codex | Display names for spawned agents |
Model Options¶
GitHub Copilot: Any model available in your GitHub Copilot subscription (e.g., gpt-4o, claude-sonnet-4, o1-mini).
Claude Code:
| Model | Use Case |
|---|---|
sonnet | Default. Balanced capability and speed |
opus | Complex reasoning, highest capability |
haiku | Fast, low-latency for simple tasks |
inherit | Use same model as main conversation |
Permission Modes (Claude only)¶
| Mode | Description |
|---|---|
default | Standard permission checking with prompts |
acceptEdits | Auto-accept file edits |
dontAsk | Auto-deny permission prompts |
bypassPermissions | Skip all permission checks (use with caution!) |
plan | Plan mode (read-only exploration) |
Compiled Output¶
With version: full, agents are generated as separate files:
.github/agents/code-reviewer.md
---
name: code-reviewer
description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability.
tools: ['read', 'search', 'execute']
model: Claude Sonnet 4.5
---
You are a senior code reviewer ensuring high standards of code quality and security.
When invoked:
1. Run git diff to see recent changes
...
GitHub Copilot Mappings
PromptScript automatically maps tool and model names to GitHub Copilot's format:
Tools:
| PromptScript | GitHub Copilot |
|---|---|
Read | read |
Grep, Glob | search |
Bash | execute |
Edit, Write | edit |
WebFetch, WebSearch | web |
Task | agent |
TodoWrite | todo |
Models:
| PromptScript | GitHub Copilot |
|---|---|
sonnet | Claude Sonnet 4.5 |
opus | Claude Opus 4.5 |
haiku | Claude Haiku 4.5 |
sonnet-4 | Claude Sonnet 4 |
inherit | (omitted) |
Claude-specific fields like disallowedTools, permissionMode, and skills are ignored for GitHub output.
.claude/agents/code-reviewer.md
---
name: code-reviewer
description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability.
tools: ['Read', 'Grep', 'Glob', 'Bash']
model: sonnet
---
You are a senior code reviewer ensuring high standards of code quality and security.
When invoked:
1. Run git diff to see recent changes
...
.claude/agents/db-reader.md
Using with Skills and MCP Servers¶
Agents can reference reusable skills and project MCP servers:
@skills {
error-handling: {
description: "Error handling patterns"
content: """
Always use try-catch blocks...
"""
}
}
@mcpServers {
issue-tracker: {
transport: "stdio"
command: ["node", "./tools/issues.mjs"]
}
}
@agents {
debugger: {
description: "Debug specialist"
skills: ["error-handling"]
mcpServers: ["issue-tracker"]
content: "You are an expert debugger."
}
}
The full content of each skill is injected into the subagent's context at startup.
Configuration¶
Enable agents in your promptscript.yaml:
id: agents-example
syntax: '1.4.0'
targets:
- github:
version: full # Required for agents
- claude:
version: full # Required for agents
- cursor:
version: full
- factory:
version: full
- codex:
version: full
Platform Comparison¶
| Target | Native agent output | Notable capabilities |
|---|---|---|
| GitHub Copilot | .github/agents/<name>.md | Tools, model mapping, specification model |
| Claude Code | .claude/agents/<name>.md | Tools, deny lists, permissions, skills, MCP references |
| Cursor | .cursor/agents/<name>.md | Model, tools, MCP references |
| Factory AI | .factory/droids/<name>.md | Models, reasoning effort, tools, MCP references |
| Codex | .codex/agents/<name>.toml | Reasoning effort, sandbox, nicknames, skills |
| OpenCode | .opencode/agents/<name>.md | Models, tools, permissions |
Project lifecycle hooks are defined separately through @hooks. Agents can reference shared capabilities from @skills and @mcpServers.