Golem is a workflow layer for AI coding agents. It gives your LLM the same process a good engineering team uses: a ticket lifecycle, distinct roles that check each other's work, a searchable wiki that grows with the project, and a code graph so agents navigate without reading every file.
Two modes, one tool:
- CLI — run Golem locally, one developer, one repo. Full lifecycle from your terminal.
- Orchestrator + Shem — distributed mode. A central web UI manages tickets; autonomous worker nodes (shems) claim and execute them in parallel, streaming progress back to the dashboard.
Why Golem
LLM agents left to their own devices are fast but sloppy. They skip specs, invent abstractions, miss conventions, and forget everything between sessions. Golem doesn't try to make the model smarter — it gives it structure.
Every change starts as a ticket. The ticket goes through brainstorm → plan → implement → review → close. At each step, a different role runs: a developer to write code, a convention-enforcer to check patterns, a spec-adherence checker to keep scope honest, a reviewer to attest the whole thing. Per ticket you choose how much control you want: manual approval (a human approves the spec and the plan) or automatic (the shem's own validation is the gate).
The code graph (golem graph build) indexes every module so agents find the right file without scanning everything. It helps most on large repos, where an agent would otherwise wander through grep hits; see docs/benchmarks/code-graph-tokens.md for what was measured.
CLI Mode
Prerequisites
Git 2.40+ is required (git check-attr --source). Source builds need Go 1.27+
and a C compiler. Shems need a dedicated secret-free checkout and a backend CLI with
hook support: see shem safety and project setup.
Install
go install github.com/leonp92/golem/cmd/golem@latest
Quick Start
# 1. Initialise Golem in your repo
golem init --backend claude-code
# 2. Build the code graph (optional but recommended for larger repos)
golem graph build
# 3. Open a ticket
golem ticket new "Add rate limiting to the auth middleware"
# 4. Work through the lifecycle
golem ticket advance --to plan
golem ticket advance --to implement
golem ticket review
golem ticket close
How It Works
Tickets
Every piece of work is a ticket. Golem creates a dedicated git worktree and branch (ticket/<id>) so work is isolated from main and from other in-flight tickets.
.golem/tickets/<id>/
state.json ← phase, branch, worktree path
log.jsonl ← append-only blackboard: every finding, blocker, resolution
Roles
The default roles below ship with golem init. Each is a markdown prompt in .golem/roles/ — owned by your repo and editable after init.
| Role |
When it runs |
What it checks |
developer |
During implement |
Writes code following YAGNI/KISS identity |
convention-enforcer |
After the last plan-step commit |
Naming, structure, project patterns |
spec-adherence |
After the last plan-step commit |
Scope creep, plan alignment |
reviewer |
At ticket review |
Full attestation; ends with VERDICT: PASS or VERDICT: FAIL |
tester |
After a ticket with the tester gate is pushed (any ticket; an epic run sets it on every child) |
Judges the sandboxed acceptance results at the pushed head; posts a verdict |
Observer
The observer dispatches watcher roles once at the end of implementation (after the last plan step is committed), not per commit. You call it manually, keeping control of when checks fire:
golem observer dispatch --ticket <id> --role convention-enforcer --commit $(git rev-parse HEAD)
golem observer dispatch --ticket <id> --role spec-adherence --commit $(git rev-parse HEAD)
Each dispatch is fire-and-forget: the role reads the diff and ticket log, writes findings to the blackboard. Multiple dispatches run in parallel.
Gate
golem ticket review runs the commands in your gate.commands config (plus an epic child's acceptance commands), logs the result for the exact head, then runs the reviewer on the log and the branch diff. A failing command or a reviewer VERDICT: FAIL sends the ticket to needs-attention (for an epic child, so does a missing verdict).
gate:
commands:
- make build
- make test
Code Graph
golem graph build # full index of the entire repo
golem graph update # incremental — only changed modules since last build
golem graph status # show what's stale
Module pages (exports, types, imports, subsystem) are extracted with tree-sitter for Go, Python, JS/TS, Rust, Java and Ruby, and written to .golem/wiki/graph/. The graph-builder agent writes one short narrative per subsystem.
symbols.md and types.md give each export's file and line range, e.g. - `pkg` (`pkg/a.go`) [L2-L5] — Run, so agents read only that slice. Ranges reflect the last indexed commit; graph update (also run at ticket close) re-extracts changed modules.
Wiki
.golem/wiki/ is a markdown knowledge base committed to your repo. Agents search it before writing code to avoid reinventing what already exists. Search is TF-IDF with co-mention link expansion — zero API calls:
golem wiki search "rate limiting"
Soul
When a human resolves a ticket differently from what a role recommended, Golem notices. At ticket close, the reviewer generalises the divergence into a durable heuristic and promotes it to .golem/wiki/soul/. Future agents find it via wiki search and apply it automatically.
GitHub Issues
golem issue list and golem issue sync pull issues from a GitHub repo onto local tickets — both are read-only against GitHub, they never create, comment on, or close anything:
export GOLEM_GITHUB_TOKEN=ghp_... # required for all `golem issue` commands
golem issue list # open issues carrying the trigger label
golem issue sync --ticket <id> # refresh a ticket's description (title + body) from its linked issue
golem ticket new --from-issue 42 --id t1 # create a ticket from issue #42; the description is the issue's title, a blank line, then its body
Configure the repo and trigger label in .golem/config.yaml:
github:
repo: your-org/your-repo # "org/repo"; required, not inferred from the git remote
label: golem # trigger label for `golem issue list`; defaults to "golem"
write: true # see "Two-writer guard" below
Two-writer guard: github.write controls whether this repo is allowed to have the CLI act as a GitHub writer. golem init sets it to true for standalone use. When a shem (see Orchestrator + Shem below) initialises or preflights a repo it manages, it forces github.write back to false on every run — an orchestrator-managed repo must have exactly one writer, or the CLI and the orchestrator would post duplicate comments and fight over labels. golem issue list, golem issue sync, and golem ticket new --from-issue do not themselves call any GitHub write endpoint, so github.write currently has no enforcement effect on the CLI — it only records which side owns write access. A future write-capable CLI command must check cfg.GitHub.Write itself before writing; nothing does that automatically today.
Using with Claude Code
golem init --backend claude-code generates subagent definitions in .claude/agents/ and two slash commands:
/golem:new-ticket — walks the full ticket lifecycle interactively from inside Claude Code.
/golem:tickets — lists active tickets and their current phase.
Configuration
.golem/config.yaml is created by golem init and committed to your repo:
backend: claude-code
gate:
commands:
- make build
- make test
graph:
ignore_patterns:
- "migrations/**"
max_file_size_kb: 200
extra_extensions:
- ".graphql"
- ".proto"
role_models: # keyed by role, or by stage; the role key wins
reviewer: claude-opus-4-7
graph: claude-haiku-4-5
github:
repo: your-org/your-repo
label: golem
write: true
Commands
golem init --backend <name> initialise .golem in a repo
golem ticket new "<description>" create ticket, worktree, branch
golem ticket new --base <ref> pin the worktree to the exact commit <ref> names
golem ticket new --accept "<cmd>" acceptance command the gate also runs (repeatable)
golem ticket advance --to <phase>
golem ticket set-step --expected-lines <n>
golem ticket verify run the gate as self-verification (exit 2 on failure)
golem ticket review
golem ticket close
golem ticket resume
golem tickets list all active tickets
golem graph build [--concurrency N] full graph rebuild
golem graph update [--concurrency N] incremental update
golem graph status show stale modules
golem wiki search "<query>"
golem wiki rebuild
golem issue list list open issues carrying the trigger label
golem issue sync --ticket <id> refresh a ticket's description from its linked issue
golem ticket new --from-issue <n> create a ticket from a GitHub issue's title and body
golem observer dispatch --ticket <id> --role <role> --commit <sha>
golem log emit --ticket <id> --role <role> --type <type> <message>
golem models list --config <shem.yaml> a backend's tiers, models and per-stage defaults
golem models probe --config <shem.yaml> check each catalog model and print the verified block
Every agent-invoking subcommand takes --model <id> for one invocation, and
--backend <name> or --backend-config <path> to pick the adapter.
Orchestrator + Shem (Distributed Mode)
The orchestrator adds a team-scale coordination layer on top of the CLI. Instead of running tickets manually, you create them in a web UI and autonomous shem worker nodes execute them in parallel.
Browser ──► Orchestrator (dashboard, approval gates)
│
┌─────────┴──────────┬──────────┐
Shem-A Shem-B Shem-C
(worker) (worker) (worker)
repo A repo A repo B
Benefits over CLI mode:
- Parallel execution — multiple tickets run simultaneously across one or more shems. Work doesn't queue behind a single terminal session.
- Per-ticket approval mode — tick "Require my approval after the spec and the plan" when creating a ticket (or switch it on an unclaimed ticket) and the shem pauses after brainstorm and after plan until you approve or request changes in the UI. Leave it off and the shem advances on its own automatic spec/plan validation. Default: automatic.
- Real-time visibility — the blackboard log streams to the dashboard as the shem works. Blockers and findings surface immediately.
- Atomic ticket claiming — multiple shems on the same repo claim tickets without races. No duplicated work.
- Horizontal scaling — add more shem nodes to increase parallelism. Each shem is stateless; the orchestrator holds all state in SQLite.
Quick Start (Docker Compose)
# Clone the repo, then:
./run.sh
On first run the script creates .env from the example and exits — fill in GOLEM_ADMIN_PASSWORD (8+ characters) and one Claude Code auth option (or another backend's — see Backends), then run it again. GOLEM_BACKEND is required and ships as claude-code; change it to run another backend. CLAUDE_CODE_OAUTH_TOKEN (from claude setup-token) or ANTHROPIC_API_KEY are the ones to reach for. CLAUDE_HOME, which mounts your own ~/.claude, does not carry your login on macOS — Claude Code keeps OAuth credentials in the system keychain rather than in that directory — and it also brings your hooks and MCP commands in with host absolute paths that do not resolve inside the container. See the comments in .env.example. It auto-generates a shem API key and starts the stack. Open http://localhost:8080 when it's done.
GOLEM_GITHUB_TOKEN in the same file is optional and turns on the GitHub Issues integration — see GitHub Issues below for what else it needs.
Create a ticket from the UI. The shem will pick it up within seconds and run brainstorm. With manual approval on, it pauses for your approval before plan and again before implementation; otherwise it advances after automatic validation.
Prebuilt Images
Each release publishes two images to GHCR, tagged with the release version (plus latest on the newest stable release):
ghcr.io/leonp92/golem-orchestrator
ghcr.io/leonp92/golem-shem — every supported agent CLI installed; GOLEM_BACKEND picks one when the container starts. Headless Chromium via Playwright (pinned) is baked in, so a ticket can test UI in a browser without any setup: npx playwright test when the repo pins @playwright/test, the global playwright CLI or require("playwright") otherwise.
The images are configured entirely through the environment. A shem container without a valid GOLEM_BACKEND and a credential for that backend exits with an error at startup instead of failing its first ticket. docker compose pull fetches the prebuilt images; docker compose up still builds from source when they are absent.
The packages publish private. Anonymous pulls work once the maintainer makes a package public (a one-time, irreversible package setting); until then pull with a PAT that has read:packages.
How It Works
- You create a ticket in the UI with a description and target repo.
- A shem claims it atomically via the REST API.
- The shem runs
golem ticket new to scaffold the worktree, then invokes the configured agent CLI (Claude Code by default) for the brainstorm phase.
- The shem posts the spec to the orchestrator and validates it. In manual mode it then waits for human approval.
- The shem runs the plan phase — same gate (human approval in manual mode, validation otherwise).
- Once cleared, the shem implements and reviews. When done, the ticket enters
ready-for-review.
- You close the ticket from the UI.
At every step the shem tails the ticket's log.jsonl and forwards entries to the orchestrator over HTTP, which fans them out to the browser via SSE.
Epic Runs
An epic turns one specification into several dependent tickets (UI: Epics).
- Create with a repo, base branch and spec. Choose a branch strategy
(
epic-branch integrates children into epic/<id>; trunk-flags into
base) and a delivery target (feature-branch: the final merge is yours;
base-branch). Options: auto-merge children (makes a tester pass
mandatory) and auto-approve child phases (snapshotted into each child
when it is created).
- Plan: paste a plan revision as JSON — requirements, nodes (title,
scope,
acceptance_commands, requirement_ids) and dependency edges.
It is validated (coverage, cycles, keys); every save is a new immutable
revision.
- Approve the current revision (bound to its content hash), then
Start: each node becomes an ordinary ticket. A child is claimable
only while the run is
running and all its predecessors are integrated.
- Children run the normal lifecycle. Their acceptance commands run in the
gate; with the tester required, the shem runs the
tester role on the
pushed head and records its verdict.
- Integration: the shem that finished a child merges it into the
run's integration branch itself, through plain git — no GitHub, no
pull requests. Once the tester has passed the exact head, the shem
takes the run's integration slot (one merge at a time per run),
merges in a Golem-owned mirror, and pushes the integration branch.
With pushes enabled that push goes to the run's remote; with
no_push (or a local:// repo) the merge lands in the local
repository, next to the ticket branches. The receipt unblocks
successors; a conflict sends the child back to revising with the
conflicted files as feedback (bounded by GOLEM_FIX_ATTEMPTS,
default 3). Each result consumes the unique lease for its tested
head; stale results cannot release newer work. The worker reconciles
unfinished integrations every 10 seconds, including after outages or
a restart. Paused runs wait without spending fix attempts. A human can also record a receipt by hand via
POST /api/epics/{id}/nodes/{key}/integrate.
- Pause/Resume stops and restarts claims and merges. Cancel
(UI or
POST /api/epics/{id}/cancel) abandons a run that has not
completed and closes its open tickets; branches are kept. When every node
is integrated the run waits for final review (trunk-flags completes
instead). With the GitHub add-on enabled for the repo, this is when
the integration branch's pull request to base is opened.
The final merge to base is always yours: mark the run completed (UI or
POST /api/epics/{id}/merge-final) with the resulting base head SHA after merging the integration
branch. Details: .golem/wiki/modules/orchestrator-epics.md.
GitHub Issues
Issues carrying a trigger label become tickets. The orchestrator polls, ingests, and — as the ticket moves — labels the issue, comments on it, closes it, and opens the pull request.
A ticket's description is the issue's title and body: the title, a blank line, then the body, or the title alone when the body is empty. That is byte-for-byte what golem ticket new --from-issue stores in CLI mode, so an issue produces the same ticket either way, and an issue whose title says everything still gives the agent something to work on.
There is no add-repo form and no token field on /settings/github. Repositories are discovered from the shems that register with them, and the token is read from the environment only, never stored in the database. The full path from a fresh install to a working sync is:
-
Give the orchestrator a token. Create a fine-grained PAT with, on the target repository: Issues read/write, Pull requests read/write, Contents read, Metadata read. Put it in .env as GOLEM_GITHUB_TOKEN or in the orchestrator's environment directly. The variable's name is configurable as github.token_env in orchestrator.yaml. Docker compose gives this one to the orchestrator only — the shem's push credential is a separate, opt-in variable, for the reason given under Shem Configuration.
The token is read once, at startup. If it was empty when the orchestrator started, sync stays off until you set it and restart — the log says so, and Sync now answers "GitHub sync is not running on this orchestrator". Enabling a repository does not need a restart; only supplying the token for the first time does.
-
Set base_url in orchestrator.yaml to the orchestrator's externally reachable address, e.g. https://golem.example.com. Golem's milestone comments link back to <base_url>/tickets/<id>; leaving it empty produces a bare /tickets/<id> with no host — a broken link in a real GitHub comment. Startup logs a WARNING when sync runs without it.
-
Point a shem at the repository. Add it to the shem's repos: list with its GitHub remote:
repos:
- path: /repos/your-repo
remote: https://github.com/your-org/your-repo
The repository appears on /settings/github once that shem has registered.
-
Enable it on /settings/github. Tick Enabled and set the trigger label (default golem; it must not start with golem:, which is Golem's own namespace — see below). Polling starts on the next interval, or immediately via Sync now.
-
Approve each ingested ticket. See the next section — this step is required and is easy to miss.
Poll interval, drain interval, manual-sync cooldown, and a GitHub Enterprise api_base are all under github: in orchestrator.yaml.
Changing the trigger label
The label defaults to golem. To use a different one everywhere without
setting it per repository, set GOLEM_GITHUB_LABEL in .env (or
github.default_label in orchestrator.yaml; the environment wins, since that
file is bind-mounted read-only in Docker):
GOLEM_GITHUB_LABEL=needs-golem
This is a default, not an override. It seeds the label when a repository is
first registered, and is what /settings/github offers for a repository no
shem has registered yet. A repository whose label you already saved keeps that
value — it is a deliberate per-repo choice, and the environment silently
rewriting it would discard it. Change those on the settings page, where each
repository can differ.
The label must not start with golem:. That namespace belongs to the phase
labels Golem writes back, and applyPhaseLabel removes every golem:* label
it does not currently want — so a trigger inside it would be stripped from the
issue on its first phase change, un-enrolling the issue from the label that
enrolled it. The settings form refuses one, and the orchestrator now refuses to
start with one configured.
Removing a repository
/settings/github shows the union of two things: repositories you have saved
settings for, and every remote your registered shems declare. A remote a shem
declares has no database row until you save its settings, and it disappears
from the page once that shem stops declaring it — remove it from the shem's
repos: and restart the shem.
A repository you saved settings for has a row, and the row outlives the shem
config. Remove it with:
golem-orchestrator repos list
golem-orchestrator repos remove https://github.com/owner/name
In Docker, the image's entrypoint is the binary, so pass only the subcommand —
the same shape as backfill below:
docker compose run --rm orchestrator repos list
docker compose run --rm orchestrator repos remove https://github.com/owner/name
Removal is refused while tickets ingested from that repository still exist —
they keep their issue number and repository remote, and deleting the settings
underneath them leaves work that can never sync. Pass --force to remove it
anyway; queued GitHub writes for those tickets are cleared in the same
transaction, since otherwise they would retry forever against settings that no
longer exist.
Unticking Enabled is the lighter option: a disabled repository is never
polled and never written to.
The intake approval gate
An ingested ticket is not claimable until a human approves it. It arrives in phase pending-approval, and no shem can take it until someone opens it in the dashboard, reads the description, and presses Approve & Start.
This is deliberate and is the feature's load-bearing control. An issue is written by anyone who can open one on that repository, and its text is interpolated into the prompts that drive brainstorm, plan, implement, and revise — one of which has shell and repository write access.
The approval binds to the exact text you were shown, title included. If the issue is edited between the page rendering and your click, the approval is refused with a 409 and you are asked to reload and read the new text. If the issue is edited after approval and the ticket has not been claimed yet, it returns to pending-approval for a fresh read; if it has already been claimed, the running agent keeps working from the text that was approved and the change is recorded in the ticket's log. Editing only the title counts as an edit — the title is part of what the agent is given, so it is part of what you approved.
The CLI has no such gate, on purpose: golem ticket new --from-issue 42 is typed by the human who would otherwise be approving, so the act of running it is the approval.
The golem:<phase> label convention
Golem owns the golem: prefix on issues it manages and nothing else. On each phase transition it applies golem:<phase> — golem:pending-approval, golem:brainstorm, golem:plan, golem:implement, golem:ready-for-review — and removes any other golem:* label, so an issue carries exactly one at a time. Every other label, including the trigger label golem (no colon) and all of your own, is left untouched.
That is also why the trigger label may not itself start with golem:: the first phase transition would strip it and un-enroll the issue from its own filter. The settings form rejects such a label.
Golem also comments at three milestones — spec written, plan approved, implementation complete — closes the issue when the ticket is closed, and opens a draft pull request once the ticket reaches ready-for-review and its branch has been pushed. Pushing requires no_push: false in the shem config plus a push credential; see deploy/shem.yaml.
When a GitHub write fails often enough, it parks and stops retrying. Parked writes are listed at the bottom of /settings/github with a Retry button — check there if the issue stops reflecting the ticket.
The orchestrator is the sole GitHub writer for any repo it manages: it posts comments, updates labels, and reflects ticket-state changes back onto the linked issue. This is why the shem forces github.write: false in that repo's .golem/config.yaml (see "Two-writer guard" under CLI Mode above) — the CLI must stay read-only there so the two systems never race each other on the same issue.
Upgrading
Upgrading an existing deployment to the GitHub Issues release has one required
step for some databases and three behaviour changes worth knowing about. See
docs/releases/2026-09-github-issues-integration.md.
Run this before you start the new binary, not after. If your database was
last written by a build from partway through this work, some of its
GitHub-linked tickets carry a blank approval hash, and the release note
explains which of those shapes were claimable without one:
golem-orchestrator backfill body-hash --dry-run # rehearse; writes nothing
golem-orchestrator backfill body-hash
Shem Configuration
# shem.yaml
orchestrator: http://localhost:8080
name: my-shem
# api_key: set via GOLEM_SHEM_API_KEY env var
no_push: true # for local testing; see below
repos:
- path: /path/to/local/repo
remote: https://github.com/your-org/your-repo
backend:
adapter: claude-code # registered adapter name
command: claude # binary; the adapter's default when empty
extra_args: ["--add-dir", "/opt/toolchains"] # appended after the adapter's own args
env: # extra env for the agent process (not GOLEM_*)
ANTHROPIC_BASE_URL: "..."
supports_selection: true # whether the backend accepts a per-call model
tiers: [small, medium, large] # operator labels, cheapest first
models: # selectable models, in display order
- {id: haiku, label: "Haiku", tier: small}
stage_defaults: # the tier each stage falls back to
brainstorm: large
To see the catalog a shem will report, and to check each model against the
vendor CLI:
docker compose exec shem golem models list --config /etc/golem/shem.yaml
docker compose exec shem golem models probe --config /etc/golem/shem.yaml # paste the printed block into shem.yaml
An absent backend: block means claude-code with its default catalog. A
block without models: keeps the adapter's default models and overrides only
the catalog keys it sets, so supports_selection: false alone turns selection
off. Unknown keys are an error. --backend <name> runs an agent-invoking
subcommand against a registered adapter with no backend document.
Registered adapters are claude-code, codex and opencode; see
Backends for what each needs.
Selecting a model
The new-ticket form offers one model select per stage plus a ticket-wide
default, drawn from the catalogs registered shems have reported. The same panel
is on the ticket page while the ticket is unclaimed and not closed, with Save
models and Clear model selections. Re-queue carries a model_default select
and Request changes a model_revise one, both usable while a shem is working
the ticket.
A selection naming a concrete model id binds the ticket to that backend, so
only a shem running it can claim the ticket. With shems on several backends
the selects also offer sizes ("Any shem, by size"): a size binds nothing, and
each backend resolves it against its own catalog, so large means "whatever
this machine calls large". With one backend a size only duplicates a model, so
the selects list models alone.
A ticket bound to a backend no shem runs shows a waiting for a <backend> shem
badge on the dashboard and a banner on its own page, and waits. Clearing its
model selections releases it.
no_push: true routes git push to the local repository instead of a remote, which is ideal for trying Golem out — but it also means no branch reaches GitHub and no pull request is ever opened. The shipped deploy/shem.yaml keeps it on, because the compose stack's default repositories are a throwaway local one and whatever GOLEM_REPO_PATH points at. To get the pull request, set no_push: false and give the shem a push credential: GOLEM_SHEM_GITHUB_TOKEN in .env (the container's entrypoint installs it as an HTTPS credential helper for github.com) or an SSH key. Without one the push fails and the pull request is silently never opened — the ticket still reaches ready-for-review.
The shem also needs that credential to clone a private repository, which it does the first time it works a ticket for one — so a private repo needs GOLEM_SHEM_GITHUB_TOKEN set even while no_push stays true. Contents: Read is enough to clone; pushing needs Contents: Read and write. A fine-grained token that is not scoped to the repository fails the clone with remote: Write access to repository not granted and a 403, which is GitHub's wording for a missing permission rather than a literal statement about writing. Organisation repositories may also require the org to approve the token. If you would rather the shem container held no credential at all, clone the repository onto the host and mount it at the path deploy/shem.yaml names — Golem only clones when nothing is there.
That is a different variable from the orchestrator's GOLEM_GITHUB_TOKEN, and it is empty unless you set it. The shem container is where the agent runs, and it runs on issue text anyone can open an issue to write; the approval gate makes a successful prompt injection unlikely, not impossible. So the shem is handed a repository credential only when someone has decided it needs one. Use a second, push-only token rather than the orchestrator's if you can. The agent never sees either token. Golem runs claude — and any gate command from your .golem/config.yaml, which an agent can edit — with an allow-listed environment that excludes everything in the GOLEM_ namespace. Golem's own commands, including git push, keep the full environment, so the credential helper answers the push and yields an empty password to anything the agent runs or arranges to have run.
One orchestrator process per database
Run exactly one orchestrator process against any one database. Shems scale
out; the orchestrator does not.
db.Open accepts a PostgreSQL DSN, and the usual reason to reach for
PostgreSQL is to run more than one process — so this is worth stating plainly
rather than leaving it to be discovered. The GitHub write outbox is drained by
a select that takes no lock and writes no claim: no FOR UPDATE SKIP LOCKED,
no claim column, no lease. Two orchestrators against one database both select
the same due rows and both deliver them.
What that looks like in practice: duplicate milestone comments on issues,
duplicate label writes, and — because each process marks the row done
afterwards without complaint — no error anywhere to tell you it happened. It
burns GitHub rate limit on a feature whose whole design is built around
conserving it. The issue polling has the same shape.
This is a constraint, not a bug being worked around: fixing it means either
FOR UPDATE SKIP LOCKED on the outbox select or a claimed-by column checked
with RowsAffected == 1 before delivery, and neither is in place. Note that
the test suite structurally cannot catch a violation — :memory: SQLite pins
the pool to a single connection, so every test serialises at the driver.
For availability, run one process and restart it; the outbox is durable, so
work queued while it is down is delivered when it comes back.
Running Multiple Shems
Each shem is a stateless binary. To scale:
# On additional machines or containers, point at the same orchestrator
GOLEM_SHEM_API_KEY=<key> golem-shem --config shem.yaml
Register each shem with a unique name:
golem-orchestrator shems add --name shem-2
Running Without Docker
# Orchestrator
go build -o golem-orchestrator ./cmd/orchestrator
./golem-orchestrator orchestrator.yaml
# Shem (same or different machine)
go build -o golem-shem ./cmd/shem
./golem-shem shem.yaml
Backends
Golem's core never calls a backend directly — all execution goes through the agentrunner.Adapter interface.
| Adapter |
CLI |
Permissions golem writes |
Auth (see .env.example) |
claude-code (default) |
claude --print |
.claude/settings.json allow/deny |
CLAUDE_CODE_OAUTH_TOKEN, ANTHROPIC_API_KEY, or CLAUDE_HOME |
codex |
codex exec |
.codex/rules/golem.rules prefix rules; repo trusted in ~/.codex/config.toml |
CODEX_API_KEY, CODEX_ACCESS_TOKEN, or CODEX_HOME (ChatGPT login) |
opencode |
opencode run |
permission block merged into opencode.json; roles in .opencode/agents/ |
provider key (ANTHROPIC_API_KEY, OPENAI_API_KEY), OPENCODE_HOME, or OPENCODE_CONFIG_CONTENT |
To run codex or opencode in the compose stack:
- In
.env, set GOLEM_BACKEND (required — which backend the entrypoint
authenticates and the shem runs) plus that backend's auth. The images
install all three CLIs by default, local builds included, so nothing is
rebuilt to switch. GOLEM_BACKENDS exists to slim a custom local build.
- Optionally add a
backend: block to deploy/shem.yaml to override models
or settings. An explicit adapter: there that disagrees with
GOLEM_BACKEND stops the shem at startup; with no block (or no adapter:
key) the environment selects.
- Check it:
docker compose exec shem golem models probe --config /etc/golem/shem.yaml.
Notes:
CODEX_HOME / OPENCODE_HOME are mounted read-only; their credential files
are copied in at start, so golem never edits your own config. A refreshed
codex login stays in the container.
- Codex's own sandbox cannot start under Docker, so the container sets
GOLEM_CODEX_SANDBOX=danger-full-access (outside Docker the default is
workspace-write). Codex custom providers must speak the Responses API.
- Opencode is the adapter for any OpenAI-compatible endpoint. Declare a
provider (
"npm": "@ai-sdk/openai-compatible", baseURL,
"apiKey": "{env:OPENAI_API_KEY}") in OPENCODE_CONFIG_CONTENT, put the
key in OPENAI_API_KEY, and list provider/model ids under models:.
.env.example has a working Ollama Cloud example.
- Unlisted commands are denied, not prompted:
opencode run would abort on a
prompt. Codex rules match plain commands; a compound shell line can slip past
a forbidden prefix.
Adding a backend means implementing agentrunner.Adapter and calling
Register from an init.
Project Layout
cmd/
golem/ ← CLI entry point
orchestrator/ ← web server + admin subcommands
shem/ ← distributed worker binary
internal/
agentrunner/ ← Runner interface + backend adapters
cli/ ← command handlers
graph/ ← code graph: discovery, parser, writer, meta
wiki/ ← TF-IDF index + document loader
ticket/ ← ticket state machine
blog/ ← append-only blackboard log
observer/ ← role dispatch
workspace/ ← git worktree management
roles/ ← embedded default role prompts
soul/ ← learned preference extraction
gate/ ← build/test gate runner
epic/ ← epic plan core: schema, validation, readiness
tester/ ← tester verdict contract and scenario sandbox
orchestrator/ ← orchestrator packages (db, auth, api, epics, ghsync, ws, sse, ui)
shem/ ← shem packages (config, client, worker)
deploy/
orchestrator.yaml ← orchestrator config for Docker Compose
shem.yaml ← shem config for Docker Compose
compose_test.go ← keeps docker-compose.yml honest about what it delivers
docs/
releases/ ← upgrade notes
Golem built Golem. The reviewer approved.
License
MIT — see LICENSE.