zig-cinterop

zig-cinterop is a skill for Claude Code, Codex from mohitmishra786/low-level-dev-skills. It costs 99 tokens per session (1,814 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.

not rated 203repo +8 2mo ago A scan Socket: passSnyk: passSkillSpector: pass 99 tokens original MIT

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 99 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,814 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 18 Mar 2026
  • Snyk pass 21 Feb 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.00099 $0.01814
Opus 5 $0.00049 $0.00907
Sonnet 5 $0.00020 $0.00363
Haiku 4.5 $0.00010 $0.00181

Measured 9d ago against content hash a16de11aa08b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, 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 9d 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 · 232 lines

How it starts

The opening of the file, as written. The whole thing — 232 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: @cImport/@cInclude 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 use @cImport and @cInclude?"
  • "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 with @cImport

const c = @cImport({
    @cInclude("stdio.h");
    @cInclude("string.h");
    @cInclude("mylib.h");
    @cDefine("MY_FEATURE", "1");  // Equivalent to -DMY_FEATURE=1
    @cUndef("SOME_MACRO");
});

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));
}

In build.zig:

exe.linkLibC();  // Required when using C functions
exe.addIncludePath(b.path("include/"));

2. translate-c — inspect C header translation

translate-c converts C headers to Zig declarations, letting you see exactly how Zig sees a C API:

# Translate a header file
zig translate-c /usr/include/stdio.h > stdio.zig

# Translate with defines/includes
zig translate-c -I include/ -DFEATURE=1 mylib.h > mylib.zig

# Translate and inspect specific types
zig translate-c mylib.h | grep -A5 "struct MyStruct"

This is Zig's equivalent of bindgen — you use it to understand what Zig generates, then use @cImport directly in code.

3. C type mapping

C type Zig type
int c_int
unsigned int c_uint
long c_long
unsigned long c_ulong
long long c_longlong
size_t usize
ssize_t isize
char * [*:0]u8 (null-terminated)
const char * [*:0]const u8
void * *anyopaque
NULL null
bool bool (C99) or c_int (older)
float f32
double f64

Read the full file on GitHub · 232 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. 9d 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 (203 stars, last pushed 2mo ago), licensed MIT. It adds 99 tokens to every session and 1,814 once invoked, about $0.0005 per session on Opus 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

Other skills, from other repositories

header-only-c-cpp-ingestion

Inspect C and C++ headers for public contracts and data structures before reading implementation files.

alivirgo/Major-AI-Skills · 25 tokens

zoom-meeting-sdk-unreal

Zoom Meeting SDK for Unreal Engine wrapper integrations. Use when building Unreal projects that embed Zoom meetings with C++ and Blueprint wrappers, including wrapper-to-SDK mapping concerns.

anthropics/knowledge-work-plugins · 41 tokens

cudaq-importing

Use when porting circuits from another framework (e.g. Qiskit) into CUDA-Q kernels while preserving the source algorithm and validation fidelity.

NVIDIA/cuda-quantum · 34 tokens

embedded-stm32

Best practices for embedded C/C++ development on STM32 microcontrollers using the HAL, covering peripherals, DMA, interrupts, memory constraints, and hardware-focused testing. Use when writing STM32 HAL code, configuring peripherals generated by STM32CubeMX, working with interrupts or DMA, debugging with SWD/JTAG…

Mindrally/skills · 87 tokens

carbon-lang

Use when evaluating Carbon for a C++ code base, running the carbon toolchain from a nightly or Bazel build, or comparing Carbon with staying on C++. Not for C++ modules: use cpp-modules.

OutlineDriven/outline-driven-development · 46 tokens

acad-arx-wizard

Agentic ObjectARX project scaffolding for AutoCAD 2027 / Visual Studio 2026. Replaces the broken .vsz VsWizardEngine wizard with a PowerShell script that generates identical C++ project files. Works for new ARX/DBX/CRX projects and add-on class wizards (Jig, Reactors, Custom Object, MFC, .NET Wrapper, COM Wrapper…

autodesk-platform-services/skills · 92 tokens