by mensfeld
Run coding agents in hardened Incus containers with real-time network threat detection, automatic threat response (pause/kill), credential isolation, protected paths, session persistence, and multi-slot support.
# Add to your Claude Code skills
git clone https://github.com/mensfeld/code-on-incuscoi)Security-Hardened Container Runtime for AI Coding Agents with Real-Time Threat Detection
Run AI coding assistants (Claude Code, opencode, Aider, and more) in isolated, production-grade Incus containers with zero permission headaches, perfect file ownership, and true multi-session support.
Limited Blast Radius: Prepare your workspace upfront, let the AI agent run in isolation, validate the outcome. No SSH keys, no environment variables, no credentials exposed. If compromised, damage is contained to your workspace. Network isolation helps prevent data exfiltration. Your host system stays protected.
Security First: Unlike Docker or bare-metal execution, your environment variables, SSH keys, and Git credentials are never exposed to AI tools. Containers run in complete isolation with no access to your host credentials unless explicitly mounted.
Proactive Defense: COI doesn't just isolate AI tools — it can actively watch them. Enable the built-in security monitoring daemon ([monitoring] enabled = true) to detect reverse shells, credential scanning, and large data reads in real time, automatically pausing or killing the container before damage can occur. No manual intervention needed.
Think Docker for AI coding tools, but with system containers that actually work like real machines.

No comments yet. Be the first to share your thoughts!
Currently supported:
Coming soon:
Tool selection:
coi shell # Uses default tool (Claude Code)
coi shell --tool opencode # Use opencode instead
Permission mode - Control whether AI tools run autonomously or ask before each action:
# ~/.coi/config.toml or .coi/config.toml
[tool]
name = "claude" # Default AI tool
permission_mode = "bypass" # "bypass" (default) or "interactive"
See the Supported Tools wiki page for detailed configuration, API key setup, and adding new tools.
Core Capabilities
Host Integration
[ssh] forward_agent = true)forward_env in config)[timezone] config)~/SANDBOX_CONTEXT.md tells AI tools about their environment (network mode, workspace path, persistence, etc.). Automatically loaded into each tool's native context system: Claude Code via ~/.claude/CLAUDE.md, OpenCode via the instructions field in opencode.json (opt out with auto_context = false)Security & Isolation
.env files, Git credentials, and environment variables are never exposed unless explicitly mountedsecurity.privileged=true is detected, which defeats all container isolationcoi health checks seccomp, AppArmor, and privilege settings to confirm full isolation.git/hooks, .git/config, .husky, .vscode mounted read-only to prevent supply-chain attacksSafe Dangerous Operations
# Install
curl -fsSL https://raw.githubusercontent.com/mensfeld/code-on-incus/master/install.sh | bash
# Build image (first time only, ~5-10 minutes)
coi build
# Start coding with your preferred AI tool (defaults to Claude Code)
cd your-project
coi shell
# Or use opencode instead
coi shell --tool opencode
# That's it! Your AI coding assistant is now running in an isolated container with:
# - Your project mounted at /workspace
# - Correct file permissions (no more chown!)
# - Full Docker access inside the container
# - GitHub CLI available for PR/issue management
# - All workspace changes persisted automatically
# - No access to your host SSH keys, env vars, or credentials
Incus is a modern Linux container and virtual machine manager, forked from LXD. Unlike Docker (which uses application containers), Incus provides system containers that behave like lightweight VMs with full init systems.
| Capability | code-on-incus | Docker Sandbox | Bare Metal | |------------|-------------------|----------------|------------| | Credential isolation | Default (never exposed) | Partial | None | | Real-time threat detection | Kernel-level (nftables) | No | No | | Reverse shell detection | Auto-kill | No | No | | Data exfiltration alerts | Auto-pause | No | No | | Network isolation | Firewalld (3 modes) | Basic | No | | Protected paths | Read-only mounts | No | No | | Auto response (pause/kill) | Yes | No | No | | Audit logging | JSONL forensics | No | No | | Supply-chain attack prevention | Git hooks/IDE configs protected | No | No |
Linux-first, not Linux-last. Docker Sandboxes' microVM isolation is only available on macOS and Windows. Linux gets a legacy container-based fallback. COI is built for Linux from the ground up because Incus is Linux-native.
No Docker Desktop required. Docker Sandboxes is a Docker Desktop feature. Docker Desktop is not open source and has commercial licensing requirements for larger organizations. COI depends only on Incus - fully open source, no vendor lock-in, no additional runtime.
System containers, not containers-in-VMs. Incus system containers run a full OS with systemd and native Docker support inside - one clean isolation layer. Docker Sandboxes nests application containers inside microVMs, adding architectural complexity.
No permission hell. Incus automatic UID/GID shifting means files created by agents have correct ownership