Skip to content
Skills Library
Programming · Building & coding

rocket

/rocket

Rocket Rust web framework. Covers routing, fairings, guards, state, and testing. Use for type-safe, boilerplate-free Rust APIs. USE WHEN: user mentions "rocket", "rust type-safe api", "rocket guards", asks about "rocket fairings", "rocket state", "compile-time route checking", "rust web macros", "rocket testing" DO NOT USE FOR: Axum projects - use `axum` instead, Actix-web projects - use `actix-web` instead, Warp projects - use `warp` instead, non-Rust backends

Licence
MIT
Last repository change
21.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 21.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Rocket Rust web framework. Covers routing, fairings, guards, state, and testing. Use for type-safe, boilerplate-free Rust APIs. USE WHEN: user mentions "rocket", "rust type-safe api", "rocket guards", asks about "rocket fairings", "rocket state", "compile-time route checking", "rust web macros", "rocket testing" DO NOT USE FOR: Axum projects - use `axum` instead, Actix-web projects - use `actix-web` instead, Warp projects - use `warp` instead, non-Rust backends

Triggers from the description

rocketrust type-safe apirocket guardsrocket fairingsrocket statecompile-time route checkingrust web macrosrocket testing
Original author description

Rocket Rust web framework. Covers routing, fairings, guards, state, and testing. Use for type-safe, boilerplate-free Rust APIs. USE WHEN: user mentions "rocket", "rust type-safe api", "rocket guards", asks about "rocket fairings", "rocket state", "compile-time route checking", "rust web macros", "rocket testing" DO NOT USE FOR: Axum projects - use `axum` instead, Actix-web projects - use `actix-web` instead, Warp projects - use `warp` instead, non-Rust backends

How it works

  1. Basic Setup
  2. Routing
  3. Request Guards
  4. State Management
  5. Fairings (Middleware)
  6. When NOT to Use This Skill
  7. Anti-Patterns
  8. Quick Troubleshooting
  9. Production Checklist
  10. Reference Documentation
Original SKILL.md headings · 166 lines, 555 words
SKILL.md preview
---
name: rocket
description: |
  Rocket Rust web framework. Covers routing, fairings, guards, state,
  and testing. Use for type-safe, boilerplate-free Rust APIs.

  USE WHEN: user mentions "rocket", "rust type-safe api", "rocket guards",
  asks about "rocket fairings", "rocket state", "compile-time route checking",
  "rust web macros", "rocket testing"

  DO NOT USE FOR: Axum projects - use `axum` instead, Actix-web projects - use `actix-web` instead,
  Warp projects - use `warp` instead, non-Rust backends
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Rocket Core Knowledge

> **Full Reference**: See [advanced.md](advanced.md) for custom guards (authentication, API key), fairings (CORS, timing), database state, error catchers, and testing patterns.

> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `rocket` for comprehensive documentation.

## Basic Setup

```toml
# Cargo.toml
[dependencies]
rocket = { version = "0.5", features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
```

```rust
#[macro_use] extern crate rocket;

#[get("/")]
fn index() -> &'static str {
    "Hello, World!"
}

#[launch]
fn rocket() -> _ {
    rocket::build().mount("/", routes![index])
}
```

## Routing

```rust
#[get("/users/<id>")]
fn get_user(id: u32) -> String {
    format!("User {}", id)
}

#[post("/users", data = "<user>")]
fn create_user(user: Json<CreateUser>) -> Json<User> {
    Json(User::from(user.into_inner()))
}

#[get("/files/<path..>")]
fn get_file(path: PathBuf) -> Option<NamedFile> {
    NamedFile::open(Path::new("static/").join(path)).ok()
}

// Query parameters
#[derive(FromForm)]
struct Pagination { page: Option<u32>, per_page: Option<u32> }

#[get("/users?<pagination..>")]
fn list_users(pagination: Pagination) -> Json<Vec<User>> {
    let page = pagination.page.unwrap_or(1);
    Json(fetch_users(page, pagination.per_page.unwrap_or(20)))
}

// Mounting
#[launch]
fn rocket() -> _ {
    rocket::build()
        .mount("/", routes![index])
        .mount("/api/v1", routes![list_users, get_user, create_user])
}
```

## Request Guards

```rust
// JSON body
#[post("/users", data = "<user>")]
fn create_user(user: Json<CreateUser>) -> Json<User> {
    Json(User::from(user.into_inner()))
}

// Form data
#[post("/login", data = "<login>")]
fn login(login: Form<LoginForm>) -> String {
    format!("Welcome, {}", login.username)
}

// Cookies
#[get("/session")]
fn session(cookies: &CookieJar<'_>) -> Option<String> {
    cookies.get("session_id").map(|c| c.value().to_string())
}
```

## State Management

```rust
use std::sync::atomic::{AtomicU64, Ordering};

struct HitCount(AtomicU64);

#[get("/count")]
fn count(hit_count: &State<HitCount>) -> String {
    let count = hit_count.0.fetch_add(1, Ordering::Relaxed);
    format!("Hits: {}", count)
}

#[launch]
fn rocket() -> _ {
    rocket::build()
        .manage(HitCount(AtomicU64::new(0)))
        .mount("/", routes![count])
}
```

## Fairings (Middleware)

```rust
use rocket::fairing::AdHoc;

#[launch]
fn rocket() -> _ {
    rocket::build()
        .attach(AdHoc::on_liftoff("Liftoff", |_| Box::pin(async {
            println!("Rocket has launched!");
        })))
}
```

## When NOT to Use This Skill

- **Axum projects** - Axum integrates better with Tower ecosystem
- **Actix-web projects** - Actix has more performance optimizations
- **Stable Rust requirement** - Rocket requires nightly (though v0.5 works on stable)

## Anti-Patterns

| Anti-Pattern | Why It's Bad | Solution |
|--------------|--------------|----------|
| Using `Outcome::Forward` everywhere | Routes become hard to trace | Use specific error types |
| Not using request guards | Repetitive validation code | Create custom `FromRequest` guards |
| Mutable state without sync primitives | Data races | Use `Mutex` or `RwLock` with `State` |
| No database connection pooling | Resource exhaustion | Use `rocket_db_pools` |
| Hardcoded secrets in Rocket.toml | Security risk | Use environment variables |

## Quick Troubleshooting

| Problem | Diagnosis | Fix |
|---------|-----------|-----|
| "Use of unstable library feature" | Wrong Rust version | Install nightly or use Rocket 0.5+ |
| Route not matching | Rank conflict | Specify `rank` attribute or reorder routes |
| Guard returns error | Validation failed | Check guard implementation logic |
| Database error on startup | Wrong connection string | Verify `Rocket.toml` database config |
| CORS issues | No fairing | Add CORS fairing with proper config |

## Production Checklist

- [ ] Rocket.toml configured for production
- [ ] CORS fairing attached
- [ ] Custom error catchers registered
- [ ] Request guards for authentication
- [ ] Database pool configured
- [ ] Health/readiness endpoints
- [ ] Secret key set for release

## Reference Documentation

- [Guards](quick-ref/guards.md)
- [Fairings](quick-ref/fairings.md)
Files in this package (2)
  • SKILL.md 5 KB
  • advanced.md 7 KB

Versions

RepositoryScoreLicence
This page · claude-dev-suite/claude-dev-suite100MIT
TerminalSkills/skills100Apache-2.0
Exxzzent/rocket100MIT
ar4mirez/samuel100MIT

Database snapshot: 13.11.2026 · package version 13765f59cd5d (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100actix-web
    Actix-web Rust web framework. Covers routing, extractors, middleware, state management, and WebSocket. Use for high-performance Rust APIs. USE WHEN: user mentions "actix-web", "actix", "rust web framework", "rust api", asks about "rust async web", "actix middleware", "actix…
  • 100warp
    Warp Rust web framework using filters. Covers routing, filters, rejection, WebSocket, and TLS. Use for composable, type-safe Rust APIs. USE WHEN: user mentions "warp", "rust filters", "composable rust api", asks about "warp filters", "warp rejection", "filter composition rust",…
  • 100actix-web
    Actix Web is a high-performance async web framework for Rust. It provides type-safe extractors, routing, middleware and a built-in test harness for building fast, memory-safe HTTP APIs. Use when a user asks to build a Rust REST API, add an Actix handler or middleware, handle…
  • 95rs-domain-web
    Use when building web services. Keywords: web server, HTTP, REST API, GraphQL, WebSocket, axum, actix, warp, rocket, tower, hyper, reqwest, middleware, router, handler, extractor, state management, authentication, authorization, JWT, session, cookie, CORS, rate limiting
  • 100rust-web
    Design, implement, test, and operate production Rust server-side HTTP services, including axum, Actix Web, routing, extractors, application state, error mapping, middleware order, timeouts, body limits, observability, graceful shutdown, and database boundaries. Use when users…
  • 100rust-actix-web
    Use this skill when implementing blazingly fast, multi-threaded asynchronous HTTP services in Rust using Actix Web.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.