[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B1XKBW7T0SE2K5NVEPJ1P0":3,"skill-same:01M7B1XKBW7T0SE2K5NVEPJ1P0":53},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":14,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M7B1XKBW7T0SE2K5NVEPJ1P0","zig-0.16",null,"Zig 0.16.0 API guidance and porting notes. Use this when writing or upgrading Zig code to the 0.16.0 stable release (std.Io era, @Type removal, @cImport deprecation).","Yabuku-xD\u002Fomfx","Yabuku-xD","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78594762?v=4","01M7B1X88FX04Z53K2S2P3N2Z9","Shyamalan Kannan","01M7B1X89G34W3D025T1F4KNKF",0,"MIT","https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzig-0-16\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: zig-0.16\ndescription: Zig 0.16.0 API guidance and porting notes. Use this when writing or upgrading Zig code to the 0.16.0 stable release (std.Io era, @Type removal, @cImport deprecation).\nlicense: MIT\ncompatibility:\n  - opencode\n  - claude-code\nmetadata:\n  version: \"0.16.0\"\n  language: \"zig\"\n  category: \"programming-language\"\n---\n\n# Zig 0.16.0 Programming Guide\n\n> **Version Scope**: This skill is pinned to **Zig 0.16.0** (stable).\n> **Release Notes**: https:\u002F\u002Fziglang.org\u002Fdownload\u002F0.16.0\u002Frelease-notes.html\n\nZig 0.16.0 is a major release introducing `std.Io` as the unified I\u002FO interface, removing `@Type`, deprecating `@cImport`, and significantly reworking the build system package management.\n\n---\n\n## Local Documentation First\n\nRun `zig env` to discover installation paths — never hardcode them. Key fields: `.lib_dir`, `.std_dir`, `.version`.\n\n- **Language Reference**: `\u003Clib_dir>\u002F..\u002Fdoc\u002Flangref.html`\n- **Std Library Source**: read files under `.std_dir` for API verification.\n- **Std Library Docs**: run `zig std` to start a local HTTP server.\n\nAlways check local docs before web search.\n\n---\n\n## Quick Reference: Top Breaking Changes\n\n| Old (0.15.x) | New (0.16.0) |\n|--------------|--------------|\n| `@Type(.Int(...))` | `@Int(.signed, bits)` |\n| `@Type(.Struct(...))` | `@Struct(layout, BackingInt, field_names, field_types, field_defaults, field_is_comptime, field_alignments)` |\n| `@Type(.Pointer(...))` | `@Pointer(size, attrs, Element, sentinel)` |\n| `@Type(.Fn(...))` | `@Fn(param_types, param_attrs, ReturnType, attrs)` |\n| `@Type(.Tuple(...))` | `@Tuple(field_types)` |\n| `@cImport({...})` | `b.addTranslateC(...)` + `@import(\"c\")` (deprecated) |\n| `std.net` | `std.Io.net` |\n| `std.ArrayList.init(allocator)` | `std.ArrayList.initCapacity(allocator, n)` |\n| `std.crypto.random` | `std.Io.randomSecure(io, buf)` |\n| `std.meta.intToEnum` | `std.enums.fromInt` |\n| `std.fmt.FormatOptions` | `std.fmt.Options` |\n| `std.fmt.bufPrintZ` | `std.fmt.bufPrintSentinel` |\n| `std.io.fixedBufferStream` | `std.Io.Writer.fixed(buf)` |\n| `error.RenameAcrossMountPoints` | `error.CrossDevice` |\n| `error.NotSameFileSystem` | `error.CrossDevice` |\n| `error.SharingViolation` | `error.FileBusy` |\n| `error.EnvironmentVariableNotFound` | `error.EnvironmentVariableMissing` |\n| `std.Build.Step.ConfigHeader` cmake handling | fixed leading whitespace |\n\n---\n\n## Language Changes\n\n### @Type Removed — Use Individual Builtins\n\n`@Type` is gone. Replace with these builtins:\n\n```zig\n\u002F\u002F Integer type\nconst MyInt = @Int(.signed, 32);\n\n\u002F\u002F Struct type\nconst MyStruct = @Struct(\n    .auto,           \u002F\u002F layout\n    null,            \u002F\u002F BackingInt (for packed)\n    &.{\"x\", \"y\"},    \u002F\u002F field_names\n    &.{ i32, i32 },  \u002F\u002F field_types\n    &.{ null, null },\u002F\u002F field_defaults\n    &.{ false, false }, \u002F\u002F field_is_comptime\n    &.{ null, null },\u002F\u002F field_alignments\n);\n\n\u002F\u002F Pointer type\nconst MyPtr = @Pointer(.one, .{\n    .alignment = 8,\n    .address_space = .generic,\n    .is_const = false,\n    .is_volatile = false,\n}, u8, null);\n\n\u002F\u002F Function type\nconst MyFn = @Fn(&.{i32, i32}, &.{.{}, .{}}, i32, .{});\n\n\u002F\u002F Tuple type\nconst MyTuple = @Tuple(&.{ i32, bool });\n\n\u002F\u002F Enum literal type\nconst EnumLitType = @EnumLiteral();\n```\n\n### @cImport Deprecated — Use Build System Translation\n\n`@cImport` is deprecated. Use `addTranslateC` in `build.zig`:\n\n```zig\n\u002F\u002F build.zig\nconst translate_c = b.addTranslateC(.{\n    .root_source_file = b.path(\"src\u002Fc.h\"),\n    .target = target,\n    .optimize = optimize,\n});\ntranslate_c.linkSystemLibrary(\"glfw\", .{});\n\nconst exe = b.addExecutable(.{\n    .name = \"myapp\",\n    .root_module = b.createModule(.{\n        .root_source_file = b.path(\"src\u002Fmain.zig\"),\n        .optimize = optimize,\n        .target = target,\n        .imports = &.{\n            .{ .name = \"c\", .module = translate_c.createModule() },\n        },\n    }),\n});\n```\n\nThen in Zig: `const c = @import(\"c\");`\n\n**Note**: The C translator is now backed by arocc instead of libclang.\n\n### Switch Improvements\n\n- `packed struct` and `packed union` may now be used as switch prong items (compared by backing integer).\n- `decl literals` and result-type-dependent expressions (e.g. `@enumFromInt`) may now be used as switch prong items.\n- Union tag captures are now allowed for all prongs, not just inline ones.\n- Switch prong captures may no longer all be discarded.\n- `.awake` atomic order removed; use `.monotonic` \u002F `.seq_cst`.\n\n### Other Language-Level Gotchas\n\n- **Small integer types coerce to floats** — e.g. `u8` → `f32` is now allowed.\n- **Runtime vector indexes forbidden** — vector indexing must be comptime-known.\n- **Vectors and arrays no longer support in-memory coercion** — must explicitly cast element-wise.\n- **Trivial local addresses cannot be returned from functions** — e.g. `return &local;` is rejected more consistently.\n- **Packed unions must not have unused bits** — all bit patterns must be valid.\n- **Pointers forbidden in packed structs\u002Funions**.\n- **Explicitly-aligned pointer types are now distinct** from naturally-aligned ones in type system.\n- **Simplified dependency loop rules** — most code still works, but self-referential alignment queries now error.\n\n---\n\n## Standard Library: std.Io\n\n### Networking\n\n- `std.net` is gone. Use `std.Io.net` (types: `IpAddress`, `Stream`, `Server`, `UnixAddress`).\n- High-level helpers like `tcpConnectToHost`, `Address.parseIp`, `Stream.connect` removed. Use `Io` vtables: `io.vtable.netConnectIp`, `netRead`, `netWrite`, `netListenIp`, `netAccept`.\n- Raw fd operations: use `std.os.linux.socket`, `accept4`, `connect`, `bind`, `listen`, `write`, `read`, `close`.\n- `posix.socket`, `posix.bind`, `posix.accept`, `posix.shutdown`, `posix.writev`, `posix.listen`, `posix.pipe2`, `posix.getrandom`, `std.net.has_unix_sockets` removed.\n- Epoll: `std.os.linux.epoll_create1\u002Fepoll_ctl\u002Fepoll_wait` directly.\n- New: `std.Io.net.Socket.createPair` for socketpair usage in tests.\n\n### I\u002FO Readers\u002FWriters\n\n- Writer\u002Freader interfaces live under `std.Io`. TLS expects `*std.Io.Reader` \u002F `*std.Io.Writer` (struct fields `.interface`). Pass pointers to interfaces, not call `interface()` as a function.\n- `std.time.sleep` removed; use `std.Io.sleep(io, Duration, Clock)`.\n- `std.Io.GenericWriter`, `std.Io.AnyWriter`, `std.Io.null_writer`, `std.Io.CountingReader` removed.\n\n### Time \u002F Random \u002F Env \u002F Exit\n\n- `std.time.milliTimestamp` removed. Use `std.time.Timer` or `std.Io.Clock.now(clock, io)` and compare `Timestamp.nanoseconds`.\n- Random secure bytes: `std.Io.randomSecure(io, buf)`; no `std.crypto.random` or `std.posix.getrandom` convenience.\n- `std.process.getEnvVarOwned` removed; use `std.c.getenv` and copy.\n- `std.posix.exit` removed; use `std.process.exit`.\n\n### TLS Client Options\n\n- `std.crypto.tls.Client.Options` requires `entropy: *const [entropy_len]u8` and `realtime_now_seconds: i64`. Fill entropy with `std.Io.randomSecure`; compute seconds with `Io.Clock.now(.real, io)` \u002F `ns_per_s`.\n\n### MemoryPool API Changes\n\n- `std.heap.MemoryPool(T).initCapacity(allocator, n)` returns the pool.\n- `create`\u002F`destroy` now require allocator. No bare `init()` or zero-arg `deinit()`.\n\n### Format Options\n\n- `std.fmt.Options` replaces `FormatOptions`.\n- `std.fmt.format` helper removed; call `writer.print` directly (writers live in `std.Io.Writer`).\n- `std.fmt.Formatter` renamed to `Alt`.\n- `std.fmt.bufPrintZ` renamed to `std.fmt.bufPrintSentinel`.\n\n### Randomness \u002F Crypto\n\n- `std.crypto.random` removed. Use an `std.Io` instance: `const io = std.Io.Threaded.global_single_threaded.ioBasic(); io.random(&buf);`.\n- `Ed25519.KeyPair.generate` now requires an `io: std.Io` argument.\n\n### Enum Conversion\n\n- `std.meta.intToEnum` removed. Use `std.enums.fromInt(EnumType, value)` (returns `?EnumType`).\n- `meta.declList` removed.\n\n### Fixed-Buffer Writers in Tests\n\n- `std.io.fixedBufferStream` removed. For in-memory writes use `var w = std.Io.Writer.fixed(buf);` and read bytes with `std.Io.Writer.buffered(&w)`.\n- `std.ArrayList` no longer has `.init(allocator)` shorthand; use `.initCapacity(allocator, n)`.\n\n### Collections\n\n- `SegmentedList` removed.\n- `BitSet`, `EnumSet`: replace `initEmpty`, `initFull` with decl literals (e.g. `.{}`, `.{ .a = true }`).\n- New: `Io.Dir.renamePreserve` — rename without replacing destination.\n- `std.Io.Dir.rename` returns `error.DirNotEmpty` rather than `error.PathAlreadyExists`.\n\n### Error Set Renames\n\n```zig\n\u002F\u002F Old -> New\nerror.RenameAcrossMountPoints -> error.CrossDevice\nerror.NotSameFileSystem       -> error.CrossDevice\nerror.SharingViolation        -> error.FileBusy\nerror.EnvironmentVariableNotFound -> error.EnvironmentVariableMissing\n```\n\n### Math\n\n- `math.sign` now returns the smallest integer type that fits possible values.\n\n### Threading\n\n- `Thread.Mutex.Recursive` removed.\n\n### Compression\n\n- `lzma`, `lzma2`, `xz` updated to `Io.Reader` \u002F `Io.Writer` interfaces.\n\n### Dynamic Libraries\n\n- `DynLib` removed Windows support. Use `LoadLibraryExW` and `GetProcAddress` directly.\n\n---\n\n## New Execution Model: Juicy Main\n\nZig 0.16.0 introduces `std.process.Init` as the preferred `main` parameter. This is the biggest entrypoint change in this release.\n\n### `main` signatures\n\n```zig\n\u002F\u002F 1. Bare (no args\u002Fenv available)\npub fn main() !void { }\n\n\u002F\u002F 2. Minimal (raw argv + environ only)\npub fn main(init: std.process.Init.Minimal) !void { }\n\n\u002F\u002F 3. Juicy Main (recommended)\npub fn main(init: std.process.Init) !void { }\n```\n\n### `std.process.Init` contents\n\n```zig\npub const Init = struct {\n    minimal: Minimal,\n    arena: *std.heap.ArenaAllocator,  \u002F\u002F process-lifetime arena, threadsafe\n    gpa: Allocator,                     \u002F\u002F general-purpose allocator\n    io: Io,                             \u002F\u002F default Io implementation\n    environ_map: *Environ.Map,          \u002F\u002F env vars (not threadsafe)\n    preopens: Preopens,                 \u002F\u002F WASI-style preopened files\n\n    pub const Minimal = struct {\n        environ: Environ,\n        args: Args,\n    };\n};\n```\n\n### Example\n\n```zig\nconst std = @import(\"std\");\n\npub fn main(init: std.process.Init) !void {\n    const gpa = init.gpa;\n    const io = init.io;\n\n    try std.Io.File.stdout().writeStreamingAll(io, \"Hello, world!\\n\");\n\n    const args = try init.minimal.args.toSlice(init.arena.allocator());\n    for (args, 0..) |arg, i| {\n        std.log.info(\"arg[{d}] = {s}\", .{ i, arg });\n    }\n\n    std.log.info(\"{d} env vars\", .{init.environ_map.count()});\n}\n```\n\n**Rule of thumb**: if your program needs I\u002FO, allocations, or environment variables, use `std.process.Init`.\n\n---\n\n## Environment Variables & Process Args Are Non-Global\n\n`std.os.environ` and `std.process.args` as global state are gone. They are now only available through `main`'s `init` parameter.\n\n### Environment variables\n\n```zig\n\u002F\u002F Juicy Main\nfor (init.environ_map.keys(), init.environ_map.values()) |key, value| {\n    std.log.info(\"env: {s}={s}\", .{ key, value });\n}\n\n\u002F\u002F Minimal main\nstd.log.info(\"HOME: {?s}\", .{init.environ.getPosix(\"HOME\")});\nstd.log.info(\"EDITOR: {s}\", .{ try init.environ.getAlloc(arena, \"EDITOR\") });\nconst map = try init.environ.createMap(arena);\n```\n\n### CLI arguments\n\n```zig\n\u002F\u002F Iterate lazily\nvar args = init.args.iterate();\nwhile (args.next()) |arg| {\n    std.log.info(\"arg: {s}\", .{arg});\n}\n\n\u002F\u002F To slice (needs allocator)\nconst args = try init.args.toSlice(arena);\n```\n\nAny function that needs environment variables should accept `*const process.Environ.Map` or `process.Environ` as a parameter.\n\n---\n\n## Thread.Pool Removed → Use std.Io\n\n`std.Thread.Pool` is removed. Replace with `std.Io.Group`, `std.Io.async`, or `std.Io.concurrent`.\n\n### Migration example\n\n```zig\n\u002F\u002F OLD (0.15)\nfn doAllTheWork(pool: *std.Thread.Pool) void {\n    var wg: std.Thread.WaitGroup = .{};\n    pool.spawnWg(wg, doSomeWork, .{ pool, &wg, first_work_item });\n    wg.wait();\n}\n\n\u002F\u002F NEW (0.16)\nfn doAllTheWork(io: std.Io) void {\n    var g: std.Io.Group = .init;\n    errdefer g.cancel(io);\n    g.async(io, doSomeWork, .{ io, &g, first_work_item });\n    g.wait(io);\n}\n\nfn doSomeWork(io: std.Io, g: *std.Io.Group, foo: Foo) void {\n    foo.doTheThing();\n    for (foo.new_work_items) |new| {\n        g.async(io, doSomeWork, .{ io, g, new });\n    }\n}\n```\n\n**Important**: when migrating from `Thread.Pool` to `Io`, convert `Thread.Mutex`, `Thread.Condition`, `Thread.ResetEvent` to `Io.Mutex`, `Io.Condition`, `Io.Event`.\n\n---\n\n## File I\u002FO & fs API Changes\n\n### readFileAlloc \u002F readToEndAlloc\n\n```zig\n\u002F\u002F OLD\nconst contents = try std.fs.cwd().readFileAlloc(allocator, file_name, 1234);\n\n\u002F\u002F NEW\nconst contents = try std.Io.Dir.cwd().readFileAlloc(io, file_name, allocator, .limited(1234));\n\u002F\u002F Note: FileTooBig -> StreamTooLong when limit reached.\n```\n\n```zig\n\u002F\u002F OLD\nconst contents = try file.readToEndAlloc(allocator, 1234);\n\n\u002F\u002F NEW\nvar file_reader = file.reader(&.{});\nconst contents = try file_reader.interface.allocRemaining(allocator, .limited(1234));\n```\n\n### setTimestamps\n\n```zig\n\u002F\u002F OLD\ntry atomic_file.file_writer.file.setTimestamps(io, src_stat.atime, src_stat.mtime);\n\n\u002F\u002F NEW\ntry atomic_file.file_writer.file.setTimestamps(io, .{\n    .access_timestamp = .init(src_stat.atime),\n    .modify_timestamp = .init(src_stat.mtime),\n});\n```\n\n`Io.File.Stat.atime` is now `?Timestamp` (can be `null` on e.g. ZFS).\n\n### Directory walking\n\n- `std.Io.Dir.walk` still exists.\n- New: `std.Io.Dir.walkSelectively` — opt-in recursion per directory, avoiding redundant open\u002Fclose syscalls.\n- Both `Walker` and `SelectiveWalker` gained `leave()` and `depth()`.\n\n### fs.path.relative is now pure\n\n```zig\n\u002F\u002F OLD\nconst relative = try std.fs.path.relative(gpa, from, to);\n\n\u002F\u002F NEW\nconst cwd_path = try std.process.currentPathAlloc(io, gpa);\nconst relative = try std.fs.path.relative(gpa, cwd_path, environ_map, from, to);\n```\n\n### fs.path Windows changes\n\n- `windowsParsePath`\u002F`diskDesignator`\u002F`diskDesignatorWindows` → `parsePath`, `parsePathWindows`, `parsePathPosix`\n- Added `getWin32PathType`\n- `componentIterator`\u002F`ComponentIterator.init` can no longer fail\n\n### Current Directory API renamed\n\n```zig\n\u002F\u002F OLD\nstd.process.getCwd(buffer)\nstd.process.getCwdAlloc(allocator)\n\n\u002F\u002F NEW\nstd.process.currentPath(io, buffer)\nstd.process.currentPathAlloc(io, allocator)\n```\n\n---\n\n## Preopens & Atomic \u002F Temporary Files\n\n### Preopens\n\n```zig\n\u002F\u002F OLD (WASI)\nconst wasi_preopens: std.fs.wasi.Preopens = try .preopensAlloc(arena);\n\n\u002F\u002F NEW\nconst preopens: std.process.Preopens = try .init(arena);\n\u002F\u002F Or simply use init.preopens from Juicy Main.\n```\n\n`Preopens` is `void` on non-WASI targets — zero-cost abstraction.\n\n### Atomic \u002F Temporary Files\n\n`std.Io.File.Atomic` is the new API for atomic file writes and temporary files.\n\n- Linux: integrates with `O_TMPFILE` when possible.\n- New: `std.Io.File.hardLink`\n- Temporary\u002Frandom filenames are generated via the Io vtable instead of `std.crypto.random`.\n\n---\n\n## Memory & Allocator Changes\n\n### ArenaAllocator is now lock-free and thread-safe\n\n`std.heap.ArenaAllocator` no longer needs `ThreadSafeAllocator` wrapping. Performance is comparable single-threaded and faster under contention (~7 threads).\n\n### ThreadSafe Allocator removed\n\n`std.heap.ThreadSafe` is removed; use `ArenaAllocator` directly, or synchronize access manually.\n\n### Memory Locking \u002F Protection moved to `std.process`\n\n```zig\n\u002F\u002F OLD\ntry std.posix.mlock();\ntry std.posix.mlock2(slice, std.posix.MLOCK_ONFAULT);\ntry std.posix.mlockall(slice, std.posix.MCL_CURRENT | std.posix.MCL_FUTURE);\n\n\u002F\u002F NEW\ntry std.process.lockMemory(slice, .{});\ntry std.process.lockMemory(slice, .{ .on_fault = true });\ntry std.process.lockMemoryAll(.{ .current = true, .future = true });\n```\n\nmmap\u002Fmprotect flags are now type-safe structs instead of bitwise OR:\n\n```zig\n\u002F\u002F OLD\nstd.posix.PROT.READ | std.posix.PROT.WRITE\n\n\u002F\u002F NEW\n.{ .READ = true, .WRITE = true }\n```\n\n### MemoryPool\n\n- `std.heap.MemoryPool(T).initCapacity(allocator, n)` returns the pool.\n- `create`\u002F`destroy` now require allocator parameter.\n- New unmanaged variants: `MemoryPoolUnmanaged`, `MemoryPoolAlignedUnmanaged`, `MemoryPoolExtraUnmanaged`.\n\n### Io.Writer.Allocating alignment field\n\n```zig\nalignment: std.mem.Alignment,  \u002F\u002F new field\n```\n\n---\n\n## Container & Collection Changes\n\n### Migration to \"Unmanaged\"\n\nManaged variants with embedded `Allocator` fields are being phased out.\n\n- `ArrayHashMap`, `AutoArrayHashMap`, `StringArrayHashMap` **removed**.\n- `AutoArrayHashMapUnmanaged` → `array_hash_map.Auto`\n- `StringArrayHashMapUnmanaged` → `array_hash_map.String`\n- `ArrayHashMapUnmanaged` → `array_hash_map.Custom`\n\n### PriorityQueue\n\n```zig\nvar queue = std.PriorityQueue(u32, void, lessThan).empty;\n```\n\n- `init` → `initContext`\n- `add` → `push`\n- `addSlice` → `pushSlice`\n- `remove` \u002F `removeOrNull` → `pop`\n- `removeIndex` → `popIndex`\n\n### PriorityDequeue\n\n```zig\nvar dq = std.PriorityDequeue(u32, void, lessThan).empty;\n```\n\n- `init` → `.empty`\n- `add` → `push`\n- `removeMinOrNull` \u002F `removeMin` → `popMin`\n- `removeMaxOrNull` \u002F `removeMax` → `popMax`\n- `removeIndex` → `popIndex`\n\n### BitSet \u002F EnumSet\n\nUse decl literals instead of `initEmpty` \u002F `initFull`:\n\n```zig\nvar set = std.EnumSet(MyEnum).empty;\nvar full = std.EnumSet(MyEnum).full;\n```\n\n### SegmentedList\n\n- `std.SegmentedList` removed.\n\n---\n\n## Removed APIs (Quick List)\n\n| Removed API | Replacement |\n|-------------|-------------|\n| `std.Thread.Pool` | `std.Io.Group`, `Io.async`, `Io.concurrent` |\n| `std.heap.ThreadSafe` | `std.heap.ArenaAllocator` (now thread-safe) |\n| `std.io.fixedBufferStream` | `std.Io.Reader.fixed(data)` \u002F `std.Io.Writer.fixed(buf)` |\n| `std.Io.GenericReader` | `std.Io.Reader` |\n| `std.Io.AnyReader` | `std.Io.Reader` |\n| `std.Io.GenericWriter` | `std.Io.Writer` |\n| `std.Io.AnyWriter` | `std.Io.Writer` |\n| `std.Io.null_writer` | Use `std.Io.Writer` directly |\n| `std.Io.CountingReader` | No direct replacement; track bytes manually |\n| `std.SegmentedList` | None |\n| `std.meta.declList` | None |\n| `std.fs.getAppDataDir` | None |\n| `std.posix.getCwd*` | `std.process.currentPath*` |\n| `std.posix.mlock*` | `std.process.lockMemory*` |\n| `std.posix.PROT_*` bitwise flags | Struct literal flags |\n| `std.ArrayHashMap` | `array_hash_map.Auto` \u002F `.String` \u002F `.Custom` |\n\n---\n\n## Common Idioms in Zig 0.16.0\n\n### ArrayList\n\n```zig\nconst std = @import(\"std\");\n\npub fn main(init: std.process.Init) !void {\n    const gpa = init.gpa;\n\n    var list = try std.ArrayList(u8).initCapacity(gpa, 16);\n    defer list.deinit(gpa);\n\n    try list.append(gpa, 'a');\n    try list.appendSlice(gpa, \"hello\");\n    try list.ensureTotalCapacity(gpa, 100);\n\n    const owned = try list.toOwnedSlice(gpa);\n    defer gpa.free(owned);\n}\n```\n\n### HashMap (Default \u002F Unmanaged Style)\n\n```zig\nvar map = std.StringHashMap(u32).empty;\ndefer map.deinit(gpa);\n\ntry map.put(gpa, \"key\", 42);\nconst val = map.get(\"key\") orelse 0;\n```\n\n### stdout \u002F stderr with Juicy Main\n\n```zig\npub fn main(init: std.process.Init) !void {\n    const io = init.io;\n\n    \u002F\u002F Direct streaming write\n    try std.Io.File.stdout().writeStreamingAll(io, \"Hello, world!\\n\");\n\n    \u002F\u002F Or via writer interface\n    var stdout_writer = std.Io.File.stdout().writer(&.{});\n    try stdout_writer.interface.print(\"value: {d}\\n\", .{42});\n}\n```\n\n### Fixed-Buffer Reader \u002F Writer\n\n```zig\n\u002F\u002F Reader from byte slice\nvar data = \"line1\\nline2\\n\";\nvar reader: std.Io.Reader = .fixed(data);\n\n\u002F\u002F Writer into a stack buffer\nvar buf: [256]u8 = undefined;\nvar writer: std.Io.Writer = .fixed(&buf);\ntry writer.interface.print(\"count: {d}\", .{7});\n```\n\n### File I\u002FO\n\n```zig\n\u002F\u002F Read entire file\nconst contents = try std.Io.Dir.cwd().readFileAlloc(io, \"input.txt\", gpa, .limited(1024 * 1024));\ndefer gpa.free(contents);\n\n\u002F\u002F Write file atomically\nvar atomic = try std.Io.File.Atomic.init(io, gpa, \"output.txt\");\ntry atomic.file_writer.interface.print(\"data: {s}\\n\", .{\"hello\"});\ntry atomic.commit(io);\n```\n\n### JSON\n\n```zig\nconst MyStruct = struct {\n    name: []const u8,\n    value: u32,\n};\n\n\u002F\u002F Parsing\nconst json_str =\n    \\\\{\"name\": \"test\", \"value\": 42}\n;\nconst parsed = try std.json.parseFromSlice(MyStruct, gpa, json_str, .{});\ndefer parsed.deinit();\n\n\u002F\u002F Serialization to string (via Io.Writer.Allocating)\nvar out: std.Io.Writer.Allocating = .init(gpa);\ndefer out.deinit();\nvar stringify: std.json.Stringify = .{\n    .writer = &out.writer,\n    .options = .{},\n};\ntry stringify.write(parsed.value);\nconst json_output = out.written();\n```\n\n### Type Reflection (Comptime)\n\n```zig\nconst info = @typeInfo(T);\nif (info == .pointer) { ... }\nif (info == .slice) { ... }\nif (info == .@\"struct\") { ... }\nif (info == .@\"enum\") { ... }\nif (info == .@\"union\") { ... }\nif (info == .optional) { ... }\n```\n\n### Testing\n\n```zig\ntest \"basic arithmetic\" {\n    const std = @import(\"std\");\n    try std.testing.expectEqual(4, 2 + 2);\n    try std.testing.expectError(error.OutOfMemory, mightFail());\n}\n\ntest \"no leaks\" {\n    const std = @import(\"std\");\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer std.testing.expect(gpa.deinit() == .ok) catch @panic(\"leak\");\n    const allocator = gpa.allocator();\n\n    const ptr = try allocator.create(u32);\n    defer allocator.destroy(ptr);\n}\n```\n\n### Leb128 (Binary Format)\n\n```zig\n\u002F\u002F OLD: std.leb.readUleb128(reader)\n\u002F\u002F NEW:\nconst value = try reader.takeLeb128(u64);\n```\n\n---\n\n## Common Error Messages and Fixes (0.16)\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `no field named 'getStdOut'` | Using old `std.io.getStdOut()` | Use `std.Io.File.stdout()` |\n| `expected 2 argument(s), found 1` | `ArrayList` method missing allocator | Add allocator as first argument |\n| `no member named 'Pool' in 'Thread'` | `std.Thread.Pool` removed | Use `std.Io.Group` + `Io.async` |\n| `expected type '*const process.Environ.Map'` | Function needs env map param | Pass it from `main(init)` |\n| `no member named 'fixedBufferStream'` | Old stream API removed | Use `std.Io.Reader.fixed(...)` or `std.Io.Writer.fixed(...)` |\n| `no field named 'getCwd' in 'process'` | Renamed | Use `std.process.currentPath*` |\n| `fingerprint field missing` | Old `build.zig.zon` | Add `.fingerprint = 0x...` and change `.name = \"x\"` to `.name = .x` |\n| `type depends on itself for alignment` | Self-referential alignment query | Remove `@alignOf(@This())` or restructure |\n\n---\n\n## Build System Changes\n\n### Fingerprint Required in build.zig.zon\n\n`build.zig.zon` now requires a `fingerprint` field, and `name` must be an enum literal, not a string:\n\n```zig\n.{\n    .name = .myproject,  \u002F\u002F enum literal, not \"myproject\"\n    .fingerprint = 0x123456789abcdef0,\n    .version = \"0.1.0\",\n    .dependencies = .{},\n}\n```\n\n`zig build` will fail if these are missing.\n\n### Local Package Overrides: --fork\n\nNew CLI flag for temporary local overrides:\n\n```bash\nzig build --fork=\u002Fpath\u002Fto\u002Flocal\u002Ffork\n```\n\nAny dependency with matching `name` + `fingerprint` will resolve to the local path instead of being fetched. This is ephemeral — remove the flag to revert.\n\n### Packages Fetched to zig-pkg Directory\n\nDependencies are now fetched into a local `zig-pkg\u002F` directory (next to `build.zig`) instead of the global cache. After filtering, they are recompressed into the global cache for future reuse.\n\n### Unit Test Timeouts\n\nSpecify per-test timeouts:\n\n```bash\nzig build test --test-timeout 500ms\n```\n\nAfter the timeout, the test process is killed and restarted for the next test.\n\n### ConfigHeader\n\n- `std.Build.Step.ConfigHeader` now handles leading whitespace for cmake-style config headers correctly.\n\n---\n\n## Compiler \u002F Toolchain\n\n### C Translation\n\n- `@cImport` still exists but is deprecated and now backed by arocc instead of libclang.\n- For new code, always use `addTranslateC` in `build.zig`.\n\n### Type Resolution\n\n- Reworked internal type resolution. Most previously-working code still works, and some \"dependency loop\" errors are now resolved.\n- Self-referential alignment queries (e.g. `align(@alignOf(@This()))`) now correctly error.\n\n### LLVM Backend\n\n- Experimental incremental compilation support.\n- Error set types now lowered as enums in debug info, so error names are visible at runtime.\n\n---\n\n## Target Support\n\nNotable additions:\n- `aarch64-freebsd`, `aarch64-netbsd`, `loongarch64-linux`, `powerpc64le-linux`, `s390x-linux`, `x86_64-freebsd`, `x86_64-netbsd`, `x86_64-openbsd` now tested in CI.\n- `aarch64-maccatalyst`, `x86_64-maccatalyst` cross-compilation added.\n- Initial `loongarch32-linux` support (no libc yet).\n- Basic support added for Alpha, KVX, MicroBlaze, OpenRISC, PA-RISC, SuperH.\n- Solaris, AIX, z\u002FOS support removed.\n- Stack tracing improved across almost all major targets.\n\n---\n\n## Testing Adjustments\n\n- For in-process client\u002Fserver tests, use `std.Io.net.Socket.createPair` or raw `socketpair(AF.UNIX, SOCK.STREAM|CLOEXEC, 0, &fds)` to avoid relying on Io vtable network (Threaded nets return `NetworkDown` if not wired).\n- Error sets tightened in many std.Io functions — remove unreachable branches accordingly.\n\n---\n\n## Porting Strategy (0.15 → 0.16)\n\n1. **Replace `@Type` calls** with the specific new builtin functions.\n2. **Replace `@cImport`** with `addTranslateC` in `build.zig`.\n3. **Add `fingerprint` and fix `name`** in `build.zig.zon`.\n4. **Thread `std.Io` through your app** — any function doing I\u002FO, sleep, random, or time needs an `io` parameter.\n5. **Update `std.net` usages** to `std.Io.net` or raw syscalls.\n6. **Update `ArrayList` calls** to pass allocator explicitly and use `initCapacity`.\n7. **Fix error set names** (CrossDevice, FileBusy, EnvironmentVariableMissing, DirNotEmpty).\n8. **Run `zig build test --test-timeout 500ms`** to catch hanging tests early.\n\nUse this skill when writing new Zig 0.16.0 code or upgrading from 0.15.x.\n","# Zig 0.16.0 Programming Guide\n\n> **Version Scope**: This skill is pinned to **Zig 0.16.0** (stable).\n> **Release Notes**: https:\u002F\u002Fziglang.org\u002Fdownload\u002F0.16.0\u002Frelease-notes.html\n\nZig 0.16.0 is a major release introducing `std.Io` as the unified I\u002FO interface, removing `@Type`, deprecating `@cImport`, and significantly reworking the build system package management.\n\n---\n\n## Local Documentation First\n\nRun `zig env` to discover installation paths — never hardcode them. Key fields: `.lib_dir`, `.std_dir`, `.version`.\n\n- **Language Reference**: `\u003Clib_dir>\u002F..\u002Fdoc\u002Flangref.html`\n- **Std Library Source**: read files under `.std_dir` for API verification.\n- **Std Library Docs**: run `zig std` to start a local HTTP server.\n\nAlways check local docs before web search.\n\n---\n\n## Quick Reference: Top Breaking Changes\n\n| Old (0.15.x) | New (0.16.0) |\n|--------------|--------------|\n| `@Type(.Int(...))` | `@Int(.signed, bits)` |\n| `@Type(.Struct(...))` | `@Struct(layout, BackingInt, field_names, field_types, field_defaults, field_is_comptime, field_alignments)` |\n| `@Type(.Pointer(...))` | `@Pointer(size, attrs, Element, sentinel)` |\n| `@Type(.Fn(...))` | `@Fn(param_types, param_attrs, ReturnType, attrs)` |\n| `@Type(.Tuple(...))` | `@Tuple(field_types)` |\n| `@cImport({...})` | `b.addTranslateC(...)` + `@import(\"c\")` (deprecated) |\n| `std.net` | `std.Io.net` |\n| `std.ArrayList.init(allocator)` | `std.ArrayList.initCapacity(allocator, n)` |\n| `std.crypto.random` | `std.Io.randomSecure(io, buf)` |\n| `std.meta.intToEnum` | `std.enums.fromInt` |\n| `std.fmt.FormatOptions` | `std.fmt.Options` |\n| `std.fmt.bufPrintZ` | `std.fmt.bufPrintSentinel` |\n| `std.io.fixedBufferStream` | `std.Io.Writer.fixed(buf)` |\n| `error.RenameAcrossMountPoints` | `error.CrossDevice` |\n| `error.NotSameFileSystem` | `error.CrossDevice` |\n| `error.SharingViolation` | `error.FileBusy` |\n| `error.EnvironmentVariableNotFound` | `error.EnvironmentVariableMissing` |\n| `std.Build.Step.ConfigHeader` cmake handling | fixed leading whitespace |\n\n---\n\n## Language Changes\n\n### @Type Removed — Use Individual Builtins\n\n`@Type` is gone. Replace with these builtins:\n\n```zig\n\u002F\u002F Integer type\nconst MyInt = @Int(.signed, 32);\n\n\u002F\u002F Struct type\nconst MyStruct = @Struct(\n    .auto,           \u002F\u002F layout\n    null,            \u002F\u002F BackingInt (for packed)\n    &.{\"x\", \"y\"},    \u002F\u002F field_names\n    &.{ i32, i32 },  \u002F\u002F field_types\n    &.{ null, null },\u002F\u002F field_defaults\n    &.{ false, false }, \u002F\u002F field_is_comptime\n    &.{ null, null },\u002F\u002F field_alignments\n);\n\n\u002F\u002F Pointer type\nconst MyPtr = @Pointer(.one, .{\n    .alignment = 8,\n    .address_space = .generic,\n    .is_const = false,\n    .is_volatile = false,\n}, u8, null);\n\n\u002F\u002F Function type\nconst MyFn = @Fn(&.{i32, i32}, &.{.{}, .{}}, i32, .{});\n\n\u002F\u002F Tuple type\nconst MyTuple = @Tuple(&.{ i32, bool });\n\n\u002F\u002F Enum literal type\nconst EnumLitType = @EnumLiteral();\n```\n\n### @cImport Deprecated — Use Build System Translation\n\n`@cImport` is deprecated. Use `addTranslateC` in `build.zig`:\n\n```zig\n\u002F\u002F build.zig\nconst translate_c = b.addTranslateC(.{\n    .root_source_file = b.path(\"src\u002Fc.h\"),\n    .target = target,\n    .optimize = optimize,\n});\ntranslate_c.linkSystemLibrary(\"glfw\", .{});\n\nconst exe = b.addExecutable(.{\n    .name = \"myapp\",\n    .root_module = b.createModule(.{\n        .root_source_file = b.path(\"src\u002Fmain.zig\"),\n        .optimize = optimize,\n        .target = target,\n        .imports = &.{\n            .{ .name = \"c\", .module = translate_c.createModule() },\n        },\n    }),\n});\n```\n\nThen in Zig: `const c = @import(\"c\");`\n\n**Note**: The C translator is now backed by arocc instead of libclang.\n\n### Switch Improvements\n\n- `packed struct` and `packed union` may now be used as switch prong items (compared by backing integer).\n- `decl literals` and result-type-dependent expressions (e.g. `@enumFromInt`) may now be used as switch prong items.\n- Union tag captures are now allowed for all prongs, not just inline ones.\n- Switch prong captures may no longer all be discarded.\n- `.awake` atomic order removed; use `.monotonic` \u002F `.seq_cst`.\n\n### Other Language-Level Gotchas\n\n- **Small integer types coerce to floats** — e.g. `u8` → `f32` is now allowed.\n- **Runtime vector indexes forbidden** — vector indexing must be comptime-known.\n- **Vectors and arrays no longer support in-memory coercion** — must explicitly cast element-wise.\n- **Trivial local addresses cannot be returned from functions** — e.g. `return &local;` is rejected more consistently.\n- **Packed unions must not have unused bits** — all bit patterns must be valid.\n- **Pointers forbidden in packed structs\u002Funions**.\n- **Explicitly-aligned pointer types are now distinct** from naturally-aligned ones in type system.\n- **Simplified dependency loop rules** — most code still works, but self-referential alignment queries now error.\n\n---\n\n## Standard Library: std.Io\n\n### Networking\n\n- `std.net` is gone. Use `std.Io.net` (types: `IpAddress`, `Stream`, `Server`, `UnixAddress`).\n- High-level helpers like `tcpConnectToHost`, `Address.parseIp`, `Stream.connect` removed. Use `Io` vtables: `io.vtable.netConnectIp`, `netRead`, `netWrite`, `netListenIp`, `netAccept`.\n- Raw fd operations: use `std.os.linux.socket`, `accept4`, `connect`, `bind`, `listen`, `write`, `read`, `close`.\n- `posix.socket`, `posix.bind`, `posix.accept`, `posix.shutdown`, `posix.writev`, `posix.listen`, `posix.pipe2`, `posix.getrandom`, `std.net.has_unix_sockets` removed.\n- Epoll: `std.os.linux.epoll_create1\u002Fepoll_ctl\u002Fepoll_wait` directly.\n- New: `std.Io.net.Socket.createPair` for socketpair usage in tests.\n\n### I\u002FO Readers\u002FWriters\n\n- Writer\u002Freader interfaces live under `std.Io`. TLS expects `*std.Io.Reader` \u002F `*std.Io.Writer` (struct fields `.interface`). Pass pointers to interfaces, not call `interface()` as a function.\n- `std.time.sleep` removed; use `std.Io.sleep(io, Duration, Clock)`.\n- `std.Io.GenericWriter`, `std.Io.AnyWriter`, `std.Io.null_writer`, `std.Io.CountingReader` removed.\n\n### Time \u002F Random \u002F Env \u002F Exit\n\n- `std.time.milliTimestamp` removed. Use `std.time.Timer` or `std.Io.Clock.now(clock, io)` and compare `Timestamp.nanoseconds`.\n- Random secure bytes: `std.Io.randomSecure(io, buf)`; no `std.crypto.random` or `std.posix.getrandom` convenience.\n- `std.process.getEnvVarOwned` removed; use `std.c.getenv` and copy.\n- `std.posix.exit` removed; use `std.process.exit`.\n\n### TLS Client Options\n\n- `std.crypto.tls.Client.Options` requires `entropy: *const [entropy_len]u8` and `realtime_now_seconds: i64`. Fill entropy with `std.Io.randomSecure`; compute seconds with `Io.Clock.now(.real, io)` \u002F `ns_per_s`.\n\n### MemoryPool API Changes\n\n- `std.heap.MemoryPool(T).initCapacity(allocator, n)` returns the pool.\n- `create`\u002F`destroy` now require allocator. No bare `init()` or zero-arg `deinit()`.\n\n### Format Options\n\n- `std.fmt.Options` replaces `FormatOptions`.\n- `std.fmt.format` helper removed; call `writer.print` directly (writers live in `std.Io.Writer`).\n- `std.fmt.Formatter` renamed to `Alt`.\n- `std.fmt.bufPrintZ` renamed to `std.fmt.bufPrintSentinel`.\n\n### Randomness \u002F Crypto\n\n- `std.crypto.random` removed. Use an `std.Io` instance: `const io = std.Io.Threaded.global_single_threaded.ioBasic(); io.random(&buf);`.\n- `Ed25519.KeyPair.generate` now requires an `io: std.Io` argument.\n\n### Enum Conversion\n\n- `std.meta.intToEnum` removed. Use `std.enums.fromInt(EnumType, value)` (returns `?EnumType`).\n- `meta.declList` removed.\n\n### Fixed-Buffer Writers in Tests\n\n- `std.io.fixedBufferStream` removed. For in-memory writes use `var w = std.Io.Writer.fixed(buf);` and read bytes with `std.Io.Writer.buffered(&w)`.\n- `std.ArrayList` no longer has `.init(allocator)` shorthand; use `.initCapacity(allocator, n)`.\n\n### Collections\n\n- `SegmentedList` removed.\n- `BitSet`, `EnumSet`: replace `initEmpty`, `initFull` with decl literals (e.g. `.{}`, `.{ .a = true }`).\n- New: `Io.Dir.renamePreserve` — rename without replacing destination.\n- `std.Io.Dir.rename` returns `error.DirNotEmpty` rather than `error.PathAlreadyExists`.\n\n### Error Set Renames\n\n```zig\n\u002F\u002F Old -> New\nerror.RenameAcrossMountPoints -> error.CrossDevice\nerror.NotSameFileSystem       -> error.CrossDevice\nerror.SharingViolation        -> error.FileBusy\nerror.EnvironmentVariableNotFound -> error.EnvironmentVariableMissing\n```\n\n### Math\n\n- `math.sign` now returns the smallest integer type that fits possible values.\n\n### Threading\n\n- `Thread.Mutex.Recursive` removed.\n\n### Compression\n\n- `lzma`, `lzma2`, `xz` updated to `Io.Reader` \u002F `Io.Writer` interfaces.\n\n### Dynamic Libraries\n\n- `DynLib` removed Windows support. Use `LoadLibraryExW` and `GetProcAddress` directly.\n\n---\n\n## New Execution Model: Juicy Main\n\nZig 0.16.0 introduces `std.process.Init` as the preferred `main` parameter. This is the biggest entrypoint change in this release.\n\n### `main` signatures\n\n```zig\n\u002F\u002F 1. Bare (no args\u002Fenv available)\npub fn main() !void { }\n\n\u002F\u002F 2. Minimal (raw argv + environ only)\npub fn main(init: std.process.Init.Minimal) !void { }\n\n\u002F\u002F 3. Juicy Main (recommended)\npub fn main(init: std.process.Init) !void { }\n```\n\n### `std.process.Init` contents\n\n```zig\npub const Init = struct {\n    minimal: Minimal,\n    arena: *std.heap.ArenaAllocator,  \u002F\u002F process-lifetime arena, threadsafe\n    gpa: Allocator,                     \u002F\u002F general-purpose allocator\n    io: Io,                             \u002F\u002F default Io implementation\n    environ_map: *Environ.Map,          \u002F\u002F env vars (not threadsafe)\n    preopens: Preopens,                 \u002F\u002F WASI-style preopened files\n\n    pub const Minimal = struct {\n        environ: Environ,\n        args: Args,\n    };\n};\n```\n\n### Example\n\n```zig\nconst std = @import(\"std\");\n\npub fn main(init: std.process.Init) !void {\n    const gpa = init.gpa;\n    const io = init.io;\n\n    try std.Io.File.stdout().writeStreamingAll(io, \"Hello, world!\\n\");\n\n    const args = try init.minimal.args.toSlice(init.arena.allocator());\n    for (args, 0..) |arg, i| {\n        std.log.info(\"arg[{d}] = {s}\", .{ i, arg });\n    }\n\n    std.log.info(\"{d} env vars\", .{init.environ_map.count()});\n}\n```\n\n**Rule of thumb**: if your program needs I\u002FO, allocations, or environment variables, use `std.process.Init`.\n\n---\n\n## Environment Variables & Process Args Are Non-Global\n\n`std.os.environ` and `std.process.args` as global state are gone. They are now only available through `main`'s `init` parameter.\n\n### Environment variables\n\n```zig\n\u002F\u002F Juicy Main\nfor (init.environ_map.keys(), init.environ_map.values()) |key, value| {\n    std.log.info(\"env: {s}={s}\", .{ key, value });\n}\n\n\u002F\u002F Minimal main\nstd.log.info(\"HOME: {?s}\", .{init.environ.getPosix(\"HOME\")});\nstd.log.info(\"EDITOR: {s}\", .{ try init.environ.getAlloc(arena, \"EDITOR\") });\nconst map = try init.environ.createMap(arena);\n```\n\n### CLI arguments\n\n```zig\n\u002F\u002F Iterate lazily\nvar args = init.args.iterate();\nwhile (args.next()) |arg| {\n    std.log.info(\"arg: {s}\", .{arg});\n}\n\n\u002F\u002F To slice (needs allocator)\nconst args = try init.args.toSlice(arena);\n```\n\nAny function that needs environment variables should accept `*const process.Environ.Map` or `process.Environ` as a parameter.\n\n---\n\n## Thread.Pool Removed → Use std.Io\n\n`std.Thread.Pool` is removed. Replace with `std.Io.Group`, `std.Io.async`, or `std.Io.concurrent`.\n\n### Migration example\n\n```zig\n\u002F\u002F OLD (0.15)\nfn doAllTheWork(pool: *std.Thread.Pool) void {\n    var wg: std.Thread.WaitGroup = .{};\n    pool.spawnWg(wg, doSomeWork, .{ pool, &wg, first_work_item });\n    wg.wait();\n}\n\n\u002F\u002F NEW (0.16)\nfn doAllTheWork(io: std.Io) void {\n    var g: std.Io.Group = .init;\n    errdefer g.cancel(io);\n    g.async(io, doSomeWork, .{ io, &g, first_work_item });\n    g.wait(io);\n}\n\nfn doSomeWork(io: std.Io, g: *std.Io.Group, foo: Foo) void {\n    foo.doTheThing();\n    for (foo.new_work_items) |new| {\n        g.async(io, doSomeWork, .{ io, g, new });\n    }\n}\n```\n\n**Important**: when migrating from `Thread.Pool` to `Io`, convert `Thread.Mutex`, `Thread.Condition`, `Thread.ResetEvent` to `Io.Mutex`, `Io.Condition`, `Io.Event`.\n\n---\n\n## File I\u002FO & fs API Changes\n\n### readFileAlloc \u002F readToEndAlloc\n\n```zig\n\u002F\u002F OLD\nconst contents = try std.fs.cwd().readFileAlloc(allocator, file_name, 1234);\n\n\u002F\u002F NEW\nconst contents = try std.Io.Dir.cwd().readFileAlloc(io, file_name, allocator, .limited(1234));\n\u002F\u002F Note: FileTooBig -> StreamTooLong when limit reached.\n```\n\n```zig\n\u002F\u002F OLD\nconst contents = try file.readToEndAlloc(allocator, 1234);\n\n\u002F\u002F NEW\nvar file_reader = file.reader(&.{});\nconst contents = try file_reader.interface.allocRemaining(allocator, .limited(1234));\n```\n\n### setTimestamps\n\n```zig\n\u002F\u002F OLD\ntry atomic_file.file_writer.file.setTimestamps(io, src_stat.atime, src_stat.mtime);\n\n\u002F\u002F NEW\ntry atomic_file.file_writer.file.setTimestamps(io, .{\n    .access_timestamp = .init(src_stat.atime),\n    .modify_timestamp = .init(src_stat.mtime),\n});\n```\n\n`Io.File.Stat.atime` is now `?Timestamp` (can be `null` on e.g. ZFS).\n\n### Directory walking\n\n- `std.Io.Dir.walk` still exists.\n- New: `std.Io.Dir.walkSelectively` — opt-in recursion per directory, avoiding redundant open\u002Fclose syscalls.\n- Both `Walker` and `SelectiveWalker` gained `leave()` and `depth()`.\n\n### fs.path.relative is now pure\n\n```zig\n\u002F\u002F OLD\nconst relative = try std.fs.path.relative(gpa, from, to);\n\n\u002F\u002F NEW\nconst cwd_path = try std.process.currentPathAlloc(io, gpa);\nconst relative = try std.fs.path.relative(gpa, cwd_path, environ_map, from, to);\n```\n\n### fs.path Windows changes\n\n- `windowsParsePath`\u002F`diskDesignator`\u002F`diskDesignatorWindows` → `parsePath`, `parsePathWindows`, `parsePathPosix`\n- Added `getWin32PathType`\n- `componentIterator`\u002F`ComponentIterator.init` can no longer fail\n\n### Current Directory API renamed\n\n```zig\n\u002F\u002F OLD\nstd.process.getCwd(buffer)\nstd.process.getCwdAlloc(allocator)\n\n\u002F\u002F NEW\nstd.process.currentPath(io, buffer)\nstd.process.currentPathAlloc(io, allocator)\n```\n\n---\n\n## Preopens & Atomic \u002F Temporary Files\n\n### Preopens\n\n```zig\n\u002F\u002F OLD (WASI)\nconst wasi_preopens: std.fs.wasi.Preopens = try .preopensAlloc(arena);\n\n\u002F\u002F NEW\nconst preopens: std.process.Preopens = try .init(arena);\n\u002F\u002F Or simply use init.preopens from Juicy Main.\n```\n\n`Preopens` is `void` on non-WASI targets — zero-cost abstraction.\n\n### Atomic \u002F Temporary Files\n\n`std.Io.File.Atomic` is the new API for atomic file writes and temporary files.\n\n- Linux: integrates with `O_TMPFILE` when possible.\n- New: `std.Io.File.hardLink`\n- Temporary\u002Frandom filenames are generated via the Io vtable instead of `std.crypto.random`.\n\n---\n\n## Memory & Allocator Changes\n\n### ArenaAllocator is now lock-free and thread-safe\n\n`std.heap.ArenaAllocator` no longer needs `ThreadSafeAllocator` wrapping. Performance is comparable single-threaded and faster under contention (~7 threads).\n\n### ThreadSafe Allocator removed\n\n`std.heap.ThreadSafe` is removed; use `ArenaAllocator` directly, or synchronize access manually.\n\n### Memory Locking \u002F Protection moved to `std.process`\n\n```zig\n\u002F\u002F OLD\ntry std.posix.mlock();\ntry std.posix.mlock2(slice, std.posix.MLOCK_ONFAULT);\ntry std.posix.mlockall(slice, std.posix.MCL_CURRENT | std.posix.MCL_FUTURE);\n\n\u002F\u002F NEW\ntry std.process.lockMemory(slice, .{});\ntry std.process.lockMemory(slice, .{ .on_fault = true });\ntry std.process.lockMemoryAll(.{ .current = true, .future = true });\n```\n\nmmap\u002Fmprotect flags are now type-safe structs instead of bitwise OR:\n\n```zig\n\u002F\u002F OLD\nstd.posix.PROT.READ | std.posix.PROT.WRITE\n\n\u002F\u002F NEW\n.{ .READ = true, .WRITE = true }\n```\n\n### MemoryPool\n\n- `std.heap.MemoryPool(T).initCapacity(allocator, n)` returns the pool.\n- `create`\u002F`destroy` now require allocator parameter.\n- New unmanaged variants: `MemoryPoolUnmanaged`, `MemoryPoolAlignedUnmanaged`, `MemoryPoolExtraUnmanaged`.\n\n### Io.Writer.Allocating alignment field\n\n```zig\nalignment: std.mem.Alignment,  \u002F\u002F new field\n```\n\n---\n\n## Container & Collection Changes\n\n### Migration to \"Unmanaged\"\n\nManaged variants with embedded `Allocator` fields are being phased out.\n\n- `ArrayHashMap`, `AutoArrayHashMap`, `StringArrayHashMap` **removed**.\n- `AutoArrayHashMapUnmanaged` → `array_hash_map.Auto`\n- `StringArrayHashMapUnmanaged` → `array_hash_map.String`\n- `ArrayHashMapUnmanaged` → `array_hash_map.Custom`\n\n### PriorityQueue\n\n```zig\nvar queue = std.PriorityQueue(u32, void, lessThan).empty;\n```\n\n- `init` → `initContext`\n- `add` → `push`\n- `addSlice` → `pushSlice`\n- `remove` \u002F `removeOrNull` → `pop`\n- `removeIndex` → `popIndex`\n\n### PriorityDequeue\n\n```zig\nvar dq = std.PriorityDequeue(u32, void, lessThan).empty;\n```\n\n- `init` → `.empty`\n- `add` → `push`\n- `removeMinOrNull` \u002F `removeMin` → `popMin`\n- `removeMaxOrNull` \u002F `removeMax` → `popMax`\n- `removeIndex` → `popIndex`\n\n### BitSet \u002F EnumSet\n\nUse decl literals instead of `initEmpty` \u002F `initFull`:\n\n```zig\nvar set = std.EnumSet(MyEnum).empty;\nvar full = std.EnumSet(MyEnum).full;\n```\n\n### SegmentedList\n\n- `std.SegmentedList` removed.\n\n---\n\n## Removed APIs (Quick List)\n\n| Removed API | Replacement |\n|-------------|-------------|\n| `std.Thread.Pool` | `std.Io.Group`, `Io.async`, `Io.concurrent` |\n| `std.heap.ThreadSafe` | `std.heap.ArenaAllocator` (now thread-safe) |\n| `std.io.fixedBufferStream` | `std.Io.Reader.fixed(data)` \u002F `std.Io.Writer.fixed(buf)` |\n| `std.Io.GenericReader` | `std.Io.Reader` |\n| `std.Io.AnyReader` | `std.Io.Reader` |\n| `std.Io.GenericWriter` | `std.Io.Writer` |\n| `std.Io.AnyWriter` | `std.Io.Writer` |\n| `std.Io.null_writer` | Use `std.Io.Writer` directly |\n| `std.Io.CountingReader` | No direct replacement; track bytes manually |\n| `std.SegmentedList` | None |\n| `std.meta.declList` | None |\n| `std.fs.getAppDataDir` | None |\n| `std.posix.getCwd*` | `std.process.currentPath*` |\n| `std.posix.mlock*` | `std.process.lockMemory*` |\n| `std.posix.PROT_*` bitwise flags | Struct literal flags |\n| `std.ArrayHashMap` | `array_hash_map.Auto` \u002F `.String` \u002F `.Custom` |\n\n---\n\n## Common Idioms in Zig 0.16.0\n\n### ArrayList\n\n```zig\nconst std = @import(\"std\");\n\npub fn main(init: std.process.Init) !void {\n    const gpa = init.gpa;\n\n    var list = try std.ArrayList(u8).initCapacity(gpa, 16);\n    defer list.deinit(gpa);\n\n    try list.append(gpa, 'a');\n    try list.appendSlice(gpa, \"hello\");\n    try list.ensureTotalCapacity(gpa, 100);\n\n    const owned = try list.toOwnedSlice(gpa);\n    defer gpa.free(owned);\n}\n```\n\n### HashMap (Default \u002F Unmanaged Style)\n\n```zig\nvar map = std.StringHashMap(u32).empty;\ndefer map.deinit(gpa);\n\ntry map.put(gpa, \"key\", 42);\nconst val = map.get(\"key\") orelse 0;\n```\n\n### stdout \u002F stderr with Juicy Main\n\n```zig\npub fn main(init: std.process.Init) !void {\n    const io = init.io;\n\n    \u002F\u002F Direct streaming write\n    try std.Io.File.stdout().writeStreamingAll(io, \"Hello, world!\\n\");\n\n    \u002F\u002F Or via writer interface\n    var stdout_writer = std.Io.File.stdout().writer(&.{});\n    try stdout_writer.interface.print(\"value: {d}\\n\", .{42});\n}\n```\n\n### Fixed-Buffer Reader \u002F Writer\n\n```zig\n\u002F\u002F Reader from byte slice\nvar data = \"line1\\nline2\\n\";\nvar reader: std.Io.Reader = .fixed(data);\n\n\u002F\u002F Writer into a stack buffer\nvar buf: [256]u8 = undefined;\nvar writer: std.Io.Writer = .fixed(&buf);\ntry writer.interface.print(\"count: {d}\", .{7});\n```\n\n### File I\u002FO\n\n```zig\n\u002F\u002F Read entire file\nconst contents = try std.Io.Dir.cwd().readFileAlloc(io, \"input.txt\", gpa, .limited(1024 * 1024));\ndefer gpa.free(contents);\n\n\u002F\u002F Write file atomically\nvar atomic = try std.Io.File.Atomic.init(io, gpa, \"output.txt\");\ntry atomic.file_writer.interface.print(\"data: {s}\\n\", .{\"hello\"});\ntry atomic.commit(io);\n```\n\n### JSON\n\n```zig\nconst MyStruct = struct {\n    name: []const u8,\n    value: u32,\n};\n\n\u002F\u002F Parsing\nconst json_str =\n    \\\\{\"name\": \"test\", \"value\": 42}\n;\nconst parsed = try std.json.parseFromSlice(MyStruct, gpa, json_str, .{});\ndefer parsed.deinit();\n\n\u002F\u002F Serialization to string (via Io.Writer.Allocating)\nvar out: std.Io.Writer.Allocating = .init(gpa);\ndefer out.deinit();\nvar stringify: std.json.Stringify = .{\n    .writer = &out.writer,\n    .options = .{},\n};\ntry stringify.write(parsed.value);\nconst json_output = out.written();\n```\n\n### Type Reflection (Comptime)\n\n```zig\nconst info = @typeInfo(T);\nif (info == .pointer) { ... }\nif (info == .slice) { ... }\nif (info == .@\"struct\") { ... }\nif (info == .@\"enum\") { ... }\nif (info == .@\"union\") { ... }\nif (info == .optional) { ... }\n```\n\n### Testing\n\n```zig\ntest \"basic arithmetic\" {\n    const std = @import(\"std\");\n    try std.testing.expectEqual(4, 2 + 2);\n    try std.testing.expectError(error.OutOfMemory, mightFail());\n}\n\ntest \"no leaks\" {\n    const std = @import(\"std\");\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer std.testing.expect(gpa.deinit() == .ok) catch @panic(\"leak\");\n    const allocator = gpa.allocator();\n\n    const ptr = try allocator.create(u32);\n    defer allocator.destroy(ptr);\n}\n```\n\n### Leb128 (Binary Format)\n\n```zig\n\u002F\u002F OLD: std.leb.readUleb128(reader)\n\u002F\u002F NEW:\nconst value = try reader.takeLeb128(u64);\n```\n\n---\n\n## Common Error Messages and Fixes (0.16)\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `no field named 'getStdOut'` | Using old `std.io.getStdOut()` | Use `std.Io.File.stdout()` |\n| `expected 2 argument(s), found 1` | `ArrayList` method missing allocator | Add allocator as first argument |\n| `no member named 'Pool' in 'Thread'` | `std.Thread.Pool` removed | Use `std.Io.Group` + `Io.async` |\n| `expected type '*const process.Environ.Map'` | Function needs env map param | Pass it from `main(init)` |\n| `no member named 'fixedBufferStream'` | Old stream API removed | Use `std.Io.Reader.fixed(...)` or `std.Io.Writer.fixed(...)` |\n| `no field named 'getCwd' in 'process'` | Renamed | Use `std.process.currentPath*` |\n| `fingerprint field missing` | Old `build.zig.zon` | Add `.fingerprint = 0x...` and change `.name = \"x\"` to `.name = .x` |\n| `type depends on itself for alignment` | Self-referential alignment query | Remove `@alignOf(@This())` or restructure |\n\n---\n\n## Build System Changes\n\n### Fingerprint Required in build.zig.zon\n\n`build.zig.zon` now requires a `fingerprint` field, and `name` must be an enum literal, not a string:\n\n```zig\n.{\n    .name = .myproject,  \u002F\u002F enum literal, not \"myproject\"\n    .fingerprint = 0x123456789abcdef0,\n    .version = \"0.1.0\",\n    .dependencies = .{},\n}\n```\n\n`zig build` will fail if these are missing.\n\n### Local Package Overrides: --fork\n\nNew CLI flag for temporary local overrides:\n\n```bash\nzig build --fork=\u002Fpath\u002Fto\u002Flocal\u002Ffork\n```\n\nAny dependency with matching `name` + `fingerprint` will resolve to the local path instead of being fetched. This is ephemeral — remove the flag to revert.\n\n### Packages Fetched to zig-pkg Directory\n\nDependencies are now fetched into a local `zig-pkg\u002F` directory (next to `build.zig`) instead of the global cache. After filtering, they are recompressed into the global cache for future reuse.\n\n### Unit Test Timeouts\n\nSpecify per-test timeouts:\n\n```bash\nzig build test --test-timeout 500ms\n```\n\nAfter the timeout, the test process is killed and restarted for the next test.\n\n### ConfigHeader\n\n- `std.Build.Step.ConfigHeader` now handles leading whitespace for cmake-style config headers correctly.\n\n---\n\n## Compiler \u002F Toolchain\n\n### C Translation\n\n- `@cImport` still exists but is deprecated and now backed by arocc instead of libclang.\n- For new code, always use `addTranslateC` in `build.zig`.\n\n### Type Resolution\n\n- Reworked internal type resolution. Most previously-working code still works, and some \"dependency loop\" errors are now resolved.\n- Self-referential alignment queries (e.g. `align(@alignOf(@This()))`) now correctly error.\n\n### LLVM Backend\n\n- Experimental incremental compilation support.\n- Error set types now lowered as enums in debug info, so error names are visible at runtime.\n\n---\n\n## Target Support\n\nNotable additions:\n- `aarch64-freebsd`, `aarch64-netbsd`, `loongarch64-linux`, `powerpc64le-linux`, `s390x-linux`, `x86_64-freebsd`, `x86_64-netbsd`, `x86_64-openbsd` now tested in CI.\n- `aarch64-maccatalyst`, `x86_64-maccatalyst` cross-compilation added.\n- Initial `loongarch32-linux` support (no libc yet).\n- Basic support added for Alpha, KVX, MicroBlaze, OpenRISC, PA-RISC, SuperH.\n- Solaris, AIX, z\u002FOS support removed.\n- Stack tracing improved across almost all major targets.\n\n---\n\n## Testing Adjustments\n\n- For in-process client\u002Fserver tests, use `std.Io.net.Socket.createPair` or raw `socketpair(AF.UNIX, SOCK.STREAM|CLOEXEC, 0, &fds)` to avoid relying on Io vtable network (Threaded nets return `NetworkDown` if not wired).\n- Error sets tightened in many std.Io functions — remove unreachable branches accordingly.\n\n---\n\n## Porting Strategy (0.15 → 0.16)\n\n1. **Replace `@Type` calls** with the specific new builtin functions.\n2. **Replace `@cImport`** with `addTranslateC` in `build.zig`.\n3. **Add `fingerprint` and fix `name`** in `build.zig.zon`.\n4. **Thread `std.Io` through your app** — any function doing I\u002FO, sleep, random, or time needs an `io` parameter.\n5. **Update `std.net` usages** to `std.Io.net` or raw syscalls.\n6. **Update `ArrayList` calls** to pass allocator explicitly and use `initCapacity`.\n7. **Fix error set names** (CrossDevice, FileBusy, EnvironmentVariableMissing, DirNotEmpty).\n8. **Run `zig build test --test-timeout 500ms`** to catch hanging tests early.\n\nUse this skill when writing new Zig 0.16.0 code or upgrading from 0.15.x.\n",{"name":5,"license":15,"metadata":24,"description":7,"compatibility":28},{"version":25,"category":26,"language":27},"0.16.0","programming-language","zig",[29,30],"opencode","claude-code","main","ebe6483a57ceac5b9da32b4a23fa4ba2fa7ac170",".agents\u002Fskills\u002Fzig-0-16","https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx","https:\u002F\u002Fgithub.com\u002FYabuku-xD","shyamalankannan.com","😳 Indie-head with a versatile knowledge in development and modeling.","2026-11-13 04:46:29",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add Yabuku-xD\u002Fomfx --skill zig-0.16",{"tool":45,"command":46},"bunx","bunx skills add Yabuku-xD\u002Fomfx --skill zig-0.16",{"tool":48,"command":49},"pnpm","pnpm dlx skills add Yabuku-xD\u002Fomfx --skill zig-0.16","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzig-0-16\u002FSKILL.md",true,[],[54,61,68,75,81,88],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7B1ZQXR4F45F34W3A9DH795","hello-omfx","Example skill. Use when testing omfx skill discovery.","https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx\u002Fblob\u002Fmain\u002Fskills\u002Fhello-omfx\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7B1ZJ19F0WDTZKD05EMGS5V","zig-tiger-style","TigerStyle Zig coding guidelines — distilled from TigerBeetle's production codebase. Use this skill whenever the user is writing, reviewing, or refactoring Zig code, asking about Zig idioms, best practices, assertions, memory layout, naming conventions, or code style. Also trigger when the user asks how to structure Zig structs, handle errors, write safe loops, or design Zig APIs. Even if the user just says \"write me some Zig\" or pastes Zig code for review, consult this skill first.","https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzig-tiger-style\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7B1ZFD4G462R79S6GYFXZBM","zig-testing","Zig 测试与调试技能。涉及 std.testing 的断言、测试组织、内存泄漏检测、以及 std.debug 的日志、堆栈回溯。在需要编写测试、调试代码、诊断问题时调用。","https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzig-testing\u002FSKILL.md",[],[],{"skillNo":76,"name":70,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7B1Z9K5AWQ89KBWSVK7Q9KM","Zig testing skill for writing and running tests. Use when using zig build test, writing comptime tests, using test filters, working with test allocators to detect leaks, or using Zig's built-in fuzz testing (0.14+). Activates on queries about Zig tests, zig test, zig build test, comptime testing, test allocators, Zig fuzz testing, or detecting memory leaks in Zig tests.","https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzig-testing-lowlevel\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7B1Z52KAWNN9PPKMX9FP06N","zig-project-structure","Zig 项目结构全生命周期管理。创建项目骨架（exe\u002Flib\u002F多模块\u002F带依赖）或检查已有项目的目录结构、文件命名、构建配置合规性，输出结构化报告。","https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzig-project-structure\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7B1YXXZMP87C8DDYPM213N8","zig-memory-patterns","This skill should be used when the user asks questions like \"how do allocators work in Zig\", \"explain Zig memory management\", \"when to use arena allocator\", \"how does Zig compare to Rust ownership\", \"how to manage memory in Zig\", or asks about memory allocation patterns for programmers coming from C, C++, Rust, or garbage-collected languages.","https:\u002F\u002Fgithub.com\u002FYabuku-xD\u002Fomfx\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fzig-memory-patterns\u002FSKILL.md",[],[]]