Home › Rust › Rust library crate AGENTS.md

Rust library crate AGENTS.md

AGENTS.md for publishable Rust library crates: API design, error types, features, MSRV, docs, and semver checks.

AGENTS.mdRust

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

AGENTS.mdDownload  
# AGENTS.md: Rust library crate

## Commands
`cargo build` · `cargo test --all-features` · `cargo clippy --all-targets --all-features -- -D warnings` · `cargo fmt --check` · `cargo doc --no-deps` · `cargo semver-checks` (before releases)

## API design
- Keep the public surface small and intentional; re-export from `lib.rs`. Mark exhaustive-looking enums/structs `#[non_exhaustive]` if they may grow.
- Accept generic, borrowed inputs (`impl AsRef<Path>`, `&str`, `impl IntoIterator`) and return owned, concrete types.
- Errors: a crate `Error` enum with `thiserror`; implement `std::error::Error` and keep sources. Don't expose `anyhow` in public APIs, and never panic on bad input; `unwrap` only on proven invariants with a comment.
- Builders for types with many optional settings.
- Implement common traits where they make sense: `Debug`, `Clone`, `PartialEq`, `Default`, `Display`, `serde` behind a `serde` feature.

## Crate hygiene
- `#![warn(missing_docs)]`; every public item has rustdoc with an example that compiles as a doc test.
- Optional dependencies behind features; default features minimal. Features must be additive.
- Declare `rust-version` (MSRV) in `Cargo.toml` and don't use newer std APIs without bumping it.
- No `unsafe` unless necessary; each block gets a `// SAFETY:` comment.
- Update `CHANGELOG.md` for user-visible changes.

## Never
Run `cargo publish` or bump the major version without approval.

More: all Rust rules · all AGENTS.md rules

Related rules

Rust Actix Web rules

Cursor rules for Actix Web 4 services in Rust: app state, extractors, ResponseError, middleware, and integration tests.

CursorRust

Rust async (Tokio) .claude/rules file

A path-scoped Claude Code rules file for async Rust on Tokio: no blocking, cancellation safety, locks, and tasks.

Claude Code (CLAUDE.md)Rust

Rust Axum web API rules

Cursor rules for Rust web services with Axum 0.8, Tokio, sqlx, typed errors, and tracing.

CursorRust

Rust CLI CLAUDE.md

CLAUDE.md for Rust command-line tools built with clap, anyhow and thiserror.

Claude Code (CLAUDE.md)Rust

REST API design AGENTS.md

AGENTS.md for designing consistent HTTP/JSON APIs: resource naming, status codes, errors, pagination, and versioning.

AGENTS.mdAPI design

Blazor (.NET 10) AGENTS.md

AGENTS.md for Blazor Web Apps on .NET 10: render modes, components, forms and validation, state, and bUnit tests.

AGENTS.md.NET / ASP.NET Core

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.