rust-system-calls

rust-system-calls is a skill for Claude Code from twaldin/hone. It costs 42 tokens per session (1,111 once invoked), scanned A, original, MIT.

A Rust guide for making system calls and handling files with Bun's `bun_sys` library instead of Rust's standard file APIs or raw C calls. It covers opening, reading, writing, and closing files.

In plain words
What is it for?
Use it when implementing low-level file operations, opening file descriptors, or adding system-call code in Rust.
Why use it?
It helps avoid platform differences and gives clearer error details, automatic retries for interrupted calls, and safer file-descriptor ownership.

Skill for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions CLAUDE.md.

Good fit Use it when implementing low-level file operations, opening file descriptors, or adding system-call code in Rust.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/twaldin/hone/rust-system-calls
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 rust-system-calls
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 rust-system-calls

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/twaldin/hone/rust-system-calls"><img src="https://agentmods.dev/badge/skills/twaldin/hone/rust-system-calls.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,111 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.00042 $0.01111
Opus 5 $0.00021 $0.00556
Sonnet 5 $0.00008 $0.00222
Haiku 4.5 $0.00004 $0.00111

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

Security

Grade A, and why

rust-system-calls 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/rust-system-calls/SKILL.md · 97 lines

How it starts

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

System Calls & File I/O in Rust

Use bun_sys instead of std::fs or raw libc for cross-platform syscalls with proper error handling.

bun_sys::File (Preferred)

For most file operations, use the bun_sys::File wrapper. It owns the fd and closes on Drop.

use bun_sys::{File, Fd, O};

let file = File::openat(Fd::cwd(), b"path/to/file", O::RDONLY, 0)?;
let mut buf = vec![0u8; 4096];
let n = file.read_all(&mut buf)?;     // loops until EOF or full
// `file` closes on Drop.

Complete Example

use bun_sys::{File, Fd, O};

pub fn write_file(path: &[u8], data: &[u8]) -> Result<(), bun_sys::Error> {
    let file = File::openat(Fd::cwd(), path, O::WRONLY | O::CREAT | O::TRUNC, 0o664)?;
    file.write_all(data)?;
    Ok(())
}

Why bun_sys?

Aspect bun_sys std::fs / libc
Return Type Maybe<T> with rich Error io::Error (lossy)
Windows Full support with libuv fallback Incomplete/POSIX-ish
Error Info errno, syscall tag, path, fd errno only
EINTR Automatic retry Manual handling
Paths &[u8] (WTF-8 safe) &Path (UTF-8 lossy)

Error Handling with Maybe

bun_sys functions return Maybe<T> = Result<T, bun_sys::Error>. Propagate with ?; convert to a JS exception via bun_sys_jsc::ErrorJsc::to_js:

use bun_sys_jsc::ErrorJsc;
use bun_sys::{File, Fd, O};

let file = match File::openat(Fd::cwd(), path, O::RDONLY, 0) {
    Ok(f) => f,
    Err(err) => return Ok(err.to_js(global)?),
};

bun_sys::Error carries errno, syscall: Tag, and path: Box<[u8]>. To branch on errno:

match bun_sys::unlink(path) {
    Ok(()) => {}
    Err(e) if e.errno() == bun_c::ENOENT => {} // already gone
    Err(e) => return Err(e),
}

Key Types and Functions

  • Fd (bun_core::Fd) — cross-platform file descriptor. Fd::cwd(), Fd::stdin()/stdout()/stderr(), fd.close().
  • File::open(path: &ZStr, flags, mode) / File::openat(dir: Fd, path: &[u8], flags, mode) / File::make_open(...) (creates parent dirs) / File::create(dir, path, truncate)
  • file.read(buf) / read_all(buf) / read_to_end() / read_to_end_small() / write(buf) / write_all(buf)
  • bun_sys::open, read, write, pread, pwrite, stat, fstat, lstat, mkdir, unlink, rename, symlink, chmod — free fns over Fd
  • Open flags: bun_sys::O::RDONLY, O::WRONLY | O::CREAT | O::TRUNC, etc.

Read the full file on GitHub · 97 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 · 97 lines · 42 tokens per session scan A 3f7ccb3f4c27

Subscribe to this mod's changes

rust-system-calls is a skill published in the GitHub repository twaldin/hone (47 stars, last pushed today), licensed MIT. It adds 42 tokens to every session and 1,111 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.