CI status

If Claude Code is where you work, cpb is how you run more than one of it.

One ~/.claude holds one setup: one set of settings and hooks, one memory, one login, one environment, all with full access to your machine. cpb (Claude PlayBooks) gives you as many Claude Codes as you need, each behind its own launcher, each isolated as far as you choose, and each described in a file you can apply anywhere.

quick start
$ cpb CREATE PLAYBOOK work                                               # a playbook, and a `work` command that opens it
$ cpb CREATE PLAYBOOK side SET login = 'isolated'                        # a second account, running beside the first
$ cpb CREATE PLAYBOOK sre SET sandbox.always = true, login = 'isolated'  # every launch inside a microVM
$ work                                                                   # Claude Code, bound to that playbook
verified against v4.2.0, throwaway HOME

Four layers

Isolation, as far as you choose

Each playbook gets its own config, and can go further: its own environment, its own login, or its own process boundary. You decide per playbook.

Config home

Its own CLAUDE.md, settings.json, hooks, memory, history, sessions, plugins, MCP servers and skills. Your ~/.claude never moves.

every playbook, always

Environment

Its own account (where requests go, one credential by reference, the provider's model names) and its own variables, set or blocked at launch. Your shell stays as it is.

USE ACCOUNT · SET VAR · BLOCK VAR

Login

Its own Claude login, sharing nothing with ~/.claude.

login = 'isolated'

Process

A microVM with its own kernel, filesystem and network. It sees only your working directory and its own config; your machine's login never enters it. By default a host-side proxy injects backend API keys, so the sandbox never holds them.

sandbox.always · --sandbox

Try it

Try things without touching your daily setup

A scratch playbook, used and dropped. ~/.claude is never touched.

real run, v4.2.0
$ cpb CREATE PLAYBOOK scratch
Created playbook "scratch" at /home/you/.claude-playbooks/scratch
Launcher: scratch  (at /home/you/bin/scratch)

Run it now:
  'scratch'
$ cpb SHOW PLAYBOOK scratch
Name:                 scratch
Version:              (none)
Path:                 /home/you/.claude-playbooks/scratch
Source:               (none)
Launcher:             scratch
Env sets:             (none)
Variables:            (none)
Sandbox:              no
Login:                shared with ~/.claude (default)
Global instructions:  excluded (default): ~/.claude's CLAUDE.md and rules are not loaded (SET global_instructions = 'inherited' loads them)
$ cpb DROP PLAYBOOK scratch --yes
Removed launcher "scratch"
Deleted playbook "scratch".
verified against v4.2.0, throwaway HOME

A throwaway session in a throwaway folder works the same way: cpb start /tmp/x --delete.

Accounts & models

Route one playbook to another model

An account says where a playbook's requests go and how they authenticate: the provider, its address, one credential by reference and the provider's model names. A playbook names the accounts it may run on, and every launch takes its address, key and models from one of them, so an address never changes while its key stays behind. A custom /model list travels with the playbook too.

real run, v4.2.0
$ cpb CREATE ACCOUNT router SET provider = 'gateway', base_url = 'http://localhost:4000/v1', auth_token FROM 'keychain:router-key', model = 'glm-5.3'
Created ACCOUNT router
  provider  gateway
  base_url  http://localhost:4000/v1
  auth_token  <from keychain:router-key>
  model  glm-5.3
$ cpb CREATE PLAYBOOK glm SET login = 'isolated' USE ACCOUNT router
Created playbook "glm" at /home/you/.claude-playbooks/glm
Login isolated: it shares no login with ~/.claude; run /login once in it.
Launcher: glm  (at /home/you/bin/glm)

Run it now:
  'glm'
Altered PLAYBOOK glm
  accounts  router
$ cpb ALTER PLAYBOOK glm ADD MODEL 'glm-5.3' LABEL 'GLM 5.3' DESCRIPTION 'via the router'
Altered PLAYBOOK glm
  model     glm-5.3
$ cpb ALTER PLAYBOOK glm ADD MODEL 'glm-5.3-flash' LABEL 'GLM 5.3 Flash' BEHAVES AS 'claude-sonnet-5'
Altered PLAYBOOK glm
  model     glm-5.3-flash
$ cpb ALTER PLAYBOOK glm SET model_picker.mode = 'only'
Altered PLAYBOOK glm
  picker    only
$ cpb SHOW ACCOUNTS
NAME    PROVIDER  ADDRESS                   CREDENTIAL                           ACCESS  USED BY
----    --------  -------                   ----------                           ------  -------
router  gateway   http://localhost:4000/v1  auth_token from keychain:router-key  any     glm
$ cpb EXPLAIN PLAYBOOK glm
A launch of glm changes no environment variables.

Secret helper: /home/you/helper (from CPB_SECRET_HELPER)
Login: isolated, shares nothing with ~/.claude: no link to its login and no machine token; /login once in it (SET login = 'shared' shares it again)
Global instructions: excluded (default): ~/.claude's CLAUDE.md and rules are not loaded (SET global_instructions = 'inherited' loads them)
Account: router (gateway http://localhost:4000/v1, auth_token from a reference; the playbook's first)
Plugins: (none)
Agent: (none)
Model: glm-5.3 (account router); a launch's --model and /model still win
Model picker: only: glm-5.3 (GLM 5.3), glm-5.3-flash (GLM 5.3 Flash)
verified against v4.2.0, throwaway HOME, with a stand-in secret helper

login = 'isolated' keeps your Claude login away from that provider: cpb refuses a playbook that shares your login on an account that uses none. cpb run glm --account <name> runs one launch on another account the playbook lists, and a variable that tries to route around the account refuses the launch. The accounts guide →

Process isolation

Let an agent loose without letting it near your machine

With --sandbox, Claude Code runs in a microVM that sees your working directory and the playbook's own directory — not your home, ~/.claude, your shell's environment, or your other playbooks.

sbx (Docker Sandboxes)
$ cpb run --sandbox work                                         # this folder is the workdir
$ cpb run --sandbox --sandbox-fresh --clone --workdir ~/untrusted-repo work   # a private clone; your tree is untouched
$ cpb run --sandbox --mount ~/shared-libs:ro work                # one more directory, read-only
$ cpb run --sandbox-host me@buildbox work                        # the same launch, sandboxed on another machine

By default your backend API keys stay on the host: the sandbox sees a placeholder that a host-side proxy swaps for the real key, for that endpoint only. If a key can't be registered with the proxy, the launch refuses rather than fall back to sending it in plain; ALTER PLAYBOOK work SET sandbox.secrets = 'env' is the only way to pass one in as a variable instead. A sandbox.always playbook is sandboxed on every launch: ALTER PLAYBOOK work SET sandbox.always = true, login = 'isolated' makes an existing playbook one, and SET sandbox.always = false turns it off. The sandbox settings (backend, host, mounts, allow_net and the rest) are set one by one the same way: SET sandbox.host = 'me@buildbox'.

The DDL grammar

Put the whole setup in a file

Every statement above can live in a .cpb file: a recipe, since its ALTER PLAYBOOK names no playbook. APPLY checks all of it before writing anything, --dry-run shows every change, and applying twice changes nothing.

reviewer.cpb
-- reviewer.cpb: a recipe (it names no playbook)
ALTER PLAYBOOK
  ADD MCP SERVER files COMMAND 'npx' ARGS '-y' '@modelcontextprotocol/server-filesystem' '/srv/notes'
  ALLOW TOOL 'Bash(gh pr *)'  DENY TOOL 'Bash(git push *)'
  ADD SKILL review FROM '/home/you/skills-src/review'
  SET model = 'claude-opus-5-5';
real run, v4.2.0
$ cpb APPLY reviewer.cpb TO reviewer --dry-run
reviewer.cpb:2       created   CREATE PLAYBOOK reviewer
reviewer.cpb:2       changed   ALTER PLAYBOOK reviewer  (would run: claude mcp add-json files --scope user; link skills/review to /home/you/skills-src/review)
Would apply reviewer.cpb: 1 created, 1 changed, 0 unchanged, 0 dropped
$ cpb APPLY reviewer.cpb TO reviewer
-- reviewer.cpb:2: CREATE PLAYBOOK reviewer
Created playbook "reviewer" at /home/you/.claude-playbooks/reviewer
Launcher: reviewer  (at /home/you/bin/reviewer)

Run it now:
  'reviewer'
-- reviewer.cpb:2: ALTER PLAYBOOK reviewer
Altered PLAYBOOK reviewer
  MCP server files
  skill     review (link of /home/you/skills-src/review)
  allow     Bash(gh pr *)
  deny      Bash(git push *)
  model     claude-opus-5-5
Applied reviewer.cpb: 1 created, 1 changed, 0 unchanged, 0 dropped
$ cpb SHOW CREATE PLAYBOOK reviewer --skip-secrets
CREATE OR ALTER PLAYBOOK reviewer
  RESET launcher
  SET login = 'shared', global_instructions = 'excluded'
  RESET sandbox, agent, statusline, model_picker.mode
  USE ENV ''
  USE ACCOUNT '';

ALTER PLAYBOOK reviewer
  ALLOW TOOL 'Bash(gh pr *)'
  DENY TOOL 'Bash(git push *)'
  SET model = 'claude-opus-5-5';

ALTER PLAYBOOK reviewer
  ADD MCP SERVER files COMMAND 'npx' ARGS '-y' '@modelcontextprotocol/server-filesystem' '/srv/notes'
  ADD SKILL review FROM '/home/you/skills-src/review';
verified against v4.2.0, throwaway HOME

Secrets are references, resolved at launch by your helper; SHOW CREATE never prints a value. A recipe applies to any playbook or to ~/.claude itself. cpb SHOW CREATE ALL > playbook.cpb exports the whole machine; cpb APPLY playbook.cpb rebuilds it on the next one.

Configuration

MCP servers, with secrets by reference

ADD MCP SERVER builds the config and runs Claude Code's own claude mcp add-json for the playbook. A credential must come FROM '<ref>': Claude's config gets only a placeholder, and a configured secret helper resolves it into the session at launch.

real run, v4.2.0
$ cpb ALTER PLAYBOOK researcher ADD MCP SERVER sentry URL 'https://mcp.sentry.dev/mcp' HEADER 'Authorization' FROM 'keychain:sentry-auth'
Altered PLAYBOOK researcher
  MCP server sentry
$ cpb EXPLAIN PLAYBOOK researcher
VARIABLE                                 VALUE                        FROM
--------                                 -----                        ----
CPB_MCP_SENTRY_H_AUTHORIZATION_32770652  <from keychain:sentry-auth>  PLAYBOOK researcher

Secret helper: /home/you/helper (from CPB_SECRET_HELPER)
Global instructions: excluded (default): ~/.claude's CLAUDE.md and rules are not loaded (SET global_instructions = 'inherited' loads them)
Account: machine (Anthropic, the playbook's own login; none named)
Plugins: (none)
Agent: (none)
MCP servers: files, sentry
$ cpb SHOW CREATE PLAYBOOK researcher --skip-secrets
CREATE OR ALTER PLAYBOOK researcher
  SET launcher = '', login = 'shared', global_instructions = 'excluded'
  RESET sandbox, model, agent, statusline, model_picker.mode
  USE ENV ''
  USE ACCOUNT '';

ALTER PLAYBOOK researcher
  ADD MCP SERVER files COMMAND 'npx' ARGS '-y' '@modelcontextprotocol/server-filesystem' '/srv/notes'
  ADD MCP SERVER sentry URL 'https://mcp.sentry.dev/mcp' HEADER 'Authorization' FROM 'keychain:sentry-auth';
verified against v4.2.0, throwaway HOME

The value never appears in a file, in argv, or in any SHOW/EXPLAIN output. Claude's own config gets only ${CPB_MCP_SENTRY_H_AUTHORIZATION_…}, which the secret helper expands at launch.

Sessions & SQL

See everything that is running

cpb SHOW SESSIONS lists every live Claude Code session, in every playbook. SELECT queries the same state as tables — built in for plain column lists, or through clickhouse local for WHERE, ORDER BY and functions.

real run, v4.2.0, with example 18's stand-in session
$ cpb SHOW SESSIONS
PLAYBOOK  PID     TTY  KIND         STATUS  AGE  ACTIVE  MODEL            SESSION                               CWD
--------  ---     ---  ----         ------  ---  ------  -----            -------                               ---
worker    447747  -    interactive  idle    0s   0s      claude-opus-5-5  0e5c1a2b-0000-4000-8000-000000000001  /home/you/project
$ cpb "SELECT name, accounts, login FROM PLAYBOOKS"
name	accounts	login
glm	router	isolated
researcher	-	shared
reviewer	-	shared
side	-	isolated
sre	-	isolated
work	-	shared
$ cpb "SELECT name, login FROM PLAYBOOKS WHERE has(accounts, 'router') ORDER BY name"
name	login
glm	isolated
verified against v4.2.0, throwaway HOME (SELECT …WHERE via clickhouse local)

cpb run worker --continue resumes the newest session in this folder, and --resume <id> resumes one, through its playbook (a launcher takes the same flags). cpb refuses a session that is still live — two processes on one session id would corrupt it — and one typed in the wrong folder. SHOW SESSIONS --json gives each session's resume command in its resume field, cd included.

cpb tui

Browse playbooks, sessions and env sets on one screen

A read-only terminal UI over the grammar: every screen names the cpb … --json statement it reads, on its last line. No screen ever holds a secret value. The blocks below are the real screens, from cpb's own test goldens.

cpb tui — Playbooks (80×24)
 cpb  [1 Playbooks]  2 Sessions   3 Env sets   4 Defaults   5 Log        ? help
────────────────────────────────────────────────────────────────────────────────
  NAME    LAUNCHER  VERSION  ENV SETS  LOGIN     SESSIONS  MODEL
▸ alpha   al        v1.2.0   -         shared    1         claude-opus-5-5
  router  rt        -        proxy     isolated  1         glm-5.3

────────────────────────────────────────────────────────────────────────────────
 2 playbooks · 2 live sessions · read 0s ago
 enter open  s sessions  c SHOW CREATE  e export  y copy  / filter  q quit
reads: cpb SHOW PLAYBOOKS --json · cpb SHOW SESSIONS --json
cpb tui — a playbook's Overview (80×24)
 cpb   1 Playbooks   2 Sessions   3 Env sets   4 Defaults   5 Log        ? help
────────────────────────────────────────────────────────────────────────────────
 router  (launcher rt · ~/.claude-playbooks/router)
 [Overview] Env  Vars  Plugins  MCP  Skills  Status line  Model  Sessions

  Version         -
  Source          (none)
  Login           isolated
  Env sets        proxy
  Tools           -
  Live sessions   1 · newest 2d ago in ~/DEV/app

────────────────────────────────────────────────────────────────────────────────
 2 playbooks · 2 live sessions · read 0s ago
 ←→/1-9 tab  c SHOW CREATE  e export .cpb  y copy  r refresh  esc back  q quit
reads: cpb SHOW PLAYBOOK router --json · cpb SHOW SESSIONS --json

cpb tui in a terminal opens it; a script reads the same state with the statement named on the screen's last line.

Testing

How it is tested

Every change is tested the same way, on the exact commit a release tags.

23 examples applied in CI on every change — dry run, apply, re-apply (no-op), then each README's own checks
upgrade-tested the previous release's binary applies its own examples; this build takes over the same state and must read it identically
arena regression a full gentar run on the exact commit each release is tagged from

CI status

Get it

Install

install
$ curl -fsSL https://raw.githubusercontent.com/ramazanpolat/claude-playbooks/main/install.sh | sh
$ cpb --version
cpb version v4.2.0
verified against v4.2.0

Linux and macOS, amd64/arm64 (no native Windows — WSL works). devbox, Nix, npx and source builds →