Skip to content

Reference guide for calling C/C++ native libraries from Bun through the bun:ffi module.

CCM score
52 of 100
skills.sh installs
409
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers dlopen library loading, FFI type mappings, function signatures, and string, pointer, struct, and callback handling
  • Includes platform-specific library suffixes, cross-platform path selection, and a worked SQLite example
  • Explains memory management, synchronous blocking behavior, and offloading long calls to Web Workers
  • Designed for developers integrating existing C or C++ libraries into Bun applications

Install

$ npx -y skills add secondsky/claude-skills --skill bun-ffi -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Bun FFI

Bun's FFI allows calling native C/C++ libraries from JavaScript.

Quick Start

import { dlopen, suffix, FFIType } from "bun:ffi";

// Load library
const lib = dlopen(`libc.${suffix}`, {
  printf: {
    args: [FFIType.cstring],
    returns: FFIType.int,
  },
});

// Call function
lib.symbols.printf("Hello from C!\n");

Loading Libraries

Platform-Specific Paths

import { dlopen, suffix } from "bun:ffi";

// suffix is: "dylib" (macOS), "so" (Linux), "dll" (Windows)

// System library
const libc = dlopen(`libc.${suffix}`, { ... });

// Custom library
const myLib = dlopen(`./libmylib.${suffix}`, { ... });

// Absolute path
const sqlite = dlopen("/usr/lib/libsqlite3.so", { ... });

Cross-Platform Loading

function getLibPath(name: string): string {
  const platform = process.platform;
  const paths = {
    darwin: `/usr/local/lib/lib${name}.dylib`,
    linux: `/usr/lib/lib${name}.so`,
    win32: `C:\\Windows\\System32\\${name}.dll`,
  };
  return paths[platform] || paths.linux;
}

const lib = dlopen(getLibPath("mylib"), { ... });

FFI Types

import { FFIType } from "bun:ffi";

Details

Repository
github.com/secondsky/claude-skills
Category
Backend & APIs
First seen
Jun 3, 2026

Questions

What does the bun-ffi skill do?

The bun-ffi skill teaches an agent how to call native C and C++ libraries from JavaScript in Bun using bun:ffi. It covers loading libraries with dlopen, mapping FFI types, defining function signatures, passing strings and pointers, structs, callbacks and memory handling.

How do I install the bun-ffi skill?

Run npx -y skills add secondsky/claude-skills --skill bun-ffi -y in your project to install it. After that, bun-ffi lets the agent answer questions about calling native libraries from Bun.

When should I use the bun-ffi skill?

Use bun-ffi when you need to call C or C++ shared libraries from a Bun project, for example through dlopen, a native SQLite library or a custom .so, .dylib or .dll file. The skill is written for prompts about bun:ffi, foreign function interface and native code integration.

Where does bun-ffi stand in the Backend & APIs category?

bun-ffi is listed under Backend & APIs on Claude Marketplaces, next to entra-app-registration, neon, firebase-basics, firebase-auth-basics and workers-best-practices. Its focus is narrower than those skills: it covers only Bun's native library interface rather than hosted backend services.

More from secondsky/claude-skills

All 116

Similar to Bun Ffi

More Backend & APIs