Specialist skill for production Axum-based Rust web services. Use when task involves Axum routers, extractors, typed application state, Tower middleware, or Tokio async service lifecycle. Triggers — Axum, Tower, tower-http, Tokio, Router, handler, extractor, IntoResponse, graceful shutdown. Negative trigger — CLI tools, procedural macros crate, WASM-only targets, pure library crates with no HTTP transport.
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
Specialist skill for production Axum-based Rust web services. Use when task involves Axum routers, extractors, typed application state, Tower middleware, or Tokio async service lifecycle. Triggers — Axum, Tower, tower-http, Tokio, Router, handler, extractor, IntoResponse, graceful shutdown. Negative trigger — CLI tools, procedural macros crate, WASM-only targets, pure library crates with no HTTP transport.
Identify the Axum version, Tokio runtime flavour (#[tokio::main] vs. manual Builder), and project layout (src/main.rs, src/lib.rs, src/routes/, src/handlers/).
Keep transport (handlers/extractors), business logic (domain services), and persistence (repository traits + impls) in separate modules; never leak axum::extract or http types past the handler boundary.
Define application-wide shared resources in a typed AppState struct passed via Router::with_state; use FromRef for sub-state extraction instead of wrapping everything in Arc<Mutex<…>>.
Validate and deserialize request input through Axum extractors (Json<T>, Query<T>, Path<T>) with serde derive; apply additional validation (e.g., validator crate) before entering business logic.
Implement a unified error type that implements IntoResponse; map internal errors to appropriate HTTP status codes in one place, never expose internal details or backtraces to clients.
Layer Tower middleware deliberately: TraceLayer → request-id → CORS → auth → rate-limit → body-limit → application middleware; apply layers via Router::layer or ServiceBuilder.
Keep all I/O operations (sqlx, reqwest, HTTP clients, file I/O) fully async on Tokio; never call blocking code on the async executor — use tokio::task::spawn_blocking for CPU-bound or synchronous FFI work.
Propagate cancellation through CancellationToken or tokio::select! where long-running tasks need cooperative shutdown; respect request timeouts via tower_http::timeout::TimeoutLayer.
Emit structured traces with tracing and tracing-subscriber; expose /health and /ready endpoints; propagate OpenTelemetry context when distributed tracing is present.
Implement graceful shutdown: bind with tokio::net::TcpListener, serve via axum::serve(…).with_graceful_shutdown(signal), and drain in-flight connections before exiting the Tokio runtime.
Run cargo clippy -- -D warnings, cargo fmt --check, and cargo test before marking the task complete; confirm no new unsafe blocks without justification.
Reference Guide
Topic
Reference
Load When
Delivery checklist
references/checklist.md
Any Axum service feature, refactor, or review
Constraints
Do not mix HTTP transport concerns, domain logic, and persistence in one handler function or module.
Do not hold MutexGuard or any lock across .await points; prefer message passing or tokio::sync primitives.
Do not use unwrap() / expect() on fallible operations in handler paths; convert to the unified error type.
Do not spawn detached tasks (tokio::spawn) from handlers without lifecycle tracking (e.g., TaskTracker, JoinSet).
Do not expose raw sqlx::Error, reqwest::Error, or panic backtraces in HTTP responses.
Treat dependency upgrades, middleware reordering, extractor ordering changes, and Send/Sync bound modifications as high-risk.