CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Rust CLI for deploying and managing StackAI's 50+ service Docker Compose platform on enterprise customer infrastructure (Ubuntu 24.04, 64GB RAM, 16 cores). Fortune 500 customers with 99.9% uptime SLA.
Build & Development Commands
# Build and run
cargo run -- --help
cargo run -- deploy status
cargo run -- diagnose doctor
# Use cargo aliases (defined in .cargo/config.toml)
cargo lint # Clippy with warnings as errors
cargo format # Check formatting
cargo fformat # Fix formatting
cargo test-all # All tests with output
cargo test-verbose # Single-threaded with output
# Run specific test
cargo test vault::tests::test_encrypt_decrypt
# CI checks (what pre-commit runs)
cargo lint && cargo test-all && cargo ci-audit && cargo ci-deny
# Build release
cargo br # Linux musl release buildSafe Testing (Isolated Environment)
Never modify real ~/.config/stackai/ during development:
Command Contract (Immutable - 5 Commands Only)
Never add new top-level commands. Never use deprecated names like install, configure, start, stop.
Architecture
4-layer service stack:
L1 Databases: postgres, mongodb, weaviate, redis, minio
L2 Supabase: kong, auth, realtime, storage, studio, pooler
L3 Backend: stackend, celery, temporal workers, unstructured
L4 Frontend: nginx, stackweb
Key Files
~/.config/stackai/docker-compose.yaml- Generated by CLI, don't edit manually~/.config/stackai/.env- Generated secrets~/.config/stackai/secrets.vault- License-key encrypted vaultconfig/versions.json- Platform version → service version mappingsconfig/.release- Current deployed platform version
Crate Conventions
CLI
clap 4.5 derive
structopt
Async
tokio + futures-util
std::thread blocking
Docker
bollard + compose_spec
shelling out for core ops
Prompts
inquire
dialoguer
Progress
indicatif
manual spinners
Encryption
aes-gcm + argon2
keyring
Errors
anyhow + thiserror
panic!/unwrap
Adding a New Subcommand
Add variant to enum in
cli.rsCreate
src/commands/{group}/newcmd.rsExport in
src/commands/{group}/mod.rsWire dispatch in parent handler
Add tests in the module
Pre-commit Checks
The repo has pre-commit hooks that run: format, lint, tests, audit, deny. All must pass before commit.
Migration from Legacy
Import from stackai-auto-docker to CLI-managed deployment:
What happens:
Copies volume data (postgres, mongodb, weaviate, minio, redis) →
~/.config/stackai/data/Imports
.env→ encrypts secrets tosecrets.vaultAuto-generates
kong.yamlwith correct service names (supabase-auth, not auth)Detects & copies Let's Encrypt certs from
/etc/letsencrypt/live/*/
TLS certs:
Deployment (Auto-Release)
Every push to main automatically produces a release:
version-checkcomparesCargo.tomlversion vs latestv*tagIf
Cargo.tomlversion > latest tag → uses that version as-isIf
Cargo.tomlversion ≤ latest tag → auto-bumps patch (e.g. 0.1.3 → 0.1.4), commits, pushesBot bump commits (
chore: bump version to *) are skipped to prevent loops
CI runs (fmt, clippy, test, security, build) using the resolved ref
Release tags the version, bundles CLI +
config/to S3, creates GitHub release
PR to main
CI only — no version check, no release
Merge PR (Cargo.toml unchanged)
Auto-bumps patch, builds, releases
Merge PR (Cargo.toml bumped to 1.0.0)
Detects 1.0.0 > tag, builds, releases
Manual workflow_dispatch
CI only — no release
To do a major/minor bump, update Cargo.toml version in your PR before merging.
Last updated
Was this helpful?

