Skip to main content

CLI Command Reference

Use mutagent <command> --help for detailed help on any command. Add --json to any command for machine-readable output.

Global Options

These options apply to all commands:
OptionDescription
--jsonOutput results as JSON for machine-readable output
--non-interactiveDisable all interactive prompts (also enabled by CI=true env var)
--api-key <key>Override API key for this command
--endpoint <url>Override API endpoint
--helpShow help for any command
-v, --versionShow CLI version
JSON output includes _links objects with deep links to the corresponding resource on app.mutagent.io. This is useful for AI agents that need to reference the web UI.
{
  "data": { ... },
  "_links": {
    "self": "https://app.mutagent.io/prompts/123",
    "dashboard": "https://app.mutagent.io/dashboard"
  }
}

Environment Variables

VariableDescription
MUTAGENT_API_KEYAPI key (skips login entirely)
MUTAGENT_ENDPOINTCustom API endpoint
MUTAGENT_NON_INTERACTIVE=trueNon-interactive mode
CI=trueEnables non-interactive mode

Authentication

mutagent login

Top-level shortcut for mutagent auth login. Opens an interactive login flow.
mutagent login
mutagent login --browser
mutagent login --non-interactive
OptionDescription
--browserForce browser-based OAuth authentication
--non-interactiveDisable interactive prompts (auto-selects browser auth)
--endpoint <url>API endpoint (default: https://api.mutagent.io)

mutagent auth login

Authenticate with MutagenT. In interactive mode, prompts you to choose between browser OAuth and API key entry. In non-interactive mode, auto-selects browser auth.
# Interactive (choose method)
mutagent auth login

# Browser OAuth flow
mutagent auth login --browser

# Non-interactive auto browser flow (AI agents)
mutagent auth login --non-interactive
OptionDescription
--browserForce browser-based OAuth authentication
--non-interactiveDisable interactive prompts (auto-selects browser auth)
--endpoint <url>API endpoint (default: https://api.mutagent.io)
For CI/CD pipelines, set the MUTAGENT_API_KEY environment variable instead of using auth login. The CLI picks it up automatically — no login step required. You can also pass the global --api-key flag to any command.
On successful login, the CLI auto-detects your organization and workspace. If you have multiple organizations or workspaces, you will be prompted to select one (interactive mode only).

mutagent auth status

Check authentication status. Validates the stored API key against the server. Shows onboarding completion state, .mutagent/mutation-context.md presence, and resource counts (prompts, datasets, evaluations).
mutagent auth status
mutagent auth status --json

mutagent auth logout

Clear stored credentials.
mutagent auth logout

Configuration

mutagent config list

Display all configuration values. The API key is masked for security.
mutagent config list
mutagent config list --json

mutagent config get <key>

Get a specific configuration value.
mutagent config get endpoint
mutagent config get defaultWorkspace
mutagent config get defaultOrganization
mutagent config get apiKey
KeyDescription
apiKeyStored API key (masked in output)
endpointAPI endpoint URL
formatOutput format preference
timeoutRequest timeout
defaultWorkspaceDefault workspace ID
defaultOrganizationDefault organization ID

mutagent config set workspace <id>

Set the default workspace ID. Persists so you do not need to pass headers on every request.
mutagent config set workspace ws_abc123

mutagent config set org <id>

Set the default organization ID. Required for org-scoped API keys.
mutagent config set org org_abc123

Prompts

mutagent prompts list

List all prompts.
mutagent prompts list
mutagent prompts list --limit 10
mutagent prompts list --json
OptionDescriptionDefault
-l, --limit <n>Max prompts to return50

mutagent prompts get <id>

Get prompt details with optional nested data.
mutagent prompts get <id>
mutagent prompts get <id> --with-datasets --with-evals
mutagent prompts get <id> --json
OptionDescription
--with-datasetsInclude linked datasets
--with-evalsInclude evaluation history

mutagent prompts create

Create a new prompt. Supports multiple input methods.
# System + Human with output schema (recommended)
mutagent prompts create --name "classifier" --system "Classify emails" --human "{email}" --output-schema '{"type":"object","properties":{"category":{"type":"string"}}}'

# Inline raw prompt with template variables
mutagent prompts create --name "raw-prompt" --raw "Summarize: {text}"

# System + human message pair
mutagent prompts create --name "my-prompt" --system "You are helpful" --human "Hello"

# Full messages array
mutagent prompts create --name "chat" --messages '[{"role":"system","content":"..."}]'
OptionDescription
-n, --name <name>Prompt name
--description <text>Prompt description (shown in dashboard)
-r, --raw <text>Raw prompt text (single prompt with {variables})
--system <text>System prompt (use with --human)
--human <text>Human/user prompt (use with --system)
--messages <json>Full messages array as JSON
--output-schema <json>Output schema as JSON (required for optimization)
-c, --content <content>Prompt content (deprecated, use --raw)
Input methods (pick one, priority order): --system/--human > --raw > --messages.
outputSchema is required for optimization. Provide it via --output-schema. In interactive mode, you will be prompted if missing.

mutagent prompts update <id>

Update an existing prompt.
mutagent prompts update <id> --name "new-name"
mutagent prompts update <id> --system "Updated system prompt"
mutagent prompts update <id> --raw "Updated raw prompt"
OptionDescription
-n, --name <name>New name
--description <text>New description
-r, --raw <text>New raw prompt text
--system <text>New system prompt
--human <text>New human prompt
--messages <json>New messages array as JSON
--input-schema <json>Input schema as JSON string
--input-schema-file <path>Input schema from JSON file
--output-schema <json>Output schema as JSON string
--output-schema-file <path>Output schema from JSON file
-c, --content <content>New content (deprecated, use --raw)

mutagent prompts delete <id>

Delete a prompt.
mutagent prompts delete <id>
mutagent prompts delete <id> --force
mutagent prompts delete <id> --force --json
OptionDescription
--forceSkip confirmation prompt (required for non-interactive/CI usage)

Datasets

Datasets are scoped to prompts and managed via the prompts dataset subcommand group.

mutagent prompts dataset list <prompt-id>

List datasets for a prompt.
mutagent prompts dataset list <prompt-id>
mutagent prompts dataset list <prompt-id> --json

mutagent prompts dataset add <prompt-id>

Add a dataset to a prompt.
# Inline JSON data
mutagent prompts dataset add <prompt-id> -d '[{"input":{"text":"hello"},"expectedOutput":{"result":"world"}}]'

# With a custom name
mutagent prompts dataset add <prompt-id> -d '[...]' --name "My Dataset"
OptionDescription
-d, --data <json>Inline JSON array of dataset items
-n, --name <name>Dataset name (default: timestamped)

mutagent prompts dataset delete <prompt-id> <dataset-id>

Delete a dataset from a prompt.
mutagent prompts dataset delete <prompt-id> <dataset-id>
mutagent prompts dataset delete <prompt-id> <dataset-id> --force
OptionDescription
--forceSkip confirmation prompt

Evaluations

Evaluations are scoped to prompts and managed via the prompts evaluation subcommand group.

mutagent prompts evaluation list <prompt-id>

List evaluations for a prompt.
mutagent prompts evaluation list <prompt-id>
mutagent prompts evaluation list <prompt-id> --json

mutagent prompts evaluation get <evaluation-id>

Get evaluation details including criteria.
mutagent prompts evaluation get <evaluation-id>
mutagent prompts evaluation get <evaluation-id> --json

mutagent prompts evaluation create <prompt-id>

Create an evaluation configuration for a prompt. Evaluations define the criteria used to score prompt outputs during optimization.
# Guided mode (interactive -- builds criteria step by step)
mutagent prompts evaluation create <prompt-id> --guided

# Inline JSON (for pre-validated criteria)
mutagent prompts evaluation create <prompt-id> -d '{"name":"Accuracy","evalConfig":{"criteria":[...]}}'

# Basic evaluation
mutagent prompts evaluation create <prompt-id> --name "Accuracy Check"

# With description
mutagent prompts evaluation create <prompt-id> --name "QA" --description "Quality assurance eval"
OptionDescription
-d, --data <json>Evaluation as JSON string (for pre-validated criteria)
-n, --name <name>Evaluation name (required unless using --guided)
--description <text>Evaluation description
--guidedInteractive guided mode — build criteria step by step
Use --guided for an interactive walkthrough that fetches the prompt’s outputSchema and helps you build criteria targeting specific output fields.

mutagent prompts evaluation delete <evaluation-id>

Delete an evaluation.
mutagent prompts evaluation delete <evaluation-id>
mutagent prompts evaluation delete <evaluation-id> --force
OptionDescription
--forceSkip confirmation prompt

Optimization

Optimization jobs are managed via the prompts optimize subcommand group.

mutagent prompts optimize start <prompt-id>

Start a prompt optimization job. Requires a configured LLM provider, a dataset, and evaluation criteria.
# Basic optimization (dataset and evaluation are required)
mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>

# With tuning parameters
mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --max-iterations 5

# With target score and model override
mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --target-score 0.95 --model claude-sonnet-4-6
OptionDescriptionDefault
-d, --dataset <id>Dataset ID for optimization (required)
-e, --evaluation <id>Evaluation ID for scoring (required)
--max-iterations <n>Max optimization iterations1
--target-score <n>Target accuracy score 0-1 (e.g., 0.9)0.8
--patience <n>Iterations without improvement before stopping
--model <model-id>Target LLM model (e.g., claude-sonnet-4-6)
--eval-model <model-id>Evaluation model (defaults to target model)
Prerequisites (all required):
  1. LLM Provider configured — check with mutagent providers list or configure at app.mutagent.io/settings/providers
  2. Dataset uploaded — check with mutagent prompts dataset list <prompt-id>
  3. Evaluation criteria defined — via dashboard or mutagent prompts evaluation create

mutagent prompts optimize status <job-id>

Check optimization job status. Includes a progress bar in table mode.
mutagent prompts optimize status <job-id>
mutagent prompts optimize status <job-id> --json

mutagent prompts optimize results <job-id>

Get optimization results after the job completes. Results display an optimization scorecard with before/after comparison, score progression across iterations, and an apply/reject flow for the optimized prompt.
mutagent prompts optimize results <job-id>
mutagent prompts optimize results <job-id> --diff
mutagent prompts optimize results <job-id> --apply
mutagent prompts optimize results <job-id> --json
OptionDescription
--applyApply the optimized prompt as new version
--diffShow the prompt diff (before/after)

Traces

mutagent traces list

List traces with optional filtering.
mutagent traces list
mutagent traces list --prompt <prompt-id>
mutagent traces list --source claude-code --json
mutagent traces list --limit 10 --json
OptionDescriptionDefault
-p, --prompt <id>Filter by prompt ID
-s, --source <source>Filter by trace source (e.g., claude-code, sdk, langchain)
-l, --limit <n>Max traces to return50

mutagent traces get <id>

Get full trace details including spans, tokens, and latency.
mutagent traces get <trace-id>
mutagent traces get <trace-id> --json

mutagent traces analyze <prompt-id>

Aggregate trace data for a prompt: average latency, token usage, error rates.
mutagent traces analyze <prompt-id>
mutagent traces analyze <prompt-id> --json

mutagent traces export

Export traces to a file or stdout.
mutagent traces export
mutagent traces export --format json --output traces.json
mutagent traces export --format csv --output traces.csv
mutagent traces export --prompt <prompt-id> --format json
OptionDescriptionDefault
-p, --prompt <id>Filter by prompt ID
-f, --format <format>Export format: json or csvjson
-o, --output <path>Output file path (stdout if omitted)

Integrations

mutagent integrate

When called without a framework argument, returns framework detection/exploration instructions for AI coding agents.
mutagent integrate

mutagent integrate <framework>

Generate integration instructions for a specific framework. This is a skill loader for AI coding agents — it returns instructions that agents execute, not auto-install.
mutagent integrate langchain
mutagent integrate openai
mutagent integrate vercel-ai --verify
mutagent integrate langchain --output INTEGRATION.md
mutagent integrate langchain --raw
FrameworkDescription
langchainPopular LLM framework
langgraphAgent workflow framework
vercel-aiAI SDK for streaming chat
openaiDirect OpenAI SDK integration
OptionDescription
-o, --output <path>Save instructions to file
--rawOutput raw markdown (no formatting)
--verifyVerify integration after generation

mutagent integrate list

List all available framework integrations with their npm packages and descriptions.
mutagent integrate list
mutagent integrate list --json

Init

mutagent init

Initialize a MutagenT project in the current directory. Creates .mutagentrc.json with workspace config. In interactive mode, it detects your framework (Mastra, LangChain, LangGraph, Vercel AI, OpenAI), suggests packages, and optionally runs mutagent explore.
mutagent init
mutagent init --non-interactive
After mutagent auth login, the CLI may offer to run mutagent init as part of the onboarding flow.

Explore

mutagent explore

Scan your codebase for prompts, datasets, and MutagenT markers. Results are saved to .mutagent/mutation-context.md.
mutagent explore
mutagent explore --path ./src
mutagent explore --include "**/*.{ts,py}" --depth 5
mutagent explore --markers-only
mutagent explore --json
OptionDescriptionDefault
-p, --path <dir>Directory to scan.
--depth <n>Max directory depth10
--include <glob>Include file pattern**/*.{ts,js,py,tsx,jsx}
--exclude <dirs>Comma-separated directories to excludenode_modules,dist,.git,build,.next,__pycache__,venv,.venv
--markers-onlyOnly find existing MutagenT markers
Detection modes:
  • Heuristic — Detects template variables ({var}), prompt constants, and schema definitions in your source code.
  • Marker — Finds MutagenT:START / MutagenT:END comment markers from previous uploads.
Results are saved to .mutagent/mutation-context.md for use by other commands.

Playground

mutagent playground run <prompt-id>

Execute a prompt in the playground. Supports inline JSON input, file input, prompt-style flags, and streaming.
# Inline JSON input
mutagent playground run <prompt-id> --input '{"topic": "AI observability"}'

# Streaming mode
mutagent playground run <prompt-id> --input '{"topic": "AI"}' --stream

# With model override
mutagent playground run <prompt-id> --input '{"topic": "AI"}' --model gpt-5

# With prompt-style flags
mutagent playground run <prompt-id> --system "You are a helpful assistant." --human "Hello!"

# Full messages array
mutagent playground run <prompt-id> --messages '[{"role":"user","content":"Hi"}]'
OptionDescription
-i, --input <json>Input variables as JSON
-s, --streamStream the response (tokens output as generated)
-m, --model <model>Override the prompt’s default model
--system <text>System prompt text
--human <text>Human/user message text
--messages <json>Full messages array as JSON string
Input methods are mutually exclusive. Use one of:
  • --input for template variable input
  • --system / --human for quick message construction
  • --messages for full messages array
In streaming mode with --json, each token is output as a separate JSON object.

Agents

mutagent agents list

List agents with optional filtering.
mutagent agents list
mutagent agents list --status active
mutagent agents list --name "reviewer" --json
OptionDescriptionDefault
-l, --limit <n>Max agents to return50
-o, --offset <n>Pagination offset0
-n, --name <name>Filter by name
-s, --status <status>Filter by status (active, paused, archived)

mutagent agents get <id>

Get agent details including system prompt, model, status, tools, and tags.
mutagent agents get <agent-id>
mutagent agents get <agent-id> --json

mutagent agents create

Create a new agent.
# Inline JSON (recommended for CI/scripts/agents)
mutagent agents create -d '{"name":"Code Reviewer","slug":"code-reviewer","systemPrompt":"Review code for bugs"}'

# With individual flags
mutagent agents create --name "Code Reviewer" --slug code-reviewer --system-prompt "Review code for bugs"

# With optional fields
mutagent agents create --name "Helper" --slug helper --system-prompt "..." --model claude-sonnet-4-6 --description "General helper agent"
OptionDescription
-d, --data <json>Agent as JSON string (recommended for CI/scripts/agents)
-n, --name <name>Agent name
-s, --slug <slug>URL-friendly slug
-p, --system-prompt <prompt>System prompt
-m, --model <model>Model (e.g., claude-sonnet-4-6, claude-opus-4-5, claude-haiku-4-5)
--description <desc>Agent description

mutagent agents update <id>

Update an existing agent.
mutagent agents update <id> --name "New Name"
mutagent agents update <id> --status paused
mutagent agents update <id> --model claude-sonnet-4-6
mutagent agents update <id> -d '{"name":"New Name","status":"paused"}'
OptionDescription
-d, --data <json>Agent updates as JSON string (CI/scripts/agents)
-n, --name <name>New name
-p, --system-prompt <prompt>New system prompt
-m, --model <model>New model
--description <desc>New description
-s, --status <status>New status (active, paused, archived)

mutagent agents delete <id>

Delete an agent.
mutagent agents delete <id>
mutagent agents delete <id> --force
OptionDescription
--forceSkip confirmation prompt (required for non-interactive/CI usage)

Workspaces

Manage workspaces in the dashboard at app.mutagent.io.

mutagent workspaces list

List workspaces.
mutagent workspaces list
mutagent workspaces list --limit 10 --json
OptionDescriptionDefault
-l, --limit <n>Max workspaces to return50
-o, --offset <n>Pagination offset0

mutagent workspaces get <id>

Get workspace details.
mutagent workspaces get <workspace-id>
mutagent workspaces get <workspace-id> --json

Providers

Configure providers in the dashboard at app.mutagent.io/settings/providers.

mutagent providers list

List configured LLM providers.
mutagent providers list
mutagent providers list --type openai
mutagent providers list --json
OptionDescriptionDefault
-l, --limit <n>Max providers to return50
-o, --offset <n>Pagination offset0
-t, --type <type>Filter by provider type
Provider types: openai, anthropic, google, azure, bedrock, groq, glm, moonshot, custom

mutagent providers get <id>

Get provider details.
mutagent providers get <provider-id>
mutagent providers get <provider-id> --json

mutagent providers test <id>

Test a provider connection. Returns connectivity status, response time, and available models.
mutagent providers test <provider-id>
mutagent providers test <provider-id> --json

Skills

mutagent skills install

Install the MutagenT CLI skill for Claude Code. Creates .claude/skills/mutagent-cli/SKILL.md that teaches coding agents how to use the MutagenT CLI.
mutagent skills install
mutagent skills install --json
After installing, Claude Code will understand MutagenT CLI commands and can autonomously create prompts, upload datasets, run optimizations, and check traces on your behalf.

Hooks

Hook handlers for AI coding assistants. Currently supports Claude Code session telemetry via the traces/spans model. All handlers are non-blocking — failures print a warning to stderr and exit 0.
Hooks are designed to be configured in your AI assistant’s settings file. They read JSON from stdin and send lightweight telemetry to the MutagenT API.

Configuration

Add to .claude/settings.local.json:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "echo '{\"session_id\": \"$SESSION_ID\", \"tool_name\": \"$TOOL_NAME\"}' | mutagent hooks claude-code pre-tool-use"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "echo '{\"session_id\": \"$SESSION_ID\", \"tool_name\": \"$TOOL_NAME\"}' | mutagent hooks claude-code post-tool-use"
          }
        ]
      }
    ]
  }
}

mutagent hooks claude-code session-start

Handle session start event. Creates a new trace with source claude-code.
echo '{"session_id": "abc-123"}' | mutagent hooks claude-code session-start

mutagent hooks claude-code session-end

Handle session end event. Closes the trace and cleans up state.
echo '{"session_id": "abc-123"}' | mutagent hooks claude-code session-end

mutagent hooks claude-code pre-tool-use

Handle pre-tool-use event. Opens a tool span within the session trace.
echo '{"session_id": "abc-123", "tool_name": "Read", "tool_input": {"file": "main.ts"}}' | mutagent hooks claude-code pre-tool-use

mutagent hooks claude-code post-tool-use

Handle post-tool-use event. Closes the matching tool span.
echo '{"session_id": "abc-123", "tool_name": "Read"}' | mutagent hooks claude-code post-tool-use

Stdin Schema

FieldRequiredEventsDescription
session_idYesAllSession identifier
tool_nameYespre/post-tool-useName of the tool
tool_inputNopre-tool-useTool input data
tool_resultNopost-tool-useTool result data
Session state is stored in /tmp/mutagent-hook-{sessionId}.json during the session and cleaned up on session-end. The API calls use a 5-second timeout and fire-and-forget pattern.

Usage

mutagent usage

Show resource counts (prompts, datasets, evaluations) and optimization run limits for your current plan.
mutagent usage
mutagent usage --json
The command shows a progress bar for optimization usage and a link to upgrade at app.mutagent.io/settings/billing.

Workflows

Common command sequences for typical tasks.

Evaluate and Optimize Loop

# 1. Create a prompt
mutagent prompts create --name "My Prompt" --raw "Your prompt text here"

# 2. Upload a dataset
mutagent prompts dataset add <prompt-id> --name "Training Data" --file data.json

# 3. Create evaluation criteria
mutagent prompts evaluation create <prompt-id> --name "Quality Check" --file criteria.json

# 4. Start optimization
mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --max-iterations 3

# 5. Monitor progress
mutagent prompts optimize status <job-id>

# 6. Get results
mutagent prompts optimize results <job-id>

Quick Test

mutagent playground run <prompt-id> --input '{"key": "value"}'

CI/CD Integration

export MUTAGENT_API_KEY=mt_xxxx
mutagent prompts list --json
mutagent traces list --prompt <prompt-id> --json

Exit Codes

CodeMeaning
0Success
1General error
2Authentication required
3Configuration error
5Network error
6Rate limit exceeded
8Permission error