Best use case
nix-rust-leptos is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Conventions for building Leptos CSR apps with Nix (crane + Trunk).
Teams using nix-rust-leptos should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/nix-rust-leptos/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How nix-rust-leptos Compares
| Feature / Agent | nix-rust-leptos | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Conventions for building Leptos CSR apps with Nix (crane + Trunk).
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Leptos CSR + Nix Build
## Use Trunk for production builds
Don't manually run wasm-bindgen + wasm-opt + hash-rename. Use `craneLib.buildTrunkPackage` which delegates to Trunk — it handles WASM compilation, wasm-bindgen, wasm-opt, Tailwind CSS, asset hashing, SRI, and cross-reference rewriting automatically.
## Workspace layout
Trunk expects to run from the crate directory containing `index.html` and `Cargo.toml`. In a workspace, use `postUnpack` to cd into the client crate:
```nix
clientDist = craneLib.buildTrunkPackage {
pname = "my-client";
inherit src;
cargoExtraArgs = "-p my-client";
wasm-bindgen-cli = pkgs.wasm-bindgen-cli;
nativeBuildInputs = [ pkgs.tailwindcss ]; # not auto-included
postUnpack = ''
cd $sourceRoot/client
sourceRoot="."
'';
};
```
## Source filtering
Crane's default source filter strips non-Rust files. Preserve HTML, CSS, and JS for Trunk:
```nix
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
(craneLib.fileset.commonCargoSources ./.)
(lib.fileset.fileFilter (f: lib.any f.hasExt [ "html" "css" "js" ]) ./.)
];
};
```
## Version matching
`wasm-bindgen-cli` in nixpkgs must match `wasm-bindgen` in `Cargo.lock` exactly. Check with `nix eval --raw 'nixpkgs#wasm-bindgen-cli.version'`.
## Tailwind CSS
Use `<link data-trunk rel="tailwind-css" href="input.css" />` in index.html. Trunk processes it automatically. Add `pkgs.tailwindcss` to `nativeBuildInputs` (not auto-included by crane).
## leptos-use for browser APIs
Use the `leptos-use` crate instead of raw `web_sys` for browser APIs. It provides reactive hooks with automatic cleanup on component unmount — no more `Closure::wrap` + `.forget()` memory leaks.
Key hooks:
- `use_resize_observer` — replaces manual `ResizeObserver::new()` + `Closure::wrap` + `forget`
- `use_event_listener` / `use_event_listener_with_options` — replaces manual `add_event_listener` + `Closure::wrap` + `forget`
- `use_websocket` / `use_websocket_with_options` — replaces manual `WebSocket::new()` + callback wiring
- `on_cleanup` — registers component unmount logic (dispose resources, close connections)
Version compatibility: `leptos-use` 0.18.x works with Leptos 0.8.x. Use the `codee` crate for WebSocket codecs (e.g. `codee::string::FromToStringCodec`).
For JS objects that aren't `Send + Sync` (like wasm-bindgen types), wrap in `send_wrapper::SendWrapper` when passing to leptos-use callbacks.
## Module structure for JS interop
Keep non-Leptos JS helpers (raw `web_sys` calls, `wasm_bindgen` utilities, localStorage, animation frames) in a separate `bridge.rs` module. Leptos components should only use Leptos reactive primitives and leptos-use hooks — not raw browser APIs directly.Related Skills
vhs
Techniques for creating deterministic terminal demo screencasts with VHS
programming-essay
Write a programming essay or blog post in the voice of the canon — Spolsky, Yegge, Graham, Mickens, Dijkstra, Brooks, Nystrom, Kleppmann, patio11. Invoke when the user wants to argue an idea about software, architecture, languages, or the craft — not a debugging war story (use debugging-story for that), not a tutorial, not a release note. The audience is working developers worldwide with taste and strong opinions of their own.
nix-typescript
pnpm + Nix build conventions. Covers fetchPnpmDeps hash management and dependency workflow.
nix-justfile
Conventions for writing justfile recipes in Nix-based projects.
nix-health
Use this when diagnosing or fixing a user's Nix installation — checks flakes, version, caches, max-jobs, direnv, rosetta, trusted-users, and shell config
nix-haskell
Use this when working on a Haskell project with Nix. Covers haskell-flake setup, adding/overriding dependencies, package settings, and devShell configuration.
nix-flake
Use this when writing or editing a flake.nix. Covers flake-parts, perSystem, formatter, shell scripts, and package conventions.
nix-ci
Use this when setting up CI for a GitHub repository — offers GitHub Actions or Vira depending on the project
frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
cargo-watch
Run cargo-watch in the background for continuous clippy feedback during code editing.
rust
Rust ecosystem = cargo + rustc + clippy + rustfmt.
reverse-engineering-rust-malware
Reverse engineer Rust-compiled malware using IDA Pro and Ghidra with techniques for handling non-null-terminated strings, crate dependency extraction, and Rust-specific control flow analysis.