بنقرة واحدة
zig-best-practices
Use when reading or writing Zig files (.zig, build.zig, build.zig.zon).
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Use when reading or writing Zig files (.zig, build.zig, build.zig.zon).
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use when the user says they are stepping away and the agent should continue without interactive approvals
Use when running e2e tests, debugging test failures, or fixing flaky tests. Covers failure taxonomy, fix rules, and workflow. Never changes source code logic or API without spec backing.
Use when auditing how well the shared agent instructions (AGENTS.md, skills) hold up in real sessions — sampling transcripts via recall, scoring them against the gap rubric, and turning findings into ratified amendments
Use when preparing clean, logical git commits from an existing working tree
Use when syncing a feature branch onto the latest origin base branch via git rebase.
Fetch latest from origin, prune remote-tracking refs, delete stale local branches and worktrees, and fast-forward important branches. Use when tidying up a worktree-based repo layout.
| name | zig-best-practices |
| description | Use when reading or writing Zig files (.zig, build.zig, build.zig.zon). |
Follows type-first, functional, and error handling patterns from AGENTS.md. 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 };
}
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 from AGENTS.md; 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.zigdoc — browse std library and dependency docs:
zigdoc std.mem.Allocator # std lib symbol
zigdoc vaxis.Window # project dependency
zigdoc @init # create AGENTS.md with API patterns
ziglint — static analysis with .ziglint.zon config:
ziglint # lint current directory
ziglint --ignore Z001 # suppress specific rule