From fuse-rust
Use when building a REST/HTTP backend in Rust — routing, extractors, shared state, middleware, error responses, database access, and structured logging. Covers the 2026 standard stack axum + tokio + sqlx + tracing, plus honest alternatives (sea-orm, diesel). Do NOT use for raw async/concurrency questions (rust-async-concurrency) or crate selection across domains (rust-ecosystem-crates).
How this skill is triggered — by the user, by Claude, or both
Slash command
/fuse-rust:rust-web-backendThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Before building the service, spawn in parallel:
Before building the service, spawn in parallel:
After building, run fuse-ai-pilot:sniper.
| Layer | Crate | Why |
|---|---|---|
| Runtime | tokio | De-facto async runtime; everything targets it |
| HTTP framework | axum 0.8.x | Tower-based, extractor ergonomics, minimal magic |
| Middleware | tower / tower-http | Composable layers (trace, cors, timeout, compression) |
| Database | sqlx 0.9 | Async, query! compile-time-checked SQL, no DSL; Postgres/MySQL/SQLite |
| Observability | tracing + tracing-subscriber | Structured, async-aware spans and logs |
Honest alternatives: sea-orm (ActiveRecord-style ORM, higher-level than sqlx), diesel 2.x (mature, synchronous — needs spawn_blocking or a sync pool in async apps). Prefer sqlx for the standard stack; reach for these only when their model fits.
/{id}, not /:id — /*rest became /{*rest}. The old matchit syntax will not compile.IntoResponse — never .unwrap() in a handler. Map domain errors to a status + body via one app error type.State<T>, wrapped once — put the pool/config in an Arc-friendly struct; extract it with State, do not use globals.sqlx::query! needs DATABASE_URL at compile time — or a committed .sqlx/ offline cache (cargo sqlx prepare). Plan this before CI.#[async_trait] on axum extractors — 0.8 uses RPITIT; custom FromRequestParts impls must drop the macro.| Topic | Reference | When to Consult |
|---|---|---|
| Architecture | architecture.md | Router, extractors, State, tower middleware layout |
| Error handling | error-handling.md | App error type + IntoResponse |
| Database | database.md | sqlx pool, query!, migrations, alternatives |
| Observability | observability.md | tracing spans, subscriber, request logging |
| Template | When to Use |
|---|---|
| rest-service.md | Complete minimal REST service (router + state + handlers + errors + tracing) |
let app = Router::new()
.route("/users", get(list).post(create))
.route("/users/{id}", get(show)) // NOT /:id
.with_state(state);
→ See architecture.md
let user = sqlx::query_as!(User, "SELECT id, name FROM users WHERE id = $1", id)
.fetch_optional(&pool)
.await?;
→ See database.md
IntoResponse.tower-http.query!/query_as!./:id route syntax (0.7 and earlier only)..unwrap() in handlers — return a typed error.#[async_trait] removal (fetched 2026-07-05)npx claudepluginhub fusengine/agents --plugin fuse-rustImplements and reviews Axum 0.8+ APIs in Rust — routing, State, extractors, Tower middleware, typed errors, WebSockets, CORS, timeouts, and production hardening. Use when building or changing Axum backends, handlers, middleware, or real-time WS endpoints. Do not use for SvelteKit/frontends (rc-sveltekit), SQLx/Postgres data layer alone (rc-sqlx), Rust language idioms — ownership, error types, trait design (rc-rust) — or general React/Next work.
Provides Rust backend patterns and guides for architecture, databases (Diesel, SeaORM, sqlx), APIs (Actix Web, Axum, Rocket), security (JWT, middleware), error handling (thiserror, anyhow), testing, and performance. Auto-activates on Cargo.toml, main.rs, or Actix/Axum imports.
Provides domain constraints and design patterns for building web services in Rust using axum, actix-web, warp, or rocket. Covers async handlers, state management, middleware, and authentication.