Skip to content
Development
Command

/rtk-rust-safety-net

Defensive idioms when generating Rust code.

From plugin
rtk
80k13 skills6 agents13 commands
Install
$ npx -y skills add rtk-ai/rtk --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/rtk-rust-safety-net

Context preview

What this command does when you run it.

Defensive idioms when generating Rust code.

Command definition

rtk-rust-safety-net.md

Defensive idioms when generating Rust code.

Rust safety net

When writing Rust:

  • Avoid `.unwrap()` and `.expect()` outside of tests, build scripts,

and at-startup code where a panic IS the failure mode. In every other path return `Result<T, E>` (custom error or `anyhow::Error`).

  • `clone()` is acceptable in glue code; in hot paths, prefer `&str`

over `String` and slice references over `Vec` clones.

  • `unsafe` requires a SAFETY comment immediately above explaining why

the invariants hold. No `unsafe` for "performance" without a benchmark.

  • `mem::transmute`, `from_raw_parts` on user-provided lengths, and

uninitialized memory are forbidden in business code.

  • For async: avoid blocking calls (std::fs, std::sync::Mutex held

across .await) inside an async fn. Use tokio::fs / tokio::sync.

Ships withrtk

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Get the whole plugin

Other commands on rtk.