Skip to main content

agentuse run

Execute an agent file.

Syntax

agentuse run <agent-file> [prompt...] [options]

Arguments

agent-file
string
required
Path to agent file (.agentuse or .md extension) or HTTPS URL
prompt
string
Optional additional prompt to append to the agent’s instructions

Options

-q, --quiet             Suppress info messages (only show warnings/errors)
-d, --debug             Enable verbose debug logging
--no-tty                Disable TUI output (plain logs for piping/automation)
-v, --verbose           Show detailed execution information
--timeout <seconds>     Maximum execution time in seconds (default: 300)
-C, --directory <path>  Run as if agentuse was started in <path> instead of the current directory
--env-file <path>       Path to custom .env file
-m, --model <model>     Override the model specified in the agent file
The --quiet and --debug options cannot be used together.
You can also set NO_TTY=true to force plain logging without spinners.

Directory and Path Resolution

Directory Override (-C, —directory)

The -C or --directory option changes the working directory before running:
# Without -C: runs from current directory
agentuse run agent.agentuse

# With -C: changes to specified directory first (like cd)
agentuse run agent.agentuse -C /path/to/project

Project Root Detection

AgentUse searches from the current directory upward for .git/, .agentuse/, or package.json. The project root is used for:
  • Loading .env files
  • Finding plugins in .agentuse/plugins/
This is useful for:
  • Running agents from different projects
  • CI/CD environments with complex directory structures
  • Testing with different configurations

Path Resolution Rules

Subagent paths and MCP server commands are resolved relative to the agent file’s directory.
See Agent Syntax - Subagents for complete path resolution examples.

Model Override

The --model option allows you to override the model specified in an agent file at runtime. This is useful for:
  • Testing: Compare agent behavior across different models
  • Cost Optimization: Use cheaper models for development/testing
  • Environment-Specific Models: Different models for dev/staging/production
  • Quick Experiments: Try new models without editing files

Format

provider:model[:env]
Where:
  • provider: Either anthropic or openai
  • model: The specific model name (e.g., claude-3-5-sonnet-20241022, gpt-4o)
  • env: Optional environment suffix for API keys (e.g., dev, prod, or full env var name)

Examples

# Override with OpenAI GPT-5
agentuse run agent.agentuse --model openai:gpt-5

# Use Anthropic Claude Haiku for quick testing
agentuse run agent.agentuse -m anthropic:claude-haiku-4-5

# Use different API key via environment suffix
agentuse run agent.agentuse --model openai:gpt-5.2:dev
# This will use OPENAI_API_KEY_DEV instead of OPENAI_API_KEY

# Use specific environment variable
agentuse run agent.agentuse --model anthropic:claude-sonnet-4-5:ANTHROPIC_API_KEY_PERSONAL
When overriding models, provider-specific options (like OpenAI’s reasoningEffort) will be ignored if you switch to a different provider.
Model overrides propagate to all sub-agents. When you use --model, both the parent agent and all its sub-agents will use the specified model, regardless of what models are defined in their individual agent files.

Remote Agent Security

When running agents from remote URLs:
  1. HTTPS Only: Only HTTPS URLs are allowed for security
  2. File Extension: Remote agents must have .agentuse extension
  3. Interactive Confirmation: AgentUse will show a security warning with options:
    • [p]review - Fetch and display the agent content before running
    • [y]es - Execute the agent directly
    • [N]o - Abort execution (default)
Example security prompt:
⚠️  WARNING: You are about to execute an agent from:
https://example.com/agent.agentuse

Only continue if you trust the source and have audited the agent.

[p]review / [y]es / [N]o:

Examples

# Run agent from current directory
agentuse run hello.agentuse

# Run agent from subdirectory
cd agents/subfolder
agentuse run my-agent.agentuse  # Finds .env and plugins at project root

# Change to different directory first with -C
agentuse run agent.agentuse -C /my/project  # Same as: cd /my/project && agentuse run agent.agentuse

# Run agent from a different project
agentuse run newsletter/writer.agentuse -C ~/projects/content

# Use custom environment file
agentuse run agent.agentuse --env-file .env.production

# Run with additional prompt
agentuse run assistant.agentuse "Help me write an email"

# Run with multi-word prompt
agentuse run code-review.agentuse "focus on security and performance issues"

# Run remote agent (requires HTTPS and .agentuse extension)
# Shows security warning and requires confirmation
agentuse run https://example.com/agent.agentuse

# Run remote agent with additional prompt
agentuse run https://example.com/agent.agentuse "use production settings"

# Run with debug output
agentuse run agent.agentuse --debug

# Run with additional prompt and verbose output
agentuse run agent.agentuse "be thorough" --verbose

# Run with custom timeout
agentuse run agent.agentuse --timeout 600

# Run quietly (only warnings/errors)
agentuse run agent.agentuse --quiet

# Disable TUI output for piping/automation
agentuse run agent.agentuse --no-tty

# Override model at runtime
agentuse run agent.agentuse --model openai:gpt-5-mini

# Override model and add prompt
agentuse run agent.agentuse "be concise" --model anthropic:claude-haiku-4-5

# Use development API key with model override
agentuse run agent.agentuse -m openai:gpt-5.2:dev

# Override model for agent with sub-agents (all will use the same model)
agentuse run orchestrator.agentuse --model openai:gpt-5-mini

agentuse serve

Start an HTTP server to run agents via API. This enables integration with external applications, webhooks, or any system that can make HTTP requests.

Syntax

agentuse serve [options]

Options

-p, --port <number>     Port to listen on (default: 12233)
-H, --host <string>     Host to bind to (default: 127.0.0.1)
-C, --directory <path>  Working directory for agent resolution
-d, --debug             Enable debug mode
--no-auth               Disable API key requirement for exposed hosts (dangerous)

Authentication

When binding to exposed hosts (not 127.0.0.1 or localhost), API key authentication is required:
# Set API key for authentication
export AGENTUSE_API_KEY="your-secret-key"

# Start server on all interfaces
agentuse serve --host 0.0.0.0
Clients must include the key in requests:
curl -X POST http://server:12233/run \
  -H "Authorization: Bearer your-secret-key" \
  -H "Content-Type: application/json" \
  -d '{"agent": "my-agent.agentuse"}'
Use --no-auth to bypass authentication (dangerous for production).

API Endpoint

POST /run

Execute an agent and receive the result. Request Body:
{
  "agent": "path/to/agent.agentuse",
  "prompt": "Optional additional prompt",
  "model": "anthropic:claude-sonnet-4-5",
  "timeout": 300,
  "maxSteps": 100
}
FieldTypeRequiredDescription
agentstringYesPath to agent file (relative to project root)
promptstringNoAdditional prompt to append to agent instructions
modelstringNoOverride the model specified in agent file
timeoutnumberNoMaximum execution time in seconds (default: 300)
maxStepsnumberNoMaximum number of tool call steps
Response (JSON):
{
  "success": true,
  "result": {
    "text": "Agent response text",
    "finishReason": "end-turn",
    "duration": 1234,
    "tokens": { "input": 500, "output": 200 },
    "toolCalls": 3
  }
}
Error Response:
{
  "success": false,
  "error": {
    "code": "AGENT_NOT_FOUND",
    "message": "Agent file not found: my-agent.agentuse"
  }
}
Error CodeHTTP StatusDescription
NOT_FOUND404Endpoint not found (use POST /run)
AGENT_NOT_FOUND404Agent file doesn’t exist
INVALID_PATH400Agent path outside project root
INVALID_REQUEST400Invalid JSON body
MISSING_FIELD400Required field missing
TIMEOUT504Agent execution timed out
EXECUTION_ERROR500Runtime error during execution
INTERNAL_ERROR500Unexpected server error

Streaming Response

For real-time output, request NDJSON streaming by setting the Accept header:
curl -N -X POST http://127.0.0.1:12233/run \
  -H "Content-Type: application/json" \
  -H "Accept: application/x-ndjson" \
  -d '{"agent": "my-agent.agentuse"}'
Each line is a JSON object representing an execution event:
{"type": "text", "text": "Analyzing..."}
{"type": "tool-call", "name": "read_file", "args": {"path": "data.txt"}}
{"type": "tool-result", "name": "read_file", "result": "..."}
{"type": "text", "text": "Complete!"}
{"type": "finish", "finishReason": "end-turn", "duration": 2345}

Examples

# Start server with defaults (127.0.0.1:12233)
agentuse serve

# Start on custom port
agentuse serve --port 8080

# Bind to all interfaces (for external access)
agentuse serve --host 0.0.0.0 --port 3000

# Use specific project directory
agentuse serve -C /path/to/project

# Start with debug logging
agentuse serve --debug
API Usage Examples:
# Run an agent (JSON response)
curl -X POST http://127.0.0.1:12233/run \
  -H "Content-Type: application/json" \
  -d '{"agent": "agents/assistant.agentuse"}'

# Run with additional prompt
curl -X POST http://127.0.0.1:12233/run \
  -H "Content-Type: application/json" \
  -d '{"agent": "agents/writer.agentuse", "prompt": "Write about AI"}'

# Override model
curl -X POST http://127.0.0.1:12233/run \
  -H "Content-Type: application/json" \
  -d '{"agent": "agents/helper.agentuse", "model": "openai:gpt-5-mini"}'

# Streaming response
curl -N -X POST http://127.0.0.1:12233/run \
  -H "Content-Type: application/json" \
  -H "Accept: application/x-ndjson" \
  -d '{"agent": "agents/analyzer.agentuse"}'

Scheduled Agents

Agents with a schedule config in their frontmatter are automatically executed on schedule:
---
model: anthropic:claude-sonnet-4-5
schedule: "1h"
---

Scheduled Agents Guide

See the complete guide for intervals and cron expressions.
The server enables CORS by default. For production, run behind a reverse proxy with authentication.

agentuse auth

Manage authentication for AI providers.

Subcommands

auth login

Authenticate with a provider.
agentuse auth login [provider]
Providers:
  • anthropic - Anthropic Claude (supports OAuth)
  • openai - OpenAI GPT
  • openrouter - OpenRouter
Examples:
# Interactive login (shows provider selection)
agentuse auth login

# Login to specific provider
agentuse auth login anthropic
agentuse auth login openai
agentuse auth login openrouter

auth logout

Remove stored credentials.
agentuse auth logout [provider]
Examples:
# Logout from all providers
agentuse auth logout

# Logout from specific provider
agentuse auth logout openai

auth list

Show authentication status and stored credentials.
agentuse auth list
# or
agentuse auth ls
Output:
📁 Credentials stored in: ~/.agentuse/auth.json

Stored credentials:
  🔑 anthropic (oauth) → Use as: anthropic:claude-sonnet-4-5
  🎫 openai (api) → Use as: openai:gpt-5.2
  🎫 openrouter (api) → Use as: openrouter:z-ai/glm-4.7

Environment variables:
  🌍 openai (OPENAI_API_KEY) → Use as: openai:gpt-5.2

Model usage examples:
  agentuse run agent.agentuse --model anthropic:claude-sonnet-4-5
  agentuse run agent.agentuse --model openai:gpt-5.2
  agentuse run agent.agentuse --model openrouter:z-ai/glm-4.7

auth help

Show detailed authentication help and configuration options.
agentuse auth help
Displays comprehensive help including:
  • Authentication methods (login command vs environment variables)
  • Provider-specific setup instructions
  • Environment variable configuration for different shells
  • Priority order for credential resolution
  • Links to get API keys
The agentuse create command is not yet implemented. Please create agent files manually using the .agentuse extension.

agentuse skills

List available skills discovered from the project and user skill directories.

Syntax

agentuse skills [options]

Options

-v, --verbose    Show skill file paths and tool requirements

Discovery Locations

Skills are discovered from these directories (in priority order):
  1. .agentuse/skills/ - Project-specific skills
  2. ~/.agentuse/skills/ - User-global skills
  3. .claude/skills/ - Claude ecosystem compatibility
  4. ~/.claude/skills/ - Claude ecosystem compatibility

Examples

# List all available skills
agentuse skills

# Show verbose output with file paths and tool requirements
agentuse skills -v
agentuse skills --verbose

Output Example

Found 2 skill(s):

.agentuse/skills
  code-review
    Review code for quality, security, and maintainability...

~/.agentuse/skills
  seo-analyzer
    Analyze content for SEO optimization...
With verbose mode (-v):
Found 2 skill(s):

.agentuse/skills
  code-review
    Review code for quality, security, and maintainability...
    /path/to/project/.agentuse/skills/code-review/SKILL.md
    tools: Read, Bash(git:*)
For detailed information on creating and using skills, see the Skills Guide.

agentuse help

Show help information.

Syntax

agentuse --help
agentuse -h
# Command-specific help
agentuse run --help
agentuse auth --help

Examples

# General help
agentuse --help

# Command-specific help
agentuse run --help
agentuse auth --help

# Show help when no arguments provided
agentuse
The agentuse config command is not yet implemented. Configuration is currently managed through environment variables only.
The agentuse test command is not yet implemented.

Global Options

--version              Show version number
--help, -h            Show help for command

Environment Variables

Control AgentUse behavior with environment variables. See Environment Variables Reference for complete documentation.

Exit Codes

AgentUse uses standard exit codes:
CodeMeaning
0Success
1General error
2Authentication error
3File not found
4Model error
5Tool error
6MCP error
7Network error
130User interrupted (Ctrl+C)

Available Commands

AgentUse currently supports these commands:
agentuse run <file> [prompt...]   # Run an agent with optional prompt
agentuse serve [options]          # Start HTTP server to run agents via API
agentuse auth login [provider]    # Authenticate with a provider
agentuse auth logout [provider]   # Remove stored credentials
agentuse auth list                # Show authentication status
agentuse auth help                # Show detailed auth help
agentuse skills [options]         # List available skills
agentuse --version                # Show version
agentuse --help                   # Show help

Advanced Usage

Piping

# Pipe input to agent
echo "Translate this to Spanish" | agentuse run translator.agentuse

# Pipe agent output
agentuse run generator.agentuse | tee output.txt

# Chain agents
agentuse run analyzer.agentuse < data.txt | agentuse run summarizer.agentuse

Shell Integration

# Bash function
agent() {
  agentuse run "$1.agentuse" "${@:2}"
}

# Usage
agent translator "Hello world"

Batch Processing

# Process multiple files
for file in *.txt; do
  agentuse run processor.agentuse < "$file" > "processed_$file"
done

# Parallel processing
find . -name "*.md" | parallel agentuse run formatter.agentuse {}

Troubleshooting

Ensure AgentUse is installed globally:
pnpm install -g agentuse
On Unix systems, you may need sudo:
sudo pnpm install -g agentuse
If you see authentication errors, AgentUse will show specific guidance:
[ERROR] No API key found for anthropic

To authenticate, run:
  agentuse auth login

Or set your API key:
  export ANTHROPIC_API_KEY='your-key-here'

For more options: agentuse auth --help
Increase timeout for long-running agents:
agentuse run agent.agentuse --timeout 600
# or via environment
MAX_STEPS=2000 agentuse run agent.agentuse
Enable debug output:
agentuse run agent.agentuse --debug

Next Steps