Builds high-performance HTTP APIs in Rust with Actix Web: scaffolding, routing, JSON extractors, middleware, and release builds.
Agentic Workflow: Read -> Reason -> Act (actix-web)
You are Actix Web (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for actix-web
- Domain: Builds high-performance HTTP APIs in Rust with Actix Web: scaffolding, routing, JSON extractors, middleware, and release builds.
- project-scaffold: Create and configure a new Actix Web project with Cargo. —
cargo new my-api
- serve-and-test: Build, run, lint, and test the Actix server. —
cargo build --release
- Check
knowledge and prerequisites: cargo
2. Reason — think for actix-web
- For
project-scaffold: Create and configure a new Actix Web project with Cargo. — decide which checks to run
- For
serve-and-test: Build, run, lint, and test the Actix server. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with actix-web tools
- Tools:
Glob, Grep, Read, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
actix-web:cabea6b9
Actix Web
What this skill does
Develops HTTP services in Rust with Actix Web: scaffolding projects, defining routes and state, extracting typed JSON payloads, adding middleware, and producing release binaries.
When to use
- Building a new Rust REST API
- Adding JSON endpoints, middleware, or WebSockets to an Actix app
- Tuning a server build for production
Real commands
cargo new my-api
cargo add actix-web serde --features serde/derive
cargo run
curl http://localhost:8080/health
# Production build
cargo build --release
ACTIX_WORKERS=4 ./target/release/my-api
# Lint and test
cargo clippy -- -D warnings
cargo test
Minimal server
use actix_web::{get, App, HttpServer, Responder};
#[get("/health")]
async fn health() -> impl Responder { "ok" }
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(health))
.bind(("127.0.0.1", 8080))?
.run()
.await
}
JSON endpoint
#[derive(Deserialize)]
struct User { name: String }
#[post("/users")]
async fn create(user: web::Json<User>) -> HttpResponse {
HttpResponse::Created().json(user.0)
}
Testing
- Unit-test handlers with actix_web::test::init_service + TestRequest
- Run
cargo test for handlers and cargo clippy in CI
Best practices
- Put app state behind web::Data instead of statics
- Use --release builds in production; debug builds are much slower
- Set ACTIX_WORKERS to the number of cores
Capabilities
project-scaffold
Create and configure a new Actix Web project with Cargo.
Parameters:
features (string): Cargo features for actix-web (openssl, client)
crate (string): Additional crate, e.g. actix-cors or serde_json
Commands:
cargo new my-api
cargo add actix-web
cargo add serde --features derive
cargo build
cargo run
Examples:
- cargo new my-api && cargo add actix-web@4
- cargo add actix-web --features openssl
- cargo add actix-cors
serve-and-test
Build, run, lint, and test the Actix server.
Parameters:
port (number): Bind port (default 8080)
workers (number): Actix worker threads via ACTIX_WORKERS env
Commands:
cargo build --release
cargo clippy -- -D warnings
cargo test
cargo run --release
curl -s http://localhost:8080/health
Examples:
- cargo clippy --all-targets -- -D warnings
- cargo test -- --nocapture
- cargo build --release && ./target/release/my-api
References
1---2name: "actix-web"3description: "Builds high-performance HTTP APIs in Rust with Actix Web: scaffolding, routing, JSON extractors, middleware, and release builds. Use when working with project scaffold, serve and test, api or when the user mentions project scaffold, serve and test, api."4license: "MIT"5compatibility: "Requires cargo. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/actix-web8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(cargo:*) Bash(curl:*)"12---1314Builds high-performance HTTP APIs in Rust with Actix Web: scaffolding, routing, JSON extractors, middleware, and release builds.1516## Agentic Workflow: Read -> Reason -> Act (actix-web)1718You are **Actix Web** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `actix-web`21- Domain: Builds high-performance HTTP APIs in Rust with Actix Web: scaffolding, routing, JSON extractors, middleware, and release builds.22- **project-scaffold**: Create and configure a new Actix Web project with Cargo. — `cargo new my-api`23- **serve-and-test**: Build, run, lint, and test the Actix server. — `cargo build --release`24- Check `knowledge` and `prerequisites: cargo`2526### 2. Reason — think for `actix-web`27- For `project-scaffold`: Create and configure a new Actix Web project with Cargo. — decide which checks to run28- For `serve-and-test`: Build, run, lint, and test the Actix server. — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `actix-web` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `actix-web:cabea6b9`3536# Actix Web3738## What this skill does3940Develops HTTP services in Rust with Actix Web: scaffolding projects, defining routes and state, extracting typed JSON payloads, adding middleware, and producing release binaries.4142## When to use4344- Building a new Rust REST API45- Adding JSON endpoints, middleware, or WebSockets to an Actix app46- Tuning a server build for production4748## Real commands4950```bash51cargo new my-api52cargo add actix-web serde --features serde/derive5354cargo run55curl http://localhost:8080/health5657# Production build58cargo build --release59ACTIX_WORKERS=4 ./target/release/my-api6061# Lint and test62cargo clippy -- -D warnings63cargo test64```6566## Minimal server6768```rust69use actix_web::{get, App, HttpServer, Responder};7071#[get("/health")]72async fn health() -> impl Responder { "ok" }7374#[actix_web::main]75async fn main() -> std::io::Result<()> {76 HttpServer::new(|| App::new().service(health))77 .bind(("127.0.0.1", 8080))?78 .run()79 .await80}81```8283## JSON endpoint8485```rust86#[derive(Deserialize)]87struct User { name: String }8889#[post("/users")]90async fn create(user: web::Json<User>) -> HttpResponse {91 HttpResponse::Created().json(user.0)92}93```9495## Testing9697- Unit-test handlers with actix_web::test::init_service + TestRequest98- Run `cargo test` for handlers and `cargo clippy` in CI99100## Best practices101102- Put app state behind web::Data<T> instead of statics103- Use --release builds in production; debug builds are much slower104- Set ACTIX_WORKERS to the number of cores105106## Capabilities107108### project-scaffold109Create and configure a new Actix Web project with Cargo.110111**Parameters:**112- `features` (string): Cargo features for actix-web (openssl, client)113- `crate` (string): Additional crate, e.g. actix-cors or serde_json114115**Commands:**116- `cargo new my-api`117- `cargo add actix-web`118- `cargo add serde --features derive`119- `cargo build`120- `cargo run`121122**Examples:**123- cargo new my-api && cargo add actix-web@4124- cargo add actix-web --features openssl125- cargo add actix-cors126127### serve-and-test128Build, run, lint, and test the Actix server.129130**Parameters:**131- `port` (number): Bind port (default 8080)132- `workers` (number): Actix worker threads via ACTIX_WORKERS env133134**Commands:**135- `cargo build --release`136- `cargo clippy -- -D warnings`137- `cargo test`138- `cargo run --release`139- `curl -s http://localhost:8080/health`140141**Examples:**142- cargo clippy --all-targets -- -D warnings143- cargo test -- --nocapture144- cargo build --release && ./target/release/my-api145146## References147- [Actix Web Docs](https://actix.rs/docs)148- [Actix Web API Reference](https://docs.rs/actix-web)149- [Actix Examples](https://github.com/actix/examples)