zig

Installation
SKILL.md

Zig 0.16 for Native SDK code

The Native SDK requires Zig 0.16.0 (minimum_zig_version in build.zig.zon; the CLI pins the same version and offers a checksum-verified download into ~/.native/toolchains/ when the zig on PATH does not match). Training data and older guides teach Zig 0.15 idioms, and 0.16 moved everything that touches the outside world — files, stdout, clocks, sleeping, process spawning, sockets — behind an explicit std.Io value, while containers became allocator-per-call. Each section below is headed by the exact compile error the old idiom produces, so search this file by error text.

Two rules resolve most failures:

  • Operations on the outside world take a std.Io first (or right after the receiver). Get one from init.io in main(init: std.process.Init), from std.testing.io in tests, or from std.Io.Threaded in code with no Init to thread through.
  • Containers are unmanaged: initialize with .empty and pass the allocator to every mutating call.

In a UiApp, update never sees an Io — persistence, record and relational storage, secure credentials, subprocesses, HTTP, clocks, and timers go through the typed effects channel (fx.persist, fx.storeSet/storeGet/storeDelete/storeScan/storeSetMany, fx.dbQuery/dbExec, fx.credentialsSet/credentialsGet/credentialsDelete, fx.readFile/appendFile/statFile/deleteFile/streaming file verbs, fx.spawn, fx.fetch, fx.wallMs, fx.startTimer; see native skills get native-ui). Whole-file IO stays capped at 1 MiB; streamed reads deliver 256-KiB chunks, and streamed writes finalize atomically on close. External raw paths require the filesystem permission, while the app's six resolved directories are exempt after symlink-safe canonicalization. Raw std.Io belongs in main, tests, and standalone tools. Record-store apps declare "store"; relational apps declare "sqlite"; credentials require both the "credentials" capability and permission. Credential Msg arms carry EffectCredentialsResult; consume successful get bytes immediately and never retain them in Model. The engine owns database paths and app-scoped credential namespaces, while every result still returns as a Msg and crosses the replay journal (credential bytes are redacted). Use TestHarness().createWithRelationalStore for a hermetic in-memory relational database and TestHarness().createWithCredentials for a hermetic in-memory credential store. And because Zig analyzes lazily, a 0.15-ism can hide in code only one build path references: run BOTH zig build and zig build test before calling a change done.

error: struct 'heap' has no member named 'GeneralPurposeAllocator' — allocators come from main(init: std.process.Init)

Zig 0.15 and earlier:

Installs
4
GitHub Stars
7.7K
First Seen
Aug 3, 2026
zig — vercel-labs/native