CLI Reference
The herdctl CLI provides commands for managing and interacting with your agent fleet.
Installation
Section titled “Installation”# Install globallynpm install -g herdctl
# Or use via npxnpx herdctl [command]Run herdctl --version to print the installed version, and herdctl --help (or herdctl <command> --help) for built-in help.
Commands
Section titled “Commands”Initialize a new fleet or add an agent. Running herdctl init without a subcommand launches an interactive selector.
herdctl init # Interactive: choose fleet or agentherdctl init fleet # Create a new herdctl.yamlherdctl init agent # Add a new agent (interactive)Options:
| Option | Description |
|---|---|
-y, --yes | Accept all defaults without prompting (requires an explicit subcommand: init fleet or init agent <name>) |
-f, --force | Overwrite existing files |
init fleet
Section titled “init fleet”Create a new herdctl.yaml fleet configuration and .herdctl/ state directory.
herdctl init fleet [options]Options:
| Option | Description |
|---|---|
-n, --name <name> | Fleet name (defaults to directory name) |
-f, --force | Overwrite existing configuration |
Examples:
# Initialize with default nameherdctl init fleet
# Initialize with a specific fleet nameherdctl init fleet --name my-fleetinit agent
Section titled “init agent”Add a new agent to the fleet via an interactive wizard or flags. Generates agents/<name>/agent.yaml and appends a reference to herdctl.yaml.
herdctl init agent [name] [options]Arguments:
| Argument | Description |
|---|---|
name | Agent name (optional — prompted if not given) |
Options:
| Option | Description |
|---|---|
-d, --description <desc> | Agent description |
--permission-mode <mode> | Permission mode: default, acceptEdits, bypassPermissions, plan, delegate, dontAsk |
--docker / --no-docker | Enable or disable Docker isolation |
--runtime <runtime> | Runtime backend (sdk or cli) |
--discord | Add Discord chat integration |
--slack | Add Slack chat integration |
-y, --yes | Skip all prompts, use defaults |
-f, --force | Overwrite existing agent file |
Examples:
# Interactive agent creationherdctl init agent
# Create agent with a name (still prompts for other options)herdctl init agent price-checker
# Fully non-interactiveherdctl init agent price-checker --yes --runtime cli --docker
# With chat integrationsherdctl init agent my-bot --discord --slack --yesStart the fleet. Runs in the foreground, streaming fleet logs to stdout until you press Ctrl+C. Writes a PID file to the state directory (.herdctl/herdctl.pid) that herdctl stop uses.
herdctl start [options]Options:
| Option | Description |
|---|---|
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
-v, --verbose | Enable verbose debug logging (sets HERDCTL_LOG_LEVEL=debug) |
--web | Enable the web dashboard |
--web-port <port> | Web dashboard port (default: 3232) |
Examples:
# Start the fleet (all agents)herdctl start
# Start with verbose debug outputherdctl start --verbose
# Start with web dashboardherdctl start --web
# Start with web dashboard on a custom portherdctl start --web --web-port 8080
# Use a specific config fileherdctl start --config ./fleets/prod/herdctl.yamlZero-Config Mode:
When no herdctl.yaml configuration file is found, herdctl start automatically launches in web-only mode. This enables session browsing without any fleet configuration:
# Start web dashboard without fleet confignpx herdctl start
# Output:# No fleet configuration found — starting web UI only.# Browse your Claude Code sessions at http://localhost:3232In web-only mode, you can:
- Browse all Claude Code sessions from
~/.claude/on your machine - View session details and conversation history
- Resume CLI sessions as ad hoc chats
- Use the All Chats page to discover sessions across all projects
This is particularly useful when you want to explore and interact with your Claude Code sessions without setting up a full herdctl fleet.
Stop the running fleet process. Reads the PID file from the state directory, sends SIGTERM, and waits for graceful shutdown. If the timeout is reached, the process is force-killed with SIGKILL.
herdctl stop [options]Options:
| Option | Description |
|---|---|
-f, --force | Immediate stop — send SIGKILL right away (cancels running jobs) |
-t, --timeout <seconds> | Wait max seconds for graceful shutdown before force kill (default: 30) |
-s, --state <path> | Path to state directory (default: .herdctl) |
Examples:
# Graceful stop (waits up to 30s)herdctl stop
# Wait up to 60 seconds before force killingherdctl stop --timeout 60
# Immediate force stopherdctl stop --forcestatus
Section titled “status”Show fleet status or details for a specific agent.
herdctl status [agent] [options]Arguments:
| Argument | Description |
|---|---|
agent | Agent name (optional — use qualified name for sub-fleet agents) |
Options:
| Option | Description |
|---|---|
--json | Output as JSON for scripting |
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
Examples:
# Show all agentsherdctl status
# Show specific agentherdctl status price-checker
# Show sub-fleet agent using qualified nameherdctl status herdctl.security-auditor
# JSON output for scriptingherdctl status --jsonWhen using fleet composition, status output groups agents by their fleet hierarchy.
Show agent logs, or logs for a specific job.
herdctl logs [agent] [options]Options:
| Option | Description |
|---|---|
-f, --follow | Follow log output continuously |
--job <id> | Logs from a specific job |
-n, --lines <count> | Number of lines to show (default: 50) |
--json | Output as newline-delimited JSON (one log entry per line) |
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
Examples:
# Recent logs from all agentsherdctl logs
# View recent logs for one agentherdctl logs price-checker
# Follow logs in real-timeherdctl logs price-checker -f
# Show the last 200 linesherdctl logs price-checker -n 200
# View specific job logsherdctl logs --job job-2024-01-15-abc123
# Newline-delimited JSON for scriptingherdctl logs --jsontrigger
Section titled “trigger”Manually trigger an agent to run a job. By default the agent’s output is streamed to the terminal as it runs, then a job summary is printed.
herdctl trigger <agent> [options]Arguments:
| Argument | Description |
|---|---|
agent | Name of the agent to trigger (use qualified name for sub-fleet agents) |
Options:
| Option | Description |
|---|---|
-S, --schedule <name> | Trigger a specific schedule defined for the agent |
-p, --prompt <prompt> | Custom prompt (overrides the schedule/default prompt) |
-w, --wait | Wait for the job to complete and stream job output |
-q, --quiet | Suppress output display (just show job info) |
--json | Output as JSON for scripting |
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
Examples:
# Trigger with the agent's default promptherdctl trigger price-checker
# Trigger a specific scheduleherdctl trigger price-checker -S daily-check
# Trigger with custom promptherdctl trigger hurricane-watcher --prompt "Check for storms near Miami"
# Trigger a sub-fleet agent using qualified nameherdctl trigger herdctl.security-auditor
# Wait for completion and stream job outputherdctl trigger my-agent --wait
# Quiet mode - no streamed output, just job infoherdctl trigger my-agent -q
# JSON output for scriptingherdctl trigger my-agent --jsonStreaming Output:
By default, the trigger command streams the agent’s output in real-time:
$ herdctl trigger price-checkerI'll check the current prices for office chairs at Staples and IKEA.
First, let me fetch the Staples Hyken chair page...[...]
Job completedJob ID: job-2024-01-15-abc123Agent: price-checker
Run 'herdctl logs --job job-2024-01-15-abc123' to view detailed logs.If nothing was streamed, the agent’s final output is displayed after completion (truncated at 20,000 characters if needed). Use --quiet to suppress output entirely.
With --wait, pressing Ctrl+C exits with code 130 but the job keeps running in the background.
Hooks:
If the agent has hooks configured, they run after the job completes. Hook execution is logged:
Executing 1 after_run hook(s) for event: completedDiscord hook completed successfully in 245ms: channel 123456789012345678 (204)Hook execution complete: 1 succeeded, 0 failed, 0 skipped (245ms)List recent jobs, with filtering and a configurable limit.
herdctl jobs [options]Options:
| Option | Description |
|---|---|
-a, --agent <name> | Filter by agent name |
-S, --status <status> | Filter by status: pending, running, completed, failed, cancelled |
-l, --limit <count> | Number of jobs to show (default: 20) |
--json | Output as JSON for scripting |
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
Examples:
# List the 20 most recent jobsherdctl jobs
# Jobs for a specific agentherdctl jobs --agent price-checker
# Only running jobsherdctl jobs --status running
# Show more historyherdctl jobs --limit 50
# JSON output for scriptingherdctl jobs --jsonShow details for a single job.
herdctl job <id> [options]Arguments:
| Argument | Description |
|---|---|
id | Job ID |
Options:
| Option | Description |
|---|---|
-L, --logs | Also show the job’s output |
--json | Output as JSON for scripting |
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
Examples:
# Show job detailsherdctl job job-2024-01-15-abc123
# Include the job's outputherdctl job job-2024-01-15-abc123 --logs
# JSON output for scriptingherdctl job job-2024-01-15-abc123 --jsoncancel
Section titled “cancel”Cancel a running (or pending) job. By default this shows the job details and asks for interactive confirmation before cancelling — use --yes in scripts to skip the prompt.
herdctl cancel <id> [options]Arguments:
| Argument | Description |
|---|---|
id | ID of the job to cancel |
Options:
| Option | Description |
|---|---|
-f, --force | Force cancel — shortens the graceful-termination window to 1 second before SIGKILL (a normal cancel allows 10 seconds) |
-y, --yes | Skip the confirmation prompt (for scripted use) |
--json | Output as JSON for scripting (also skips the interactive prompt) |
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
Examples:
# Cancel a job (prompts for confirmation)herdctl cancel job-2024-01-15-abc123
# Cancel without confirmation (scripts/CI)herdctl cancel job-2024-01-15-abc123 --yes
# Force cancel with SIGKILLherdctl cancel job-2024-01-15-abc123 --force --yes
# JSON output for scriptingherdctl cancel job-2024-01-15-abc123 --jsonOnly jobs with status running or pending can be cancelled; attempting to cancel a finished job exits with an error.
sessions
Section titled “sessions”List and manage Claude Code sessions for your agents. When agents run with session persistence enabled, herdctl tracks their Claude Code session IDs, making them discoverable and resumable.
herdctl sessions [options]Options:
| Option | Description |
|---|---|
-a, --agent <name> | Filter sessions by agent name |
-v, --verbose | Show full resume commands for each session |
--json | Output as JSON for scripting |
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
Examples:
# List all sessionsherdctl sessions
# Output:# Sessions (2)# ══════════════════════════════════════════════════════════════════════════════# AGENT SESSION ID LAST ACTIVE JOBS# ──────────────────────────────────────────────────────────────────────────────# bragdoc-developer a166a1e4-c89e-41f8-80c8-d73f6cd0d39c 5m ago 19# price-checker b234e5f6-a78b-49c0-d12e-3456789abcde 2h ago 3
# Filter by agentherdctl sessions --agent bragdoc-developer
# Show full resume commandsherdctl sessions --verbose
# JSON output for scriptingherdctl sessions --jsonsessions resume
Section titled “sessions resume”Resume a Claude Code session interactively. This launches Claude Code with the --resume flag in the agent’s configured workspace directory.
herdctl sessions resume [session-id] [options]Arguments:
| Argument | Description |
|---|---|
session-id | Session ID, partial ID, or agent name (optional — defaults to most recent) |
Options:
| Option | Description |
|---|---|
-c, --config <path> | Path to config file or directory |
-s, --state <path> | Path to state directory (default: .herdctl) |
Behavior:
- If no argument is provided, resumes the most recently active session
- Supports partial session ID matching (e.g.,
a166a1e4matchesa166a1e4-c89e-41f8-80c8-d73f6cd0d39c) - Accepts an agent name to resume that agent’s session
- Automatically changes to the agent’s workspace directory before launching Claude
Examples:
# Resume the most recent sessionherdctl sessions resume
# Resume by full session IDherdctl sessions resume a166a1e4-c89e-41f8-80c8-d73f6cd0d39c
# Resume by partial session IDherdctl sessions resume a166a1e4
# Resume by agent nameherdctl sessions resume bragdoc-developerOutput:
Resuming session for bragdoc-developer (19 jobs, last active 5m ago)Session: a166a1e4-c89e-41f8-80c8-d73f6cd0d39cWorkspace: /path/to/project
Running: claude --resume a166a1e4-c89e-41f8-80c8-d73f6cd0d39c in: /path/to/projectSee Sessions for more about session modes and persistence.
Manage distributable agents — install from GitHub or local paths, list installed agents, and remove agents you no longer need.
The agent command group accepts a shared option:
| Option | Description |
|---|---|
-c, --config <path> | Path to config file or directory (applies to all agent subcommands) |
agent add
Section titled “agent add”Install an agent from GitHub or a local path.
herdctl agent add <source> [options]Arguments:
| Argument | Description |
|---|---|
source | Agent source: github:user/repo[@ref] or ./local/path |
Options:
| Option | Description |
|---|---|
--path <path> | Override installation directory (default: ./agents/<name>/) |
--dry-run | Preview changes without installing |
-f, --force | Overwrite existing agent directory |
Examples:
# Install from GitHubherdctl agent add github:edspencer/competitive-analysis-agent
# Install specific versionherdctl agent add github:edspencer/competitive-analysis-agent@v1.0.0
# Install from a branchherdctl agent add github:edspencer/competitive-analysis-agent@main
# Install from local directoryherdctl agent add ./my-local-agent
# Preview installation without making changesherdctl agent add github:user/repo --dry-run
# Overwrite existing agentherdctl agent add github:user/repo --force
# Install to custom pathherdctl agent add github:user/repo --path ./agents/my-custom-nameOutput:
After installation, the command displays:
- Files installed and their locations
- Fleet config changes made
- Required environment variables to configure
- Next steps for testing the agent
agent list
Section titled “agent list”List all agents in the fleet. When the fleet has sub-fleets, output is a tree grouped by fleet hierarchy; otherwise it’s a flat table.
herdctl agent list [options]Options:
| Option | Description |
|---|---|
--json | Output as JSON for scripting |
Examples:
# List all agentsherdctl agent list
# Output:# Name Source Version Installed Status# ------------------------------------------------------------------------------------------# competitor-tracker user/competitive-analysis-agent 1.0.0 Jan 13, 2024 installed# github-triager manual - - manual
# JSON output for scriptingherdctl agent list --jsonagent info
Section titled “agent info”Show detailed information about an agent.
herdctl agent info <name> [options]Arguments:
| Argument | Description |
|---|---|
name | Name of the agent |
Options:
| Option | Description |
|---|---|
--json | Output as JSON for scripting |
Examples:
# Show agent detailsherdctl agent info competitor-tracker
# Output:# Agent: competitor-tracker# Description: Competitive intelligence for Acme SaaS Platform# Status: Installed (via GitHub)# Source: https://github.com/edspencer/competitive-analysis-agent# Version: 1.0.0# Installed: 2024-01-13T10:00:00.000Z## Schedules:# daily-competitive-scan: cron (0 8 * * *)## Environment Variables:# Required:# COMPETITOR_WEBSITES## Files:# agent.yaml# CLAUDE.md## Workspace: agents/competitor-tracker/workspace/
# JSON outputherdctl agent info competitor-tracker --jsonagent remove
Section titled “agent remove”Remove an installed agent from the fleet.
herdctl agent remove <name> [options]Arguments:
| Argument | Description |
|---|---|
name | Name of the agent to remove |
Options:
| Option | Description |
|---|---|
-f, --force | Reserved for future use — currently a no-op (removal does not prompt for confirmation) |
--keep-workspace | Preserve the workspace directory while removing the agent |
Examples:
# Remove an agent (no confirmation prompt — removes immediately)herdctl agent remove competitor-tracker
# Remove but keep workspace dataherdctl agent remove competitor-tracker --keep-workspaceThe removal process:
- Removes the agent directory from
./agents/ - Removes the agent reference from
herdctl.yaml - Lists environment variables that were used (for manual cleanup)
See Installing Agents for a complete guide to the agent distribution system.
config
Section titled “config”Configuration management commands.
config validate
Section titled “config validate”Validate the current configuration (fleet config plus all referenced agent configs). Exits with code 0 if valid, 1 if not.
herdctl config validate [options]Options:
| Option | Description |
|---|---|
--fix | Show suggestions for fixing validation errors |
-c, --config <path> | Path to config file or directory |
Examples:
# Validate the configuration in the current directoryherdctl config validate
# Validate with fix suggestionsherdctl config validate --fix
# Validate a specific config fileherdctl config validate --config ./fleets/prod/herdctl.yamlOn success, prints the fleet name, config path, and the list of resolved agents. On failure, prints schema/YAML/environment-variable errors (with suggested fixes when --fix is set).
config show
Section titled “config show”Show the merged/resolved configuration — fleet info, defaults, and every resolved agent with its schedules and tool permissions.
herdctl config show [options]Options:
| Option | Description |
|---|---|
--json | Output as JSON |
-c, --config <path> | Path to config file or directory |
Examples:
# Human-readable resolved configherdctl config show
# Full resolved config as JSONherdctl config show --jsonCommon Options
Section titled “Common Options”There are no global options other than --version and --help — options like -c and -v are defined per command. Most commands share these:
| Option | Description | Available on |
|---|---|---|
-c, --config <path> | Path to config file or directory | Most commands (see each command’s table) |
-s, --state <path> | Path to state directory (default: .herdctl) | start, stop, status, logs, trigger, jobs, job, cancel, sessions |
--json | Machine-readable output for scripting | status, logs, trigger, jobs, job, cancel, sessions, agent list, agent info, config show |
-v, --verbose | Verbose output | start (debug logging), sessions (full resume commands) |
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Success |
1 | General error (config not found, agent not found, job failed, etc.) |
130 | Interrupted by signal (128 + SIGINT signal number 2) |
trigger --wait propagates the job’s success or failure through its exit code. Interrupting trigger --wait or logs --follow with Ctrl+C exits with 130; a job being waited on continues running in the background.
Environment Variables
Section titled “Environment Variables”| Variable | Description |
|---|---|
HERDCTL_LOG_LEVEL | Log level: debug, info, warn, error (default: info; start --verbose sets debug) |
NO_COLOR | Disable colored output (see no-color.org) |
FORCE_COLOR | Force colored output even when not a TTY |
ANTHROPIC_API_KEY | Claude API key, passed through to agent runs (Docker isolation requires it; local runs can also use your existing Claude Code authentication) |
Additional environment variables may be required for integrations:
| Variable | Description |
|---|---|
GITHUB_TOKEN | GitHub API access for work sources |
DISCORD_BOT_TOKEN | Discord bot token for notifications/chat |
Agent configs can reference arbitrary environment variables with ${VAR} interpolation — herdctl agent info <name> lists the variables an installed agent requires.
Configuration Files
Section titled “Configuration Files”herdctl looks for configuration in this order:
- Path specified with
-c/--config herdctl.yaml(orherdctl.yml) found by walking up the directory tree from the current directory
Agent definitions live in files referenced from herdctl.yaml (conventionally ./agents/<name>/agent.yaml).
See Fleet Configuration and Agent Configuration for details.
Related Pages
Section titled “Related Pages”- Getting Started — First-time setup guide
- Agent Configuration — Agent YAML reference
- Sessions — Session modes and persistence
- Hooks — Post-job notifications and actions
- Triggers — How jobs are started