A Docker container that runs Claude Code in a respawning loop.
Point it at a repo and a prompt — it works, commits, pushes, and repeats.
Tasks go in, code comes out.
There are plenty of autonomous loop runners now. AgentMill differs on four things:
- Container-first, not sandbox-as-a-flag. The loop is defined by
docker-compose.yml— isolation isn't an opt-in mode bolted onto a host script. Nothing touches your machine's Claude config,PATH, or working tree. - Real multi-agent, not multi-window.
mill multi ~/repo 3starts three headless agents on the same upstream, each in its own workspace, each pushing to its own branch (agent-1,agent-2, …), rebasing and retrying on conflict with a hard retry cap. No tmux, no supervision, no worktree juggling. - Shared memory between agents. Agents read and write
memory/as flock-guarded append-only markdown, so what agent 2 learns at iteration 40 is available to agent 1 at iteration 41. Inspect it withmill memory. - Fresh context every iteration. Each pass runs Claude from a clean context, commits, and respawns — long runs don't degrade as the window fills.
Every iteration appends to logs/results.tsv (agent, files changed, commits, status), so a 200-iteration overnight run is auditable after the fact with mill history.
Use something else if you want to supervise parallel agents from a GUI and review each diff by hand — that's a different job, well served by the worktree-and-dashboard tools. AgentMill is for work you want to leave running.
- Configure — copy
.env.exampleto.env, setREPO_PATHand auth - Write your prompt — edit
prompts/PROMPT.mdwith the task - Run — pick a mode below
- Stop —
docker compose down(finishes current session, commits WIP, exits cleanly)
cp .env.example .env # then edit REPO_PATH and auth
nano prompts/PROMPT.md # describe the taskSet one of these in .env:
- API Key — set
ANTHROPIC_API_KEY - OAuth Token — run
claude setup-tokenon the host, setCLAUDE_CODE_OAUTH_TOKEN
For GitHub Actions PR review with Claude Code and DeepSeek, see docs/claude-code-github-actions.md.
Pick the mode that fits your workflow:
Claude runs in a loop in the background. No UI — output goes to ./logs/. Restarts automatically on crash. Best for CI, overnight runs, or when you don't need to watch.
REPO_PATH=/path/to/repo docker compose up headless
# Use REPO_PATH from .env, or pass /path/to/repo to override it
./mill run --iterations 3Loop: pull → run Claude → commit → push → wait → repeat.
Full Claude Code TUI in your terminal. Claude works autonomously (all tool calls auto-approved) while you watch file edits, tool calls, and reasoning in real time. You're an observer, not a driver.
# Single autonomous session, then exit
REPO_PATH=/path/to/repo docker compose run watch
# With Ralph loop — bounded iteration (runs up to N times, then stops)
REPO_PATH=/path/to/repo AUTO_RALPH=true AUTO_RALPH_MAX_ITERATIONS=10 \
docker compose run watch
# With respawn — restart Claude automatically after each session
REPO_PATH=/path/to/repo RESPAWN=true docker compose run watchPlain Claude Code TUI. No prompt injected, no automation. You type, Claude responds. Same as running claude locally, but inside the container with the repo and tools already set up.
REPO_PATH=/path/to/repo docker compose run interactiveMultiple headless agents on the same repo. Each pushes to its own branch (agent-1, agent-2, etc.) and rebases on conflict. Assign different prompts for different roles.
# Two agents, different tasks
PROMPT_FILE_1=/prompts/features.md PROMPT_FILE_2=/prompts/tests.md \
REPO_PATH=/path/to/repo docker compose up agent-1 agent-2
# Three agents, same branch (rebase on conflict)
AGENT_BRANCH=main REPO_PATH=/path/to/repo docker compose up agent-1 agent-2 agent-3All modes:
| Env Var | Default | Description |
|---|---|---|
REPO_PATH |
(required unless passed) | Absolute path to the repo on your host; mill run/watch/multi/shell [repo] can override it |
ANTHROPIC_API_KEY |
— | API key auth |
CLAUDE_CODE_OAUTH_TOKEN |
— | OAuth token auth (alternative to API key) |
MODEL |
sonnet |
Claude model (sonnet, opus, etc.) |
PROMPT_FILE |
/prompts/PROMPT.md |
Prompt file path inside the container |
GIT_USER |
agentmill |
Git commit author name |
GIT_EMAIL |
agent@agentmill |
Git commit author email |
AUTO_SETUP |
true |
Auto-detect and install repo dependencies on start |
REPO_SETUP_COMMAND |
— | Custom bootstrap command (overrides auto-detect) |
EXTRA_PYTHON_TOOLS |
— | Additional pip packages to install (e.g. ruff pytest) |
Headless / multi-agent only:
| Env Var | Default | Description |
|---|---|---|
MAX_ITERATIONS |
0 (infinite) |
Stop after N loop iterations |
LOOP_DELAY |
5 |
Seconds between iterations |
AUTO_COMMIT |
wip |
wip = commit uncommitted changes as safety net, on = always commit, off = never |
AGENT_BRANCH |
auto | Branch name for multi-agent (default: agent-$ID) |
PROMPT_FILE_1/2/3 |
PROMPT_FILE |
Per-agent prompt overrides (multi-agent only) |
Watch / interactive only:
| Env Var | Default | Description |
|---|---|---|
RESPAWN |
false |
Restart Claude automatically after each session |
LOOP_DELAY |
5 |
Seconds between respawns |
SKIP_PROMPT |
false |
Skip prompt injection (set automatically for interactive) |
AUTO_RALPH |
false |
Auto-start Ralph loop for bounded autonomous iteration |
AUTO_RALPH_MAX_ITERATIONS |
10 |
Max Ralph loop iterations |
AUTO_RALPH_COMPLETION_PROMISE |
TASK_COMPLETE |
Token that signals task completion to Ralph |
When AUTO_SETUP=true (default), AgentMill bootstraps the repo's dev environment:
REPO_SETUP_COMMANDif set, otherwise:pyproject.toml+uv.lock→uv sync --frozenpyproject.tomlalone →pip install .requirements.txt→pip install -r requirements.txt
The .venv/bin is prepended to PATH, so tools like pytest and ruff are available to Claude.
Recommendation: Add a Makefile to your upstream repo with an install target that sets up the full dev environment. Then point AgentMill at it:
REPO_SETUP_COMMAND='make install' docker compose up headlessThis keeps build logic in the repo where it belongs, and any setup — system deps, virtual envs, code generation — just works.
| Host | Container | Purpose |
|---|---|---|
./prompts |
/prompts |
Agent prompt files |
./logs |
/workspace/logs |
Session logs |
$REPO_PATH |
/workspace/repo or /workspace/upstream |
Target repository |
~/.claude.json |
/home/agent/.host-claude.json |
Host Claude config (read-only) |
~/.claude/settings.json |
/home/agent/.claude/settings.host.json |
Host settings (read-only) |
If a dependency lacks a Linux arm64 wheel, build or force x86 emulation:
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker compose buildClaude runs with --dangerously-skip-permissions inside the container. That is intentional — the container is the boundary, which is why AgentMill is container-first. Do not run the entrypoints directly on your host.
To report a vulnerability, see SECURITY.md.
MIT © Michal Kurc
