Live survey304 models · 14 providers · 22,792 auditsAudited grill-with-docs · SAFE →What changedHow we verifyllms.txt

Agent skill · Audited from source

dart-use-ffigen

skill · dart-lang/skillsBSD-3-Clause licenceAudited 28 Oct 2026 · source db37821a6b02

★ 531pushed 11 days ago
✓SAFEGrade B · 89/100 · 28 Oct 2026 · db37821
531repo stars · whole dart-lang/skills

Is it safe? Yes — SAFE, grade B (89/100). We read this skill's source at commit db37821a6b02 and found no filesystem, network or shell access and no hard-coded secrets. What it does: Guide agents to use `package:ffigen` to automatically generate FFI bindings instead of writing them manually. Use this skill when a task involves writing new FFI bindings, extending C/Objective-C/Swift integrations, or…

Ask an AI about this pageGChatGPTCClaudePPerplexityGeGeminiXGrok
More
Cite

Cite this page

ModelsAtlas. “dart-use-ffigen (dart-lang/skills)”. Retrieved 28 Oct 2026. https://modelsatlas.com/skills/dart-lang/dart-use-ffigen

2 skills are called “dart-use-ffigen”. You are viewing dart-lang/skills.

Trust audit

Audit 0.4.1 · source read 28 Oct 2026

Trust score89/100✓SAFE B
0 critical0 high0 medium0 low0 info

SAFE means nothing in the source contradicts what the skill says it does. Grade B is shared by 16,667 of 17,602 audited skills.

What the source does

  • FilesystemNone observedNo reads or writes in the source
  • NetworkNone observedNo outbound calls in the source
  • ShellNone observedNo commands run in the source
  • DependenciesPinnedNothing floats
  • SecretsNone foundNo keys in source

Five audit layers

LayerWhat we checkResultFindings
L0 ProvenanceRepo owner, licence, archive status, activityPASS0
L1 Static sourceSecrets, path traversal, supply chain, hidden codeNA0
L2 InstructionsPrompt injection, authority framing, hidden directivesPASS0
L3 InventoryThe files and declarations match the sourcePASS0
L4 SandboxRun in isolation and watch behaviourSKIPPED why0

Gates applied: no behavioural pass.

Findings (0)

No findings at any severity. We re-audit when the source changes.

Audit 0.4.1 · source sha db37821a6b02 · 28 Oct 2026Report an issue or request a re-scan

Provenance

Who published it, and what the verdict is pinned to

  • Publisherdart-lang GitHub organizationOwner of the repository this skill is read from
  • Source folderdart-lang/skills/skills/dart-use-ffigenThe exact folder we audited
  • LicenceBSD-3-ClauseAs the repository states it
  • Commit pinned for this verdictdb37821a6b02A new audit runs when the source changes
  • Repository statusNot archivedLast push 11 days ago
  • Sandboxed runNot runSkills are read, not executed; layer L4 is skipped

What it tells the agent

Full source on GitHub ↗

Its description: Guide agents to use `package:ffigen` to automatically generate FFI bindings instead of writing them manually. Use this skill when a task involves writing new FFI bindings, extending C/Objective-C/Swift integrations, or…

---
name: dart-use-ffigen
description: Guide agents to use `package:ffigen` to automatically generate FFI bindings instead of writing them manually. Use this skill when a task involves writing new FFI bindings, extending C/Objective-C/Swift integrations, or replacing hand-crafted `dart:ffi` setups.
metadata:
  model: models/gemini-3.1-pro-preview
  last_modified: Thu, 28 May 2026 07:21:07 GMT
---
# Generating FFI Bindings using package:ffigen

## Contents
- [Introduction](#introduction)
- [Constraints](#constraints)
- [FFIgen Overview](#ffigen-overview)
- [Step-by-Step Workflow](#step-by-step-workflow)
- [Concrete Example: Binding a C Library](#concrete-example-binding-a-c-library)
- [Verification Checklist](#verification-checklist)

## Introduction

Automate and standardize the generation of FFI bindings using `package:ffigen` (`FfiGenerator`). Writing FFI bindings by hand is error-prone, brittle, and highly discouraged.

## Constraints

*   **No Hand-Written FFI Bindings**: If native headers (`.h` files) exist or are generated by a build step, never write manual `DynamicLibrary.lookup`, `@Native` external functions, or raw struct classes. Always use `FfiGenerator` to generate them.
*   **Generator Location**: The generator script should be located at `tool/ffigen.dart` within the target package root.
*   **Header Location**: If the native header files are third-party, they should be located in `third_party/` within the target package (otherwise placing them in a `src/` directory at the package root is also acceptable). If the headers are not in one of these standard locations, notify the user that it would be cleaner to move the header files to the standard location (e.g., `third_party/`).
*   **Targeted Inclusion Filters**: Avoid importing an entire native library unless specifically needed. Always apply precise inclusion lists using positive matches to minimize the size and cognitive load of the generated code (e.g., using `Functions.includeSet` or filtering matches in `include` closures).
*   **Output Setup**: If the generated FFI bindings interface with a third-party library (or reference third-party headers), the generated files must always be placed under `lib/src/third_party/`. The primary generated FFI bindings file must strictly use the `.g.dart` extension (e.g. `sqlite3.g.dart`).
*   **Preamble & License Headers**: Always supply a premium `preamble` in the `Output` class to specify the license. This must match the native third-party library's license, explicitly include the copyright header of the target native header file, and contain an automatic generation warning (e.g. `// Generated by package:ffigen. Do not edit manually.`).
*   **No Unnecessary Commits of Stale Bindings**: Ensure you run the generator script and check if the generated files have changed *before* finishing your task. Always verify the package by running `dart analyze`.
*   **Record Usage and Tree Shaking**: If the package is integrated into standard runtime execution or compiles native assets via native hooks:
    *   Enable recorded usage on all functions by setting `recordUse: (_) => true` under `Functions`.
    *   Specify the `recordUseMapping` target in `Output` (which must strictly be a `.g.dart` file under `lib/src/third_party/`, e.g. `lib/src/third_party/sqlite3.record_use_mapping.g.dart`) to register bindings for symbol tree shaking.

## FFIgen Overview

To construct the programmatic generator, use the core configuration objects imported from `package:ffigen/ffigen.dart`:

### 1. `FfiGenerator`
The parent class that orchestrates the configuration, parsing, and code generation.
```dart
FfiGenerator({
  Headers headers = const Headers(),
  Enums enums = Enums.excludeAll,
  Functions functions = Functions.excludeAll,
  Globals globals = Globals.excludeAll,
  Integers integers = const Integers(),
  Macros macros = Macros.excludeAll,
  Structs structs = Structs.excludeAll,
  Typedefs typedefs = Typedefs.excludeAll,
  Unions unions = Unions.excludeAll,
  UnnamedEnums unnamedEnums = UnnamedEnums.excludeAll,
  ObjectiveC? objectiveC,
  required Output output,
}).generate();
```

### 2. `Headers`
Configures Clang header parsing targets and compiler flags.
*   `entryPoints`: A list of target header `Uri` inputs.
*   `include`: A filter function `bool Function(Uri header)` that handles transitive header imports.
*   `compilerOptions`: Custom preprocessor/include compiler flags to pass directly to libclang.
*   `ignoreSourceErrors`: Set to `true` to silence errors occurring inside third-party headers during parsing.

### 3. `Functions`
Specifies which native C/C++ functions to expose in Dart.
*   `include`: A matcher function (e.g. `(decl) => {'my_func'}.contains(decl.originalName)` or `Functions.includeSet({'my_func'})`).
*   `isLeaf`: Declares functions as leaf functions (`(decl) => true`) if they do not call back into Dart or block thread execution.
*   `recordUse`: Enables metadata generation for native asset tree shaking (essential in `dart-lang/native`). Set to `(_) => true`.

### 4. `Output`
Configures target generated files.
*   `dartFile`: Target `Uri` where the primary FFI bindings will be written.
*   `recordUseMapping`: Target `Uri` for recorded usage metadata maps (crucial for linking-time tree shaking).
*   `preamble`: Text inserted at the top of the generated file (licensing, annotations).
*   `format`: Set to `true` to run the Dart formatter automatically.

## Step-by-Step Workflow

### Step 1: Check/Add Dependencies
Open the package's `pubspec.yaml` and verify the `dev_dependencies` contains `ffigen`. Use the Dart MCP server or look up the latest version on [pub.dev](https://pub.dev/packages/ffigen) (e.g., `^20.1.1`).

You can add it automatically using the CLI:
```bash
dart pub add dev:ffigen
```

### Step 2: Formulate Paths Dynamically
Create a programmatic generator script under the package's `tool/` directory (e.g., `tool/ffigen.dart`).
Resolve paths relative to `Platform.script` to mak

Excerpt, first 6,000 characters of SKILL.md, verbatim from the audited commit. It is text from someone else’s repository, quoted so you can judge it before your agent reads it.

Install

Pinned to the audited commit db37821

Download folder ↗
git clone https://github.com/dart-lang/skills
git -C skills checkout db37821a6b02

The author documents no install command, so this uses the repository directly. Our verdict covers commit db37821a6b02 only.

Works in

The author has not said which agents this skill supports, and we have not tested it in any.

Audit history

Every audit, every source change

  1. ✓SAFE B 89 / 100

    first audit · source db37821a6b02

Similar skills

Questions about dart-use-ffigen

Is dart-use-ffigen safe to install?
The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.
What can dart-use-ffigen access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
How current is this page?
The grade is for one exact copy of the source (db37821a6b02), read on 2026-10-28. The repository is watched, and a new audit runs when it changes — this is the first audit.

Sources

Spotted something wrong? Report a correction · Methodology

Keep going in your AI

Opens with this page as the source. We add nothing else to the prompt.