---
title: "Contributing"
description: "Set up a development environment, run the checks, add a command or an agent, and work on this documentation site."
---

> Documentation Index
> Fetch the complete documentation index at: https://sandrinodm.github.io/agent-box/llms.txt
> Use this file to discover all available pages before exploring further.

# Contributing

This page covers building `abx` from a checkout, the checks a change must pass, and how to work on the documentation site. For a map of the code, read [Architecture](https://sandrinodm.github.io/agent-box/project/architecture/) first. Report suspected security vulnerabilities privately; see [Security](https://sandrinodm.github.io/agent-box/project/security/).

## Set up

### macOS

You need an Apple Silicon Mac with Node.js 24 or later (CI tests Node 24 and 26), pnpm 12 (the `packageManager` field in `package.json` pins it) and the Xcode Command Line Tools. smolvm 1.38.2 is needed only to run the real-VM e2e tests and to try the CLI.

### Linux

Linux development targets `x86_64` and `arm64` on glibc. `musl` is out of scope. You need:

- Node.js 26 (`engines.node` is `>=24`, and Linux CI uses Node 26) and pnpm 12.
- `clang`, `build-essential` and GNU `make`. On Linux the Makefile sets `SCRIPTC_LINKER=clang`, and `gcc` does not work with `scriptc`.
- Host tools the tests call: `/usr/bin/sqlite3`, Git 2.39 or later at `/usr/bin/git`, coreutils (`timeout`, `mkfifo`, `sleep`, `rm`, `sha256sum`) and `python3` for the native FFI test drivers.
- For the real-VM e2e tests: read and write access to `/dev/kvm` for your unprivileged account, local `ext4` for state, and a verified smolvm 1.38.2 install.

Then, from the repository root:

```sh
pnpm install --frozen-lockfile
make
```

`pnpm install` runs the native install of `scriptc` (`allowBuilds` in `pnpm-workspace.yaml`). `make` bundles the embedded guest and helper scripts, compiles the C files in `apps/cli/native` into `build/<os>-<arch>/`, links `build/<os>-<arch>/abx` with `scriptc`, and publishes `build/abx`. `scriptc` is the real compiler for this code, so passing the type check does not mean `make` passes: run both. The build is described in the [`apps/cli` README](https://github.com/sandrinodm/agent-box/blob/main/apps/cli/README.md).

All packages are private and have no per-package scripts. Run everything from the repository root.

## Run the checks

| Command | Does |
| --- | --- |
| `pnpm run build` | Same as `make`. |
| `pnpm run build:scripts` | Rebuilds the generated embedded script modules. |
| `pnpm run check` | `node scripts/build-embedded.mjs --check` and `tsc --noEmit`. |
| `pnpm run test` | Unit tests of the CLI, all packages and `scripts/`. |
| `pnpm run test:e2e:novm` | Runs `make`, then the compiled-binary e2e tests that need no VM. |
| `pnpm run test:e2e:kvm-smoke` | Runs `make`, then checks a real Linux KVM box with an image that has no third-party agents. |
| `pnpm run test:e2e` | Runs `make`, then every test in `apps/cli/e2e` except the KVM smoke test: the non-VM tests plus the real-VM tests with the pinned agents. |
| `make test-native` | Compiles and runs the C FFI host test suite. |
| `make test-native-pty` | Compiles and runs the native PTY and terminal probe suite. |
| `pnpm run format` | Formats the sources. `pnpm run format:check` only checks. |
| `pnpm run lint` | Lints `apps`, `packages` and `scripts`. |

Before you open a pull request, `pnpm run check`, `pnpm run lint`, `pnpm run test`, `pnpm run format:check` and `pnpm run test:e2e:novm` should pass. The pull request template lists the same five.

### Test tiers

- **Unit tests** sit beside the source as `*.test.ts`. They fake smolvm and build temporary Git repositories, so they need no VM. To run one package, use `pnpm exec vp test run packages/git`.
- **Native C and FFI tests** run through `make test-native`, `make test-native-pty` and `python3 apps/cli/e2e/native/installed-host.py`.
- **Compiled-binary tests without a VM** run through `pnpm run test:e2e:novm`. They cover help, auth status, the wizard, launch preflight, diagnostics and the TUI.
- **Linux KVM smoke** runs through `pnpm run test:e2e:kvm-smoke`. It builds the pinned base image and exercises a real offline box with the compiled CLI. It needs network access.
- **Full real-VM suite** runs through `pnpm run test:e2e`. It builds an image with the pinned agents, creates machines and runs the Git round trip. It needs smolvm 1.38.2, virtualization (`/dev/kvm` and local `ext4` on Linux) and network access.

When you run the binary by hand, set `ABX_HOME` (and `ABX_SMOLVM_STATE_DIR` when testing smolvm state) to a scratch directory, so you do not touch `~/.abx` or your default smolvm machines. On Linux that directory must be on local `ext4`.

### Continuous integration

`.github/workflows/ci.yml` runs on pushes and pull requests to `main`, in three job groups:

- **`check`**: macOS (`macos-26` runners) with Node 24 and 26. Both run the unit tests and `test:e2e:novm`. Node 26 also runs the native drivers, the installed-host probe, the formatter, the linter and the type check.
- **`linux`**: Ubuntu 24.04 on `x86_64` (`ubuntu-24.04`) and `arm64` (`ubuntu-24.04-arm`) with Node 26. Unit tests, native drivers, a verified smolvm 1.38.2 install, `test:e2e:novm`, format, lint, type check, and a `sh -n` and ShellCheck pass over the installer.
- **`linux-kvm`**: Ubuntu 24.04 `x86_64` with `/dev/kvm` and a verified smolvm 1.38.2 install, running `pnpm run test:e2e:kvm-smoke` and then `pnpm run test:e2e`.

A final job, `CI required`, passes only when all three groups succeed. Releases depend on a successful CI run for the tagged commit; see [Releases](https://sandrinodm.github.io/agent-box/project/releases/). The release workflow builds the macOS binary on `macos-15`, not on the `macos-26` runners CI uses.

## Embedded scripts

`abx` compiles to one standalone native binary, which cannot read loose script files at runtime. Scripts therefore live as real, linted source files and are bundled into `*.gen.ts` modules at build time by `scripts/build-embedded.mjs`. The rules, in brief (the full policy is in [`AGENTS.md`](https://github.com/sandrinodm/agent-box/blob/main/AGENTS.md)):

- Do not write inline shell, Node.js or awk scripts as strings or template literals in `.ts` files, and do not interpolate TypeScript variables into generated script source.
- Code that runs inside a VM belongs in `packages/guest`. Add the payload type, implement the command with a unit test, wire it into the dispatcher, and call it from host code only through the typed `guestCommand(...)` builder.
- Host Node.js helpers keep their logic in a normal module with a thin `*.script.ts` entrypoint registered in `scripts/build-embedded.mjs`.
- Use POSIX `sh` (`*.sh`) only where a shell genuinely beats Node. Start with `#!/bin/sh` and `set -eu`, pass structured inputs through `ABX_*` environment variables, and check syntax with `sh -n`.
- Never edit `*.gen.ts` files by hand. After changing guest, image, git or Codex helper sources, run `node scripts/build-embedded.mjs`. `node scripts/build-embedded.mjs --check` fails when a generated file is stale, and `pnpm run check` includes it.
- Changes to `packages/guest` change `artifactDigest`, which invalidates older templates. The tests that pin the expected digest values must be updated with the bundles.

## Add a command

1. Create `apps/cli/src/commands/<name>.ts` that exports a `Command`: name, summary, usage, arguments, flags (built with `flag()` from `flags.ts`), notes, examples and `run`. Throw `UsageError` for bad input, so the exit status is 2. `rm.ts` is a small example.

2. Add it to `COMMANDS` in `commands/registry.ts`. Help, `abx help --json` and dispatch all come from that list.

3. Put the logic in `apps/cli/src/boxes` or a package, not in the command file. `commands` may import `boxes`, but `boxes` must not import `commands`.

4. Add tests beside the command, and update `apps/cli/e2e/help.test.ts` if the help output changes.

5. Document the command on this site under [CLI reference](https://sandrinodm.github.io/agent-box/reference/cli/), and check it against `abx help --json`.

## Add an agent

Follow the steps in the [`agent-api` README](https://github.com/sandrinodm/agent-box/blob/main/packages/agent-api/README.md#adding-an-agent). In short: create `packages/agent-<name>` that exports one `AgentAdapter`, add the name to `AgentName`, register the adapter in `apps/cli/src/agents.ts`, add a wizard label, and run the checks and `make`. Then add a page for the agent under [Agents](https://sandrinodm.github.io/agent-box/agents/), and a README beside the adapter.

## Pull requests

- Keep a change focused, and explain the reason for it in the description.
- Run the five checks above before you push. CI runs them again on macOS and Linux.
- Every `abx` command in the documentation must exist in the current binary with that syntax. Check it with `abx help <command>`.
- Packages must not name `abx` commands in their errors. `apps/cli/src/output/errors.ts` adds those.
- Update the documentation when behavior changes, and the CLI reference when commands or options change.

## Working on this documentation site

The documentation site lives on the orphan branch `docs-site` of the same repository. It shares no history with `main` and never merges into it. Work on it in a separate worktree:

```sh
git worktree add ../agent-box-docs docs-site   # from an agent-box checkout
cd ../agent-box-docs
npm ci
npm run dev                                     # http://localhost:4321/agent-box/
```

The site is built with Nimbus (Astro) and uses npm with its own lockfile, separate from the pnpm workspace on `main`. Pages are `.mdx` files in `src/content/docs/`. The folder tree is the URL structure and the sidebar, and `sidebar.order` in the frontmatter orders pages within a group. Components such as `Steps`, `Tabs` and `Aside` are available in every page without an import. Content shared by several pages goes in `src/content/partials/` and is included with `<Render file="..." />`.

Rules for page content:

- **The source of truth is the code on `main`**, not these pages. Before you write or change a claim about a command, option, default, path, environment variable, error code, exit code or version, find it in the TypeScript on `main` and in `abx help --json` from a build of `main`. If you cannot confirm it, leave it out.
- Write internal links from the site root with a trailing slash (`/get-started/quickstart/`), never with `/agent-box`. Link source files at `https://github.com/sandrinodm/agent-box/blob/main/<path>`.
- Examples pin the current release and smolvm: abx 0.3.0 and smolvm 1.38.2.
- Give every code block a language, and do not repeat the page title as a heading.

Before you push, check, build, then check again, because link checking needs the build:

```sh
npx @cloudflare/nimbus-docs check
npm run build
npx @cloudflare/nimbus-docs check
```

Commit only to `docs-site`. The `.github/workflows/pages.yml` workflow on that branch builds every push and pull request and deploys pushes to GitHub Pages. Nothing rebuilds the site when `main` changes, so when behavior changes on `main`, update the pages here and push to `docs-site`. The `AGENT.md` file on the branch has the full instructions, including those for coding agents.

Source: https://sandrinodm.github.io/agent-box/project/contributing/index.mdx
