Getting Started
This guide walks you through installing herdctl and running your first autonomous agent fleet. By the end, you’ll have a working fleet with visible output confirming success.
Prerequisites
Section titled “Prerequisites”Before you begin, ensure you have:
- Node.js 20+ - herdctl requires Node.js 20 or later
- Claude Code CLI - Agents use Claude Code under the hood (install instructions)
- Git - For workspace management and repo cloning
Installation
Section titled “Installation”# Install as a global CLI toolpnpm add -g herdctl
# Or install the library in your projectpnpm add @herdctl/core# Install as a global CLI toolnpm install -g herdctl
# Or install the library in your projectnpm install @herdctl/coreVerify the installation:
herdctl --versionQuick Start: Your First Fleet
Section titled “Quick Start: Your First Fleet”-
Create a project directory
Terminal window mkdir my-fleet && cd my-fleet -
Create the fleet configuration (
herdctl.yaml)herdctl.yaml version: 1agents:- path: ./agents/hello-agent.yaml -
Create an agent configuration (
agents/hello-agent.yaml)Terminal window mkdir -p agentsagents/hello-agent.yaml name: hello-agentdescription: "A simple agent that says hello"schedules:greet:type: intervalinterval: 30sprompt: "Say hello and report the current time." -
Start the fleet
Terminal window herdctl start -
Verify it’s working
You should see output like:
✓ Fleet initialized with 1 agent✓ Scheduler started✓ hello-agent/greet triggered
Using herdctl as a Library
Section titled “Using herdctl as a Library”For programmatic control, use the @herdctl/core package directly. Here’s a minimal example extracted from the test suite:
import { FleetManager } from "@herdctl/core";
const manager = new FleetManager({ configPath: "./herdctl.yaml", stateDir: "./.herdctl",});
await manager.initialize();await manager.start();
manager.on("job:created", (payload) => { console.log(`Job created: ${payload.job.id}`);});
manager.on("schedule:triggered", (payload) => { console.log(`${payload.agentName}/${payload.scheduleName} triggered`);});
// Keep running until interruptedprocess.on("SIGINT", async () => { await manager.stop(); process.exit(0);});This example:
- Creates a
FleetManagerwith your config - Initializes and starts the fleet
- Listens for job and schedule events
- Handles graceful shutdown
Required Files and Directories
Section titled “Required Files and Directories”Configuration Files
Section titled “Configuration Files”| File | Purpose | Required |
|---|---|---|
herdctl.yaml | Fleet configuration (agents list, defaults) | Yes |
agents/*.yaml | Individual agent configurations | At least one |
State Directory (.herdctl/)
Section titled “State Directory (.herdctl/)”herdctl automatically creates and manages a .herdctl/ directory to track fleet state:
.herdctl/├── state.yaml # Fleet state (agent status, schedules)├── jobs/ # Job metadata and output│ ├── job-*.yaml # Job metadata (YAML)│ └── job-*.jsonl # Job streaming output (JSONL)└── sessions/ # Claude session data for resume capabilityConfiguration Reference
Section titled “Configuration Reference”Minimal Fleet Config
Section titled “Minimal Fleet Config”The simplest fleet configuration:
version: 1
agents: - path: ./agents/my-agent.yamlMinimal Agent Config
Section titled “Minimal Agent Config”The simplest agent configuration:
name: my-agentAn agent without schedules can still be triggered manually via the CLI or API.
Typical Agent Config
Section titled “Typical Agent Config”A more realistic agent that processes work periodically:
name: coderdescription: "Implements features from GitHub issues"
schedules: check-issues: type: interval interval: 5m prompt: | Check for GitHub issues labeled "ready". Implement the oldest one and create a PR.
permission_mode: acceptEditsallowed_tools: - Read - Write - Edit - Bash - Glob - GrepCLI Commands
Section titled “CLI Commands”Once your fleet is configured, use these commands:
# Start the fleet (all agents)herdctl start
# Start a specific agentherdctl start coder
# Check fleet statusherdctl status
# Manually trigger an agentherdctl trigger coder check-issues
# View logsherdctl logs coder
# Stop the fleetherdctl stopVerifying Your Setup
Section titled “Verifying Your Setup”After starting your fleet, you can verify it’s working:
Check Fleet Status
Section titled “Check Fleet Status”herdctl statusExpected output:
Fleet: runningAgents: 1 total, 1 idleSchedules: 1 active
Agents: hello-agent idle greet: next run in 25sCheck Logs
Section titled “Check Logs”herdctl logs hello-agentInspect State Files
Section titled “Inspect State Files”# View fleet statecat .herdctl/state.yaml
# List jobsls .herdctl/jobs/
# View a job's outputcat .herdctl/jobs/job-*.jsonlTroubleshooting
Section titled “Troubleshooting”Fleet won’t start
Section titled “Fleet won’t start”- Check config syntax:
herdctl config validate - Verify agent paths: Ensure paths in
agents:are correct relative toherdctl.yaml - Check permissions: Ensure you have write access to the directory for
.herdctl/
Agent not triggering
Section titled “Agent not triggering”- Check schedule syntax: Intervals must be valid (e.g.,
5m,1h,30s) - View schedule state:
herdctl statusshows next trigger times - Check logs:
herdctl logs <agent-name>for errors
Jobs failing
Section titled “Jobs failing”- Check Claude Code CLI: Ensure
claudeis installed and authenticated - Check permissions: Verify the agent has necessary tool permissions
- View job output:
cat .herdctl/jobs/job-*.jsonlfor detailed output
Next Steps
Section titled “Next Steps”Core Concepts
Section titled “Core Concepts”Before diving deeper, understand these key concepts:
| Concept | Description |
|---|---|
| Fleet | Collection of agents defined in herdctl.yaml |
| Agent | A configured Claude instance with identity, schedules, and permissions |
| Schedule | Defines when (trigger) and how (prompt) to invoke an agent |
| Job | A single execution of an agent, with unique ID and tracked output |
| Workspace | Isolated directory where an agent operates |