An AI agent pipeline that takes coding tasks from dispatch through planning, implementation, auditing, testing, and PR creation using Claude and Codex agents in isolated git worktrees.
Each task moves through a state machine of phases, driven by a monitor loop that runs every few minutes. Agents run in tmux sessions against dedicated git worktrees, so multiple tasks can execute in parallel without interfering with each other.
flowchart LR
planning --> plan_review
plan_review --> implementing
implementing --> auditing
auditing --> fixing
fixing --> testing
testing --> pr_creating
pr_creating --> reviewing
reviewing --> pr_ready
pr_ready --> merged
| Phase | What happens |
|---|---|
| planning | Agent writes a plan; outputs PLAN_VERDICT:READY when done |
| plan_review | Optional human gate -- approve or reject the plan |
| implementing | Agent implements the plan in an isolated worktree |
| auditing | A different agent reviews the implementation for correctness |
| fixing | Agent addresses audit findings |
| testing | Agent runs tests and verifies the change |
| pr_creating | Agent creates a pull request |
| reviewing | Waits for CI and human review |
| pr_ready | CI passes, ready for merge |
| merged | Done |
Tasks that exceed iteration limits are marked needs_split and can be broken into subtasks with auto-split.sh.
.clawdbot/
├── scripts/ Bash pipeline orchestration (dispatch, monitor, spawn, notify, etc.)
├── prompts/ Prompt templates with {VAR} placeholders (plan, implement, audit, test, fix, PR)
└── plans/ Design documents for the pipeline itself
.openclaw/
├── kopiclaw/ Workspace identity, persona, tools, architecture, and memory files
└── kl/ Alternate workspace variant (K&L email pipeline)
See .clawdbot/README.md for detailed script-by-script documentation.
- macOS (scripts assume macOS paths and
launchd) - bash, python3 (stdlib only -- no pip dependencies), git, tmux, curl
- gh (GitHub CLI), authenticated via
gh auth login - claude (Claude Code CLI) and/or codex in your
PATH
# 1. Clone
git clone <repo-url> && cd b0b
# 2. Create the state directory (lives outside the repo)
mkdir -p ~/.openclaw/workspace-kopiclaw/pipeline/{logs,plans}
# 3. Create the worktree base directory
mkdir -p ~/Projects/kopi-worktrees
# Or override later: export WORKTREE_BASE=/your/preferred/path
# 4. Set up Slack credentials (optional -- needed for notifications)
mkdir -p ~/.openclaw/credentials
echo "xoxb-your-slack-bot-token" > ~/.openclaw/credentials/slack-bot-token
chmod 600 ~/.openclaw/credentials/slack-bot-token
# 5. Authenticate GitHub CLI
gh auth loginAll configuration lives in .clawdbot/scripts/config.sh. Every variable can be overridden via environment variables.
| Variable | Description | Default |
|---|---|---|
CLAWDBOT_STATE_DIR |
Root directory for state files, logs, and plans | ~/.openclaw/workspace-kopiclaw/pipeline |
WORKTREE_BASE |
Where git worktrees are created for tasks | ~/Projects/kopi-worktrees |
CLAUDE_PATH |
Path to the Claude CLI | claude |
CODEX_PATH |
Path to the Codex CLI | codex |
SLACK_BOT_TOKEN |
Slack bot token for notifications | (read from ~/.openclaw/credentials/slack-bot-token if unset) |
MAX_RUNTIME_SECONDS |
Agent timeout per phase | 2700 (45 min) |
PLANNING_TIMEOUT_SECONDS |
Planning-specific timeout | 1200 (20 min) |
MAX_ITERATIONS |
Max audit/fix cycles before giving up | 4 |
MAX_AUTO_RETRIES |
Max times a task can auto-retry from needs_split |
1 |
MAX_SPLIT_DEPTH |
Max depth of automatic task splitting | 1 |
GH_COMMENT_DISPATCH_ENABLED |
Auto-dispatch tasks from GitHub @kopi-claw mentions |
true |
GH_COMMENT_DEFAULT_AGENT |
Which agent to use for new tasks | claude |
GH_COMMENT_MAX_DISPATCHES |
Max tasks dispatched per monitor cycle | 3 |
.clawdbot/scripts/dispatch.sh \
--task-id my-feature \
--branch feat/my-feature \
--product-goal "Add widget support" \
--description "Implement widget component with tests" \
--user-request "Original conversation context" \
--agent claude \
--phase planningThe --user-request flag provides the original conversation context shown to the planning agent. Without it, the agent investigates the codebase independently and may choose an approach you didn't intend.
.clawdbot/scripts/approve-plan.sh <task-id>
.clawdbot/scripts/reject-plan.sh <task-id> --reason "scope too broad".clawdbot/scripts/pipeline-status.sh # Slack-formatted summary
.clawdbot/scripts/check-agents.sh # Raw agent statusThe monitor is the heartbeat of the pipeline. It checks agent status, advances phases, processes GitHub mentions, and sends Slack notifications.
.clawdbot/scripts/monitor.shIn production, run it on a schedule (e.g. every 5 minutes via launchd or cron).
.clawdbot/scripts/cleanup-worktrees.shpython3 -m pytest .clawdbot/scripts/Or run individual test files:
python3 .clawdbot/scripts/test_monitor_phase_advance.py
python3 .clawdbot/scripts/test_gh_poll_process.py