Logo di Nim C Bindings

Nim C Bindings

Community
planetis-m
nim-c-bindings

Bind C libraries to Nim and make them build reliably across Linux, macOS, and Windows, including headers, types, linking, shared-library loading, and CI/release workflows. Use when wrapping a C dependency, fixing Nim FFI build issues, or setting up cross-platform GitHub Actions for a Nim native library project.

Panoramica

Pubblicato daplanetis-m
Repositoryskills
Nome della skillnim-c-bindings
Stelle
66
Fork
7
File inclusi
3
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • File inclusi: 3

    Script, template e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da planetis-m su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Nim C Bindings in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/planetis-m/skills/tree/master/nim-c-bindings
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/planetis-m/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/nim-c-bindings .claude/skills/nim-c-bindings
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Nim C Bindings in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Nim C Bindings non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Nim C Bindings non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Nim C Bindings & CI

Rules

Binding Fundamentals

  • Use importc with cdecl for C APIs unless the library explicitly requires a different calling convention (e.g., stdcall).
  • Represent opaque C handles as type Name = ptr object types. Use incompleteStruct for partial/opaque structs to avoid size/layout mismatches.
  • Use {.bycopy.} on structs that Nim must pass by value to C.
  • Declare the C header in the binding when the compiler needs the C definitions for compilation, for example header: "foo.h".
  • Use {.push callconv: cdecl, importc.} blocks when many declarations share the same convention.
  • Match C storage with Nim's C-compatible types such as cint, cuint, clong, culong, clonglong, csize_t, cfloat, cdouble, cstring, and pointer types.
  • Preserve the complete field order for concrete structs passed or returned by value.
  • When the requested deliverable is a raw binding, import C symbols directly. Put ergonomic aliases and conversions in a separate wrapper layer.

Linking

  • System libraries: link with -l<name> only. Do not hardcode -L paths — the OS toolchain already knows where system libs live.
  • Local/third-party libraries: add both -L<dir> and -l<name> (or .lib/.dll.lib paths on Windows MSVC).
  • Use repository-relative paths for vendored dependencies, for example third_party/libfoo, to keep builds hermetic.
  • Distinguish linker-resolved imports from Nim runtime dynlib imports. header supplies declarations for generated C; a runtime-only dynlib proc should not also use header.

Runtime Library Resolution

  • Vendored/local shared libs: colocate the .so/.dylib/.dll next to the executable. Do not rely on environment variables for discovery.
  • System-installed libs: do not copy DLLs/shared libs next to the executable. Rely on the platform's normal system loader configuration. Use environment variables only as temporary overrides.
  • On Linux, add rpath $ORIGIN only when loading colocated shared libs. From the shell, pass --passL:"-Wl,-rpath,\$ORIGIN". In Nim source, use {.passL: "-Wl,-rpath,\\$ORIGIN".}.
  • Do not use build-tree-only rpaths or absolute paths to non-system shared libraries.

Platform Rules

PlatformToolchainDepsLink flagsRuntime
LinuxSystem GCC/Clangapt-l<name> or -L<dir> -l<name>Colocate local .so; rpath $ORIGIN if needed
macOSApple ClangHomebrewstaticExec("brew --prefix") for -I/-LColocate local .dylib
WindowsMSVC (--cc:vcc)vcpkg only.lib/.dll.lib full pathsColocate .dll next to .exe
  • On macOS, resolve include/link paths via staticExec("brew --prefix <formula>").
  • On Windows, use MSVC via --cc:vcc. Use vcpkg only — avoid Chocolatey and MSYS2. Never mix toolchains.
  • On Windows, do not rely on implicit -l<name> for MSVC. Use explicit .lib or .dll.lib paths.
  • On Windows CI, export VCPKG_ROOT to the installed triplet root and prepend its bin to PATH.

CI & Release

  • CI is the authoritative spec for supported platforms, toolchains, and flags. Local workflows must be compatible with CI.
  • Keep test builds simple: compile, then run, with minimal environment mutation.
  • Align the local toolchain with CI (e.g., MSVC + vcpkg x64-windows-release with --cc:vcc).
  • Use the reference workflows as starting points — references/ci.yml for validation, references/release.yml for tagged releases.

Verification

  • Compile against the real header and call the real C implementation.
  • Exercise concrete structs passed and returned by value. Compare Nim layout with C sizeof and offsetof probes when layout is in doubt.
  • Test bundled shared libraries after copying the executable and library into a clean directory.
  • For dynlib, verify runtime loading without also linking that library.

Workflow

  1. Identify the C API. Determine calling convention, opaque vs value types, and ownership.
  2. Write bindings. Use importc, correct calling convention, incompleteStruct for opaque types, bycopy for value types. Add header pragma.
  3. Set up linking. System libs: -l only. Local libs: -L + -l with repo-relative paths. Windows: explicit .lib paths.
  4. Handle runtime. Colocate local shared libs. For system-installed libs, rely on the normal loader search path. Add rpath $ORIGIN on Linux only for colocated local libs.
  5. Verify the ABI. Run a real C round trip for the types and calls used by the binding.
  6. Add CI. Copy references/ci.yml, adapt placeholders (<package>, <src/main.nim>, dependency lists).
  7. Add release. Copy references/release.yml, adapt placeholders, configure draft releases.
  8. Test locally, then push. Verify the build works locally with the same flags CI uses.

Common Mistakes

MistakeWhy it's wrong
Hardcoding -L paths for system librariesOS toolchain already knows where they are; breaks portability
Mixing MSVC + MSYS2/MinGW on WindowsIncompatible ABIs, linker errors, runtime crashes
Using implicit -l<name> with MSVCMSVC doesn't resolve libs the same way GCC does; use explicit .lib paths
Relying on env vars for vendored shared libsFragile across machines; colocate instead
Build-tree-only rpathsBreaks when the binary moves; use $ORIGIN for colocated libs
Guessing Windows dependency pathsNon-deterministic; use vcpkg with known install roots
Compiling C sources into the executable when the task requires an existing shared libraryBypasses shared-library link and relocation behavior
Adding Nim-bodied wrappers to a requested raw binding surfaceHides whether the C API was imported directly and changes the requested layer

References

  • references/raw_binding.md — Mapping an opaque handle and by-value C struct.
  • references/ci.yml — Building a C-dependent project on Linux, macOS, and Windows with Nim, Atlas, and vcpkg.
  • references/release.yml — Publishing tagged cross-platform archives in a draft release.

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Nim C Bindings?

Bind C libraries to Nim and make them build reliably across Linux, macOS, and Windows, including headers, types, linking, shared-library loading, and CI/release workflows. Use when wrapping a C dependency, fixing Nim FFI build issues, or setting up cross-platform GitHub Actions for a Nim native library project.

Perché usare Nim C Bindings su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Nim C Bindings è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Nim C Bindings in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/planetis-m/skills/tree/master/nim-c-bindings. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Nim C Bindings?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Nim C Bindings?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Nim C Bindings: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Nim C Bindings è gratuita?

È pubblicata su GitHub da planetis-m. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇