examples/bash-agent/README.md
A bash script demonstrating how an AI agent can use bd to manage tasks autonomously.
discovered-fromgo install github.com/steveyegge/beads/cmd/bd@latestbrew install jq (macOS) or apt install jq (Linux)bd init# Make executable
chmod +x agent.sh
# Run with default 10 iterations
./agent.sh
# Run with custom iteration limit
./agent.sh 20
The agent runs in a loop:
in_progress)š Beads Agent starting...
Max iterations: 10
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Beads Statistics
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Open: 5 In Progress: 0 Closed: 2
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Iteration 1/10
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā¹ Looking for ready work...
ā¹ Claiming task: bd-3
ā Task claimed
ā¹ Working on: Fix authentication bug (bd-3)
Priority: 1
ā Discovered issue while working!
ā Created issue: bd-8
ā Linked bd-8 ā discovered-from ā bd-3
ā¹ Completing task: bd-3
ā Task completed: bd-3
Continuous Integration
# Run agent in CI to process testing tasks
./agent.sh 5
Cron Jobs
# Run agent every hour
0 * * * * cd /path/to/project && /path/to/agent.sh 3
One-off Task Processing
# Process exactly one task and exit
./agent.sh 1
Edit the script to customize behavior:
# Change discovery probability (line ~80)
if [[ $((RANDOM % 2)) -eq 0 ]]; then # 50% chance
# Change to:
if [[ $((RANDOM % 10)) -lt 3 ]]; then # 30% chance
# Add assignee filtering
bd ready --json --assignee "bot" --limit 1
# Add priority filtering
bd ready --json --priority 1 --limit 1
# Add custom labels
bd create "New task" -l "automated,agent-discovered"
This script is a starting point. To integrate with a real LLM:
do_work() with calls to your LLM API