This skill provides expertise in Zig, a general-purpose programming language focused on robustness, optimality, and maintainability. The skill includes version-specific documentation (0.2.0 through master), automatic version detection, code templates, and comprehensive reference materials organized for progressive disclosure.
/plugin marketplace add plurigrid/asi/plugin install asi-skills@asi-skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
README.mdassets/templates/basic-program.zigassets/templates/build.zigassets/templates/c-interop-module.zigassets/templates/cli-application.zigassets/templates/cross-version/build-adaptive.zigassets/templates/library-module.zigassets/templates/test.zigexamples/build_example/README.mdexamples/build_example/build.zigexamples/build_example/src/main.zigexamples/build_example/src/math_utils.zigexamples/build_example/src/string_utils.zigexamples/c_interop.zigexamples/comptime_example.zigexamples/error_handling.zigexamples/memory_management.zigexamples/string_manipulation.zigrecipes/build-system.mdrecipes/c-interop.mdThis skill provides expertise in Zig, a general-purpose programming language focused on robustness, optimality, and maintainability. The skill includes version-specific documentation (0.2.0 through master), automatic version detection, code templates, and comprehensive reference materials organized for progressive disclosure.
Important: References are version-specific. Use scripts/get_references.py to get the correct reference path for the detected Zig version, or load from references/latest/ (symlink to current stable: 0.15.2).
Load documentation progressively based on task complexity. Use this decision tree:
New to Zig? Start with fundamentals in order:
references/latest/core-language.md → Basic syntax, types, operatorsreferences/latest/control-flow.md → If, while, for, switchreferences/latest/functions-errors.md → Functions and error handlingreferences/latest/quick-reference.md → Syntax quick lookupSolving specific problems? Jump directly to:
latest/functions-errors.md + latest/patterns-error-testing.mdlatest/memory-management.md + latest/patterns-memory-comptime.mdlatest/arrays-slices.md, latest/structs-methods.md, latest/enums-unions.md, latest/pointers-references.mdlatest/patterns-data-structures.mdlatest/stdlib-builtins.md (large file, 68KB)latest/c-interop.md + latest/patterns-integration.mdlatest/build-system.md + latest/patterns-integration.mdAdvanced topics (after mastering fundamentals):
references/latest/comptime.md - Compile-time execution and genericsreferences/latest/patterns-memory-comptime.md - Advanced memory and comptime patternsreferences/latest/testing-quality.md - Testing framework and best practicesVersion migration → references/version-differences.md (shared across versions, comprehensive migration guides)
Using version-specific references:
# Get reference path for detected version
python scripts/get_references.py
# Output: references/v0.15.2
# With specific version
python scripts/get_references.py --version 0.13.0
# Output: references/v0.15.2 (with fallback warning)
# JSON output for programmatic use
python scripts/get_references.py --json
The skill includes 223 tested recipes from the Zig BBQ Cookbook, organized by topic. All recipes include complete, compilable code verified against Zig 0.15.2.
Finding recipes by topic:
recipes/fundamentals.md - Philosophy, basics (19 recipes)recipes/data-structures.md - Arrays, hashmaps, sets (20 recipes)recipes/strings-text.md - String processing (14 recipes)recipes/memory-allocators.md - Allocator patterns (6 recipes)recipes/comptime-metaprogramming.md - Compile-time (24 recipes)recipes/structs-objects.md - Structs, unions (22 recipes)recipes/functions.md - Function patterns (11 recipes)recipes/files-io.md - File operations (19 recipes)recipes/networking.md - HTTP, sockets (18 recipes)recipes/concurrency.md - Threading, atomics (8 recipes)recipes/build-system.md - Build.zig, modules (18 recipes)recipes/testing-debugging.md - Testing (14 recipes)recipes/c-interop.md - C FFI (7 recipes)recipes/data-encoding.md - JSON, CSV, XML (9 recipes)recipes/iterators.md - Iterator patterns (8 recipes)recipes/webassembly.md - WASM targets (6 recipes)Querying recipes programmatically:
# List all topics with counts
python scripts/query_recipes.py --list-topics
# Find recipes by topic
python scripts/query_recipes.py --topic memory-allocators
# Find recipes by tag
python scripts/query_recipes.py --tag hashmap
# Search by keyword
python scripts/query_recipes.py --search "error handling"
# Get specific recipe details
python scripts/query_recipes.py --recipe 1.1
# Filter by difficulty
python scripts/query_recipes.py --difficulty beginner
# JSON output for programmatic use
python scripts/query_recipes.py --topic data-structures --json
Recipe format: Each recipe includes Problem, Solution, Discussion sections plus full tested code.
When to use recipes vs references:
Copy and customize these starting points:
assets/templates/basic-program.zig - Basic program with allocatorassets/templates/build.zig - Build configurationassets/templates/test.zig - Test file structureassets/templates/cli-application.zig - CLI app with arg parsingassets/templates/library-module.zig - Library/module structureassets/templates/c-interop-module.zig - C interop moduleComplete, runnable code demonstrating patterns:
examples/string_manipulation.zig - String processingexamples/memory_management.zig - Allocator patternsexamples/error_handling.zig - Error handlingexamples/c_interop.zig - C FFIexamples/comptime_example.zig - Compile-time programmingexamples/build_example/ - Multi-file projectUse these Python automation tools for version management, recipe queries, and code generation:
Version Detection & Reference Loading:
scripts/get_references.py - Detect user's Zig version and return correct reference path (use this first)scripts/detect_version.py - Standalone version detection with confidence levelsRecipe Queries:
scripts/query_recipes.py - Search and filter recipes by topic, tag, difficulty, or keywordCode Generation:
scripts/code_generator.py - Generate Zig code from JSON specificationsWhen to execute vs reference:
get_references.py at the start of any Zig task to determine the correct reference pathquery_recipes.py when searching for practical code examples or solutionsSee scripts/README.md for complete script documentation.
assets/templates/try, catch, or errdefertest blocks alongside implementation/// doc comments for exported functionsZig-specific gotchas:
@TypeOf() inspection or add explicit castsdefer cleanup order and errdefer on error paths.? only when certain; prefer orelse or if unwrap for safetyDebug tools: std.debug.print() for inspection, -Doptimize=Debug for stack traces, zig test to isolate issues
To teach Zig concepts effectively:
examples/ directoryDefault to Zig 0.15.2 unless user specifies otherwise or detection determines a different version.
At the start of any Zig task, determine the user's version using this workflow:
1. Check for explicit specification:
build.zig.zon has minimum_zig_version field2. Automated detection (recommended):
# Run get_references.py to detect version and get correct reference path
python scripts/get_references.py --json
This script:
scripts/detect_version.py to analyze the projectzig version command (most reliable)build.zig and .zig files for version markers3. Manual detection (if automated fails):
build.zig for API patterns:
b.path(...) → 0.11+std.Build → 0.11+b.addExecutable(.{...}) → 0.11+b.addExecutable("name", "file") → pre-0.11.zig files for syntax markers:
for (items, 0..) |item, i| → 0.13+async/await keywords → 0.9-0.10 (removed in 0.11)references/version-differences.md for full detection markers4. Ask user if ambiguous:
5. Default to 0.15.2:
After detecting version:
scripts/get_references.py to determine correct reference pathreferences/v0.15.2/)references/version-differences.md (shared file) for migration guidanceExample workflow:
# Detect version and get reference path
REF_PATH=$(python scripts/get_references.py)
# REF_PATH is now "references/v0.15.2" or "references/latest"
# Load version-specific documentation
cat $REF_PATH/core-language.md
cat $REF_PATH/build-system.md
# Version differences is shared across all versions
cat references/version-differences.md
Handling fallbacks:
Be aware of these major version differences when writing code:
std.Build, b.path())for (items, 0..) |item, i|)std.build.Builder), different error setsSee references/version-differences.md for:
When user specifies or detection determines a different version:
scripts/get_references.py --version <VERSION> to get correct reference pathreferences/version-differences.md for migration detailsBest practice for cross-version code:
@hasDecl(std, "Build") instead of if (version >= 0.11)references/latest/patterns-integration.md for @hasDecl/@hasField examples// Target Zig Version: 0.15.2assets/templates/cross-version/Core Zig idioms:
try, catch, or error unions; never ignore errorsdefer for cleanup, errdefer for error-path cleanuptest "description" {} blocks alongside implementation/// doc comments for exported functionsorelse, .?, or if unwrapping