Agent File Format
AgentUse agents are markdown files with a.agentuse
extension. They consist of:
- Frontmatter - YAML configuration
- Agent Prompt - Agent instructions
Basic Structure
The agent name is automatically derived from the filename. You don’t need to specify it in the frontmatter.
Frontmatter Configuration
Required Field
The AI model to use. Format:
provider:model-name
Examples:anthropic:claude-opus-4-1
anthropic:claude-sonnet-4-0
anthropic:claude-3-5-haiku-latest
openai:gpt-5
openai:gpt-5-mini
openai:gpt-5-nano
openrouter:meta/llama-3-70b
anthropic:claude-sonnet-4-0:dev
(uses ANTHROPIC_API_KEY_DEV)openai:gpt-5:prod
(uses OPENAI_API_KEY_PROD)openai:gpt-5:OPENAI_API_KEY_PERSONAL
(uses specific env var)
Optional Fields
A concise description of the agent’s purpose.This appears in:
- Tool descriptions when used as a sub-agent
- CLI output when running the agent
- Plugin events for logging
- Keep under 80-120 characters
- Be action-oriented
- Focus on primary capability
MCP server configurations. Each server can have:
command
+args
: For stdio-based serversurl
: For HTTP-based serversenv
: Environment variables for the serverrequiredEnvVars
: Required environment variables (fail if missing)allowedEnvVars
: Optional environment variables to passdisallowedTools
: Array of tool names/patterns to excludeauth
: Authentication for HTTP serversheaders
: HTTP headers for HTTP servers
List of sub-agent configurations. Each sub-agent can have:
path
: Path to the agent file (required)name
: Optional custom name for the sub-agentmaxSteps
: Optional maximum number of steps the sub-agent can take
MCP Server Integration
Connect to Model Context Protocol servers:MCP servers provide standardized access to external tools and data sources. Each server needs a unique name (key) in the
mcp_servers
object.HTTP MCP Servers
Using Sub-Agents
Agents can delegate to other agents. All sub-agent paths are resolved relative to the parent agent file’s directory:Sub-agents can be local files or HTTPS URLs. Remote agents must end with
.agentuse
extension.Environment Variables
Environment variables are used in MCP server configurations, not directly in the agent frontmatter.
Using Environment Variables in MCP
System Environment Variables
The following environment variables affect agent behavior:MAX_STEPS
- Maximum conversation turns (default: 1000)ANTHROPIC_API_KEY
- For Anthropic modelsOPENAI_API_KEY
- For OpenAI modelsOPENROUTER_API_KEY
- For OpenRouter modelsCONTEXT_COMPACTION
- Enable/disable context compaction (default: enabled, set to ‘false’ to disable)COMPACTION_THRESHOLD
- Token threshold for compaction (default: varies by model)COMPACTION_KEEP_RECENT
- Number of recent messages to keep during compaction (default: varies)
Runtime Customization
You can append additional prompts when running agents without modifying the agent file:- Testing different approaches without editing files
- Providing context-specific instructions
- Reusing agents with slight variations
- Quick experimentation
Examples
For a comprehensive collection of agent examples, including data analysis, code review, API integration, and more, visit the AgentUse Templates.Project Structure and Path Resolution
Project Root Detection
AgentUse automatically detects your project root by searching upward for.git/
, .agentuse/
, or package.json
.
Recommended Project Structure
Path Resolution Examples
Benefits of This Structure
- Portability: Share entire agent projects without breaking paths
- Organization: Clear separation of concerns
- Reusability: Utils and helpers can be shared across agents
- Version Control: Everything in one repository
- Environment Management: Single
.env
file for all agents