This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pixels is a Go CLI tool for managing disposable Linux containers (Incus) on TrueNAS via WebSocket API. It handles the full lifecycle: create, start, stop, destroy, SSH console/exec, and ZFS snapshot-based checkpoints.
go build # produces ./pixels binary
go test ./... # run all tests
go test ./internal/config # run tests for a single packageNo Makefile, no linter configured. Standard go build / go test.
main.go → cmd.Execute()
cmd/ → Cobra commands (create, start, stop, destroy, list, console, exec, checkpoint)
root.go → PersistentPreRunE loads config; shared helpers (containerName, displayName, resolveIP)
internal/
config/ → TOML config from ~/.config/pixels/config.toml, env var overrides (PIXELS_*), CLI flag overrides
cache/ → JSON disk cache in ~/.cache/pixels/ for container IP/status (avoids API round-trips)
truenas/ → WebSocket client wrapping truenas-go; provisioning (SSH keys, DNS, rc.local injection)
dataset/ → ZFS dataset path resolution for checkpoint commands
ssh/ → WaitReady (TCP poll), Console (syscall.Exec replaces process), Exec (run remote command)
Key patterns:
- All containers are prefixed
px-(hardcoded inroot.go). Commands accept bare names and prepend the prefix. - Config priority: TOML file <
PIXELS_*env vars < CLI flags (--host,--api-key,-u). - Cache is populated after
create/start/checkpoint restoreand evicted onstop/destroy. consoleandexeccheck the local cache first (fast path), falling back to the TrueNAS API.- Destroy retries 3 times with 2s delays to handle Incus storage release timing.
- NIC parent and type are auto-detected from the host's gateway interface when not configured explicitly.
truenaspackage fields use interfaces (VirtServiceAPI,InterfaceServiceAPI, etc.) for testability with library-provided mocks.
- Commit messages:
type: description(e.g.,feat:,fix:,perf:). - Standard Go error handling with
fmt.Errorfwrapping for context. - Table-driven tests in
_test.gofiles. - Remote is a self-hosted Forgejo instance.