Skip to main content

Run coding agents (Claude Code, pi, ...) in isolated Docker containers

Project description

clankr

Run coding agents in isolated Docker containers.

Supports multiple agent harnesses:

install

uv tool install clankr

setup

clankr init
# prompts for: github username, bot username, PAT, default harness

Create a classic PAT on the bot account with repo scope.

per-repo setup (recommended)

clankr setup-repo user/project
# then accept the invitation (log in as bot → github.com/notifications)

This adds the bot as a collaborator and configures the repo with:

  • Branch protection: PRs required for main, owner bypasses
  • Squash merge only, auto-delete branch on merge

This step is optional — agents work without it, but branch protection prevents them from pushing directly to main.

pi auth

Pi authenticates via ~/.pi/agent/auth.json (OAuth or API key). Options:

  • API key: set ANTHROPIC_API_KEY in your environment — pi reads it directly
  • pi OAuth: run pi/login to authenticate with a provider
  • clankr auth: convert Claude CLI OAuth tokens to pi format (use at your own risk)

usage

clankr launch user/project                        # interactive, bare profile, default harness
clankr launch -H pi user/project                  # use pi harness
clankr launch -p my-profile user/project          # custom configuration profile
clankr launch -d user/project                     # detached (tmux)
clankr launch -d -s auth-fix user/project         # named slot
clankr launch /path/to/local/repo                 # local repo

clankr run user/project -- -p "prompt"                # non-interactive, stdout capture
clankr run /path/to/repo -p ./profile -- -p "prompt"  # local repo, custom profile path

clankr sync user/project /path/to/host/repo       # register session sync mapping
clankr sync                                       # list sync mappings

clankr resume project-1                           # relaunch a stopped slot
clankr attach project-1                           # reattach to detached agent
clankr save project-1 /path/to/host/repo          # export sessions to host
clankr ls                                         # list slots
clankr rm project-1                               # remove (warns if unpushed)
clankr clean                                      # remove all stopped clean slots
$ clankr ls
SLOT                 HARNESS  PROFILE  STATUS       SYNC   REPO
hello-world-1        claude   bare     detached     yes    /home/max/.local/share/clankr/repos/hello-world-1
project-2            pi       bare     running      -      /home/max/.local/share/clankr/repos/project-2
project-1            claude   bare     stopped      -      /home/max/.local/share/clankr/repos/project-1

profiles

Each profile is an agent config — settings, init scripts, host mounts. Clankr ships with one profile (bare); for a real-life example see e.g. MaxWolf-01/agents.

-p takes a profile name (looked up in ~/.config/clankr/profiles/) or a path to a profile directory. Each profile is a directory with any of:

  • CLAUDE.md — context file for Claude Code harness
  • AGENTS.md — context file for pi (and other) harnesses. If only one exists, it's used for both.
  • claude.settings.json — Claude Code settings
  • pi.settings.json — pi settings. An env key here is extracted by clankr and passed as docker --env (pi ignores unknown keys; this is how we get env vars in since pi's schema has no native env field)
  • pi.SYSTEM.md — pi system prompt override (pi's default prompt triggers Anthropic's subscription-blocking detection; see agent/knowledge/pi-auth.md)
  • init — executable script that runs inside the container before the agent starts
  • mounts — bind-mount host paths into the container (one per line: source:destination[:ro|rw], default rw, ~ expanded, ./ relative to profile dir)
clankr profiles                                   # list available profiles
cp -r ~/.config/clankr/profiles/bare ~/.config/clankr/profiles/my-custom
vim ~/.config/clankr/profiles/my-custom/CLAUDE.md

how it works

  • each slot gets its own repo clone and agent config
  • harness: -H selects the agent runtime (claude, pi). Default configurable via clankr init
  • session sync: sessions bind-mounted to the host for the active harness's session layout
  • session preservation: rm/clean auto-archive sessions before deleting (--purge to skip)
  • credentials copied fresh from host on each launch (Claude: ~/.claude/.credentials.json, pi: ~/.pi/agent/auth.json)
  • -d wraps the container in a tmux session — survives SSH disconnects
  • git identity: configurable bot account with scoped PAT
  • branch protection via setup-repo: require PR + approval for main, owner bypasses, squash-only merges

commands

Command Description
clankr init First-time setup: config + default profiles
clankr launch Launch an agent (-H harness, -p profile, -s slot, -d detach)
clankr run Run agent non-interactively (-H harness, -p profile, -s slot, -- args)
clankr ls List all slots
clankr resume <slot> Relaunch a stopped slot (keeps repo, profile, sync)
clankr attach <slot> Attach to detached agent's tmux session
clankr auth Convert Claude CLI OAuth tokens to pi auth format
clankr sync [repo] [path] Manage session sync mappings (list / add / --remove)
clankr save <slot> <path> Export sessions to host for backup/resume
clankr rm <slot> Remove slot, auto-archives sessions (--purge to skip)
clankr clean Remove all stopped clean slots, auto-archives (--purge to skip)
clankr logs <slot> Show container logs
clankr setup-repo <repo> Add bot collaborator + branch protection + squash merge
clankr profiles List available profiles
clankr version Print clankr version

paths

What Where
Config ~/.config/clankr/config.toml
Sync mappings ~/.config/clankr/sync_map.json
Profiles ~/.config/clankr/profiles/
Dockerfile override ~/.config/clankr/Dockerfile.{claude,pi}
Repo clones ~/.local/share/clankr/repos/
Slot state ~/.local/share/clankr/run/
Archived sessions ~/.local/share/clankr/sessions/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clankr-2.0.1.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clankr-2.0.1-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file clankr-2.0.1.tar.gz.

File metadata

  • Download URL: clankr-2.0.1.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clankr-2.0.1.tar.gz
Algorithm Hash digest
SHA256 1794431c025afd8c4ace1a3f898d3250c63de3dbf66c991c8a2c979337ca7421
MD5 0de7bbc95a42b25f8d971cc2fc29f82e
BLAKE2b-256 f85812339e498ec9649d7b8f06dadfef04ab3ae12c8d2617a751cb20b2b315c1

See more details on using hashes here.

File details

Details for the file clankr-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: clankr-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clankr-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97b36f09a7bd1ba7388e55ca2e5271dde797d23c01d6fa5f4e0132e1e1ec0091
MD5 a74996b4e7cbfda09b73f2daaa22a60c
BLAKE2b-256 7ad1bc5191cad290813a31f29a24f22620587f06713c19013377092c0b5a97b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page