AI sandbox 🤖
  • Nix 72.8%
  • Python 27.2%
Find a file
Casper V. Kristensen 00d442b852 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/64c08a7ca051951c8eae34e3e3cb1e202fe36786?narHash=sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o%3D' (2026-05-23)
  → 'github:NixOS/nixpkgs/331800de5053fcebacf6813adb5db9c9dca22a0c?narHash=sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw%3D' (2026-05-31)
2026-06-02 09:47:19 +02:00
clank mount absolute path 2026-05-23 06:35:32 +02:00
container fix: update system prompt to avoid writing em-dashes in comments and commit messages 2026-06-01 15:53:32 +02:00
.gitignore Initial commit 2026-02-26 00:58:32 +01:00
AGENTS.md feat: actually implement opencode support 2026-04-22 14:31:25 +02:00
flake.lock flake.lock: Update 2026-06-02 09:47:19 +02:00
flake.nix feat: remove docker 2026-04-23 17:58:32 +02:00
LICENSE LICENSE: add Magenta Aps 2026-04-20 12:50:37 +02:00
pyproject.toml python cli 2026-04-20 13:35:01 +02:00
README.md mistral 2026-05-28 12:42:00 +02:00

🤖 Clank

clank is an AI sandbox, pre-configured to quickly start using AI.

Note

This tool is designed for internal use at Magenta. It is open source, so you're allowed to use it and fork it, but we may not be able to help you if you don't work at Magenta.

We would like feedback from your experience with using Clank, please write your complaints in this hedgedoc.

Quick Start

❄️ Get Nix

Clank is built using the Nix package manager.

Debian / Ubuntu

sudo apt install -y nix uidmap
echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf
sudo usermod -aG nix-users $USER

At this point you need to log out and in again to effectuate the change to your user's groups.

🚀 Try Clank

Through the power of Nix, you can run Clank without installing anything else.

nix run github:magenta-aps/clank

This mounts the current directory into a sandbox, which the AI will have full access to, so maybe don't do it in a directory with sensitive data. Get the vibes going by running opencode or claude. See below for more.

📦 Install Clank

NixOS

{
  inputs = {
    clank = {
      url = "github:magenta-aps/clank";
      # inputs.nixpkgs.follows = "nixpkgs";
    };
  };
}
{clank, pkgs, ...}: {
  environment.systemPackages = [
    clank.packages.${pkgs.stdenv.hostPlatform.system}.default
  ];
}

Everything Else

alias clank='nix run github:magenta-aps/clank --'

⚙️ Configure Providers

👼 Open Code

See the OpenCode documentation for a list of providers.

  • Mistral: run opencode and then /connect to Mistral. Generate an API key here. We recommend the Devstral 2 model.
  • Gemini: run opencode and then /connect to Google. The API key is here. We recommend the Gemini 3.1 Pro Preview model.
  • Scaleway: run opencode and then /connect to Scaleway. The API key is here. We don't recommend any of these models, as they're all kinda bad.

😈 Claude Code

Anthropic doesn't allow using OpenCode with a Claude subscription, so we have to use Claude Code. Open claude and then /login using Claude account with subscription - make sure to Continue with email, not Google.

Due to a bug, you can't use regular /login if you want to use multiple concurrent Claude Code sessions. In this case, run claude setup-token and add the resulting token to ~/.config/clank.sh (on the host):

export CLAUDE_CODE_OAUTH_TOKEN='<your-access-token-here>'

💡 Tips and Tricks

OpenCode Web

CLANK_PODMAN_OPTS='--publish=127.0.0.1:4096:4096' clank opencode web --hostname=0.0.0.0 --port=4096

🧑‍🔧 Development

git clone https://github.com/magenta-aps/clank.git
nix run ~/clank

🗑️ Remove All State

rm ~/.config/clank.sh
nix run nixpkgs#podman -- rm --force --filter 'name=^clank'
nix run nixpkgs#podman -- volume rm clank-persist