---
name: "axum-tokio-tower-hyper-framework"
description: "Build modular, type-safe web APIs in Rust built directly on Tokio, Tower, and Hyper."
metadata:
  author: "Tokio"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "create axum router"
  - "axum with_state extractor"
  - "tower middleware axum"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Axum Ergonomic Modular Web Framework for Rust

Architects APIs with Axum: Router with nested route merging, type-safe extractors (Path, Query, Json, Extension), state management with with_state, Tower middleware layers, and WebSocket upgrades.

## When to Invoke
Invoke this skill whenever you need to:
- create axum router
- axum with_state extractor
- tower middleware axum

## Execution SOP & Rules
1. Create router: let app = Router::new().route('/users', get(list_users).post(create_user)).with_state(state);
2. Extract state and params: async fn get_user(State(state): State<AppState>, Path(id): Path<u64>) -> Result<Json<User>, StatusCode> { ... }.
3. Attach Tower middleware: app.layer(TraceLayer::new_for_http()).
4. Serve with tokio: let listener = tokio::net::TcpListener::bind('0.0.0.0:3000').await?; axum::serve(listener, app).await?;

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
