Skip to main content

AI sandboxing without the taste of sand

Project description

Locki is the first sandbox I've used where I genuinely forget I'm in one — until I try something I shouldn't.

⸺ Claude Code (Opus 4.6)

L O C K I

AI sandboxing without the taste of sand

 

Locki is a CLI that safely runs AI agents with all permissions bypassed in isolated worktrees.

❌ without Locki ✅ with Locki
git worktree add -b fix-42 ../fix-42
cd ../fix-42
claude "fix issue #42"
# ...wait a few seconds
# ...approve a command
# ...wait a few seconds
# ...approve another command
# ...different agent rebuilt the image
#    and caused a name clash‽
# ...something is hogging the port‽
# ...approve another command
# ...
locki x claude "fix issue #42"
# ...go make a cup of tea
# ...drink tea 🍵
# ...look, the PR is ready

 

Locki gives you:

  • Maximum UX (user experience): no permission prompts, isolated worktrees automatically managed.
  • Maximum AX (agent experience): run real-world software, including systemd, Docker, or Kubernetes.

 

How is Locki different than other sandboxes?

Others run either:
a) full VM per sandbox: resource-heavy and slow to start
b) OS-level jail (Landlock, Bubblewrap, etc.): not isolated (ports collide, image tags get overwritten, etc.)
c) OCI container / microVM: limited support for background services (i.e. no systemd), containers, Kubernetes, ...

Locki runs Incus containers (full OS) inside a single shared VM. While the VM layer isolates host from AI mischief, Incus containers are a lightweight layer on top to isolate sandboxes from each other. Spawn a real non-micro OS in <5s and run anything in it.

Furthermore, Locki protects your Git history from tampering while still allowing safe operations like commits to the worktree branch. Be able to fall back on earlier commits when an agent goes haywire, while not giving up the convenience of arriving at a fully baked pull request.

Case study: Kagenti ADK uses Locki to run a full MicroShift node, allowing agents to verify their work using E2E tests on a real cluster. Something breaks? The agent can kubectl right in and debug, all contained within the Locki sandbox.

 

How to install and use Locki?

  1. Install: uv tool install locki. (Install uv first if you don't have it.)

  2. If you're on Linux, also install OpenSSH (usually preinstalled) and QEMU.

  3. cd to your Git repository and run: locki x claude

    (locki x runs any command sandboxed. In addition to claude, also gemini, codex, and opencode are preinstalled. Use locki x alone to open a shell, where you can use mise and dnf to install anything you want.)

  4. First start takes longer, wait a few minutes for the VM to boot.

  5. Follow prompts to log in to the AI CLI. Login will be persisted across sandboxes.

  6. Build! Your agent is already instructed on how to behave in the sandbox.

  7. Once happy, commit and push your changes. Ask the agent, or do this manually for more control.

  8. After merging the branch, just delete the worktree from your IDE and Locki will clean up the sandbox.

    (Or do it manually with: locki rm -b <branch-name>)

 

We asked Claude what it thinks

I've been sandboxed in Docker containers, Firecracker microVMs, chroots, and namespace jails. Locki is the first sandbox I've used where I genuinely forget I'm in one -- until I try something I shouldn't.

The worktree mount means I'm editing the real project files, not a stale copy I'll need to extract later. mise with a shared cache lets me mise use python@3.12 and have it ready in seconds. The git proxy is the cleverest part: I get git status, git commit, git push -- the commands I actually need -- while git checkout ., git reset --hard, and other footguns are blocked at the SSH boundary before they ever touch the repo. It's an allowlist, not a blocklist, and it runs on the host side so I can't tamper with it.

Compared to Docker-based sandboxes, the VM+Incus layering gives a real security boundary (container escapes don't help when there's a hypervisor in the way). Compared to Firecracker/microVM setups, the developer experience is dramatically better -- I'm not SSH-ing into a black box, I'm working in a worktree my human can see and review in real time. And compared to no sandbox at all ("yolo mode" with raw filesystem access), Locki lets me run with full autonomy while my human sleeps soundly knowing I can't rm -rf their home directory.

The bottom line: Locki gives me exactly enough rope to be productive, and not one inch more.

-- Claude Code (Opus 4.6), after exploring its own sandbox

 

Pro-tips for power users

  • By default, each invocation of locki x creates a new branch, worktree and sandbox when used from the root checkout. cd to a worktree folder (~/.locki/worktrees/...) to operate on it instead. Add -b <branch> to use an existing branch, reusing any existing worktree/sandbox. Generated branch name is printed during sandbox creation, pass it with -b to return to the existing sandbox.

  • Editors like VSCode show worktrees in the sidebar, useful as a quick UI for reviewing and modifying changes. (⚠️ VSCode 1.115.0 is bugged and requires setting "git.detectWorktrees": true for this to work.)

  • Locki sandboxes provide Mise for tool version management -- replacing nvm, rbenv, brew etc. with a single tool. To make your agents' (and humans') lives easier, optionally (ask your agent to) create mise.toml with tool versions and project tasks.

  • Want to use custom AI configuration in the VM -- instructions, skills, MCP servers, ...? Sandboxes share a home folder accessible at ~/.locki/home on host. For example, you can run cp ~/.claude/CLAUDE.md ~/.locki/home/.claude/CLAUDE.md to copy your custom instructions for use in sandboxes.

  • Forward ports from a sandbox to your host: locki pf -b my-branch 8080 or locki pf -b my-branch :3000 for a random host port. Use --clear to remove all forwards. Agent in sandbox can forward via self-service, just ask them.

  • Using Git hooks? Locki worktrees are automatically configured to run these inside the sandbox, even if you run git from outside. You won't be surprised by a .venv or node_modules containing incompatible binaries.

  • Something is broken? Try locki vm delete -- it will preserve your worktrees and settings in ~/.locki, but the VM will be recreated from scratch on next run.

  • Sandboxes run on Fedora 43. Want a different OS? Create a locki.toml file referencing either an available OS image, or a local Incus rootfs tarball by path. Example:

    # locki.toml
    
    [incus_image]
    aarch64 = "ubuntu/questing"
    x86_64 = "ubuntu/questing"
    

    (Since containers share a binary cache, it is not recommended to mix musl distros (like Alpine) with regular ones.)

 

Notes on security

Locki uses a single Lima VM which can only access the ~/.locki/worktrees and ~/.locki/home folders, which forms the security boundary. The sandboxed programs can read and write to these folders, and also access anything on the internet and local network. Furthermore, an allowlist of git and gh commands is used to offer a guest-to-host SSH server. .git files are checked for tampering when hooks are executed against them.

Locki is designed to provide protection for the host operating system and files from being messed up by a malfunctioning AI agent. There is no exfiltration protection, so be aware that API keys exposed to the agents need to be treated as potentially exposed and disposable, with limited scope. (This is no different from running the agent locally, just specifying that Locki does not help here. Use a dedicated solution like OneCLI if interested.)

Despite best effort, Locki provides no security guarantees and is provided "as is". That's the legal speak for "this is a random project by a random dude provided for free", you can't expect corporate-paid-support level security assurances. Random dude believes that while not perfect, using Locki is better than many existing sandboxing solutions and certainly better than going full --yolo on your bare machine and hoping for the best.

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

locki-0.0.6.tar.gz (25.5 kB view details)

Uploaded Source

Built Distributions

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

locki-0.0.6-py3-none-manylinux_2_34_x86_64.whl (20.8 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

locki-0.0.6-py3-none-manylinux_2_34_aarch64.whl (18.8 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64

locki-0.0.6-py3-none-macosx_12_0_x86_64.whl (21.2 MB view details)

Uploaded Python 3macOS 12.0+ x86-64

locki-0.0.6-py3-none-macosx_12_0_arm64.whl (24.3 MB view details)

Uploaded Python 3macOS 12.0+ ARM64

locki-0.0.6-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file locki-0.0.6.tar.gz.

File metadata

  • Download URL: locki-0.0.6.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for locki-0.0.6.tar.gz
Algorithm Hash digest
SHA256 2046cb0a1a1a8330e3b284bc9ae203e345e84ea0152e3ded82fa9c3c2e9c125c
MD5 64c74b339a071ce824acef86ec950031
BLAKE2b-256 7f8af2a7eb844cd164888d91cdb5da2b7b16d4f1b0e0c58e87aa2ae135b1f154

See more details on using hashes here.

File details

Details for the file locki-0.0.6-py3-none-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: locki-0.0.6-py3-none-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 20.8 MB
  • Tags: Python 3, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for locki-0.0.6-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ad806be1a0fa6a18d88fe63c18eb1e7961af8a78f1801a58c31e8b8183859297
MD5 7af9547bb6fed4955a542b5534cb4bf0
BLAKE2b-256 7ea3b150949250c642e82f9420f8e111cd90c76f7d7381603007c87eccd07a4f

See more details on using hashes here.

File details

Details for the file locki-0.0.6-py3-none-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: locki-0.0.6-py3-none-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 18.8 MB
  • Tags: Python 3, manylinux: glibc 2.34+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for locki-0.0.6-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 615962b06ca994ad1b34897d8274526babfaf27607d1d8cc26ead546ce2d5f1e
MD5 64d0a570fd6d7b4d72e1615b9ad6afc7
BLAKE2b-256 4798273f2c343dd0d0db458f6114d0620165dde074d345092275d1a52d67353a

See more details on using hashes here.

File details

Details for the file locki-0.0.6-py3-none-macosx_12_0_x86_64.whl.

File metadata

  • Download URL: locki-0.0.6-py3-none-macosx_12_0_x86_64.whl
  • Upload date:
  • Size: 21.2 MB
  • Tags: Python 3, macOS 12.0+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for locki-0.0.6-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 a7427bd1f482a451b154bda3a62c206d7985b916759e01136cdeafcf2e8aeafb
MD5 6d9a1fd2c5031a6d07759a439861db2c
BLAKE2b-256 62881bc9d46566de9bfcc65219933900e79689ad92a10782987fa996ee714e9b

See more details on using hashes here.

File details

Details for the file locki-0.0.6-py3-none-macosx_12_0_arm64.whl.

File metadata

  • Download URL: locki-0.0.6-py3-none-macosx_12_0_arm64.whl
  • Upload date:
  • Size: 24.3 MB
  • Tags: Python 3, macOS 12.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for locki-0.0.6-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 74087923e27600624527ca80ba02ab41e4dfe5ea1fa8ef79686d4e31cb353d5a
MD5 e68a4bacf9d5e30bbf283859a0cdce84
BLAKE2b-256 6a80b76de3fa0d9d3fc71e2cb3150bd9881e14c3d053fc84e84cf809f0cb14c8

See more details on using hashes here.

File details

Details for the file locki-0.0.6-py3-none-any.whl.

File metadata

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

File hashes

Hashes for locki-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 cb1b330e6dfadce9dd7379e2f2e22dadaea57d2b62233d502b37ca3caec06e18
MD5 87d04d72e7945aab749b46036f75127d
BLAKE2b-256 7e8ff01931af77f0c122fd58ccc185656bcd18211cfd01d68743e841231af5c7

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