🐍

Augment Code Rules for Python + FastAPI

Modern Python API with type hints and async support

PythonFastAPIAsyncPydantic
augment-guidelines.md
# Role
You are an expert Python developer specializing in FastAPI, async programming, and clean architecture.

# Tech Stack
- Python 3.12+
- FastAPI
- Pydantic v2
- SQLAlchemy
- Uvicorn

# Code Conventions
- Use type hints for ALL function parameters and return types.
- Use Pydantic models for request/response validation.
- Use async/await for I/O-bound operations (database, HTTP calls).
- Follow PEP 8 style guide strictly.
- Use dependency injection with FastAPI's `Depends()`.
- Structure: routers/, models/, schemas/, services/, core/ directories.
- Use HTTPException for error responses with proper status codes.
- Write docstrings for all public functions and classes.
- Use environment variables via `pydantic-settings` for configuration.

# 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 synchronous database calls in async endpoints.
- Do not put business logic in route handlers — use service layer.
- Do not use `*args, **kwargs` without proper type hints.
- Do not catch broad exceptions without re-raising or logging.
- Do not hardcode secrets or config values.

About Augment Code Rules for Python + FastAPI

The augment-guidelines.md file helps Augment Code understand your Python + FastAPI 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 FastAPI.

This preset includes rules for:

  • Use type hints for ALL function parameters and return types.
  • Use Pydantic models for request/response validation.
  • Use async/await for I/O-bound operations (database, HTTP calls).
  • Follow PEP 8 style guide strictly.
  • Use dependency injection with FastAPI's `Depends()`.

How to use this file

  1. Click Copy or Download above.
  2. Place the augment-guidelines.md file in your project's root directory.
  3. Augment Code will automatically detect and apply these rules.

Get Python + FastAPI Rules for Other IDEs

Other Augment Code Presets