Home › Bevy (Rust) › Bevy game engine AGENTS.md
Bevy game engine AGENTS.md
AGENTS.md for Bevy (0.16+) games in Rust: ECS systems, plugins, required components, and fast dev builds.
AGENTS.mdBevy (Rust)
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.
AGENTS.mdDownload # AGENTS.md: Bevy game (Rust)
## Commands
- `cargo run` (dev uses the `dynamic_linking` feature if configured) · `cargo test` · `cargo clippy -- -D warnings` · `cargo fmt --check`
- Check `Cargo.toml` for the exact Bevy version before writing code; Bevy's APIs change between minor releases. Follow that version's migration guide, not older examples.
## ECS rules
- Group features into plugins (`impl Plugin for CombatPlugin`) registered in `main.rs`.
- Data lives in components (small structs with `#[derive(Component)]`); global data in `Resource`s. No game state in statics.
- Spawn with component bundles via required components (`#[require(Transform, Sprite)]`) instead of the deprecated `*Bundle` structs.
- Systems are small functions taking queries: `fn move_player(time: Res<Time>, mut q: Query<&mut Transform, With<Player>>)`. Use `delta_secs()`.
- Order with `.chain()`, `.before()/.after()`, or system sets; run conditionally with `run_if(in_state(GameState::Playing))`.
- Use `States` for menus/game/pause and `OnEnter`/`OnExit` schedules for setup/cleanup.
- Communicate between systems with events/messages or observers, not shared mutable resources everywhere.
- Use `Query::single()` style results and handle the error instead of panicking.
- Load assets via `AssetServer` handles once; don't reload per frame.
## Don't
Don't fight the borrow checker with `unsafe` or by cloning large data each frame; split the query or use `ParamSet`.