herdctl: an orchestration layer for Claude Code

I love Claude Code, but there are three things I really wish it could do:

  1. Invoke itself, on a schedule or in response to events
  2. Let me talk to it over discord or slack
  3. Let me coordinate dozens of Claude Code agents together

This is what herdctl aims to do. herdctl is an MIT-licensed orchestration layer for Claude Code. More accurately, it's an orchestration layer for the Claude Agents SDK, upon which herdctl is built. It's been built in about a week using a combination of Claude Code, ralph wiggum, and GSD. It is not production ready.

Here's a video showing it in action:

You can join the discord server to chat with those Star Trek agents. They're running in a container on an old machine in my homelab so although there's not a whole lot to be gained by trying to talk them into doing bad things, I am expecting people will try. Either I'll have a Lieutenant Worf up in time to guardrail those, or I'll just kill the agents, so YMMV.

Install it with npm install -g herdctl or check out the github repo and docs site for more.

What?

herdctl uses .yml files to define fleets of agents that can be invoked either on by schedule or by trigger. This is a thin wrapper around the Claude Agents SDK configurations, plus a couple of herdctl-specific ones like schedules and hooks.

An agent looks a bit like this:

name: price-checker
max_turns: 15
description: Monitors office chair prices across retailers
default_prompt: "Check current prices and update context."

system_prompt: |
You are a price monitoring agent tracking office chair prices across multiple retailers.

Check the price of Product X at... [TRUNCATED FOR BREVITY]

permissions:
allowed_tools:
- WebSearch
- WebFetch
- Read
- Write
- Edit
denied_tools:
- Bash
- TodoWrite
- Task
- Glob
- Grep

schedules:
check:
type: interval
interval: 4h

hooks:
after_run:
- type: discord
bot_token_env: DISCORD_BOT_TOKEN
channel_id: "${DISCORD_CHANNEL_ID}"
when: "metadata.shouldNotify"

name: price-checker
max_turns: 15
description: Monitors office chair prices across retailers
default_prompt: "Check current prices and update context."

system_prompt: |
You are a price monitoring agent tracking office chair prices across multiple retailers.

Check the price of Product X at... [TRUNCATED FOR BREVITY]

permissions:
allowed_tools:
- WebSearch
- WebFetch
- Read
- Write
- Edit
denied_tools:
- Bash
- TodoWrite
- Task
- Glob
- Grep

schedules:
check:
type: interval
interval: 4h

hooks:
after_run:
- type: discord
bot_token_env: DISCORD_BOT_TOKEN
channel_id: "${DISCORD_CHANNEL_ID}"
when: "metadata.shouldNotify"

And a fleet is as simple as this:

version: 1

fleet:
name: price-checker-example
description: Find deals and arbitrage opportunities, exploit for MAXIMUM PROFIT

agents:
- path: agents/price-checker.yaml
- path: agents/stock-checker.yaml
- path: agents/arbitrage-exploiter.yml
version: 1

fleet:
name: price-checker-example
description: Find deals and arbitrage opportunities, exploit for MAXIMUM PROFIT

agents:
- path: agents/price-checker.yaml
- path: agents/stock-checker.yaml
- path: agents/arbitrage-exploiter.yml

Spinning up a fleet looks like this:

> herdctl start
> herdctl start

You can run as many fleets as you like.

Why?

Watch the video above, but in a nutshell herdctl delivers 2 types of value:

  • immediate value is delivered by being able to chat with your agents from anywhere in the world, and have them collaborate
  • long-term value is delivered by processes being run consistently over time, automatically improving themselves as they go

Think of some of the use cases unlocked by a custom agent that knows how to wake up and do its job, day after day. A few off the top of my head from an engineering perspective:

  • Onboarding Quality Agent: does your product's onboarding process definitely work? Would you like an agent who can run the whole process every day and alert you if it's broken?
  • Engineering Manager Agent: don't want the Onboarding Quality Agent annoying you with something as trivial as broken onboarding? What if you had an Engineering Manager Agent that the QA agent could talk to? You could choose how much autonomy to give it.
  • Local Engineer Agent: the BragDoc Engineer Agent example in the video is a bit like a build-your-own Devin, but you can run it locally and it's just Claude Code underneath. Whether you connect it to discord or not, it can still do work in reaction to tickets changing status or other triggers.

But Claude Code Agents are pretty general-purpose. You could use them to do all sorts of things, like:

  • Competitor Analysis Agent: wakes up every day to check on competitors, growing its knowledge and improving its analysis over time. Wakes up once a week and emails you a report of what's going on.
  • SEO Agent: wakes up multiple times a day and spams your link over the internet. Or whatever it is that SEO folks actually do. Tracks vs analytics over time and automatically optimizes your content.
  • End of the World Agent: as I write this the world is an increasing unstable place, but doomscrolling news is bad for one's health. On the other hand, I'd wanna know pretty quick if the world was ending, so why not have an agent that wakes up, checks the news, and alerts me if I need to batten down the hatches of the ole bunker?

Ultimately, it's Claude Code that gets instantiated. You can make Claude Code do basically whatever you want. A staggering proportion of what human digital workers do today will be automated away like this. I am nervous at the implications for society and the economy, all the more pressingly due to the speed at which this will happen.

On the other hand, although I'd been thinking about something like herdctl for months, I ended up building this first version in about a week, so this is coming whether we like it or not. It's too easy to build this kind of thing so it's likely to be everywhere soon. There's no fighting it; our only option is to embrace and adapt.

Promises and Perils

Connecting a Claude Code agent running on your laptop to a public discord channel is a spectacularly bad idea. Don't do it on any computer you care about. Having AI Agents be able to join company chat channels and collaborate with human co-workers is an immensely powerful ability, but it also opens up new and exciting attack vectors.

Even within the context of a company private discord or slack instance, companies will have to be very careful about who has access to these agents and what the possibilities are for a bad actor to exploit an Agent into exfiltrating data, attacking systems, or uploading that video of you practicing your lightsaber skills to youtube.

Captain Picard is interrogated for information
Picard immediately complied with the request, but was blocked. He is smart, though, so he may find a way to get around it.

Of course, you don't have to hook anything up to discord or anywhere else. There's enormous power just in the ability to have agents run on a schedule, especially if you prompt them to improve their own performance over time.

Emerging patterns

I've starting having 2 clones of each project I work on now - one that Claude and I collaborate on in the normal way, and a second that's set aside for the herdctl engineer agent. This prevents us from stepping on each others toes.

Of course, there's no reason why you couldn't spawn 5 engineer agents, or 50, each with their own clone of the codebase to work on. herdctl provides orchestration but it doesn't provide self-organization, so if you do want 50 engineer agents you may want to consider adding some Engineering Manager agents to coordinate them.

Agents that improve themselves over time are the thing I'm most excited about at the moment (what could possibly go wrong?) and there are probably many patterns for how to have them evolve their system prompt, memories, custom tools, Claude Code skills, etc. Patterns like after-action reports, plan-vs-execution analysis, prompt and context engineering will all converge here but in principle it should be commonplace soon to have agents that automatically get smarter over time.

What's Next?

There are probably a ton of bugs, lies in the docs, and other assorted problems with herdctl in this initial incarnation, so probably there will be a little consolidation and cleanup but after that if there's demand I'd expect to build out the Slack integration and then either a little web app to visualize the state of the fleet or revisiting the communication paths between the agents and the fleet.

In the meantime, it would be really valuable to have a technology that allows a fleet of 50 agents to communicate with each other optimally, with some kind of topology around who can talk to who. herdctl doesn't attempt to solve that coordination problem - it should be a separate part of the agentic stack - but I'd love for someone to go build it please.

Share Post:

What to Read Next

Revisiting Bragdoc

9 months after the original creation of bragdoc.ai, I've rebuilt it from the ground up with privacy-first architecture, configurable LLM providers, and a proper web UI. Here's what changed and why it matters for engineers tracking their work.