ffi

ffi is a cursor rule for Cursor from quinnjr/skia-rs. It costs 0 tokens per session (525 once invoked), scanned A, original, Apache-2.0.

Foreign-function interface guidance for connecting Rust code to Skia's C and C++ graphics library. It defines naming, pointer safety, resource cleanup, and type conversions.

In plain words
What is it for?
Use it when adding or reviewing graphics bindings, exported C functions, opaque pointers, null checks, or Rust-to-Skia type mappings.
Why use it?
It reduces crashes and memory errors when code crosses between Rust and C or C++.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when adding or reviewing graphics bindings, exported C functions, opaque pointers, null checks, or Rust-to-Skia type mappings.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/quinnjr/skia-rs/ffi
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.

Clone the repo
git clone --depth 1 https://github.com/quinnjr/skia-rs

Made for: Cursor.

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 ffi

README.md
[![agentmods](https://agentmods.dev/badge/rules/quinnjr/skia-rs/ffi/github.svg)](https://agentmods.dev/rules/quinnjr/skia-rs/ffi)
Your own site
<a href="https://agentmods.dev/rules/quinnjr/skia-rs/ffi"><img src="https://agentmods.dev/badge/rules/quinnjr/skia-rs/ffi/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 ffi

Your own site · 80×15
<a href="https://agentmods.dev/rules/quinnjr/skia-rs/ffi"><img src="https://agentmods.dev/badge/rules/quinnjr/skia-rs/ffi.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 525 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.
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.00000 $0.00525
Opus 5.5 $0.00000 $0.00210
Sonnet 5.5 $0.00000 $0.00105
Haiku 4.5 $0.00000 $0.00052

Measured 3mo ago against content hash a1ad0ac4e653, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ffi 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 3mo ago.

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.

.cursor/rules/ffi.mdc · 70 lines

What it actually says

FFI Guidelines

C API Design

  • All FFI functions in skia-rs-ffi
  • Use opaque pointers for complex types
  • Follow Skia's C API naming: sk_{type}_{method}
  • Always check for null pointers
// skia-rs-ffi/src/lib.rs

/// Create a new paint object.
///
/// # Safety
/// Returns a valid pointer that must be freed with `sk_paint_delete`.
#[no_mangle]
pub unsafe extern "C" fn sk_paint_new() -> *mut Paint {
    Box::into_raw(Box::new(Paint::new()))
}

/// Delete a paint object.
///
/// # Safety
/// `paint` must be a valid pointer returned by `sk_paint_new`.
#[no_mangle]
pub unsafe extern "C" fn sk_paint_delete(paint: *mut Paint) {
    if !paint.is_null() {
        drop(Box::from_raw(paint));
    }
}

/// Set the paint color.
///
/// # Safety
/// `paint` must be a valid pointer.
#[no_mangle]
pub unsafe extern "C" fn sk_paint_set_color(paint: *mut Paint, color: u32) {
    if let Some(p) = paint.as_mut() {
        p.set_color32(Color(color));
    }
}

Type Mappings

Skia C++ Rust C FFI
SkScalar Scalar (f32) float
SkPoint Point sk_point_t
SkRect Rect sk_rect_t
SkColor Color uint32_t
SkMatrix Matrix sk_matrix_t
SkPath* *mut Path sk_path_t*
SkPaint* *mut Paint sk_paint_t*
SkCanvas* *mut Canvas sk_canvas_t*

Safety Requirements

  • All FFI functions must be marked unsafe
  • Document safety requirements in doc comments
  • Check for null pointers before dereferencing
  • Use #[repr(C)] for all FFI-visible structs
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. 3mo ago First seen · 70 lines · 0 tokens per session scan A a1ad0ac4e653

Subscribe to this mod's changes

ffi is a cursor rule published in the GitHub repository quinnjr/skia-rs (41 stars, last pushed 6d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 525 tokens. 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-09-01.

Related

ffi compared with cursor rules from other repositories

ffi next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ffiquinnjr/skia-rsCursor rule416d agoApache-2.0A0Cursor
rust-architectplatinoff/poolAICursor rule4yesterdayMITA3,367Cursor
coreSaynaAI/saynaCursor rule3186mo agoApache-2.0A1,582Cursor
monitor-c-conventionsTACC/HPCPerfStatsCursor rule60yesterdayLGPL-2.1A0Cursor
monitor-c-refactor-standardsTACC/HPCPerfStatsCursor rule60yesterdayLGPL-2.1A0Cursor
table-of-contents-standardbriangmilnes/APAS-VERUSCursor rule102mo agoMITA795Cursor
arc-deref-patternbriangmilnes/APAS-VERUSCursor rule102mo agoMITA793Cursor