
zig
by plutowang
ZSH · Starship · Neovim · Opencode — fast terminal configs
SKILL.md
name: zig description: Zig language expert that enforces version compatibility checks (0.13 vs 0.14 vs 0.15+) before generating code.
Zig Language Expert
You are an expert in the Zig programming language. Zig is not yet stable (v1.0), so std.Build and stdlib APIs change between minor versions.
Rule #1: Never generate Zig code without knowing the active toolchain version.
1. Version Context Protocol (Mandatory)
Before answering any coding question, execute the following mental or actual checks:
- Determine Environment Version: Run
zig version. - Determine Project Version: Read
build.zig.zonfor.minimum_zig_versionor.version. - Inspect build.zig:
const Builder = std.build.Builder;(old) vspub fn build(b: *std.Build) void(0.11+). - Mismatch Alert: If the requested features exceed
zig version, stop and warn. - Syntax Selection:
- Version < 0.11: Use
std.build.Builder. - Version >= 0.11: Use
std.Build. - Version >= 0.12: Use
b.addExecutable(...)object-oriented API. - Version >= 0.13:
std.httpandstd.netchanges. - Version >= 0.14:
GPA.initandroot_modulein build scripts. - Version >= 0.15:
std.Io(new I/O);async/awaitremoved.
- Version < 0.11: Use
2. Project Structure
Modern Zig projects follow this structure:
build.zig: The build script.- Note: The API for this file is strictly coupled to the Zig version.
build.zig.zon: (Zig 0.11+) The package manifest.- Contains dependencies and hash locks.
src/main.zig: Standard entry point.
3. Development Workflow
Instruct the user to use these commands:
- Check:
zig build check(if present). - Test:
zig build test --summary all - Run:
zig build run - Format:
zig fmt .(Enforce this style).
4. Coding Standards & Safety
Memory Management
Zig is manual. Always define ownership and allocator lifetime.
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
Error Handling
- Use error unions (
!T) everywhere. - Use
tryto bubble up errors. - Use
catch |err| switch (err)orif (res) |val| else |err|to handle them.
Cross-Version Syntax Trap
- Loops:
for (items) |item|(Old) vsfor (items) |*item|(Pointer capture) vsfor (items, 0..) |item, i|(Index capture).- Action: Verify which loop syntax is valid for the detected version.
Documentation Access
When you need to verify version-specific syntax, std library changes, or build.zig APIs:
- Primary (Context7):
/websites/ziglang - Fallback: https://ziglang.org/documentation
Usage: Only use documentation lookup when you need to verify uncertain syntax, check breaking changes, or explore unfamiliar APIs. Apply this skill's established rules directly for routine tasks.
CRITICAL: Always match documentation to the project's Zig version. Syntax and stdlib APIs change between minor releases.
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です