PTENES
MODULE 4.2

πŸ› Intermediate Loop: GitHub Issue Bot

An orchestrator dispatches parallel workflows to fix 4 GitHub issues simultaneously, using worktrees and database branches.

6
Topics
30
Minutes
Intermediate.
Level
Hands-on
Type
1

πŸ— Orchestrator Setup

The GitHub Issue Bot uses a primary Claude Code session as orchestrator that dispatches 4 parallel workflows. Each workflow is an independent session that receives an issue, implements the fix, runs tests, and creates the PR.

"We can use Archon to send off workflows to run in parallel, handling multiple GitHub issues at the exact same time. And this is very much like loop engineering because we have our primary cloud code here as our orchestrator."
-- Cole Medin

πŸ“‹ Orchestrator Prompt

You are the orchestrator for a GitHub issue fixing system.

1. Read the list of open issues from the GitHub API
2. For each issue, dispatch a worker workflow in a separate worktree
3. Each worker will: extract context, classify (bug/feature), implement, validate, create PR
4. Monitor all workers. When all PRs are ready, dispatch review workflows
5. Report final status with PR links

Issues to handle: #42, #45, #51, #58
Orchestrator Claude Code (main session) Worker #42worktree-42 Worker #45worktree-45 Worker #51worktree-51 Worker #58worktree-58 PR #42 PR #45 PR #51 PR #58 Validate + Review 9+ agent sessions: 1 orchestrator + 4 fix + 4 review
2

🌳 Worktrees for Isolation

When multiple workers edit code in parallel, they need complete isolation. Git worktrees solve this: each worker operates in its own repository checkout, with its own branch.

"Work trees are also a really important part of loop engineering. Boris talks about this as well. If we're having many different agents handling tasks in a loop, we need to make sure they're running in isolation so they're not stepping on each other's toes."
-- Cole Medin

πŸ’» Worktree Commands

# Criar worktree para cada issue
git worktree add ../worktree-42 -b fix/issue-42
git worktree add ../worktree-45 -b fix/issue-45
git worktree add ../worktree-51 -b fix/issue-51
git worktree add ../worktree-58 -b fix/issue-58

# Cada worker roda em seu diretorio
cd ../worktree-42 && claude --prompt "Fix issue #42..."

# Limpar apos merge
git worktree remove ../worktree-42
3

πŸ’Ύ Database Branches with Neon

Code isolation (worktrees) solves half the problem. The other half is data isolation. Neon lets you create Postgres database branches for each worker, preventing migrations and test data from conflicting.

"One thing that you have to do a lot is branches in your database. If each coding agent is working on something in parallel, you don't want them to be stepping on each other's toes, not just with code changes, but also database changes. So work trees and Neon is a super powerful thing."
-- Cole Medin

πŸ—„ Branch per Worker

# Criar branch de banco para cada worker (via Neon CLI)
neonctl branches create --name worker-42 --parent main
neonctl branches create --name worker-45 --parent main

# Cada worker recebe sua DATABASE_URL isolada
export DATABASE_URL=$(neonctl connection-string --branch worker-42)

# Apos merge do PR, deletar branch
neonctl branches delete worker-42

🎯 Reflection Point

Database branches are essential when workers run migrations or modify the schema. Without them, one worker can break the database another is using. Neon makes this trivial, but any database branching system (PlanetScale, Supabase branching) works.

4

πŸ”„ Full Flow: Issue to PR

Each worker follows a deterministic 7-step pipeline. The process is fixed (the human defines the steps), but each step uses an LLM to execute. This combines the best of loops and deterministic workflows.

"Another really important thing about Archon is that we don’t let the agent drive everything. The process is more deterministic because we configure it in this workflow file."
-- Cole Medin

πŸ”§ Worker Pipeline (7 Steps)

1

Extract issue number

Deterministic: parses the input to get the issue ID

2

Fetch issue context

GitHub API: title, description, labels, comments

3

Classify (bug vs. feature)

Small LLM (Haiku/Kimi): decides the issue type

4

Research

Medium LLM: investigates the codebase, identifies relevant files

5

Implement

Strong LLM (Claude): writes the fix code

6

Validate

Deterministic: runs tests, lint, and type checks

7

Create PR

Deterministic: git push + gh pr create

5

πŸ’° Model Mix by Step

One of the biggest advantages of deterministic workflows over pure loops is the ability to use different models at each step. This drastically reduces cost without sacrificing quality where it matters.

"One of the other big issues I see with using slash goal or routines or loops in cloud code is you're just using one model for pretty much everything. That's part of the problem of why it's so expensive."
-- Cole Medin

🎯 Model Map by Step

StepModelRationale
Extract / FetchDeterministicNo LLM, pure code
ClassifyHaiku / Kimi K2.7Simple decision, inexpensive model
ResearchKimi K2.7Exploration, medium model
ImplementClaude CodeRequires maximum quality
ValidateDeterministicRuns tests, no LLM
ReviewCodex / ClaudeCode review requires reasoning
6

❓ Questions

The issue bot is powerful, but it's not magic. Real questions that come up in practice.

Actual cost of 4 issues in parallel

Cole reports that a single run with an orchestrator and workers cost more than 1 million tokens. With 4 running in parallel, multiply that. A mix of models helps, but the cost is still significant for anyone without an infinite budget.

Quality of generated PRs

Automatic PRs need human review. Agent code review helps, but Cole emphasizes keeping a human in the loop: "we can always have it pause for us to validate something before it continues."

When it is and isn't worth it

For batches of simple issues (typos, dependency updates, standard refactorings), it's very useful. For complex issues that require design thinking, the agent will produce superficial fixes. Use it judiciously.

🎯 Reflection Point

The issue bot is the bridge between the simple loop (module 4.1) and the multi-agent orchestrator (module 4.3). It introduces parallelism, isolation, and a model mix. Once you master these concepts, the jump to multi-agent will feel natural.

πŸ“‹ Module Summary

βœ“
Orchestrator -- main session that dispatches and monitors workers
βœ“
Worktrees -- code isolation for parallel workers
βœ“
Neon branches -- database isolation per worker
βœ“
7-step pipeline -- extract, fetch, classify, research, implement, validate, PR
βœ“
Model mix -- the right model for each step reduces cost

Next Module:

4.3 -- Advanced Loop: Multi-Agent Orchestrator (spec, rounds, HITL)