plugins/rust-expert/skills/rust-web-backend/SKILL.md
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).
npx skillsauth add fusengine/agents rust-web-backendInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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)testing
Copy self-audit and ban-lists — filler verbs/hype adjectives, slop placeholder names, fake-precise numbers, Title Case headlines, humor in error copy ('Oops!'), em-dash crutch, one copy register per page.
development
Logged-in web apps — dashboards, auth flows, settings, onboarding, data tables, command palettes, modals, toasts. Register `product`: density and glance-speed over marketing polish, no hero/CTA-tricks, every data surface covers empty/loading/error explicitly, tables and dataviz follow preattentive-processing rules.
development
Marketing sites, landing pages, campaign pages — register `brand` (design IS the product). Structure comes from the register's POV + a macrostructure pick, never from copying an inspiration site's section flow. Hero discipline, deviated section order, asymmetric grids, and a silhouette lookalike-test gate before ship.
development
Token-strategy core — OKLCH color rules, neutral tinting, accent-commitment levels, type scale, 8pt spacing grid, touch targets, and the canonical output format of design-system.md (the file the harness gates on). This is routing step 1 of design-method/SKILL.md — read it before design-web/design-webapp/design-ios/design-android, before picking or auditing a single color/type/spacing value.