zig-idioms

Guides Zig code writing, review, and migration against version-specific official practices.

Updated Jul 4, 2023
One-click install
npx skills add https://github.com/kohdice/dotfiles --skill zig-idioms-kohdice
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: zig-idioms
Source: https://github.com/kohdice/dotfiles/tree/main/config/agents/skills/zig-idioms
Command: npx skills add https://github.com/kohdice/dotfiles --skill zig-idioms-kohdice

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Zig evolves rapidly and removes APIs between releases, so code advice that was correct last year may fail to compile today. This Skill resolves the project's declared minimum Zig version first, then applies a version-tagged catalog of official idioms, removals, and deprecations so recommendations always match the actual toolchain baseline. ## Core Features & Use Cases - Version-aware baseline resolution: Reads build.zig.zon for minimum_zig_version and checks zig version before writing or reviewing any code, refusing APIs introduced after the declared minimum. - std.Io migration catalog: Provides verified 0.16.0 call shapes for the "I/O as an Interface" rewrite, including std.process.Init main signatures, Io.Dir.readFileAlloc, and buffered stdout writers. - Structured review reports: Emits findings tagged [error], [warn], [recommend], or [gated-option], each citing the exact Zig version that removed, deprecated, or introduced the API. - Use Case: When reviewing a Zig project declaring minimum_zig_version = "0.15.1", the Skill flags usingnamespace as [error], @cImport as a 0.16-gated concern, and suggests unmanaged std.ArrayList patterns compatible with the baseline. ## Quick Start Ask the AI to review or refactor the Zig code in this project using the zig-idioms skill, respecting the minimum Zig version declared in build.zig.zon.

Frequently Asked Questions about zig-idioms

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Zig code to the 0.16 std.Io interface?▼

Thread an `Io` instance from the entry point through the call chain, using `std.process.Init` in main for CLI executables or `std.Io.Threaded` for manual bootstrap. Replace `std.fs.cwd()` with `std.Io.Dir.cwd()` and use `Io.Dir.readFileAlloc` for whole-file reads.

How to review Zig code for version compatibility?▼

Read `build.zig.zon` for `minimum_zig_version` and check `zig version` first, then flag any API introduced after that minimum. Tag findings as error, warn, recommend, or gated-option, citing the Zig version that removed or deprecated each API.

What replaced usingnamespace and async/await in Zig 0.15?▼

Zig 0.15 removed `usingnamespace` in favor of explicit re-declarations or namespaced access, and removed the `async`/`await` keywords in favor of `std.Io` async APIs. Code claiming 0.15 or newer support must not contain either construct.

Does std.ArrayList still take an allocator in init?▼

Since Zig 0.15, `std.ArrayList(T)` is unmanaged: initialize it with the `.empty` declaration literal and pass an explicit allocator to `append` and `deinit`. The `std.array_list.Managed` alias remains but is deprecated.

Why does @cImport fail or warn in newer Zig versions?▼

`@cImport` is deprecated in Zig 0.16; C header translation should use `b.addTranslateC()` in build.zig instead. On a 0.16 baseline it is a warn-level finding with an official replacement.

When should Zig API recommendations be verified against std sources?▼

Verify when the project's minimum version exceeds the catalog coverage version, when an unlisted API is boundary-relevant near the baseline, or when a catalog entry conflicts with compiler behavior. Prefer inspecting installed std sources found via `zig env`.