Skip to content

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.

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
Terminal window
# Install as a global CLI tool
pnpm add -g herdctl
# Or install the library in your project
pnpm add @herdctl/core

Verify the installation:

Terminal window
herdctl --version
  1. Create a project directory

    Terminal window
    mkdir my-fleet && cd my-fleet
  2. Create the fleet configuration (herdctl.yaml)

    herdctl.yaml
    version: 1
    agents:
    - path: ./agents/hello-agent.yaml
  3. Create an agent configuration (agents/hello-agent.yaml)

    Terminal window
    mkdir -p agents
    agents/hello-agent.yaml
    name: hello-agent
    description: "A simple agent that says hello"
    schedules:
    greet:
    type: interval
    interval: 30s
    prompt: "Say hello and report the current time."
  4. Start the fleet

    Terminal window
    herdctl start
  5. Verify it’s working

    You should see output like:

    ✓ Fleet initialized with 1 agent
    ✓ Scheduler started
    ✓ hello-agent/greet triggered

For programmatic control, use the @herdctl/core package directly. Here’s a minimal example extracted from the test suite:

quickstart.ts
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 interrupted
process.on("SIGINT", async () => {
await manager.stop();
process.exit(0);
});

This example:

  • Creates a FleetManager with your config
  • Initializes and starts the fleet
  • Listens for job and schedule events
  • Handles graceful shutdown
FilePurposeRequired
herdctl.yamlFleet configuration (agents list, defaults)Yes
agents/*.yamlIndividual agent configurationsAt least one

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 capability

The simplest fleet configuration:

herdctl.yaml
version: 1
agents:
- path: ./agents/my-agent.yaml

The simplest agent configuration:

agents/my-agent.yaml
name: my-agent

An agent without schedules can still be triggered manually via the CLI or API.

A more realistic agent that processes work periodically:

agents/coder.yaml
name: coder
description: "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: acceptEdits
allowed_tools:
- Read
- Write
- Edit
- Bash
- Glob
- Grep

Once your fleet is configured, use these commands:

Terminal window
# Start the fleet (all agents)
herdctl start
# Start a specific agent
herdctl start coder
# Check fleet status
herdctl status
# Manually trigger an agent
herdctl trigger coder check-issues
# View logs
herdctl logs coder
# Stop the fleet
herdctl stop

After starting your fleet, you can verify it’s working:

Terminal window
herdctl status

Expected output:

Fleet: running
Agents: 1 total, 1 idle
Schedules: 1 active
Agents:
hello-agent idle greet: next run in 25s
Terminal window
herdctl logs hello-agent
Terminal window
# View fleet state
cat .herdctl/state.yaml
# List jobs
ls .herdctl/jobs/
# View a job's output
cat .herdctl/jobs/job-*.jsonl
  1. Check config syntax: herdctl config validate
  2. Verify agent paths: Ensure paths in agents: are correct relative to herdctl.yaml
  3. Check permissions: Ensure you have write access to the directory for .herdctl/
  1. Check schedule syntax: Intervals must be valid (e.g., 5m, 1h, 30s)
  2. View schedule state: herdctl status shows next trigger times
  3. Check logs: herdctl logs <agent-name> for errors
  1. Check Claude Code CLI: Ensure claude is installed and authenticated
  2. Check permissions: Verify the agent has necessary tool permissions
  3. View job output: cat .herdctl/jobs/job-*.jsonl for detailed output

Before diving deeper, understand these key concepts:

ConceptDescription
FleetCollection of agents defined in herdctl.yaml
AgentA configured Claude instance with identity, schedules, and permissions
ScheduleDefines when (trigger) and how (prompt) to invoke an agent
JobA single execution of an agent, with unique ID and tracked output
WorkspaceIsolated directory where an agent operates