Example Projects
The herdctl repository includes example projects demonstrating various features and patterns. Each example is self-contained and can be run immediately.
Quick Start
Section titled “Quick Start”# Clone the repositorygit clone https://github.com/herdctl/herdctl.gitcd herdctl
# Install and buildpnpm installpnpm build
# Navigate to an examplecd examples/hello-world
# Run the agent../../packages/cli/bin/herdctl.js trigger hello-worldAvailable Examples
Section titled “Available Examples”hello-world
Section titled “hello-world”Difficulty: Beginner Features: Basic configuration, default_prompt, max_turns
The simplest possible agent—just responds to greetings. Perfect for understanding the minimal configuration required.
cd examples/hello-world../../packages/cli/bin/herdctl.js trigger hello-worldWhat you’ll learn:
- Minimal agent YAML structure
- Using
default_promptfor trigger without--prompt - Limiting agent behavior with
max_turns - No tools required (pure conversation)
hurricane-watcher
Section titled “hurricane-watcher”Difficulty: Intermediate Features: Hooks, persistent memory, denied_tools, schedules
A monitoring agent that tracks weather activity and demonstrates several advanced features:
cd examples/hurricane-watcherexport ANTHROPIC_API_KEY="your-key"../../packages/cli/bin/herdctl.js trigger hurricane-watcherWhat you’ll learn:
- Persistent memory: Agent maintains
context.mdfile across runs - Shell hooks: Run commands after job completion
- Discord hooks: Send notifications (requires bot setup)
- Tool restrictions: Using
denied_toolsto prevent certain actions - Schedules: Configure interval-based execution
Key configuration:
# Persistent memory patternsystem_prompt: | You maintain a context.md file to remember state between runs. At the START: Read context.md At the END: Update context.md with results
# Hooks for post-job processinghooks: after_run: - type: shell command: "jq -r '.result.output'"price-checker
Section titled “price-checker”Difficulty: Advanced Features: Metadata, conditional hooks, web scraping, notifications
A sophisticated agent that monitors product prices and sends conditional notifications:
cd examples/price-checkerexport ANTHROPIC_API_KEY="your-key"../../packages/cli/bin/herdctl.js trigger price-checkerWhat you’ll learn:
- Agent metadata: Writing
metadata.jsonfor hook conditions - Conditional notifications:
when: "metadata.shouldNotify" - Web scraping: Using WebFetch to get real product data
- Discord notifications: Formatted price alerts with product links
Key configuration:
# Agent writes metadata to control hooksmetadata_file: metadata.json
hooks: after_run: # Only notify when price meets target - type: discord when: "metadata.shouldNotify" channel_id: "${DISCORD_CHANNEL_ID}" bot_token_env: DISCORD_BOT_TOKENExample metadata the agent writes:
{ "shouldNotify": true, "lowestPrice": 159.99, "retailer": "Staples", "product": "Hyken Mesh Chair", "url": "https://www.staples.com/...", "meetsTarget": true}discord-chat-bot
Section titled “discord-chat-bot”Difficulty: Advanced Features: Discord chat integration, scheduled checks, notifications, conversation memory
A price monitoring agent that combines scheduled automation with interactive Discord chat:
cd examples/discord-chat-botexport DISCORD_BOT_TOKEN="your-token"export DISCORD_GUILD_ID="your-guild-id"export DISCORD_CHANNEL_ID="your-channel-id"../../packages/cli/bin/herdctl.js startWhat you’ll learn:
- Discord chat: Two-way conversations via @mentions and DMs
- Scheduled + interactive: Same agent runs on schedule AND responds to chat
- Session context: Bot remembers conversation history (24h default)
- Slash commands:
/help,/reset,/statusbuilt-in - Tool result embeds: Tool usage, system status, and errors shown as Discord embeds
Key configuration:
# Discord chat integration - users can @mention the botchat: discord: bot_token_env: DISCORD_BOT_TOKEN session_expiry_hours: 24 output: tool_results: true # Show tool usage as embeds tool_result_max_length: 500 # Truncate long output system_status: true # Show system messages result_summary: false # Hide completion summary errors: true # Show errors guilds: - id: "${DISCORD_GUILD_ID}" channels: - id: "${DISCORD_CHANNEL_ID}" mode: mention # Requires @mention dm: enabled: true mode: auto # No @mention needed in DMsExample interactions:
You: @price-bot What's the best price right now?Bot: Based on my last check, the Hyken chair is $189 at Staples...
You: @price-bot Check prices nowBot: Checking Staples and IKEA... [performs live price check]Prerequisites:
- Discord bot with Message Content Intent enabled
- See Discord Quick Start for setup
slack-chat-bot
Section titled “slack-chat-bot”Difficulty: Advanced Features: Slack chat integration, Socket Mode, prefix commands, session context
An assistant agent that combines Slack chat with scheduled automation. Uses Slack’s Socket Mode for real-time messaging without needing a public URL:
cd examples/slack-chat-botexport SLACK_BOT_TOKEN="xoxb-your-bot-token"export SLACK_APP_TOKEN="xapp-your-app-token"export SLACK_CHANNEL_ID="C0123456789"../../packages/cli/bin/herdctl.js startWhat you’ll learn:
- Slack chat: Two-way conversations via @mentions and threads
- Socket Mode: WebSocket-based connection — no public URL needed
- Session context: Bot remembers conversation history (24h default)
- Prefix commands:
!help,!reset,!statusbuilt-in - Slack hooks: Send notification messages after scheduled runs
Key configuration:
# Slack chat integration - users @mention the bot to start a conversationchat: slack: bot_token_env: SLACK_BOT_TOKEN app_token_env: SLACK_APP_TOKEN session_expiry_hours: 24 log_level: standard channels: - id: "${SLACK_CHANNEL_ID}"
# Post schedule results to Slackhooks: after_run: - type: slack channel_id: "${SLACK_CHANNEL_ID}" bot_token_env: SLACK_BOT_TOKENPrerequisites:
- Slack App with Socket Mode enabled
- Bot Token Scopes:
app_mentions:read,chat:write,channels:history,files:write - Event Subscriptions:
app_mention,message.channels - See Slack Quick Start for setup
Pattern Reference
Section titled “Pattern Reference”Persistent Memory Pattern
Section titled “Persistent Memory Pattern”Give your agent memory across runs using a context file:
system_prompt: | ## Context Management
You maintain a `context.md` file to remember state between runs.
At the START of each run: 1. Read context.md to understand your configuration and history 2. If context.md doesn't exist, create it with sensible defaults
At the END of each run: 1. Update context.md with the results of this check 2. Keep history to the last 10 entries
allowed_tools: - Read - Write - EditSee Persistent Memory Guide for details.
Conditional Notification Pattern
Section titled “Conditional Notification Pattern”Send notifications only when specific conditions are met:
metadata_file: metadata.json
system_prompt: | After completing your task, write metadata.json with: - shouldNotify: true if the user should be alerted - Other relevant data for the notification
hooks: after_run: - type: discord when: "metadata.shouldNotify" channel_id: "..." bot_token_env: DISCORD_BOT_TOKENTool Restriction Pattern
Section titled “Tool Restriction Pattern”Prevent agents from using certain tools:
allowed_tools: - WebSearch - WebFetch - Read - Write - Editdenied_tools: - Bash # No shell access - Task # No spawning subagents - TodoWrite # Don't waste turns on todosRunning Examples
Section titled “Running Examples”Prerequisites
Section titled “Prerequisites”All examples require:
- Node.js 18+
- pnpm (for building from source)
ANTHROPIC_API_KEYenvironment variable
Some examples require additional setup:
- Discord hooks/chat:
DISCORD_BOT_TOKEN,DISCORD_GUILD_ID, andDISCORD_CHANNEL_ID - Slack chat:
SLACK_BOT_TOKEN,SLACK_APP_TOKEN, andSLACK_CHANNEL_ID - Webhook hooks: External webhook endpoint
From Source
Section titled “From Source”# Build the CLIpnpm installpnpm build
# Run from examples directorycd examples/hello-world../../packages/cli/bin/herdctl.js trigger hello-worldWith Installed herdctl
Section titled “With Installed herdctl”# Install herdctl globallynpm install -g herdctl
# Copy an examplecp -r node_modules/herdctl/examples/hello-world ./my-agentcd my-agent
# Run the agentherdctl trigger hello-worldCreating Your Own
Section titled “Creating Your Own”Use an example as a starting point:
# Copy and customizecp -r examples/price-checker ./my-agentcd my-agent
# Edit the agent configurationvim agents/price-checker.yaml
# Rename and updatemv agents/price-checker.yaml agents/my-agent.yaml# Update the 'name' field in the YAMLRelated Pages
Section titled “Related Pages”- Getting Started — Initial setup guide
- Agent Configuration — Full configuration reference
- Hooks — Post-job actions
- Persistent Memory Guide — Memory pattern details