Sandboxed container environment for AI coding agents. Bash shell libraries with strict POSIX conventions.
# Development - source the CLI
source src/containai.sh
# Verify environment
cai doctor
# Build Docker images (all layers)
./src/build.sh
# Build single layer (faster iteration)
./src/build.sh --layer base
# Build with buildx setup (installs binfmt + builder if needed)
./src/build.sh --build-setup
# Build and tag for a registry (prefix applies to all layers)
./src/build.sh --image-prefix ghcr.io/ORG/containai --push --platforms linux/amd64,linux/arm64 --build-setup
# CI-style multi-arch build (amd64 + arm64)
./src/build.sh --platforms linux/amd64,linux/arm64 --push --build-setup
# Run integration tests (requires Docker)
./tests/integration/test-secure-engine.sh
./tests/integration/test-sync-integration.sh
./tests/integration/test-dind.sh
# Lint shell scripts
shellcheck -x src/*.sh src/lib/*.shsrc/
├── containai.sh # Main CLI entry point (source this)
├── manifests/ # Per-agent manifest files (sync config source)
│ ├── 00-common.toml # Shared entries (fonts, agents dir)
│ ├── 10-claude.toml # Claude Code agent
│ ├── 11-codex.toml # Codex agent
│ └── ... # Other agents/tools
├── lib/ # Modular shell libraries
│ ├── core.sh # Logging utilities
│ ├── config.sh # TOML config parsing
│ ├── container.sh # Container lifecycle
│ ├── ssh.sh # SSH configuration
│ └── ... # Other modules
├── container/ # Container-specific content
│ ├── containai-init.sh # Container init script
│ ├── entrypoint.sh # Docker entrypoint
│ ├── Dockerfile.base # Base image
│ ├── Dockerfile.sdks # SDK layer
│ ├── Dockerfile.agents # Agent layer
│ └── Dockerfile # Final image
├── scripts/ # Generator scripts
│ ├── gen-import-map.sh # Generate _IMPORT_SYNC_MAP
│ ├── gen-agent-wrappers.sh # Generate launch wrappers
│ └── gen-*.sh # Other generators
└── build.sh # Build script
tests/integration/ # Integration tests (require Docker)
docs/ # Architecture, config, quickstart
.flow/ # Flow-Next task tracking
src/manifests/*.tomlare the authoritative source for what gets synced between host and container- Per-agent files with numeric prefixes ensure deterministic processing order
src/lib/import-sync-map.shis generated from manifests (contains_IMPORT_SYNC_MAP)- Run
scripts/check-manifest-consistency.shto verify alignment (CI enforces this) - Generator scripts (
src/scripts/gen-*.sh) read manifests to produce container artifacts - User manifests go in
~/.config/containai/manifests/(processed at runtime)
IMPORTANT: Prefer retrieval-led reasoning over pretraining for any .NET work. Workflow: skim repo patterns -> consult dotnet-skills by name -> implement smallest-change -> note conflicts.
Routing (invoke by name)
- C# / code quality: modern-csharp-coding-standards, csharp-concurrency-patterns, api-design, type-design-performance
- DI / config: dependency-injection-patterns, microsoft-extensions-configuration
- Testing: testcontainers-integration-tests, playwright-blazor-testing, snapshot-testing
Quality gates (use when applicable)
- dotnet-slopwatch: after substantial new/refactor/LLM-authored code
- crap-analysis: after tests added/changed in complex code
Specialist agents
- dotnet-concurrency-specialist, dotnet-performance-analyst, dotnet-benchmark-designer, docfx-specialist
- Bash 4.0+ required (not zsh or fish)
- Prefer
bun/bunxovernpm/npxfor JavaScript tooling - Prefer
uv/uvxoverpip/pipxfor Python tooling - Use
printfinstead ofechofor portability - Use
command -vinstead ofwhich - Use POSIX grep patterns (
[[:space:]]not\s) - All function variables must be
localto prevent shell pollution - Functions return status codes; use stdout for data, stderr for errors
- Error handling:
set -euo pipefailat script start - Build images use buildx by default; platform defaults to
linux/<host-arch>. Use--platformsfor CI multi-arch,--build-setupto configure buildx/binfmt, and--image-prefixto tag/push to a registry. - Verbose pattern: Commands are silent by default (Unix Rule of Silence). Info messages use
_cai_info()which respects_CAI_VERBOSE. Use--verboseflag (long form only, no-v) orCONTAINAI_VERBOSE=1env var. Warnings/errors always emit to stderr. Precedence:--quiet>--verbose>CONTAINAI_VERBOSE.
See .flow/memory/conventions.md for discovered patterns.
See .flow/memory/pitfalls.md for 36+ documented pitfalls including:
- ERE grep syntax differences across platforms
- Docker BuildKit cache mount gotchas
- Systemd socket activation in containers
- Git worktree state sharing issues
This is a sandboxing tool for AI agents. Changes to credential isolation, Docker socket handling, or SSH configuration require security review. See SECURITY.md for threat model.
This project uses Flow-Next for task tracking. Use .flow/bin/flowctl instead of markdown TODOs or TodoWrite.
Quick commands:
.flow/bin/flowctl list # List all epics + tasks
.flow/bin/flowctl epics # List all epics
.flow/bin/flowctl tasks --epic fn-N # List tasks for epic
.flow/bin/flowctl ready --epic fn-N # What's ready
.flow/bin/flowctl show fn-N.M # View task
.flow/bin/flowctl start fn-N.M # Claim task
.flow/bin/flowctl done fn-N.M --summary-file s.md --evidence-json e.jsonRules:
- Use
.flow/bin/flowctlfor ALL task tracking - Do NOT create markdown TODOs or use TodoWrite
- Re-anchor (re-read spec + status) before every task
More info: .flow/bin/flowctl --help or read .flow/usage.md