zig
Skill15 starsChanged 46 days agoMITView on GitHub
Expert Zig systems programming assistance covering comptime code execution, manual memory allocators, C interop, and cross-compilation. Use when writing low-level systems software, embedded apps, or high-performance libraries.
9 other projects use a version of this.
Adopted by
Most recently taken up by
- vercel-labs/fxtheir own version, first seen Nov 15, 2026
- gkurt/ai-soulstheir own version, first seen Nov 8, 2026
- TeddyAlbina/skillstheir own version, first seen Nov 1, 2026
- nzrsky/zig-skillstheir own version, first seen Oct 15, 2026
- vercel-labs/nativetheir own version, first seen Oct 13, 2026
- vercel-labs/zero-nativetheir own version, first seen Oct 8, 2026
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- vercel-labs/native★ 7.8ksame name
- vercel-labs/zero-native★ 7.8ksame name
- vercel-labs/fx★ 3.9ksame name
- rudedogg/zig-skills★ 39same name
- nzrsky/zig-skills★ 14same name
- TeddyAlbina/skills★ 2same name
- aresbit/claude-skills★ 0same name
- gkurt/ai-souls★ 0same name
- zig-incubator/zig-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository350 other files it gives its agents.
- airflowSkill
- catboostSkill
- claudeSkill
- comfyuiSkill
- cursor-aiSkill
- dalleSkill
- daskSkill
- dbtSkill
- deepseekSkill
- fastaiSkill
- geminiSkill
- github-copilotSkill
- huggingfaceSkill
- jaxSkill
- jupyterSkill
- kerasSkill
- langchainSkill
- lightgbmSkill
- llamaindexSkill
- llamaSkill
- matplotlibSkill
- midjourneySkill
- mistralSkill
- mlflowSkill
- nltkSkill
- numpySkill
- ollamaSkill
- openai-gptSkill
- opencvSkill
- pandasSkill
- perplexitySkill
- plotlySkill
- polarsSkill
- pytorchSkill
- raySkill
- scikit-learnSkill
- seabornSkill
- spacySkill
- sparkSkill
- stable-diffusionSkill
- tensorflowSkill
- vaexSkill
- weights-biasesSkill
- whisperSkill
- xgboostSkill
- api-gatewaySkill
- clean-architectureSkill
- cqrsSkill
- domain-driven-designSkill
- event-drivenSkill
- event-sourcingSkill
- graphqlSkill
- grpcSkill
- hexagonalSkill
- microservicesSkill
- modular-monolithSkill
- monolithSkill
- rest-apiSkill
- sagaSkill
- serverlessSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 165
Always pass explicit std.mem.Allocator to functions and structs that perform dynamic allocation.
- Very specific: line 166
Use defer for cleanup immediately following successful resource acquisition, and errdefer for failure rollbacks.
- Very specific: line 172
Use @ptrCast or @alignCast without verifying alignment and layout safety.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Zig
Zig is a modern systems programming language offering manual memory management, compile-time code execution (comptime), and a built-in cross-compiling C/C++ toolchain.
When to Use
- Low-Level Systems & Kernel Development: Writing bare-metal kernels, embedded device software, hypervisors, and audio engines.
- Drop-in C/C++ Compiler Toolchain: Utilizing
zig ccandzig c++for instant, cross-compilation without external dependencies. - Explicit Memory Allocation & Safety: High-performance software demanding complete control over allocations without hidden heap usage.
- Compile-Time Metaprogramming (Comptime): Writing generics, serialization, and type-level algorithms without macro systems or templates.
Quick Start
const std = @import("std");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
try stdout.print("Hello from Zig!
", .{});
}Core Concepts
Explicit Memory Allocation with GeneralPurposeAllocator
Zero hidden allocations—every data structure requires an explicit allocator:
const std = @import("std");
pub fn main() !void {
// Standard debug memory allocator with leak detection
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer {
const check = gpa.deinit();
if (check == .leak) std.debug.print("Memory leak detected!
", .{});
}
const allocator = gpa.allocator();
// Dynamically allocated array list
var list = std.ArrayList(u32).init(allocator);
defer list.deinit();
try list.append(10);
try list.append(20);
try list.append(30);
for (list.items) |item| {
std.debug.print("Item: {d}
", .{item});
}
}Comptime Generics & Metaprogramming
Compile-time code execution replacing C++ templates and C macros:
const std = @import("std");
// Generic Queue data structure generated at compile-time
pub fn Queue(comptime T: type) type {
return struct {
const Self = @this();
items: std.ArrayList(T),
pub fn init(allocator: std.mem.Allocator) Self {
return Self{
.items = std.ArrayList(T).init(allocator),
};
}
pub fn deinit(self: *Self) void {
self.items.deinit();
}
pub fn push(self: *Self, value: T) !void {
try self.items.append(value);
}
pub fn pop(self: *Self) ?T {
if (self.items.items.len == 0) return null;
return self.items.orderedRemove(0);
}
};
}Error Handling, Defer & Errdefer
Deterministic resource management and lightweight error unions:
const std = @import("std");
const FileError = error{
AccessDenied,
FileNotFound,
DiskFull,
};
fn openAndProcessFile(allocator: std.mem.Allocator, filename: []const u8) !void {
const buffer = try allocator.alloc(u8, 1024);
// defer runs unconditionally when exiting scope
defer allocator.free(buffer);
var file = std.fs.cwd().openFile(filename, .{}) catch |err| switch (err) {
error.FileNotFound => return FileError.FileNotFound,
error.AccessDenied => return FileError.AccessDenied,
else => return error.DiskFull,
};
defer file.close();
// errdefer only runs if an error is returned later in the function
errdefer std.debug.print("Error occurred while reading file: {s}
", .{filename});
_ = try file.readAll(buffer);
}Common Patterns
Explicit Memory Allocation with Defer Cleanup
Problem: Hidden allocations in language runtimes make memory leaks difficult to identify and fix.
Solution: Pass explicit allocator parameter and defer cleanup immediately:
const std = @import("std");
pub fn createBuffer(allocator: std.mem.Allocator, size: usize) ![]u8 {
const buf = try allocator.alloc(u8, size);
errdefer allocator.free(buf);
@memset(buf, 0);
return buf;
}
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const buffer = try createBuffer(allocator, 1024);
defer allocator.free(buffer);
}Best Practices
Do:
- Always pass explicit
std.mem.Allocatorto functions and structs that perform dynamic allocation. - Use
deferfor cleanup immediately following successful resource acquisition, anderrdeferfor failure rollbacks. - Leverage
zig testwith built-in leak tracking to test functions and algorithms thoroughly. - Take advantage of
zig buildas a unified, portable build system replacing Make and CMake.
Don't:
- Use
@ptrCastor@alignCastwithout verifying alignment and layout safety. - Ignore error return values; handle with
try,catch, or explicit pattern matching. - Allocate inside tight inner loops; pass pre-allocated buffers or slice views.
Troubleshooting
| Error | Cause | Solution |
error: memory leak detected | GPA allocator detected memory not freed at shutdown. | Ensure every allocator.alloc has a matching defer allocator.free. |
error: use of undeclared identifier | Symbol misspelled or missing @import. | Check spelling and verify imported namespace. |
error: expected type '...', found '...' | Static type mismatch in expression. | Use explicit cast @as(TargetType, val) or @intCast. |
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

