wrapper

Generate idiomatic Nim wrappers for C FFI bindings with ABI correctness.

54|3|Updated Feb 23, 2026
One-click install
npx skills add https://github.com/planetis-m/skills --skill wrapper
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wrapper
Source: https://github.com/planetis-m/skills/tree/main/wrapper
Command: npx skills add https://github.com/planetis-m/skills --skill wrapper

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides comprehensive guidelines and best practices for creating idiomatic Nim wrappers around C libraries, ensuring ABI correctness and improving Nim ergonomics.

Core Features & Use Cases

  • ABI Correctness: Maintain exact layouts, calling conventions, and signatures for C functions and data structures.
  • Nim Ergonomics: Expose C APIs in a safer, clearer, and more "Nim-like" manner.
  • Use Case: When integrating a C-based image processing library into a Nim project, use this Skill's guidance to create a robust wrapper that handles memory management, error reporting, and provides a clean, Nim-native API for image manipulation functions.

Quick Start

Follow the guidelines in this Skill to create a Nim wrapper for the C library 'libexample'.

Frequently Asked Questions about wrapper

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a Nim wrapper for a C library?

To build a Nim wrapper for a C library, follow guidelines covering ABI correctness, FFI mechanics, type mapping, and memory ownership to expose C APIs as safe, idiomatic Nim functions. This ensures proper calling conventions and clear project layout.

How does FFI handle memory ownership when wrapping C bindings in Nim?

FFI memory ownership in Nim wrappers requires explicit guidelines to manage allocation and deallocation across the ABI boundary. Proper handling prevents leaks and crashes when passing data structures between Nim and C libraries.

What is the best way to map C enums and flags to idiomatic Nim types?

The best way to map C enums and flags to Nim types is using specific wrapping guidelines that translate C macros and enumerations into native Nim enum and set types. This maintains ABI correctness while improving API ergonomics.

How do I implement C callbacks in a Nim FFI wrapper?

Implementing C callbacks in a Nim FFI wrapper involves defining stable ABI-compatible procedure signatures and passing them to C libraries. The wrapper guidelines ensure correct calling conventions and safe state handling across language boundaries.

What are common pitfalls when ensuring ABI correctness in Nim C bindings?

Common pitfalls in Nim C bindings include incorrect struct layouts, mismatched calling conventions, and improper error handling. Following established wrapper guidelines helps avoid these issues to create safe, usable Nim APIs.