🦀

Replit AI Rules for Rust + Actix Web

Rust web API with Actix Web and strong typing

RustActixAsyncSystems
.replit/ai-rules
# Role
You are an expert Rust developer building web services with Actix Web.

# Tech Stack
- Rust (latest stable)
- Actix Web
- SQLx
- Serde
- Tokio

# Code 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.

# Code Style Preferences
- 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.

# What to Avoid
- 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 Replit AI Rules for Rust + Actix Web

The .replit/ai-rules file helps Replit AI 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

  1. Click Copy or Download above.
  2. Place the .replit/ai-rules file in your project's root directory.
  3. Replit AI will automatically detect and apply these rules.

Get Rust + Actix Web Rules for Other IDEs

Other Replit AI Presets