AutoCraft
AutoCraft is a model harness for maintaining GitHub repositories with a large backlog. It mirrors every issue and PR into a local database, sorts them cheaply (Jev classifiers and Claude Haiku: type, size, duplicates, priority), and carries the items a maintainer picks through to merge. A maintainer says what they want for an item (review it, merge it, implement it) and AutoCraft does the work with a model session in a workspace pod: review, fix, CI fix, conflict resolution, implementation, and any free-form request. It comes back only for a decision a person must make.
Each item has one state (not started, working, waiting, needs answer, on hold, merged, closed). Every wait names what ends it, and every question carries one recommendation that a maintainer answers in words. The models' only way to change a repository is a push through one gate; all GitHub writes go through one write module with safe-merge-style checks. Actions run automatically where the rules say they are safe, and otherwise a person starts or approves them. The system is built around maintainers' judgement, which is the limited resource, not around token cost.
Originally written for the storytold craft apps, AutoCraft can also track repositories owned by other GitHub organizations or users via autocraft-server repos track owner/name without requiring source edits. See Track repos and sync for naming and GitHub App sync limitations.
How it works
Every item is sorted by the cheap stages below. The item work then carries each item a person started or approved, and each item the automatic merge rule takes, to merge. Details, limits and rules for each are in docs/pipeline.md.
| Stage | What it does | Model | Stops for a person |
|---|---|---|---|
| Sync | Mirrors every issue, PR and comment of the tracked repos into the local database, from GitHub App webhooks within seconds and from a backstop poll, reads the CI state of each default branch every 2 minutes, and makes a vector of each item's title and body for similar-item search. | Local embedding model | no |
| Classify | Gives each open item one type label and two flags (security, needs decision). Jev goes first and Haiku gives a second opinion where Jev is unsure. The classification feeds the automatic merge rule. | Jev, Haiku, Sonnet, Opus | no |
| Priority | Gives each open item a level from P0 to P4, then orders the merge queue and the waiting tasks by a work rank. | Jev, Haiku | no |
| Duplicates | Finds items that describe the same bug or request as another open item, or one closed in the last year, and compares each group. A duplicate is a signal on the items; it closes nothing and never holds a started item. | Jev, Haiku, Opus, Sonnet | no |
| Label | Writes each settled type label and flag to GitHub in repos whose switch is on. A label a person set is never changed. | none | yes: automatic work on, or a person's start |
| Item work | Carries every item a maintainer started or approved, and every item the automatic merge rule takes, through to merge: one state per item, tasks (review, fix, CI fix, conflict, update, implement, free-form requests) in a workspace session on the item's own branch, one gate for every push, and the merge queue. It stops only for a hard blocker, with one question to the repo's maintainers. | Opus, Sonnet, Haiku, Jev | yes: hard blockers only: scope, author work nobody approved, a step failing twice |
| Status comments | Keeps one status comment per pull request and issue up to date with its state line, in repos that are on and on every item a person started or approved. The item work's effects step writes it. | none | no |
| Nightly checks and self-evaluation | The nightly checks and the hourly self-evaluation are off with the new core; an operator can still request one by hand. They are rebuilt on the new core later. | Opus | no |
flowchart TD
new[New issue or PR] --> cheap["Sync, duplicates, classify, priority"]
cheap --> rule{"Small or medium bug fix<br/>by a whitelisted author?"}
rule -- yes --> goal
rule -- no --> idle["Not started: waits for a maintainer's command"]
idle -- "review, merge, implement" --> goal["Goal and approval recorded on the item"]
goal --> next{"next(): what does the item need?"}
next -- "task" --> task["Task in a workspace session: review, fix, CI fix, conflict, update, implement, do"]
task --> gate["Gate: lease, mechanical checks, lint, push check, push"]
gate --> next
next -- "an event must happen" --> wait["Waiting: CI, runner, pod, author, access, ..."]
wait --> next
next -- "a decision only a person can make" --> ask["One question with one recommendation"]
ask -- "answer in words" --> next
next -- "ready" --> queue["Merge queue: direct when CI is fresh, one batch for stale PRs"]
queue --> merged[Merged] --> post["Follow-up issues; post-merge review if AutoCraft changed the code"]
Trust boundaries
- Untrusted code runs only in a separate build environment (a worker as another OS user, with rootless Podman), never where GitHub or Claude credentials are.
- Model calls that use tools run inside a bubblewrap sandbox. They get
Read,GrepandGlobon read-only checkouts of the public tracked repos, a Haiku explorer subagent, and read-only item tools (search, item, similar items, PR diff) over a snapshot of the public items. Other calls run without tools. - Only
src/github/write.tswrites to GitHub. Every write is recorded in an audit table, and a test fails if another file writes. - A person's command is its own approval of the merge, pushes or close it asks for, for that item alone, in any tracked repo. Automatic work, on items nobody started, needs the repo's switch to be On. An operator, or a maintainer with write access to the repo, flips it on the repo page, with
GET/POST /api/repos/:repo/switch,autocraft-server repos switch <name> [on|off]or the MCP toolset_repo_switch. - The dashboard needs GitHub sign-in. A
maintainerstarts, answers, approves and holds any item, and flips the switch, of the repos they have GitHub write access to. Anoperatordoes so everywhere and keeps the instance's settings: access, the global switch and limits, prompts, build environments and the GitHub identity. Aviewerreads. - Contributors' own agents reach AutoCraft through an MCP server on the dashboard (
POST /mcp) with a personal token. They act as their user, with that user's role and repo access, and send the same commands the user can send on GitHub or the dashboard. - Each repo has one switch for automatic work. Off, AutoCraft runs only what people start, approve or command there, with all its GitHub writes; items nobody started get no triage beyond the sync, no reviews, fixes or merges. On, it also works the items nobody started, under the automatic merge rule; each maintainer's Task Runner settings decide what runs on their runner. "Fix red main" is a separate per-repo approval that works whether or not the switch is on. The global pipeline switch and the daily limits still apply.
See Trust boundary.
Dashboard browsing
Items is one filterable list; a row's details open inline under it. Home lists the reader's own items and marks those with a question for them. The item page is a chat with AutoCraft, with the GitHub and Events tabs beside it. The UI design describes the layouts and filters.
Setup
Requirements
| Needed | Used for |
|---|---|
Node 24 or later (engines in package.json), pnpm |
Runs the TypeScript directly; SQLite through the built-in node:sqlite |
gh, logged in |
Sync (gh api graphql) and every GitHub write |
git |
Clones, diffs and pushes |
claude (Claude Code CLI) |
All Claude calls |
bwrap (bubblewrap, /usr/bin/bwrap) |
Sandbox for a local Claude call. Model calls run on Task Runners, which sandbox them on their own machines: a call gets its checkout and tools whenever the checkout can be built, whether or not the server has bubblewrap or sets AUTOCRAFT_NO_SANDBOX=1 |
jev (optional) |
CLI for TypeSafe's Jev model, used by the classify, priority and duplicate steps (jev --compact ask). Without it, switched off (autocraft-server inference jev off), or when its account is out of credit or its key is rejected, Haiku does Jev's work through the Task Runners (more Claude usage) |
| Podman and a second OS user | Build environments (optional) |
sqlite3, curl |
deploy/backup.sh and deploy/hook.sh |
Install
git clone https://github.com/storytold/autocraft.git
cd autocraft
pnpm install
pnpm -C web install && pnpm -C web build # writes web/dist
node src/cli.ts # lists every command
autocraft is the bin of package.json; node src/cli.ts <command> runs the same program. The database is $AUTOCRAFT_DB, default ~/.local/share/autocraft/mirror.db.
GitHub access
gh needs an account with read access to the tracked repos for Sync. The same account writes (labels, comments, closes, pushes, merges) in the repos an operator approves, so it needs write access there.
Dashboard sign-in (GitHub OAuth App)
Create an OAuth App on GitHub:
- Homepage URL: your dashboard origin, for example
https://autocraft.example.com. - Authorization callback URL:
https://autocraft.example.com/auth/callback. It must equal<AUTOCRAFT_BASE_URL>/auth/callbackexactly. - No scopes are requested. Expiring user tokens are supported.
Write the client ID, client secret and a random session key (at least 32 characters) to a JSON file with mode 0600:
{ "github_client_id": "...", "github_client_secret": "...", "session_key": "..." }
Point AUTOCRAFT_SECRETS_FILE at it. The server refuses to start if the file is missing, incomplete, or readable by group or others.
To sign in through a GitHub App instead, register it from the dashboard's GitHub App page (operators only). The dashboard stores the app's keys in the database, sealed with a key derived from the file's session_key; the file itself is only read. Then choose "GitHub App" as the GitHub identity on the same page; it is refused unless the app covers every tracked repo. AUTOCRAFT_GITHUB_APP_NAME sets the name the registration form suggests. With the app's webhooks on, anyone who may use Queue items on the merge queue page can add a pull request or issue to the merge queue from GitHub by commenting @<app-slug> merge queue on it; the app answers in the thread (docs/operations.md, Webhooks). The same people can comment @<app-slug> autorepin <owner/name#number> on a pull request that pins another tracked repository's crates to an unmerged pull request: once that pull request is merged, AutoCraft pushes a commit that repins them to its merge commit, or with via <branch> after it, to the first commit of that branch that contains it (docs/operations.md, Autorepin).
| Variable | Meaning |
|---|---|
AUTOCRAFT_BASE_URL |
Public origin of the dashboard, no path |
AUTOCRAFT_LISTEN |
host:port, default 127.0.0.1:8993 |
AUTOCRAFT_DB |
Database path |
AUTOCRAFT_DB_URL |
A postgres:// URL, to use Postgres instead of the SQLite file |
AUTOCRAFT_SECRETS_FILE |
The secrets file above |
AUTOCRAFT_GITHUB_APP_NAME |
App name suggested on the registration form, default AutoCraft |
AUTOCRAFT_WEB_DIST |
Built frontend, default web/dist |
AUTOCRAFT_TRUST_PROXY |
The number of proxies in front that set X-Forwarded-For (1 behind one proxy) |
The server speaks plain HTTP; put a reverse proxy with HTTPS in front. More variables are in docs/operations.md.
Model calls
Claude calls run on Task Runners, never on this host (see Model calls on maintainers' machines). Jev and embeddings run here:
autocraft-server inference jev 4 # parallel Jev calls
autocraft-server inference jev off # Haiku does Jev's work; `on` switches Jev back on
See Agent runs.
Track repos and sync
autocraft-server repos home-owner <owner> # the instance's own organization, for bare names
autocraft-server repos track <name> # a known repo, or one of the home owner's
autocraft-server repos track <owner/name> # a repository owned by another organization or user
autocraft-server repos list
autocraft-server sync # first sync of the tracked repos
Repo names are unique across owners and case-sensitive. With the GitHub App identity, the app must also be installed on the home owner. See Tracked repos.
Newly tracked repositories start with automatic work off. Sync, Embed, and Rank run, and what maintainers start or command runs in full. For recurring sync, install and enable the supplied systemd timer (deploy/systemd/autocraft-sync.timer) or use the periodic service in the Docker Compose deployment. Running the initial sync does not schedule future runs. autocraft-server embed populates vectors. With the default model and an empty cache, the first embedding operation downloads the approximately 34 MB model plus supporting files.
Start the dashboard and add the first operator
autocraft-server access add <github-login> --operator
autocraft-server dash serve
Sign in at the base URL. Further users are added on the Access page or with autocraft-server access add <login> [--maintainer]. Then, on the dashboard:
- Repos page: approve each repo for the writes you want (labels, comments, fixing, pushing, merging) and switch its pipeline on.
- Run the runner:
autocraft-server runner serve. It is the only process that runs steps. - Pipeline page: turn the pipeline on, or
autocraft-server pipeline on. Set daily limits withautocraft-server pipeline limit <step> --per-day N.
AUTOCRAFT_DEV_AUTH=1 autocraft-server dash serve starts a local server with a fake GitHub sign-in on 127.0.0.1:8994, with no secrets file.
Contributors' agents
Maintainers (and operators) can work from their own agent: from the user menu (top right, Connect) they make an MCP Connector token and get the command that adds the AutoCraft MCP server to Claude Code for all their projects (claude mcp add --scope user --transport http autocraft <base URL>/mcp --header "Authorization: Bearer <token>"). Then they ask things like "is there anything open in photocraft I can help with?" or "give me 5 PRs that need a fix-up". The agent lists the items waiting for an answer and held fix-ups, works one through with them locally, and sends their command. See MCP Connector.
Discord mentions (optional)
AutoCraft can count how often tracked items are mentioned in Discord channels you choose, and answer people who mention the bot or use the issue panel or /autocraft search to find matching public issues, and /autocraft report (or the panel's bug and feature buttons) to draft a new one. It reads new messages only and keeps no text and no names. See Discord mentions, replies and search.
- In the Discord developer portal, create an application and add a bot. Under Bot, turn on the Message Content intent.
- Invite the bot with the
botandapplications.commandsscopes and the View Channels, Send Messages, Create Public Threads, Send Messages in Threads, Add Reactions and Read Message History permissions. Leave everything else off. Under Installation, allow Guild Install only. - Save the bot token in a file readable by the runner only (mode 600), and make a second file of at least 32 random characters for the key that encrypts stored message references (for example
openssl rand -base64 48). Keep the key file: without it the stored links cannot be opened. - Set
AUTOCRAFT_DISCORD_TOKEN_FILEandAUTOCRAFT_DISCORD_KEY_FILEin the env file that both the dashboard and the runner load. The runner needs both paths. The dashboard needs only the key file path: with it the dashboard shows message links and offers Link Discord in the user menu; without it the dashboard shows counts only and hides Link Discord. - Restart the runner. On the Discord page, switch on the channels to watch and enter the contact for deletion requests. The public notice is at
/privacy. - Optional, for the contributor role panel's web verification: under OAuth2 in the developer portal, add the redirect
<base URL>/verify/discord/callbackand copy the client secret into a file (mode 600). SetAUTOCRAFT_DISCORD_CLIENT_IDandAUTOCRAFT_DISCORD_CLIENT_SECRET_FILEfor the dashboard, and add<base URL>/verify/callbackto the GitHub App's callback URLs. Leave the path prefix/verifyopen in any access gate in front of the dashboard.
Deployment
deploy/ holds a production layout that runs the dashboard, runner, sync timer and a daily backup as systemd units of one unprivileged user. It deploys by git push to a bare repository.
| File | Use |
|---|---|
autocraft.env.example |
Settings file, for example /srv/autocraft/config/autocraft.env |
systemd/ |
Dashboard, runner, sync and backup units (@ROOT@, @USER@ placeholders) |
post-receive, hook.sh, push.sh |
Push-to-deploy: builds a release directory and switches the app symlink |
backup.sh |
Consistent SQLite snapshots |
craft-runner.service, craft-worker.service |
User units for the runner and the sandbox worker |
On Kubernetes, every push to main publishes the image with the tag main (.github/workflows/docker-publish.yml). A cluster that runs Flux image automation can follow that tag's digest: Flux commits each new digest to the cluster's GitOps repository and rolls it out, so a merge to main deploys itself. Roll back by reverting the commit on main; a digest pinned by hand is overwritten at the next scan until the automation is suspended.
A Docker Compose deployment is available in deploy/compose/compose.yaml. This deploys the dashboard, runner, and periodic sync/backup service, while sandbox workers run separately. See Running in a container and VPS with Docker Compose.
Details, including the worker and build environments: docs/operations.md.
Model calls on maintainers' machines
Claude calls are queued, and maintainers' and operators' own Claude Code or Codex subscriptions run them through a small Task Runner (autocraft) on their machines, in a sandbox. A Task Runner logs in with autocraft login, approved on the Connect page; its credential is separate from an MCP Connector token. Held claims make pickup immediate. Maintainers and operators can also reserve a queued call for their own Task Runners (Run on my Task Runner in the model call queue) or switch their Task Runners to Manual only.
The item core, gates, Jev calls, embeddings, GitHub writes and builds always stay on the server. A Task Runner only receives a call's prompt, read-only checkouts and per-call tools, and sends back a reply. See User-local inference for setup, eligibility and limits.
Development
pnpm test # the test suite on SQLite
pnpm check # typecheck and verify generated documentation
pnpm -C web dev # frontend on http://127.0.0.1:5173 with mock data
VITE_MOCK=1 pnpm -C web build # static mockup build, no server needed
The mock API serves fixture data; pick the role with ?as=operator|maintainer|viewer. See web/README.md and docs/ui-design.md.
| Path | Contents |
|---|---|
src/cli.ts |
Entry point; commands come from modules listed in MODULES |
src/mirror.ts, src/db.ts, src/schema.sql |
Sync and the SQLite schema |
src/classify, src/priority, src/dupes, src/embed, src/rank |
Classification, priority, duplicates, embeddings, work rank |
src/item, src/commands |
The item state machine (next(), the reducer, questions, the status view) and the command reading shared by every surface |
src/task, src/effects, src/merge |
Task kinds, the item session and the gate; effects such as comments and closes; the merge queue and its mechanics |
src/agents, src/prompts, src/sandbox, src/itemtools |
Agent runs and Jev calls, prompts, bubblewrap, read-only item tools |
src/github |
write.ts, the only module that writes to GitHub |
src/runner, src/worker, src/build |
Job runner, sandbox worker, build environments |
src/dash |
Dashboard server and API |
web/ |
React frontend |
test/ |
Tests |
docs/ |
pipeline.md, dashboard-spec.md, ui-design.md, operations.md |
License
AutoCraft is dual-licensed under MIT or Apache-2.0, at your option. The ArtCraft mark in web/public is not covered; see LICENSE-brand.txt.