/engineering-practices:zig-best-practicesfrom engineering-practices
Use when reading or writing Zig files (.zig, build.zig, build.zig.zon).
Ships in engineering-practices. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Follows the type, error, and assertion law in code-law. This skill covers Zig-specific idioms only.
Tagged unions for mutually exclusive states — prevents invalid combinations that a struct with multiple nullable fields would allow:
const RequestState = union(enum) {
idle,
loading,
success: []const u8,
failure: anyerror,
};
Explicit error sets — documents exactly what can fail; anyerror hides failure modes:
const ParseError = error{ InvalidSyntax, UnexpectedToken, EndOfInput };
fn parse(input: []const u8) ParseError!Ast { ... }
Distinct types for domain IDs — compiler prevents mixing up different ID types:
const UserId = enum(u64) { _ };
const OrderId = enum(u64) { _ };
Comptime validation — catch invalid configurations at compile time, not runtime:
fn Buffer(comptime size: usize) type {
if (size == 0) @compileError("buffer size must be greater than 0");
return struct { data: [size]u8 = undefined, len: usize = 0 };
}
Restrict who can do it — when only one scope may perform an effect, keep its functions non-pub and expose only the scope that performs it; an opaque capability that the scope alone constructs makes an out-of-scope call a compile error. Correct types are the proof.
defer resource.deinit() immediately after acquisition — keeps cleanup co-located with creation.errdefer for cleanup on error paths; defer for unconditional cleanup.std.testing.allocator in tests — reports leaks with stack traces.fn createResource(allocator: std.mem.Allocator) !*Resource {
const resource = try allocator.create(Resource);
errdefer allocator.destroy(resource); // runs only on error
resource.* = try initializeResource();
return resource;
}
Runs on the assertions-and-bounds law in code-law; these are the Zig-specific levers.
std.debug.assert for invariants; comptime asserts check design relationships between constants (type sizes, layout invariants) before the program even runs.u32, u64) where the domain owns the type; keep usize at the std-lib seam (slice lengths, indices) instead of propagating it inward through @intCast chains.fn init(target: *T) !void) for pointer stability and no intermediate copy-moves; in-place init is viral — if a field needs it, the container does too.const over var; prefer slices over raw pointers.comptime T: type over anytype; explicit types produce clearer errors. Use anytype only for genuinely polymorphic cases (callbacks, std.debug.print-style).switch: include an else returning an error or unreachable for truly impossible cases.std.log.scoped(.module_name) for namespaced logging; define a module-level const log constant.The fleet pins the Zig version (zig version); std APIs change between
releases, so read the installed std source (zig env prints std_dir) before
relying on a remembered name. Renames that bite on 0.16: the leak-checking
allocator is std.heap.DebugAllocator (no GeneralPurposeAllocator), the C
calling convention is callconv(.c), and std.ArrayList methods take the
allocator.
addFileInput, or a
declared source tree), so zig build can skip it and reruns it when one
changes.has_side_effects for steps that change something outside the cache;
a step that only reads declares its inputs instead.ziglint (static analysis, configured by .ziglint.zon) runs where the
project pins it.
https://ziglang.org/documentation/<zig version>/What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub alleneubank/agent-profile --plugin engineering-practices28 skills in this plugin
/agent-browserUse when driving a browser the agent owns through the agent-browser CLI — opening pages, clicking and filling by snapshot refs, screenshots, testing a web app, or extracting data from a rendered page./agent-deviceUse when driving an iOS, Android, macOS, or TV app through the agent-device CLI — opening an app on a simulator, emulator, or device, tapping and filling by snapshot refs, capturing screenshots, logs, or recordings, or replaying a scripted flow./agent-operabilityUse when designing or changing a CLI, API, control plane, or automation surface that an agent must inspect, operate, and verify safely./atlas-best-practicesUse when working with atlas.hcl, Atlas CLI commands, schema HCL/SQL files, or migration planning and reviews./brief-best-practicesUse when a surface needs a durable quality agreement or the user requests a BRIEF.md; ordinary drafts and repeated edits do not automatically need one./canton-network-reposUse when working with Canton Network participants, DAML smart contracts, Splice applications, or debugging LF version and package ID issues.