CLI Reference
Complete reference for all coderaft commands, options, and usage patterns.
Global Options
Section titled “Global Options”All commands support these global options:
--help, -h: Show help information
Core Commands
Section titled “Core Commands”coderaft status
Section titled “coderaft status”Show detailed container status and resource usage for a project. With no project specified, prints a quick overview of all coderaft containers.
Syntax:
coderaft status [project]Behavior:
- With a project: shows state, uptime, CPU%, memory usage/%, network I/O, block I/O, PIDs, ports, and mounts
- Without a project: lists all coderaft containers with status and image
Examples:
# Overview of all coderaft containerscoderaft status
# Detailed status for a specific projectcoderaft status myprojectcoderaft up
Section titled “coderaft up”Start a coderaft environment from a shared coderaft.json in the current directory. Perfect for onboarding: clone the repo and run coderaft up.
Syntax:
coderaft up [--dotfiles <path>] [--keep-running]Options:
--dotfiles <path>: Mount a local dotfiles directory into common locations inside the Island--keep-running: Keep the Island running after setup completes (overrides auto-stop-on-idle)
Behavior:
- Reads
./coderaft.json - Creates/starts a Island named
coderaft_<name>where<name>comes fromcoderaft.json’sname(or the folder name) - Applies ports, env, and volumes from configuration
- Runs a system update, then
setup_commands - Installs the coderaft wrapper for nice shell UX
- Records package installations you perform inside the Island to
coderaft.lock(apt/pip/npm/yarn/pnpm). On rebuilds, these commands are replayed to reproduce the environment. - If global setting
auto_stop_on_exitis enabled (default),coderaft upstops the container right away if it is idle (no exposed ports and only the init process running). Use--keep-runningto leave it running. - When
auto_stop_on_exitis enabled and yourcoderaft.jsondoes not specify arestartpolicy, coderaft uses--restart noto prevent the container from auto-restarting after being stopped.
Examples:
# Start from current folder's coderaft.jsoncoderaft up
# Mount your dotfilescoderaft up --dotfiles ~/.dotfilescoderaft init
Section titled “coderaft init”Create a new coderaft project with its own Docker island.
Syntax:
coderaft init <project> [flags]Options:
--force, -f: Force initialization, overwriting existing project--template, -t <template>: Initialize from template (python, nodejs, go, web)--generate-config, -g: Generate coderaft.json configuration file--config-only, -c: Generate configuration file only (don’t create Island)
Examples:
# Basic projectcoderaft init myproject
# Python project with templatecoderaft init python-app --template python
# Force overwrite existing projectcoderaft init myproject --force
# Generate config file onlycoderaft init myproject --config-only --template nodejs
# Create with custom configurationcoderaft init webapp --generate-configTemplates:
python: Python 3, pip, venv, development toolsnodejs: Node.js 18, npm, build toolsgo: Go 1.21, git, build toolsweb: Python + Node.js + nginx for full-stack development
coderaft shell
Section titled “coderaft shell”Open an interactive bash shell in the project’s Island.
Syntax:
coderaft shell <project> [--keep-running]Examples:
# Enter project environmentcoderaft shell myproject
# Start stopped Island and enter shellcoderaft shell python-appNotes:
- Automatically starts the Island if stopped
- Sets working directory to
/workspace - Your project files are available at
/workspace - Exit with
exit,logout, orCtrl+D - By default, the Island stops automatically after you exit the shell when global setting
auto_stop_on_exitis enabled (default) - Use
--keep-runningto keep the Island running after you exit the shell
coderaft run
Section titled “coderaft run”Run an arbitrary command inside the project’s Island.
Syntax:
coderaft run <project> <command> [args...] [--keep-running]Examples:
# Run single commandcoderaft run myproject python3 --version
# Run with argumentscoderaft run myproject apt install -y htop
# Complex command with pipescoderaft run myproject "cd /workspace && python3 -m http.server 8000"
# Execute scriptcoderaft run myproject bash /workspace/setup.shNotes:
- Commands run in
/workspaceby default - Use quotes for complex commands with pipes, redirects, etc.
- Island starts automatically if stopped
- By default, the Island stops automatically after the command finishes when global setting
auto_stop_on_exitis enabled (default) - Use
--keep-runningto keep the Island running after the command finishes
coderaft stop
Section titled “coderaft stop”Stop a project’s Island if it’s running.
Syntax:
coderaft stop <project>Examples:
# Stop a running Islandcoderaft stop myproject
# Stop another project's Islandcoderaft stop webappNotes:
- Safe to run if the Island is already stopped (no-op)
- Complements the default auto-stop behavior after
shellandrun
coderaft destroy
Section titled “coderaft destroy”Stop and remove the project’s Island.
Syntax:
coderaft destroy <project> [flags]Options:
--force, -f: Force destruction without confirmation
Examples:
# Destroy with confirmationcoderaft destroy myproject
# Force destroy without promptcoderaft destroy myproject --forceNotes:
- Preserves project files in
~/coderaft/<project>/ - Island can be recreated with
coderaft init - Use
rm -rf ~/coderaft/<project>/to remove files
coderaft list
Section titled “coderaft list”Show all managed projects and their Island status.
Syntax:
coderaft list [flags]Options:
--verbose, -v: Show detailed information including configuration
Examples:
# Basic listcoderaft list
# Detailed informationcoderaft list --verboseOutput Format:
CODERAFT PROJECTSPROJECT Island STATUS CONFIG WORKSPACE-------------------- -------------------- --------------- ------------ ------------------------------myproject coderaft_myproject Up 2 hours coderaft.json /home/user/coderaft/myprojectwebapp coderaft_webapp Exited none /home/user/coderaft/webapp
Total projects: 2coderaft lock
Section titled “coderaft lock”Generate a comprehensive environment snapshot as coderaft.lock.json for a project. This is ideal for sharing/auditing the exact Island image, container configuration, and globally installed packages.
Syntax:
coderaft lock <project> [-o, --output <path>]Options:
-o, --output <path>: Write the lock file to a custom path. Defaults to<workspace>/coderaft.lock.json.
Behavior:
- Ensures the project’s Island is running (starts it if needed).
- Inspects the container and its image to capture:
- Base image: name, digest (if available), image ID
- Container config: working_dir, user, restart policy, network, ports, volumes, labels, environment, capabilities, resources (cpus/memory)
- Installed package snapshots:
- apt: manually installed packages pinned as
name=version - pip:
pip freezeoutput - npm/yarn/pnpm: globally installed packages as
name@version(Yarn global versions are detected from Yarn’s global dir)
- apt: manually installed packages pinned as
- Registries and sources for reproducibility:
- pip:
index-urlandextra-index-url - npm/yarn/pnpm: global registry URLs
- apt:
sources.listlines, snapshot base URL if present, and OS release codename
- pip:
- If
coderaft.jsonexists in the workspace, includes itssetup_commandsfor context.
This snapshot is meant for sharing and audit. It does not currently drive coderaft up automatically; continue to use coderaft.json plus the simple coderaft.lock command list for replay. A future coderaft restore may apply coderaft.lock.json directly.
Examples:
# Write snapshot into the project workspacecoderaft lock myproject
# Write snapshot to a custom filecoderaft lock myproject -o ./env/coderaft.lock.jsonSample Output (excerpt):
{ "version": 1, "project": "myproject", "island_name": "coderaft_myproject", "created_at": "2025-09-18T20:41:51Z", "base_image": { "name": "ubuntu:22.04", "digest": "ubuntu@sha256:...", "id": "sha256:..." }, "container": { "working_dir": "/workspace", "user": "root", "restart": "no", "network": "bridge", "ports": ["3000/tcp -> 0.0.0.0:3000"], "volumes": ["bind /host/path -> /workspace (rw=true)"], "environment": {"TZ": "UTC"}, "labels": {"coderaft.project": "myproject"}, "capabilities": ["SYS_PTRACE"], "resources": {"cpus": "2", "memory": "2048MB"} }, "packages": { "apt": ["git=1:2.34.1-..."], "pip": ["requests==2.32.3"], "npm": ["typescript@5.6.2"], "yarn": ["eslint@9.1.0"], "pnpm": [] }, "registries": { "pip_index_url": "https://pypi.org/simple", "pip_extra_index_urls": ["https://mirror.example/simple"], "npm_registry": "https://registry.npmjs.org/", "yarn_registry": "https://registry.yarnpkg.com", "pnpm_registry": "https://registry.npmjs.org/" }, "apt_sources": { "snapshot_url": "https://snapshot.debian.org/archive/debian/20240915T000000Z/", "sources_lists": [ "deb https://snapshot.debian.org/archive/debian/20240915T000000Z/ bullseye main" ], "pinned_release": "jammy" }, "setup_commands": [ "apt install -y python3 python3-pip" ]}coderaft verify
Section titled “coderaft verify”Validate that the running Island matches the coderaft.lock.json exactly. Fails fast on any drift.
Syntax:
coderaft verify <project>Checks:
- Package sets: apt, pip, npm, yarn, pnpm (exact set match)
- Registries: pip index/extra-index, npm/yarn/pnpm registry URLs
- Apt sources: sources.list lines, snapshot base URL (if present), OS release codename
Returns non-zero on any mismatch and prints a concise drift report.
Example:
coderaft verify myprojectcoderaft apply
Section titled “coderaft apply”Apply the coderaft.lock.json to the running Island: configure registries and apt sources, then reconcile package sets to match the lock.
Syntax:
coderaft apply <project>Behavior:
- Registries:
- Writes
/etc/pip.confwithindex-url/extra-index-urlfrom lock - Runs
npm/yarn/pnpmconfig to set global registry URLs
- Writes
- Apt sources:
- Backs up and rewrites
/etc/apt/sources.list, clears/etc/apt/sources.list.d/*.list - Optionally sets a default release hint, then
apt update
- Backs up and rewrites
- Reconciliation:
- APT: install exact versions from lock, remove extras, autoremove
- Pip: install missing exact versions, uninstall extras
- npm/yarn/pnpm (global): add missing exact versions, remove extras
Exits non-zero if application fails at any step.
Example:
coderaft apply myprojectConfiguration Commands
Section titled “Configuration Commands”coderaft templates
Section titled “coderaft templates”Manage coderaft project templates (built-in and user-defined).
Subcommands:
coderaft templates list
Section titled “coderaft templates list”List available templates (built-in + user templates in ~/.coderaft/templates).
Syntax:
coderaft templates listcoderaft templates show
Section titled “coderaft templates show”Show a template’s JSON (name, description, and config).
Syntax:
coderaft templates show <name>coderaft templates create
Section titled “coderaft templates create”Create coderaft.json in the current directory from a template.
Syntax:
coderaft templates create <name> [project]Examples:
cd ~/coderaft/myappcoderaft templates create python MyApp
# If project name omitted, folder name is usedcoderaft templates create nodejscoderaft templates save
Section titled “coderaft templates save”Save the current folder’s coderaft.json as a reusable user template in ~/.coderaft/templates/<name>.json.
Syntax:
coderaft templates save <name>coderaft templates delete
Section titled “coderaft templates delete”Delete a user template by name.
Syntax:
coderaft templates delete <name>coderaft config
Section titled “coderaft config”Manage coderaft configurations.
Subcommands:
coderaft config generate
Section titled “coderaft config generate”Generate coderaft.json configuration file for a project.
Syntax:
coderaft config generate <project> [flags]Options:
--template, -t <template>: Use template configuration
Examples:
# Generate basic configcoderaft config generate myproject
# Generate with templatecoderaft config generate myproject --template pythoncoderaft config validate
Section titled “coderaft config validate”Validate project configuration file.
Syntax:
coderaft config validate <project>coderaft config show
Section titled “coderaft config show”Display project configuration details.
Syntax:
coderaft config show <project>Note: Template listing and management has moved to the top-level coderaft templates command.
coderaft config global
Section titled “coderaft config global”Show global coderaft configuration.
Syntax:
coderaft config globalMaintenance Commands
Section titled “Maintenance Commands”coderaft version
Section titled “coderaft version”Display the version information for coderaft.
Syntax:
coderaft versionExamples:
# Display version informationcoderaft versionOutput Format:
coderaft (v1.0)coderaft cleanup
Section titled “coderaft cleanup”Clean up Docker resources and coderaft artifacts.
Syntax:
coderaft cleanup [flags]Options:
--orphaned: Remove orphaned containers only--images: Remove unused images only--volumes: Remove unused volumes only--networks: Remove unused networks only--system-prune: Run docker system prune--all: Clean up everything--dry-run: Show what would be cleaned (no changes)--force: Skip confirmation prompts
Examples:
# Interactive cleanup menucoderaft cleanup
# Clean specific resourcescoderaft cleanup --orphanedcoderaft cleanup --images
# Comprehensive cleanupcoderaft cleanup --all
# Preview cleanup actionscoderaft cleanup --dry-run --all
# Cleanup without promptscoderaft cleanup --all --forcecoderaft maintenance
Section titled “coderaft maintenance”Perform maintenance tasks on coderaft projects and Islands.
Syntax:
coderaft maintenance [flags]Options:
--status: Show detailed system status--health-check: Check health of all projects--update: Update all Islands--restart: Restart stopped Islands--rebuild: Rebuild all Islands--auto-repair: Auto-fix common issues--force: Skip confirmation prompts
Examples:
# Interactive maintenance menucoderaft maintenance
# Individual taskscoderaft maintenance --health-checkcoderaft maintenance --updatecoderaft maintenance --restart
# Combined operationscoderaft maintenance --health-check --update --restart
# Auto-repair issuescoderaft maintenance --auto-repair
# Force operations without promptscoderaft maintenance --force --rebuildcoderaft update
Section titled “coderaft update”Pull the latest base image(s) and rebuild environment Island(es).
This command replaces Islands to ensure they are based on the newest upstream images, while preserving your workspace files on the host.
Syntax:
coderaft update [project]Behavior:
- When a project is specified, only that environment is updated
- With no project, all registered projects are updated
- Pulls the latest base image, recreates the Island with current coderaft.json config, and re-runs setup commands
- Replays package install commands from
coderaft.lockto restore your previously installed packages
Options:
- None currently. Uses your existing configuration in
coderaft.jsonif present.
Examples:
# Update a single projectcoderaft update myproject
# Update all projectscoderaft updateNotes:
- Your files remain in ~/coderaft/
/ and are re-mounted into the new Island - If the project has a coderaft.json, its settings (ports, env, volumes, etc.) are applied on rebuild
- System packages inside the Island are updated as part of the rebuild
- If the Island exists, it will be stopped and replaced; if missing, it will be created
Exit Codes
Section titled “Exit Codes”Coderaft uses standard exit codes:
0: Success1: General error2: Invalid arguments or usage125: Docker daemon not running126: Container not executable127: Container/command not found
Environment Variables
Section titled “Environment Variables”Coderaft respects these environment variables:
DOCKER_HOST: Docker daemon socketCODERAFT_HOME: Override default~/.coderaftdirectoryCODERAFT_WORKSPACE: Override default~/coderaftworkspace directory
Project Structure
Section titled “Project Structure”When you create a project, coderaft sets up:
~/coderaft/<project>/ # Project workspace (host)├── coderaft.json # Configuration file (optional)├── your-files... # Your project files└── ...
~/.coderaft/ # Global configuration├── config.json # Global settings and project registry└── ...Inside Island:
/workspace/ # Mounted from ~/coderaft/<project>/├── coderaft.json # Same files as host├── your-files...└── ...Shell Completion
Section titled “Shell Completion”coderaft completion
Section titled “coderaft completion”Generate completion scripts for your shell to enable tab autocompletion for coderaft commands, flags, project names, and template names.
Syntax:
coderaft completion [bash|zsh|fish]Supported Shells:
- Bash: Autocompletion for commands, flags, project names, and templates (Linux)
- Zsh: Full autocompletion with descriptions (Linux)
- Fish: Intelligent completion with suggestions (Linux)
Setup Instructions:
Bash:
# Load completion for current sessionsource <(coderaft completion bash)
# Install for all sessions (Linux)sudo coderaft completion bash > /etc/bash_completion.d/coderaftZsh:
# Enable completion if not already enabledecho "autoload -U compinit; compinit" >> ~/.zshrc
# Install for all sessionscoderaft completion zsh > "${fpath[1]}/_coderaft"
# Restart your shell or source ~/.zshrcFish:
# Load completion for current sessioncoderaft completion fish | source
# Install for all sessionscoderaft completion fish > ~/.config/fish/completions/coderaft.fishWhat Gets Completed:
- Command names (
init,shell,run,list, etc.) - Command flags (
--template,--force,--keep-running) - Project names for commands like
shell,run,stop,destroy - Template names for
--templateflag andtemplates show/delete
Examples:
# Tab completion examples (press TAB after typing)coderaft <TAB> # Shows: init, shell, run, list, etc.coderaft shell <TAB> # Shows: your-project-namescoderaft init myapp --template <TAB> # Shows: python, nodejs, go, webcoderaft templates show <TAB> # Shows: available-template-namesDocker Integration
Section titled “Docker Integration”Coderaft creates Islands (Docker containers) with these characteristics:
- Name:
coderaft_<project> - Base Image:
ubuntu:22.04(configurable) - Working Directory:
/workspace - Mount:
~/coderaft/<project>→/workspace - Restart Policy:
unless-stopped(ornowhenauto_stop_on_exitis enabled and no explicit policy is set) - Command:
sleep infinity(keeps Island alive)
Docker Commands Equivalent:
# coderaft init myprojectdocker create --name coderaft_myproject \ --restart unless-stopped \ -v ~/coderaft/myproject:/workspace \ -w /workspace \ ubuntu:22.04 sleep infinity
# coderaft shell myprojectdocker start coderaft_myprojectdocker exec -it coderaft_myproject bash
# coderaft run myproject <command>docker exec coderaft_myproject <command>
# coderaft destroy myprojectdocker stop coderaft_myprojectdocker rm coderaft_myproject