implementing-jsc-classes-rust

implementing-jsc-classes-rust is a skill for Claude Code from twaldin/hone. It costs 41 tokens per session (1,410 once invoked), scanned A, original, MIT.

A guide for defining JavaScript classes in TypeScript and implementing them in Rust through Bun's JavaScriptCore bindings. JavaScriptCore is the engine that runs JavaScript; the guide covers generated glue code, constructors, methods, and cleanup.

In plain words
What is it for?
Use it when adding a new JavaScript API backed by Rust, including prototypes, constructors, finalizers, and native-held JavaScript values.
Why use it?
It explains how to connect the JavaScript-facing class definition with its Rust implementation and keep native objects and asynchronous work managed correctly.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it when adding a new JavaScript API backed by Rust, including prototypes, constructors, finalizers, and native-held JavaScript values.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/twaldin/hone/implementing-jsc-classes-rust
View source ↗ twaldin/hone
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.

Any agent
npx skills add twaldin/hone --skill implementing-jsc-classes-rust
Clone the repo
git clone --depth 1 https://github.com/twaldin/hone

Made for: Claude Code.

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 implementing-jsc-classes-rust

README.md
[![agentmods](https://agentmods.dev/badge/skills/twaldin/hone/implementing-jsc-classes-rust/github.svg)](https://agentmods.dev/skills/twaldin/hone/implementing-jsc-classes-rust)
Your own site
<a href="https://agentmods.dev/skills/twaldin/hone/implementing-jsc-classes-rust"><img src="https://agentmods.dev/badge/skills/twaldin/hone/implementing-jsc-classes-rust/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 implementing-jsc-classes-rust

Your own site · 80×15
<a href="https://agentmods.dev/skills/twaldin/hone/implementing-jsc-classes-rust"><img src="https://agentmods.dev/badge/skills/twaldin/hone/implementing-jsc-classes-rust.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,410 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.00041 $0.01410
Opus 5 $0.00020 $0.00705
Sonnet 5 $0.00008 $0.00282
Haiku 4.5 $0.00004 $0.00141

Measured yesterday against content hash 47c3572443e2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

implementing-jsc-classes-rust 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 yesterday.

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.

capsules/bun-module-loader/.candidate-5187e276/.claude/skills/implementing-jsc-classes-rust/SKILL.md · 132 lines

How it starts

The opening of the file, as written. The whole thing — 132 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Bun's JavaScriptCore Class Bindings Generator

Bridge JavaScript and Rust through .classes.ts definitions and Rust implementations.

Architecture

  1. JavaScript Interface Definition (.classes.ts files)
  2. Rust Implementation (.rs files)
  3. Generated Codesrc/codegen/generate-classes.ts emits C++ + Rust into ${BUN_CODEGEN_DIR}/generated_classes.rs, include!d as crate::generated_classes in bun_runtime. Run bun bd to regenerate.

Class Definition (.classes.ts)

export default [
  define({
    name: "Glob",
    construct: true,
    finalize: true,
    hasPendingActivity: true,
    proto: {
      scan:  { fn: "scan",  length: 1 },
      match: { fn: "match", length: 1 },
    },
  }),
];

Options:

  • construct: Has a public new Foo() constructor
  • finalize: Needs cleanup beyond Drop (rarely — see Finalize below)
  • hasPendingActivity: GC keep-alive while async work is in flight
  • proto: Methods (fn:), getters (getter: true, optionally cache: true)
  • values: [...]: WriteBarrier slots for JS values the native side holds (callbacks, buffers)

Rust Implementation

use bun_jsc::{CallFrame, JSGlobalObject, JSValue, JsResult};
use std::sync::atomic::{AtomicUsize, Ordering};

#[bun_jsc::JsClass]
pub struct Glob {
    pattern: Box<[u8]>,
    has_pending_activity: AtomicUsize,
}

impl Glob {
    pub fn constructor(global: &JSGlobalObject, frame: &CallFrame) -> JsResult<Box<Glob>> {
        let arg = frame.argument(0);
        let pattern = bun_core::String::from_js(arg, global)?.to_utf8_bytes().into();
        Ok(Box::new(Glob { pattern, has_pending_activity: AtomicUsize::new(0) }))
    }

    #[bun_jsc::host_fn(method)]
    pub fn r#match(&self, global: &JSGlobalObject, frame: &CallFrame) -> JsResult<JSValue> {
        // ...
        Ok(JSValue::TRUE)
    }

    pub fn has_pending_activity(&self) -> bool {
        self.has_pending_activity.load(Ordering::SeqCst) > 0
    }
}

Canonical signatures

Read the full file on GitHub · 132 lines

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. yesterday First seen · 132 lines · 41 tokens per session scan A 47c3572443e2

Subscribe to this mod's changes

implementing-jsc-classes-rust is a skill published in the GitHub repository twaldin/hone (47 stars, last pushed yesterday), licensed MIT. It adds 41 tokens to every session and 1,410 once invoked, about $0.0002 per session on Opus 5. 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-07.