# CLAUDE.md - this project

Project instructions for Claude Code.

## Project

A Rust + Axum + Docker project.

Stack: Rust + Axum, Docker.

## Commands

- Run: `cargo run`
- Tests: `cargo test`
- Lint: `cargo clippy --all-targets -- -D warnings`
- Format: `cargo fmt`
- Local services: `docker compose up -d`

## How to work in this repo

- Read the relevant files before editing. Follow the patterns already in the codebase over these generic rules.
- Make the smallest change that solves the task. Do not refactor or reformat unrelated code.
- Before saying a task is done, run the type-check, lint and tests listed under Commands and fix what you broke.
- If requirements are ambiguous, ask one clear question instead of guessing.
- Never commit secrets, API keys or `.env` files. Use env vars and keep `.env.example` up to date.
- Do not add a new dependency when the standard library or an existing dependency already covers it.
- Ask before adding, removing or upgrading any dependency.
- Ask before changing database schemas, auth, payments or CI configuration.
- Never delete files, drop data or run destructive commands (`rm -rf`, `git push --force`, `DROP TABLE`) without explicit approval.
- Keep each change under ~200 changed lines where possible; split larger work into steps.

## Rust + Axum

- Code must pass `cargo fmt` and `cargo clippy -- -D warnings`.
- No `unwrap()` or `expect()` outside tests and truly unreachable cases; propagate errors with `?`.
- Library errors use `thiserror`; application glue may use `anyhow`.
- Axum handlers return `Result<impl IntoResponse, AppError>` where `AppError` implements `IntoResponse`.
- Share state with `State<Arc<AppState>>`; do not use global mutable statics.
- Never block the async runtime; use `tokio::task::spawn_blocking` for CPU-heavy or blocking work.
- Prefer borrowing over cloning; justify each `.clone()` in hot paths.

## Docker

- Use multi-stage builds and slim, pinned base images.
- Run the app as a non-root user in the final image.
- Keep a `.dockerignore` that excludes `.git`, `node_modules`, `.env` and build output.
- Never bake secrets into images; pass them at runtime.

## Reference docs

- [Axum docs](https://docs.rs/axum)
- [Rust book](https://doc.rust-lang.org/book/)
- [Dockerfile best practices](https://docs.docker.com/build/building/best-practices/)
