Sandbox validation
--sandbox is the fourth and most rigorous stage of the Axint pipeline. It
takes the generated Swift, drops it into a deterministic Swift Package
Manager project in a temp directory, and runs swift build.
If the build succeeds, you know the generated Swift is actually valid — not just plausible-looking. If it fails, you get the real Swift compiler output as a diagnostic, pointing at the generated line.
How it works
Section titled “How it works” ┌─────────────────────────┐IR ──────► │ generator.ts │ └──────────┬──────────────┘ │ Swift source ▼ ┌─────────────────────────┐ │ sandbox/ │ ← created in $TMPDIR │ ├── Package.swift │ on first run, reused after │ ├── Sources/ │ │ │ └── Intent.swift │ │ └── .build/ │ warm cache ≈ 1.2s └──────────┬──────────────┘ │ swift build ▼ pass / failThe sandbox lives at $TMPDIR/axint-sandbox/ by default. The .build/ cache
survives across runs, which is why the first run takes ~4 seconds (cold)
and every subsequent run takes ~1.2 seconds (warm).
When to use it
Section titled “When to use it”- Locally — when you want direct confirmation that the intent compiles before opening Xcode.
- CI — on a macOS runner, the sandbox gives you end-to-end validation for every PR.
- From MCP — set
sandbox: trueinaxint_compileand the MCP server will include the Swift build output in its response. This is how Claude Code and Cursor know whether an intent is actually valid.
Requirements
Section titled “Requirements”- macOS
- Xcode 16 or later, or
xcode-select --installfor the command-line tools only
On Linux or Windows, the sandbox stage is skipped with a friendly warning
unless you pass --strict-sandbox, which will exit non-zero.
Programmatic use
Section titled “Programmatic use”You can also use the sandbox from your own code via the reusable
sandboxCompile() API exported from @axint/compiler:
import { sandboxCompile } from "@axint/compiler";
const result = await sandboxCompile(swiftCode);if (!result.success) { console.error(result.stderr); process.exit(1);}