Skip to content

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 on every target with a native model field

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.
"""
}
}
Try in Playground

Configuration Options

Required Fields

FieldDescription
descriptionWhen the agent should be invoked

Optional Fields

FieldTypePlatformDescription
contentstringAllAdditional system prompt for the agent
toolsstring[]Target-dependentTools the agent can use (inherits all if omitted)
modelstringTarget-dependentAI model to use
reasoningEffortstringFactory, CodexTarget-native reasoning level
specModelstringGitHub, FactoryModel for Specification/planning mode (mixed models)
specReasoningEffortstringFactoryReasoning effort for spec mode (low, medium, high)
disallowedToolsstring[]ClaudeTools to deny, removed from inherited list
permissionModestringClaudeHow to handle permission prompts
skillsstring[]ClaudeSkills to preload into subagent context
mcpServersstring[]Target-dependentNamed top-level MCP servers available to the agent
sandboxModestringCodexTarget-native sandbox policy
nicknameCandidatesstring[]CodexDisplay names for spawned agents

Model Options

Write one model value, and PromptScript maps it to the model name each target expects through the model catalog:

ValueMeaning
sonnet, opus, haiku, fableFloating alias for the newest release of the Claude family
claude-opus-5-5, Claude Opus 5.5Pinned release, by profile id, alias, API id, or display name
inheritUse same model as main conversation
Any other nameWritten unchanged, unless the target has its own spelling

GitHub Copilot: Catalog models become Copilot model names, so claude-sonnet-4-5 becomes Claude Sonnet 4.5 and sonnet becomes the newest Sonnet release. inherit is omitted, and auto becomes Auto. Other names pass through unchanged, so any name from your Copilot model picker works.

Claude Code: Floating aliases and inherit stay as written. Pinned Claude releases become API ids, such as claude-sonnet-4-5-20250929. Models from other providers are omitted with a PS4004 warning.

Factory AI, Codex, and Cursor: Catalog models become model ids. Codex runs only OpenAI models, so it omits models from other providers with a PS4004 warning. Factory AI and Cursor write inherit, Codex omits it. The Model Catalog shows what each target writes.

Permission Modes (Claude only)

ModeDescription
defaultStandard permission checking with prompts
acceptEditsAuto-accept file edits
dontAskAuto-deny permission prompts
bypassPermissionsSkip all permission checks (use with caution!)
planPlan 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 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:

PromptScriptGitHub Copilot
Readread
Grep, Globsearch
Bashexecute
Edit, Writeedit
WebFetch, WebSearchweb
Taskagent
TodoWritetodo

Models:

PromptScriptGitHub Copilot
sonnet, opus, haiku, fableDisplay name of the newest release in the family
sonnet-4.5Claude Sonnet 4.5
gpt-5.3-codexGPT-5.3-Codex
inherit(omitted)

The Model Catalog lists the current release behind each floating alias.

Claude-specific fields like disallowedTools, permissionMode, and skills cannot be represented in GitHub output: each one is reported with a PS4003 compatibility warning and omitted.

:::

Claude Code

.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

---
name: 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
---
You are a database analyst with read-only access...

::::

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."
}
}
Try in Playground

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

TargetNative agent outputNotable capabilities
GitHub Copilot.github/agents/<name>.mdTools and model mapping, specification model, handoffs, inline MCP
Claude Code.claude/agents/<name>.mdTools, deny lists, permissions, skills, max turns, memory, MCP names
Cursor.cursor/agents/<name>.mdName, description, model, MCP references (no tools)
Factory AI.factory/droids/<name>.mdModels, reasoning effort, spec models, tools, MCP references
Codex.codex/agents/<name>.tomlReasoning effort, sandbox, nicknames, skills config, MCP tables
OpenCode.opencode/agents/<name>.mdDescription and content (automatic mode: subagent)
Augment.augment/agents/<name>.mdDescription and content
Amp.agents/agents/<name>.mdDescription and content
Grok Build.claude/agents/<name>.mdFull Claude contract through delegation

Fields a target cannot represent are reported with PS4003 compatibility warnings (agent name, field, target, and the targets that do support the field) instead of being dropped silently. See the Field Support Matrix for the authoritative per-target statuses.

Project lifecycle hooks are defined separately through @hooks. Agents can reference shared capabilities from @skills and @mcpServers.

See Also