coi

module
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT

README

Coi (Code on Incus) logo

Coi (Code on Incus)

Go Version Latest Release

Give the agent a machine. Just not yours.

coi runs your AI coding tool (Claude Code, Codex, opencode, pi, omp) inside its own isolated Linux system: a full-OS container with root access, systemd, Docker, and the freedom to install anything. The agent works like it would on a real server, but it cannot touch your host, cannot see your credentials, and if it does something dangerous, coi pauses or kills the container on its own.

One command drops you into a coding session. Your project is mounted, file permissions just work, and your SSH keys, tokens, and environment variables never enter the container unless you explicitly say so.

BetterStack video about Coi
Watch the BetterStack video about Coi

Demo

Get Started in Three Commands

# 1. Install
curl -fsSL https://raw.githubusercontent.com/coipond/coi/master/install.sh | bash

# 2. Build the base image (first time only, ~5-10 min)
coi build

# 3. Start coding, from any project directory
cd your-project
coi shell

Your agent now runs in an isolated container with your project at /workspace, correct file ownership (no more chown), Docker and gh available inside, and every workspace change saved back to the host. It has no access to your host SSH keys, environment variables, or credentials.

Requires Linux with Incus. macOS works too, via Colima/Lima; see macOS Setup.

Who Coi Is For

  • You run AI coding agents and want them to have full machine access (root, Docker, package managers, services) without risking your host.
  • You want to know when an agent does something suspicious, not find out after the fact.
  • You run several agents in parallel and need them isolated from each other.
  • You want persistent dev environments that survive restarts, not throwaway containers that lose your setup every time.
  • You care about your credentials never ending up inside an agent-controlled environment.

Features

  • Real machine, not a locked box — Incus system containers give the agent a full OS: root, systemd, native Docker, package managers, services.
  • Correct file ownership — workspace edits land on the host owned by you, with no chown dance.
  • Credentials stay home — SSH keys, tokens, .env, and host environment variables never enter the container unless you mount or forward them.
  • Active defense — kernel-level monitoring catches reverse shells, C2, exfiltration, and DNS tunneling in real time, then auto-pauses on HIGH and auto-kills on CRITICAL.
  • Network isolation — nftables egress control in three modes (open, restricted, allowlist), DNS pinning, and per-host port scoping.
  • Parallel agents — several slots per project, each with its own home directory, isolated from one another.
  • Persistent or ephemeral — keep a box with its installed packages, or discard it on exit; workspace files and session history are always saved, and any session resumes with full history.
  • Profiles — reusable named setups (image, tool, limits, network, build scripts, agent instructions) applied with a single flag, with inheritance.
  • Supply-chain guards — git hooks and IDE configs mounted read-only, protected paths, and a branch guard that blocks direct commits and pushes to main.
  • Headless and auditable — run prompts to completion for cron and CI (exit codes propagate), stream a JSONL threat log to your SIEM, and diagnose the setup with coi health.

Profiles: Your Setups, One Flag

A profile is a reusable, named container setup: image, tool, resource limits, mounts, network mode, build scripts, and AI-agent instructions bundled into one template you apply with a single flag.

coi shell --profile rust-dev        # spin up your Rust environment, ready to go
coi profile create rust-dev         # scaffold a new profile, then edit its config.toml
coi profile list                    # see what you have

A profile is just a config.toml:

# ~/.coi/profiles/rust-dev/config.toml
inherits = "hardened"        # optional: build on another profile

[container]
image = "coi-default"
persistent = true            # keep the box (and its installed packages) between sessions

[tool]
name = "claude"

[limits]
cpu = "4"
memory = "8GiB"

[network]
mode = "restricted"          # open / restricted / allowlist

Profiles support inheritance, ship AI-agent context files, and can carry their own build scripts, so "my hardened Python box with these limits and these tools" becomes one word. A built-in hardened preset locks a session down for untrusted code. See the Profiles wiki page for the full reference, the hardened preset, and the schema.

Supported AI Tools

  • Claude Code (default)
  • Codex CLI
  • opencode
  • pi
  • omp (Oh My Pi)

Pick one in config or a profile:

# ~/.coi/config.toml or ./.coi/config.toml
[tool]
name = "claude"              # or "codex", "opencode", "pi", "omp"
permission_mode = "bypass"   # run autonomously ("bypass") or ask first ("interactive")

Aider and Cursor are on the way. See the Supported Tools wiki page for per-tool auth, and Container Lifecycle and Sessions for running two tools in the same persistent container.

Everyday Commands

coi shell                 # interactive AI session (Claude Code by default)
coi run -- npm test       # run any command in the sandbox (streams output, propagates exit code)
coi run --prompt-name nightly   # run the agent headlessly from a predefined prompt
coi top                   # per-container CPU/memory/IO, resolved to workspace + alias
coi monitor               # real-time security dashboard
coi list --all            # active containers + saved sessions
coi attach                # attach to a running session
coi audit                 # stream the JSONL threat-event log (pipe into a SIEM or jq)
coi shutdown / coi kill   # stop or force-kill containers
coi clean                 # remove stopped containers and orphaned resources

Drop a .coi/config.toml in any repo to auto-configure coi for that project, so teams share one image, network mode, and limits. Run coi <command> --help for any command. To run agents unattended with headless prompts and cron, see Headless Orchestration.

Documentation

The README is the pitch; the wiki is the manual. Everything lives there in full:

Why Incus, Not Docker?

Incus (a modern LXD fork) gives you system containers, which behave like lightweight VMs (a real init system and full OS userspace) while sharing the host kernel, so they start in seconds, instead of Docker's application containers. That means one clean isolation layer running a full OS with native Docker inside, correct file ownership on the host by default, and no Docker Desktop, no vendor lock-in, and no opaque VM nesting. It is Linux-native and fully open source. More in the FAQ.

Coi vs. the Alternatives

Capability Coi Docker Sandbox Bare Metal
Credential isolation Default (never exposed) Partial None
Real-time threat detection Kernel-level (nftables) No No
Reverse-shell / exfil response Auto-kill / auto-pause No No
Network isolation nftables (3 modes) Basic No
Supply-chain protection Git hooks / IDE configs read-only No No
Audit logging JSONL forensics No No
Runs on Linux natively Yes microVM only on macOS/Windows -

Getting Help

Directories

Path Synopsis
cmd
coi command
Command coi runs AI coding tools inside isolated Incus containers; it is a thin entry point that executes the CLI and maps errors to exit codes.
Command coi runs AI coding tools inside isolated Incus containers; it is a thin entry point that executes the CLI and maps errors to exit codes.
internal
alias
Package alias persists workspace aliases (alias -> workspace and optional profile) and resolves them to running or launchable containers.
Package alias persists workspace aliases (alias -> workspace and optional profile) and resolves them to running or launchable containers.
audit
Package audit implements threat-event audit streaming for coi sandbox sessions.
Package audit implements threat-event audit streaming for coi sandbox sessions.
bedrock
Package bedrock detects AWS Bedrock configuration in Claude settings and validates that a Colima environment is set up correctly to use it.
Package bedrock detects AWS Bedrock configuration in Claude settings and validates that a Colima environment is set up correctly to use it.
cleanup
Package cleanup detects and removes host resources orphaned by containers that were not cleaned up properly: veth interfaces, nft and ip6 rules, nft monitoring rules, and iptables bridge-forward rules.
Package cleanup detects and removes host resources orphaned by containers that were not cleaned up properly: veth interfaces, nft and ip6 rules, nft monitoring rules, and iptables bridge-forward rules.
cli
Package cli implements the coi command-line interface: the cobra command tree and the logic behind each subcommand.
Package cli implements the coi command-line interface: the cobra command tree and the logic behind each subcommand.
config
Package config defines coi's configuration model and loads, merges and validates it from the embedded defaults, config files and profiles.
Package config defines coi's configuration model and loads, merges and validates it from the embedded defaults, config files and profiles.
container
Package container wraps the incus CLI: running incus commands, managing container lifecycle, files, devices, storage and hardening, and checking the installed Incus version.
Package container wraps the incus CLI: running incus commands, managing container lifecycle, files, devices, storage and hardening, and checking the installed Incus version.
health
Package health implements `coi health`: system, Incus, network, storage and container probes, their aggregation into an overall status, and optional remediation of failed checks.
Package health implements `coi health`: system, Incus, network, storage and container probes, their aggregation into an overall status, and optional remediation of failed checks.
image
Package image builds, versions and cleans up the Incus images coi launches containers from.
Package image builds, versions and cleans up the Incus images coi launches containers from.
limits
Package limits validates container resource limits (CPU, memory, disk, runtime) and applies them to Incus containers.
Package limits validates container resource limits (CPU, memory, disk, runtime) and applies them to Incus containers.
logger
Package logger provides per-session loggers that write to log files under ~/.coi/logs/.
Package logger provides per-session loggers that write to log files under ~/.coi/logs/.
monitor
Package monitor watches running containers for security threats (reverse shells, environment scanning, suspicious network and filesystem activity), responds to them, and records events in an audit log.
Package monitor watches running containers for security threats (reverse shells, environment scanning, suspicious network and filesystem activity), responds to them, and records events in an audit log.
network
Package network manages container network isolation: firewall rules for the restricted, open and allowlist modes, domain resolution and IP caching, and per-container /etc/hosts entries.
Package network manages container network isolation: firewall rules for the restricted, open and allowlist modes, domain resolution and IP caching, and per-container /etc/hosts entries.
nftmonitor
Package nftmonitor monitors container network activity by installing nftables logging rules, reading the resulting kernel log entries, and reporting suspicious connections as threats.
Package nftmonitor monitors container network activity by installing nftables logging rules, reading the resulting kernel log entries, and reporting suspicious connections as threats.
session
Package session sets up, runs and tears down coi sessions: container launch and configuration, mounts, credentials, git identity and guards, security hardening, and cleanup.
Package session sets up, runs and tears down coi sessions: container launch and configuration, mounts, credentials, git identity and guards, security hardening, and cleanup.
sinkguard
Package sinkguard holds a regression guard (in its test file) ensuring that packages whose code runs while a `coi shell` session is interactively attached never write to a terminal sink (os.Stdout/os.Stderr/global log/fmt.Print*).
Package sinkguard holds a regression guard (in its test file) ensuring that packages whose code runs while a `coi shell` session is interactively attached never write to a terminal sink (os.Stdout/os.Stderr/global log/fmt.Print*).
terminal
Package terminal adapts host terminal settings for use inside containers.
Package terminal adapts host terminal settings for use inside containers.
timing
Package timing is an opt-in, zero-cost-when-off wall-clock profiler for a single coi invocation.
Package timing is an opt-in, zero-cost-when-off wall-clock profiler for a single coi invocation.
tool
Package tool defines the AI coding tools (Claude Code, codex, opencode, pi, omp) that coi can run in containers: how each is launched, resumed and configured for sandboxed, permission-bypassing operation.
Package tool defines the AI coding tools (Claude Code, codex, opencode, pi, omp) that coi can run in containers: how each is launched, resumed and configured for sandboxed, permission-bypassing operation.
tool/credentials
Package credentials holds the embedded catalog of named credential bundles: which host config directory and files to copy into a container for a given tool or third-party provider.
Package credentials holds the embedded catalog of named credential bundles: which host config directory and files to copy into a container for a given tool or third-party provider.
vmhost
Package vmhost detects which VM (if any) is hosting the current container runtime, so callers can answer VM-specific behavior questions — such as whether the host already handles UID mapping for shared/mounted directories — from a single, shared piece of detection logic.
Package vmhost detects which VM (if any) is hosting the current container runtime, so callers can answer VM-specific behavior questions — such as whether the host already handles UID mapping for shared/mounted directories — from a single, shared piece of detection logic.
Package schema provides access to the Coi profile JSON Schema.
Package schema provides access to the Coi profile JSON Schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL