diff --git a/litellm-rust/AGENTS.md b/litellm-rust/AGENTS.md index 86dd2c92744..398eec4685c 100644 --- a/litellm-rust/AGENTS.md +++ b/litellm-rust/AGENTS.md @@ -15,3 +15,12 @@ Dependency direction (acyclic): litellm-core ← litellm-ai-gateway ← litellm- Adding a crate: default to a MODULE. New crate ONLY on a real trigger — separate artifact (binary/cdylib), proc-macro, shared foundation, or publishable standalone. A new provider or route is none of these. Adding a crate fails crates/core/tests/workspace_crate_allowlist.rs until you update its allowlist and this file — intentional. + +## Style + +All Rust in `litellm-rust/` follows the official Rust Style Guide: +https://doc.rust-lang.org/style-guide/ + +`rustfmt` implements its formatting by default, so run `cargo fmt` before committing; CI gates every PR on `cargo fmt --check`. Do not hand-format against rustfmt or add a `rustfmt.toml` that diverges from the default style. + +Beyond formatting, follow the guide's naming and idiom conventions rustfmt cannot auto-apply: `snake_case` items/functions/modules, `UpperCamelCase` types/traits/variants, `SCREAMING_SNAKE_CASE` constants/statics (acronyms as one word, e.g. `HttpClient`), and the import grouping and item ordering it prescribes. See CLAUDE.md for the detailed version. diff --git a/litellm-rust/CLAUDE.md b/litellm-rust/CLAUDE.md index 7c723e570ef..dac8ed1b861 100644 --- a/litellm-rust/CLAUDE.md +++ b/litellm-rust/CLAUDE.md @@ -77,6 +77,26 @@ such as `ai-gateway`, router hosts, or standalone servers: - Avoid `expect`/`unwrap` in server startup and request paths unless the panic is impossible by construction and documented. +## Rust Style Guide + +All Rust in `litellm-rust/` follows the official Rust Style Guide: +https://doc.rust-lang.org/style-guide/ + +`rustfmt` implements the guide's formatting rules by default, so the mechanical +side is enforced for you: run `cargo fmt` before committing and CI gates every +PR on `cargo fmt --check` (see Checks). Do not hand-format against rustfmt or add +a `rustfmt.toml` that diverges from the default style; the default style *is* the +guide. + +The guide also covers conventions rustfmt cannot auto-apply; follow these too: +- Naming: `snake_case` for items, functions, and modules; `UpperCamelCase` for + types, traits, and enum variants; `SCREAMING_SNAKE_CASE` for constants and + statics; acronyms count as one word (`HttpClient`, not `HTTPClient`). +- Ordering and grouping the guide prescribes: imports grouped std / external / + crate-local, derives before other attributes, and consistent item order. +- Idioms the guide recommends over the formatter fighting you (e.g. prefer + restructuring an over-long expression rather than forcing an awkward wrap). + ## Constants Magic numbers and fixed strings go in a crate-level `constants.rs`, never