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

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

 

Selling Points

  • First-class DX: locki ai, work in your CLI of choice. Zero config. No sign Locki is even there.
  • No compromises: Run anything including systemd, containers, even Kubernetes clusters.
  • Safe Git: Sandboxes are only able to modify namespaced branches. Stash is scoped. Hooks are redirected.
  • Visibility and control: Worktrees live on your computer, see and modify them right there.
  • Agent-friendly: Bundled hand-picked tools and sandbox-specific instructions for best behavior.

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.

 

Tutorial

  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 ai

    (Supported harnesses: claude, gemini, codex, opencode, pi.)

  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. Run locki ai again to open an interactive selector: continue existing session, or start a new one.

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

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

    (Or do it manually with: locki remove)

 

Comparison

Most sandboxing solutions use one of these techniques:

  • Full VM per sandbox: resource-heavy, slow to start
  • MicroVM per sandbox: none or limited support for building, running and orchestrating containers
  • OCI container per sandbox: none or limited support for building, running and orchestrating containers; potentially unsafe if runing VM-less on Linux
  • OS-level jail (Landlock, Bubblewrap, etc.): just restriction, not isolation (ports collide, image tags get overwritten, etc.)

To my knowledge Locki is the only one packing a fully vertically integrated Incus-based solution. Seriously, stop reading this README and run uvx locki ai, that's all there is.

 

Pro-tips for power users

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

  • locki list shows worktree paths. cd to a worktree folder (~/.local/share/locki/worktrees/...) to operate on it directly. locki commands default to operating on the corresponding sandbox when in worktree folder.

  • While locki ai opens a coding agent, locki exec (or short locki x) is the low-level version which can run any command. Pass a command to run in a sandbox, use --match/-m to select by branch substring or sandbox id: locki exec -m big-refactor -- pytest.

  • The first locki ai run prompts you to pick a default harness; change it later in ~/.config/locki/config.toml under [ai] harness = "...".

  • Ask your agent to forward ports, or use locki port-forward for more control.

  • Locki sandboxes provide Mise for tool version management -- replacing nvm, rbenv, brew etc. with a single tool. Adding mise.toml to your repo with tool versions and task definitions will help agents and humans alike: ask your agent to do it!

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

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

  • Sandboxes run on Fedora 43. Want a different OS? Create a locki.toml file in repo root 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 ~/.local/share/locki/worktrees and ~/.local/share/locki/home folders (honoring $XDG_DATA_HOME), 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, a guest-to-host SSH server exposes a limited set of git and gh subcommands, with write access restricted to the sandbox's own namespaced branches and stashes (so an agent in one sandbox cannot alter another sandbox's branch, the main branch, or unrelated stashes). .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.

 

Tech

  • Python CLI
  • Single Lima VM
  • Multiple Incus containers
  • Mise for ergonomic package installation
  • Host proxy for self-service commands (git, gh, port forwarding)

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.11.tar.gz (31.0 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.11-py3-none-manylinux_2_34_x86_64.whl (20.8 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

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

Uploaded Python 3manylinux: glibc 2.34+ ARM64

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

Uploaded Python 3macOS 12.0+ x86-64

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

Uploaded Python 3macOS 12.0+ ARM64

locki-0.0.11-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: locki-0.0.11.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.11.tar.gz
Algorithm Hash digest
SHA256 84c14a7d6c56fc623a2d9ede4fe158afdec93c21086f4654e0d182bfc142a420
MD5 2f3b3c2eeee099a379b57add4e1ca812
BLAKE2b-256 221566cf199e88c2ac7fcacf48a82fdc42aa898de0e9385fcbf35ca7ccc8b7d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: locki-0.0.11-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.6 {"installer":{"name":"uv","version":"0.11.6","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.11-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 655b763e126e5fe5c0d9c3a90848661bd0c04392d06396e664d1bb01cda5864a
MD5 020271ee20740954d72093a317f6b197
BLAKE2b-256 f56e4ef8c3086991ffe29d0b0577162c87136ba6db713b9ae8c366eb95370dc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: locki-0.0.11-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.6 {"installer":{"name":"uv","version":"0.11.6","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.11-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 9a52ecec8e2f93d43ff9da1e59e778faa8b9b1787ff1be7b75d5312450e034cd
MD5 b929e6d8e6271c68f29ccaab7a07cc18
BLAKE2b-256 33d3a0d787f29e51f14aa1289abeceb4f6bcf1c4ad04b01429480e96ebbe809a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: locki-0.0.11-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.6 {"installer":{"name":"uv","version":"0.11.6","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.11-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 9a54e732fe9d06c16506767bfafe2892fcd508e30bc00dc98b1d9e1b9d6e45b1
MD5 f8058d273d5ae6b2079384c472416345
BLAKE2b-256 427333e12c27a6a622c43f65b3080e708c64ed69e69eaa1309690d36d16faa6a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: locki-0.0.11-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.6 {"installer":{"name":"uv","version":"0.11.6","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.11-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 053e123022bda5b7ea63b6374656594ee32734bb4eed59e1237679f6f7c34bcb
MD5 b22b1f3c38b30beab47954fc71d17ffe
BLAKE2b-256 cf2e81c99ee9338886b0f48cebf78fb45de0eb739775aac448ceb501d856137f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: locki-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 c1dc560c580b699f52b90e808448933747b59c38511bb66bd07ed5e0d0bb9049
MD5 c1c2d5d5b5abc97b13ddd20a8d24ba1f
BLAKE2b-256 6e277857023ba2fc4233bd00b78305889ce39e6be5c4f89abb62ea9474281c62

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