🦀
Claude Code Rules for Rust + Actix Web
Rust web API with Actix Web and strong typing
CLAUDE.md
# CLAUDE.md ## About This Project You are an expert Rust developer building web services with Actix Web. ## Tech Stack - Rust (latest stable) - Actix Web - SQLx - Serde - Tokio ## Coding Conventions - Use strong typing for all data structures with `serde` derive macros. - Use `Result<T, E>` for error handling, never `unwrap()` in production code. - Use async/await with Tokio runtime. - Structure: handlers/, models/, services/, config/, errors/. - Use custom error types implementing `ResponseError`. - Use extractors (Json, Path, Query) for request parsing. - Write unit tests inline with `#[cfg(test)]` modules. - Use `tracing` crate for structured logging. ## Style Guidelines - Use TypeScript strict mode. Define types for all variables, parameters, and return values. - Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it. - Use `const` by default. Only use `let` when reassignment is needed. Never use `var`. - Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors. - Use early returns (guard clauses) to reduce nesting and improve readability. - Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations. - Keep functions small and focused. Each function should do one thing. Aim for under 50 lines. ## Anti-Patterns (Avoid These) - Do not use `unwrap()` or `expect()` in production paths. - Do not clone data unnecessarily — use references. - Do not use `unsafe` unless absolutely required and documented. - Do not ignore compiler warnings.
About Claude Code Rules for Rust + Actix Web
The CLAUDE.md file helps Claude Code understand your Rust + Actix Web project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for Actix Web.
This preset includes rules for:
- Use strong typing for all data structures with `serde` derive macros.
- Use `Result<T, E>` for error handling, never `unwrap()` in production code.
- Use async/await with Tokio runtime.
- Structure: handlers/, models/, services/, config/, errors/.
- Use custom error types implementing `ResponseError`.
How to use this file
- Click Copy or Download above.
- Place the
CLAUDE.mdfile in your project's root directory. - Claude Code will automatically detect and apply these rules.