Skip to content

Development

Working on the CLI needs Go and Make. Architecture, import boundaries, code style and test rules are in CLAUDE.md and .claude/rules/; this page covers the workflow.

Repository layout

cmd/cli, cmd/proxy     # entrypoints of the agentic and agentic-proxy binaries
internal/infra         # leaf helpers: streams, logging, host files, git, self-update
internal/config        # .agenticrc.toml, agentic.json, state, flag-over-config precedence
internal/image         # Dockerfile DSL, per-tool stages, instructions, marketplaces
internal/network       # egress proxy, credentials, per-run certs
internal/runtime       # where tools run: docker, microsandbox, dind files, runtime-neutral RunSpec
internal/usecase       # one package per action: build, clean, run, update, ...
internal/cli           # Cobra commands
test/integration       # black-box tests of the binary, one package per feature

Dockerfiles are generated in Go: see Dockerfile DSL. What each command does step by step is in Lifecycle.

Build and test

make build          # compile to bin/agentic
make lint           # run golangci-lint
make audit          # go mod verify + govulncheck
make test           # run unit tests
make test-integration # run every integration test package against a real Docker daemon
make test-integration PKGS="egress proxy" # run only these packages
make test-integration MSB=1 # require msb (and KVM) instead of skipping the microsandbox runs
make test-integration-sandbox # inside an agentic run: every package but images and microsandbox
make bench-proxy-e2e # request latency direct vs through agentic-proxy; MSB=1 adds msb native vs agentic
make dist           # cross-platform binaries -> dist/
make docker-dist    # same via Docker using build/Dockerfile (no local Go needed)

Install golangci-lint at the version CI uses:

curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.15.0
# or: brew install golangci-lint
  • Integration tests build the binary and the images they need (slow the first time, cached after), then drive agentic like a user. They skip without Docker, without msb unless MSB=1, and without direct internet for the few that reach a public host. This repo's .agenticrc.toml enables DinD, so they also run inside an agentic container. make test-integration runs packages in parallel, prints failures at the end and cleans up; for one package's live log: go test -tags integration -count=1 -v ./test/integration/proxy.
  • Proxy performance: unit tests pin what keeps the proxy fast (no tunnel waits on the log, h2 to decrypted tunnels, upstream connections reused), so CI fails on those regressions. make bench-proxy-e2e prints latency tables; run it before and after a proxy change, and on macOS to see the Docker Desktop overhead, as CI's Linux Docker has none.
  • Environment instructions are pinned by golden files in internal/usecase/run/testdata/instructions/. After changing the wording, regenerate and review the diff: go test ./internal/usecase/run -run Test_Service_buildInstructions -update.
  • CI runs make audit on every PR and push to main, and nightly to catch new advisories; the nightly opens or comments on a security-audit issue and closes it once it passes. Run the CI checks on a branch without a PR via Actions -> Validate (reusable) -> Run workflow. The smoke job sets AGENTIC_ITEST_BUILD_CACHE (read, or write on main) to reuse the GitHub Actions build cache, scoped per ISO week.

Adding a tool or runtime layer

See tools.md. Each image stores its resolved versions and apt list as labels (agentic.version-args, agentic.apt), which agentic update reads back to rebuild with the same layers.

Sidecar and derived images

Image Built Rebuilt Removed by
agentic-dind On the first --dind run, always with --pull (usecase/sidecar) When missing, built by another CLI version, or older than 7 days agentic clean --all
<image>-dockerd On the first --runtime microsandbox --dind run, FROM the tool image (usecase/run) When the tool image changes agentic clean, agentic namespace prune (first, as it depends on the tool image)
agentic-proxy On the first --proxy run (usecase/sidecar); never by agentic build Only by agentic proxy update (always --no-cache) agentic proxy clean, agentic clean --all
agentic-aqua By every agentic aqua command (usecase/aqua), cached When the pinned aqua version or Debian base changes agentic clean --all

DinD seccomp: the sidecar's profile is derived at run time from Docker's default profile, vendored verbatim in internal/runtime/dind/seccomp_default.json. To refresh it, re-copy seccomp/default.json from moby/profiles, update the commit noted next to it, and run the runtime/dind tests, which check the derived rules still hold.

Proxy from local source: released builds go install the published cmd/proxy at their own version. A dev build (make build, VERSION=dev) compiles the proxy from the source tree it finds walking up from $PWD, so run it from the repo root and never in untrusted repos:

make build
./bin/agentic run --proxy claude    # compiles the proxy from local source on first use
./bin/agentic proxy update          # rebuild after editing code the proxy links in

Docs site

docs/ is published to GitHub Pages with Zensical on every push to main (.github/workflows/docs.yml). Preview locally:

docker run --rm -it \
  -p 8000:8000 \
  -v "$PWD:/docs" \
  "zensical/zensical:$(cut -d= -f3 .github/docs-requirements.in)" \
  serve --dev-addr 0.0.0.0:8000

Releasing

When a PR merges to main and CI passes, .github/scripts/next-tag.sh tags a release if any commit since the last tag needs one, following Conventional Commits. Scoped variants (feat(tool):) count the same.

Commit type Bump
feat!:, fix!:, or any type with ! / BREAKING CHANGE: footer major
feat: minor
fix:, perf:, refactor: patch
chore:, docs:, ci:, test:, style:, build: no release
.github/scripts/next-tag.sh          # next tag based on latest git tag
.github/scripts/next-tag.sh v0.3.0   # next tag based on a specific tag

Debugging

Open a shell in the container with agentic run <tool> -- bash (see Running a command), then for example:

mount | grep -v "^cgroup\|^proc\|^tmpfs"   # what is mounted where
which claude && claude --version         # tool on PATH
env | sort                               # environment variables