agentsclimarketplace

Rust web backend

Skill fusengine/agents/plugins/rust-expert/skills/rust-web-backend

Use when building a REST/HTTP backend in Rust — axum routing, extractors, shared state, middleware, error responses, sqlx database access. Not for raw async/concurrency (rust-async-concurrency).From its SKILL.md

Install
npx -y skills add fusengine/agents --skill rust-web-backend

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

5.1 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it

<objective> This skill covers the 2026 standard Rust web-backend stack: axum 0.8.x routing (including the /{id} path syntax that replaced /:id) and extractors, sharing state via State<T>, composing tower-http middleware (trace, cors, timeout, compression), mapping domain errors to IntoResponse instead of unwrapping in handlers, and sqlx 0.9 database access with compile-time-checked query!/query_as! (including the .sqlx/ offline cache for CI).

It also names the honest alternatives — sea-orm for an ActiveRecord-style ORM, diesel for a mature but synchronous alternative needing spawn_blocking — and structured observability via tracing.

Out of scope: raw async/concurrency primitives (channels, locks, task spawning) belong to rust-async-concurrency; cross-domain crate selection belongs to rust-ecosystem-crates. </objective>

Rust Web Backend

Agent Workflow (MANDATORY)

Before building the service, spawn in parallel:

  1. fuse-ai-pilot:explore-codebase — detect the existing router, state, and DB layer
  2. fuse-ai-pilot:research-expert — verify current axum/sqlx APIs via Context7/Exa (axum 0.8 changed several APIs)
  3. mcp__context7__query-docs — pull exact extractor/handler signatures

After building, run fuse-ai-pilot:sniper.


The 2026 standard stack

LayerCrateWhy
RuntimetokioDe-facto async runtime; everything targets it
HTTP frameworkaxum 0.8.xTower-based, extractor ergonomics, minimal magic
Middlewaretower / tower-httpComposable layers (trace, cors, timeout, compression)
Databasesqlx 0.9Async, query! compile-time-checked SQL, no DSL; Postgres/MySQL/SQLite
Observabilitytracing + tracing-subscriberStructured, 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.


Critical Rules

  1. axum 0.8 path syntax is /{id}, not /:id/*rest became /{*rest}. The old matchit syntax will not compile.
  2. Errors implement IntoResponse — never .unwrap() in a handler. Map domain errors to a status + body via one app error type.
  3. Share state with State<T>, wrapped once — put the pool/config in an Arc-friendly struct; extract it with State, do not use globals.
  4. sqlx::query! needs DATABASE_URL at compile time — or a committed .sqlx/ offline cache (cargo sqlx prepare). Plan this before CI.
  5. No #[async_trait] on axum extractors — 0.8 uses RPITIT; custom FromRequestParts impls must drop the macro.

Reference Guide

Concepts

TopicReferenceWhen to Consult
Architecturearchitecture.mdRouter, extractors, State, tower middleware layout
Error handlingerror-handling.mdApp error type + IntoResponse
Databasedatabase.mdsqlx pool, query!, migrations, alternatives
Observabilityobservability.mdtracing spans, subscriber, request logging

Templates

TemplateWhen to Use
rest-service.mdComplete minimal REST service (router + state + handlers + errors + tracing)

Quick Reference

Router with the 0.8 path syntax

let app = Router::new()
    .route("/users", get(list).post(create))
    .route("/users/{id}", get(show))   // NOT /:id
    .with_state(state);

→ See architecture.md

Compile-time-checked query

let user = sqlx::query_as!(User, "SELECT id, name FROM users WHERE id = $1", id)
    .fetch_optional(&pool)
    .await?;

→ See database.md


Best Practices

DO

  • Keep one app error type that implements IntoResponse.
  • Layer cross-cutting concerns (trace, timeout, cors) via tower-http.
  • Verify queries at compile time with query!/query_as!.

DON'T

  • Use /:id route syntax (0.7 and earlier only).
  • .unwrap() in handlers — return a typed error.
  • Reach for diesel in async code without accounting for its sync nature.

Sources (verified)

  • tokio.rs/blog/2025-01-01-announcing-axum-0-8-0 — path syntax, Option extractor, #[async_trait] removal (fetched 2026-07-05)
  • crates.io — axum 0.8.9, sqlx 0.9.0, tokio 1.52.3, tracing 0.1.44 (current at fetch)

What ships with it: 5 files

18.8 KB alongside SKILL.md

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.