Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

zig

БесплатноБез исполняемых скриптовНе проверен

Zig is a systems programming language with compile-time evaluation, seamless C interop, no hidden control flow and no garbage collector. Use when writing…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Zig — Modern Systems Programming Language

Overview

Zig is a systems language with explicit allocators, errors as values, compile-time code execution (comptime), and a build system written in Zig itself. It cross-compiles to many targets from one install and can call C code. Zig has no 1.0 yet: the standard library changes in every release, so code from older tutorials often does not compile. This skill targets 0.17.0 (2026-10-01). Check zig version first and read the release notes at https://ziglang.org/download/ when your version differs.

Changes that most often break old code:

  • main can take std.process.Init (init.io, init.gpa, init.arena, init.minimal.args). Anything that does I/O needs an std.Io value.
  • std.io.getStdOut() and the old GenericWriter APIs are gone. Writers are *std.Io.Writer, buffered, and must be flushed.
  • std.net moved to std.Io.net; std.http.Server.init takes an *Io.Reader and an *Io.Writer.
  • std.ArrayList is unmanaged: start from .empty and pass the allocator to every call.
  • @cImport was removed in 0.17 (deprecated in 0.16).
  • std.heap.DebugAllocator is deprecated in 0.17 in favour of a new safe allocator.

Instructions

Install and build

brew install zig        # macOS and Linuxbrew, currently 0.17.0
# Or download the tarball for your platform from https://ziglang.org/download/ and compare
# its hash with the shasum in https://ziglang.org/download/index.json before extracting:
sha256sum zig-x86_64-linux-0.17.0.tar.xz
# 1cbe9df9f27e6b78d14ccbca43b6703a404ef79ef1c463de901d7f088d4e2026

mkdir inventory-cli && cd inventory-cli
zig init                # build.zig, build.zig.zon, src/main.zig, src/root.zig
zig build run           # compile and run
zig build test          # run all tests
zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseSafe   # cross-compile, no extra toolchain
zig test src/main.zig   # test one file (zig run src/main.zig fails here: the template imports the project module)

Targets use <arch>-<os>[-<abi>], for example aarch64-macos or x86_64-linux-musl. -Doptimize= takes Debug, ReleaseSafe, ReleaseFast or ReleaseSmall.

Core language

Run with zig run core.zig, test with zig test core.zig:

const std = @import("std");
const Allocator = std.mem.Allocator;
const Io = std.Io;

const Priority = enum { low, medium, high, urgent };
const Status = enum { todo, in_progress, review, done, cancelled };

// Structs are the primary abstraction (no classes, no inheritance)
const Task = struct {
    id: u64,
    title: []const u8, // slice: pointer + length
    priority: Priority,
    status: Status = .todo,
    due_date: ?i64 = null,

    pub fn isOverdue(self: Task, now: i64) bool {
        return self.due_date != null and self.due_date.? < now;
    }

    pub fn format(self: Task, writer: *Io.Writer) Io.Writer.Error!void {
        try writer.print("[{s}] {s} ({s})\n", .{ @tagName(self.status), self.title, @tagName(self.priority) });
    }
};

// Errors are values, not exceptions
const TaskError = error{ TitleTooLong, OutOfMemory };

// The caller chooses where memory comes from
fn createTask(allocator: Allocator, id: u64, title: []const u8, priority: Priority) TaskError!*Task {
    if (title.len > 256) return error.TitleTooLong;
    const task = try allocator.create(Task);
    errdefer allocator.destroy(task);
    task.* = .{ .id = id, .title = try allocator.dupe(u8, title), .priority = priority };
    return task;
}

pub fn main(init: std.process.Init) !void {
    const allocator = init.arena.allocator(); // freed automatically at process exit
    const io = init.io;

    const task = try createTask(allocator, 1, "Implement auth", .high);

    var buf: [256]u8 = undefined;
    var stdout: Io.File.Writer = .init(.stdout(), io, &buf);
    try task.format(&stdout.interface);
    try stdout.interface.print("overdue: {}\n", .{task.isOverdue(1_800_000_000)});
    try stdout.interface.flush(); // buffered: flush before exit
}

test "title length is checked" {
    const long: [300]u8 = @splat('x');
    try std.testing.expectError(error.TitleTooLong, createTask(std.testing.allocator, 2, &long, .low));
}

Comptime

Generic types are functions from types to types, and comptime code runs at compile time:

const std = @import("std");

// A generic container is a function that takes a type and returns a type
fn Stack(comptime T: type) type {
    return struct {
        items: std.ArrayList(T) = .empty,

        const Self = @This();

        pub fn push(self: *Self, gpa: std.mem.Allocator, item: T) !void {
            try self.items.append(gpa, item);
        }

        pub fn pop(self: *Self) ?T {
            return self.items.pop();
        }

        pub fn deinit(self: *Self, gpa: std.mem.Allocator) void {
            self.items.deinit(gpa);
        }
    };
}

// Concatenate at compile time: the result is a constant, no allocation
fn concat(comptime a: []const
Полный SKILL.md на GitHub

Установить zig в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл zig?

Zig is a systems programming language with compile-time evaluation, seamless C interop, no hidden control flow and no garbage collector. Use when writing, building, testing or cross-compiling Zig code, porting C projects, or fixing code that broke on a new Zig release (std.Io, Writergate, @cImport removal). Covers zig init, zig build, comptime generics, explicit allocators and an HTTP server on Zig 0.17.

Как установить скилл zig?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл zig запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить zig с