zig-cinterop

zig-cinterop is a skill for Claude Code, Codex from mohitmishra786/low-level-dev-skills. It costs 106 tokens per session (2,289 once invoked), scanned A, original, MIT.

A guide to connecting Zig programs with C code. It explains importing C headers, translating them for inspection, matching C data layouts, exporting Zig functions, and building mixed projects.

In plain words
What is it for?
Use it for @cImport and @cInclude, C header translation, compatible structs, exported functions, and mixed C/Zig builds.
Why use it?
It helps you call existing C libraries from Zig or make Zig code usable by C programs without mismatched types or calling conventions.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for @cImport and @cInclude, C header translation, compatible structs, exported functions, and mixed C/Zig builds.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mohitmishra786/low-level-dev-skills/zig-cinterop
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mohitmishra786/low-level-dev-skills --skill zig-cinterop
Clone the repo
git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for zig-cinterop

README.md
[![agentmods](https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/zig-cinterop/github.svg)](https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/zig-cinterop)
Your own site
<a href="https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/zig-cinterop"><img src="https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/zig-cinterop/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for zig-cinterop

Your own site · 80×15
<a href="https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/zig-cinterop"><img src="https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/zig-cinterop.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 106 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,289 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 15 Sept 2026
  • Snyk pass 15 Sept 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00106 $0.02289
Opus 5.5 $0.00042 $0.00916
Sonnet 5.5 $0.00021 $0.00458
Haiku 4.5 $0.00011 $0.00229

Measured 14d ago against content hash 2d77e545950e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

zig-cinterop scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 14d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/zig/zig-cinterop/SKILL.md · 286 lines

How it starts

The opening of the file, as written. The whole thing — 286 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Zig C Interop

Purpose

Guide agents through Zig's C interoperability: b.addTranslateC (and the deprecated @cImport) for calling C, translate-c for header inspection, extern struct and packed struct for ABI-compatible types, exporting Zig for C consumption, and zig cc for mixed C/Zig builds.

Triggers

  • "How do I call a C function from Zig?"
  • "How do I call a C library from Zig (addTranslateC / @cImport)?"
  • "How do I export Zig functions to be called from C?"
  • "How do I define a struct that matches a C struct?"
  • "What does translate-c do?"
  • "How do I build a mixed C and Zig project?"

Workflow

1. Calling C from Zig

Since Zig 0.16 the @cImport builtin is deprecated. Translate C headers in build.zig with b.addTranslateC and import the result as a normal module.

/* src/c.h — everything the Zig code needs from C */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mylib.h"
// build.zig
const c_h = b.addTranslateC(.{
    .root_source_file = b.path("src/c.h"),
    .target = target,
    .optimize = optimize,
});
c_h.addIncludePath(b.path("include/"));
c_h.defineCMacro("MY_FEATURE", "1");  // equivalent to -DMY_FEATURE=1

const exe = b.addExecutable(.{
    .name = "app",
    .root_module = b.createModule(.{
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
        .link_libc = true,  // required when calling libc
        .imports = &.{.{ .name = "c", .module = c_h.createModule() }},
    }),
});

// The header only declares the API; link the implementation too
exe.root_module.addIncludePath(b.path("include/"));
exe.root_module.addCSourceFile(.{ .file = b.path("src/mylib.c"), .flags = &.{"-std=c11"} });
// or, for a prebuilt library:
// exe.root_module.addLibraryPath(b.path("vendor/lib"));
// exe.root_module.linkSystemLibrary("mylib", .{});

b.installArtifact(exe);
// src/main.zig
const c = @import("c");

pub fn main() void {
    _ = c.printf("Hello from C: %d\n", @as(c_int, 42));

    var buf: [256]u8 = undefined;
    _ = c.snprintf(&buf, buf.len, "formatted: %d", @as(c_int, 100));
}

Read the full file on GitHub · 286 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 14d ago Changed · +54 lines · +7 tokens per session 2d77e545950e
  2. 3mo ago First seen · 232 lines · 99 tokens per session scan A a16de11aa08b

Subscribe to this mod's changes

zig-cinterop is a skill published in the GitHub repository mohitmishra786/low-level-dev-skills (310 stars, last pushed 14d ago), licensed MIT. It adds 106 tokens to every session and 2,289 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

zig-cinterop compared with skills from other repositories

zig-cinterop next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
zig-cinteropmohitmishra786/low-level-dev-skillsSkill31014d agoMITA106Claude Code, Codex
header-only-c-cpp-ingestionalivirgo/Major-AI-SkillsSkill6todayMITA25Claude Code
zoom-meeting-sdk-unrealanthropics/knowledge-work-pluginsSkill38ktodayApache-2.0A41Claude Code
cudnn-installNVIDIA/skillsSkill4.3ktodayApache-2.0A49Claude Code, Codex
ccclNVIDIA/skillsSkill4.3ktodayApache-2.0A206Claude Code, Codex
doca-argpNVIDIA/skillsSkill4.3ktodayApache-2.0A277Claude Code
address-sanitizerRedHatProductSecurity/prodsec-skillsSkill2084d agoApache-2.0A35Claude Code