Agent quickstart (learn X07 from scratch)
This page is a single entry point for LLM agents. Use the published agent portal endpoints as the canonical source of schemas/skills/examples (see Agent contracts).
If you want a single copy/paste prompt to bootstrap a new project, use: Agent initial prompt.
If you find a documentation gap, check the toolchain source directly in GitHub:
0) The mental model
- X07 source is x07AST JSON (
*.x07.json), not text. - The toolchain is JSON-first: diagnostics, patches, and reports are structured.
- Programs run in worlds (fixture or OS); OS worlds are
run-osandrun-os-sandboxed.
High-level primitives to learn early (the “one whole system”):
- Streaming pipes:
std.stream.pipe_v1(deterministic, budgeted streaming composition) - Branded bytes:
bytes@B+std.brand.*(typed boundary encodings) - Structured concurrency:
task.scope_v1(no orphan tasks; slots/select) - Record/replay:
std.rr+ rr scopes (OS → deterministic cassette) - Budget scopes:
budget.scope_v1(localize cost contracts; arch-driven budgets) - Contracts tooling:
x07 arch check,x07 schema derive,x07 sm gen(pinned contracts → deterministic checks/generation) - Property-based testing:
x07 test --pbt+x07 fix --from-pbt(counterexample → deterministic regression) - Function contracts + verification:
requires/ensures/invariant+x07 verify --bmc|--smt(bounded proof artifacts) - Review + trust artifacts:
x07 review diff+x07 trust report(human reviewable “intent-level” diff + trust report)
1) Install and verify the toolchain
- Install with
x07up(recommended).
Prerequisites (macOS / Linux):
sh+tarcurlorwget(used for downloads)- a sha256 tool (
sha256sum,shasum, oropenssl) for installer verification - for OS worlds / native deps (for example
ext-curl-c): a C toolchain and libcurl headers (x07 doctorreports missing deps)
macOS / Linux (CI-safe, no profile edits, JSON report):
curl -fsSL https://x07lang.org/install.sh | sh -s -- \
--yes \
--channel stable \
--no-modify-path \
--json
export PATH="$HOME/.x07/bin:$PATH"
If you are not in CI, you can omit --no-modify-path and the installer will attempt to persist the PATH change.
Verify:
x07 --help
x07 run --help
x07up show --json
x07 --cli-specrows
If you plan to use OS worlds (run-os*) with native deps (for example ext-net / ext-curl-c / ext-sockets-c), run:
x07 doctor
See also: Install.
2) Create a project (canonical starting point)
mkdir myapp
cd myapp
x07 init
x07 init creates both the project skeleton and the agent kit:
x07.json(withosandsandboxprofiles)x07.lock.jsonx07-toolchain.toml(pinsstableand declaresdocs+skills)AGENT.md(self-recovery guide + canonical commands).agent/docs/(offline docs; linked to the installed toolchain when available).agent/skills/(skills pack; linked to the installed toolchain when available)src/(a minimal program)tests/tests.json+tests/smoke.x07.json(a harness smoke test)
x07.json notes (common failure mode)
- The root
worldfield is required (it’s used as a fallback when no run profile is selected). - For multi-profile projects, set the root
worldto the solve-* world you want for deterministic lint/repair (for examplesolve-pure), and run OS worlds via profiles (run-os*).
Contracts-by-example (copy/paste)
If your project uses pinned rr policies, archive policies, DB migrations, or arch-driven budgets, start from a schema-valid example arch/ tree:
docs/examples/contracts_project/(copy itsarch/into your project root)
If you are creating a publishable package repo (for x07 pkg publish), use x07 init --package instead of x07 init.
See also: Available skills.
3) The core loop: run → test (auto-repair)
Run:
x07 run
x07 run runs the canonical auto-repair loop by default (format → lint → quickfix, repeatable). Use --repair=off when debugging, or --repair=memory to stage repairs without editing source files.
See: Running programs.
Diagnostics tip: many compiler errors include ptr=/... (a JSON Pointer into your x07AST) and sometimes moved_ptr=/... for ownership errors. Use x07 ast get --in src/main.x07.json --ptr /... to extract the failing node without manually counting indexes.
If you hit a compiler budget error (for example Budget: max locals exceeded or Budget: AST too large), see: Compiler limits.
Dependency tip: when compilation fails due to a missing module and prints hint: x07 pkg add ... --sync, x07 run can apply the hinted package add automatically and retry.
Run report tip: in run-os, the rr_* counters in x07 run --report ... are record/replay adapter stats and are not a count of real OS network requests.
If your program expects CLI arguments via argv_v1, pass them after -- and x07 run will encode them into input bytes:
x07 run -- tool --help
Run the deterministic harness (repo-defined suites):
x07 test --manifest tests/tests.json
If the suite includes property-based tests, run:
x07 test --all --manifest tests/tests.json
If PBT finds a counterexample, convert it into a committable regression test:
x07 fix --from-pbt target/x07test/pbt/<...>/repro.json --write
See: Property-based testing and PBT repro → regression test.
4) Repairs: quickfixes and patches
Two canonical repair mechanisms:
- Quickfixes:
x07 fixapplies the tool-providedquickfixJSON patches deterministically. - Explicit patches:
x07 ast apply-patchapplies RFC 6902 JSON Patch.
Note: x07 run, x07 build, and x07 bundle apply quickfixes automatically by default (--repair=...). Use the explicit loop below when you want raw diagnostics or tighter control.
Example loop:
x07 lint --input src/main.x07.json
x07 fix --input src/main.x07.json --write
x07 lint --input src/main.x07.json
See: Repair loop.
If you need a human-reviewable artifact for an agent patchset, use:
x07 review diff(semantic diff; HTML)x07 trust report(budgets/worlds/nondeterminism summary)
See: Review & trust artifacts.
5) Learn the language
- Start here: Language overview
- Read the concrete syntax model: Syntax & x07AST
Key x07AST shapes:
- expression call:
["head", arg1, arg2, ...] - identifier:
"std.bytes.len"
6) Packages (external dependencies)
Discover packages and versions:
- Registry UI: https://x07.io/packages
- Index catalog: https://registry.x07.io/index/catalog.json
Add a dependency:
# Add the latest non-yanked version from the index:
x07 pkg add NAME --sync
# Or pin explicitly:
x07 pkg versions NAME
x07 pkg add NAME@VERSION --sync
# Remove a dependency:
x07 pkg remove NAME --sync
Notes:
x07 pkg addeditsx07.json. With--sync, it also updatesx07.lock.json.x07 pkg add NAME@VERSIONis safe to re-run: if the same dep+version already exists, it succeeds as a no-op. If the dep exists at a different version, pick a version explicitly and update the project deps.- If a module import fails and you don’t know which package provides it, use
x07 pkg provides <module-id>. - If you’ve added a package but don’t know which modules it exports, use
x07 doc <package-name>(example:x07 doc ext-net). - For builtin
std.*modules (file:<builtin>), usex07 doc std.<module>(example:x07 doc std.bytes). - For package-provided
std.*modules, runx07 doc <module-id> --project x07.jsonafter adding the package (example: afterx07 pkg add ext-net --sync, runx07 doc std.net.tcp --project x07.json). - For special forms (pipes,
task.scope_v1,budget.*) and non-module builtins (example:std.brand.*), usex07 guide+ linked docs pages (notx07 doc). - For structured encodings, prefer branded bytes + validators over ad-hoc parsing (see
std.brand.cast_view_v1/std.brand.cast_view_copy_v1inx07 guideandmeta.brands_v1in schema-derived modules). - For streaming transforms, prefer
std.stream.pipe_v1andstd.io.bufreadover manual loops (more predictable allocations; fewer borrow/ownership hazards). x07 pkg lockdefaults to the official registry index when fetching is required; override with--indexor forbid network with--offline.- Some packages may declare required helper packages via
meta.requires_packages. When present,x07 pkg lockcan add and fetch these transitive deps, but agents should treat the capability map + templates as canonical so the dependency set is explicit. - Examples of transitive helpers:
ext-netpullsext-curl-c/ext-sockets-c/ext-url-rs, andext-db-sqlitepullsext-db-core(which pullsext-data-model).
If you hit a dependency version conflict, the canonical repair loop is:
x07 pkg versions NAME
x07 pkg remove NAME --sync
x07 pkg add NAME@VERSION --sync
See also: Packages & projects.
7) World selection (OS worlds)
run-os: real OS adapters (disk/network/time/env/process)run-os-sandboxed: policy-gated OS adapters (defaults to a VM boundary; still not a hardened sandbox if you mount secrets or enable networking)
For run-os-sandboxed, start from a schema-valid policy template instead of hand-writing JSON:
x07 policy init --template worker --out policy/sandbox.base.json --mkdir-out
Prefer profiles (x07.json.default_profile + x07.json.profiles) so agents usually run:
x07 run(project default)x07 run --profile os/x07 run --profile sandbox(explicit intent)
See: OS worlds.
8) Machine-first discovery surfaces
- CLI surface:
x07 --cli-specrows - Schemas:
spec/*.schema.json(and the synced copies on x07lang.org under/agent/.../schemas/) - External packages index:
GET /agent/latest/packages/index.jsonon x07lang.org - Offline docs:
x07up docs path --json - Local module inspection:
x07 doc <module-or-symbol>(example:x07 doc std.bytes) - Local package inspection (project deps):
x07 doc <package-name>(example:x07 doc ext-net) - Built-in reference guide:
x07 guide
9) Known-good reference projects (copy/paste)
The x07 repo ships CI-gated example projects under docs/examples/agent-gate/:
cli-newline(pure CLI payload parsing)cli-ext-cli(CLI args viaext-cli+argv_v1)web-crawler-local(sandboxed OS networking +--allow-host, against a local fixture site)
For the canonical package-focused set (examples + scenarios), see: Agent workflow.
See also: Patch-based recipes.
10) By-example tutorials (long-form)
- Sandbox policy walkthrough (progressive policy +
--allow-host) - Publishing by example (author → test → pack → publish → consume)
- Porting by example (
x07import-cliRust/C → x07 package) - Testing by example (
x07 test+ fixtures)