zig
SKILL.md
Critical Patterns
Error Handling (REQUIRED)
// ✅ ALWAYS: Use error unions
fn readFile(path: []const u8) ![]u8 {
const file = try std.fs.cwd().openFile(path, .{});
defer file.close();
return try file.readToEndAlloc(allocator, max_size);
}
// Usage with catch
const content = readFile("config.txt") catch |err| {
std.log.err("Failed: {}", .{err});
return err;
};