cgo-bindings

cgo-bindings is a skill for Claude Code, Codex from Goldziher/ai-rulez. It costs 45 tokens per session (367 once invoked), scanned A, original, MIT.

A guide for cgo, the Go feature that lets Go programs call C code, and for linking Go to a Rust library through C-compatible functions. It covers conversions between Go and C values, memory cleanup, errors, threads, and safe pointer handling.

In plain words
What is it for?
Use it when writing or reviewing Go bindings for C or Rust libraries, configuring cgo compiler and linker flags, converting strings, testing native calls, or preparing builds that require a C toolchain.
Why use it?
Calling native C or Rust code from Go introduces memory, build, and thread-safety risks that ordinary Go code does not have. The guide highlights the conventions that prevent leaks, unsafe pointers, ignored errors, and failed builds.

Skill for Claude CodeCodex

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

Good fit Use it when writing or reviewing Go bindings for C or Rust libraries, configuring cgo compiler and linker flags, converting strings, testing native calls, or preparing builds that require a C toolchain.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/goldziher/ai-rulez/cgo-bindings
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 Goldziher/ai-rulez --skill cgo-bindings
Clone the repo
git clone --depth 1 https://github.com/Goldziher/ai-rulez

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 cgo-bindings

README.md
[![agentmods](https://agentmods.dev/badge/skills/goldziher/ai-rulez/cgo-bindings/github.svg)](https://agentmods.dev/skills/goldziher/ai-rulez/cgo-bindings)
Your own site
<a href="https://agentmods.dev/skills/goldziher/ai-rulez/cgo-bindings"><img src="https://agentmods.dev/badge/skills/goldziher/ai-rulez/cgo-bindings/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 cgo-bindings

Your own site · 80×15
<a href="https://agentmods.dev/skills/goldziher/ai-rulez/cgo-bindings"><img src="https://agentmods.dev/badge/skills/goldziher/ai-rulez/cgo-bindings.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 367 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
  • 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.00045 $0.00367
Opus 5.5 $0.00018 $0.00147
Sonnet 5.5 $0.00009 $0.00073
Haiku 4.5 $0.00005 $0.00037

Measured yesterday against content hash 56f06afa180a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cgo-bindings 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 yesterday.

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.

internal/builtins/bindings/cgo/skills/cgo-bindings/SKILL.md · 17 lines

What it actually says

  • Use import "C" with // #cgo LDFLAGS: and // #cgo CFLAGS: directives for linking.
  • Declare C header functions in comment block immediately above import "C" — no blank line between.
  • Type mapping: C.int, C.long, C.char. Use C.CString() and C.GoString() for string conversion.
  • Memory: C.CString() allocates — always defer C.free(unsafe.Pointer(cStr)) immediately after creation.
  • Error handling: return error codes from C functions, convert to Go error values. Check all return values.
  • Link Rust static libraries: // #cgo LDFLAGS: -L./target/release -lmylib. Build Rust with crate-type = ["staticlib"].
  • Thread safety: C functions called from Go may run on any OS thread. Use runtime.LockOSThread() when needed.
  • Go pointer passing: use runtime.Pinner (Go 1.21+) to pin Go memory passed to C. Never pass Go pointers without pinning.
  • Test with go test (requires CGO_ENABLED=1). Mock C layer for unit tests, use integration tests for real FFI.
  • Build: CGO_ENABLED=1 go build. Cross-compilation requires appropriate C toolchain.
  • Anti-patterns: leaking C.CString memory, passing unpinned Go pointers to C, ignoring C return codes.
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. yesterday Changed · -15 tokens per session 56f06afa180a
  2. 1mo ago First seen · 17 lines · 60 tokens per session scan A 66d96af0616d

Subscribe to this mod's changes

cgo-bindings is a skill published in the GitHub repository Goldziher/ai-rulez (165 stars, last pushed yesterday), licensed MIT. It adds 45 tokens to every session and 367 once invoked, about $0.0002 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-08-30.

Related

Other skills, from other repositories

memory-mine

Mine project files or conversations into the MemPalace memory system. Indexes source code and conversation history as searchable palace drawers with semantic embeddings and room assignment.

dimetron/pi-go · 35 tokens

memory-status

Show MemPalace memory system status — drawer counts, wings, rooms, knowledge graph stats, and embedding model state.

dimetron/pi-go · 27 tokens

printing-press

Set up a new integration, connector, or CLI binding for any API. Wrap or generate a ship-ready Go CLI from an OpenAPI, HAR, or Postman spec via the lean research -> generate -> build -> shipcheck loop. Use when the user says build a CLI, wrap this API, set up a new integration, add a connector, integrate with a…

mvanhorn/cli-printing-press · 86 tokens

octo-summary

Read, create, find, and cite Octo summaries through octo-cli. Use when an agent needs to create an owner-only summary from explicit channels, discover summaries visible to its bot owner, inspect one summary, retrieve its current body, or ground an answer in returned citation metadata. Load after octo-shared.

Mininglamp-OSS/octo-cli · 68 tokens

go

Use when writing, reviewing, testing, or shipping Go code and HTTP services: idioms, %w error wrapping, goroutine/context/errgroup concurrency, net/http 1.22 routing, log/slog, project layout, table-driven tests, Go hardening. NOT language-agnostic threat modeling (that is secure-coding), NOT Dockerfile/CI shipping…

ericrisco/rsc-harness · 86 tokens

go-127

What changed in Go 1.27 (released August 2026) and how it changes the way Go is written in pi-go. Use this skill when writing or reviewing Go that could use a 1.27 feature, when bumping the go directive in go.mod, when a build or test behaves differently after a toolchain upgrade, or when code-guidelines-go points…

dimetron/pi-go · 177 tokens