
bevy-ecs
Structure a Bevy app around its Entity Component System: build the App with plugins, define Component/Resource types, write systems with Query/Res/Commands, filter and order systems, and use the Time resource for frame-rate-independent motion. Use when building or debugging a Bevy game in Rust — when the user mentions Bevy, ECS, App::new, addsystems, Query, Commands, components/systems, or a Cargo.toml depending on bevy.
- Installs
- 5.4K
- Last 24h
- +291
- Trending rank
- #992
- Security
- Pass
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill bevy-ecs- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads bevy-ecs automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
Security audits
Independent scans of the skill's instructions and bundled files.
SKILL.md
The instructions your agent reads when the skill is triggered.
Bevy ECS
Structure a Bevy game in Rust around the Entity Component System: the App and
plugins, components and resources, systems with queries, scheduling, and
frame-rate-independent updates. New examples target Bevy 0.20. If the project
already pins another release, keep that release and use its matching migration guide.
When to use
- Use when wiring a Bevy
App, definingComponent/Resourcetypes, writing systems that query entities, ordering/filtering systems, or fixing borrow-conflict panics and frame-dependent movement. - Use when
Cargo.tomldepends onbevyand code callsApp::new(),add_systems,Query, orCommands.
When not to use: this is the ECS core. Deep rendering, custom shaders/
pipelines, UI layout, and audio are separate concerns. For engine-agnostic AI or
procedural algorithms, pair with game-ai / procedural-gen.
Core workflow
- Detect and pin the version. Read
Cargo.tomlandCargo.lockfirst. For a new project usebevy = "0.20"; never silently migrate an existing project across a Bevy minor release. Treat the matching docs and migration guides as truth. - Build the
App.App::new().add_plugins(DefaultPlugins)gives windowing, input, rendering, time, etc. Register systems into schedules:Startup(once) andUpdate(every frame). - Model data as components, globals as resources.
#[derive(Component)]for per-entity data;#[derive(Resource)]for one-of-a-kind data (score, settings, theTimeclock). Since 0.19ResourceextendsComponentand each resource is stored on its own entity, so do not derive both. - Write systems as plain functions. Parameters declare data access:
Query<...>for entities,Res<T>/ResMut<T>for resources,Commandsfor deferred spawn/despawn. Systems run in parallel when their accesses don't conflict. - Drive motion by
time.delta_secs()so speed is frame-rate independent. - Order only what must be ordered with
.chain()or explicit constraints; gate systems withrun_if. Group related setup intoPlugins. Build withcargo runand read the panics — Bevy reports conflicting queries at startup.
Patterns
1. Cargo.toml + minimal App
# Cargo.toml — pin the version; the API differs across minor releases.
[dependencies]
bevy = "0.20"
// main.rs
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins) // window, input, render, time, ...
.add_systems(Startup, setup) // runs once at startup
.add_systems(Update, move_players) // runs every frame
.run();
}
2. Components, resources, and spawning
#[derive(Component)]
struct Player;
#[derive(Component)]
struct Velocity(Vec2);
#[derive(Resource)]
struct Score(u32);
fn setup(mut commands: Commands) {
commands.insert_resource(Score(0));
// Camera2d is a component with required components (bundles removed in 0.16);
// spawning it pulls in Transform, Camera, etc. automatically.
commands.spawn(Camera2d);
// Spawn an entity as a tuple of components.
commands.spawn((
Player,
Velocity(Vec2::new(150.0, 0.0)),
Transform::from_xyz(0.0, 0.0, 0.0),
));
}
3. A system with a query + the Time resource
// Iterate every entity that has BOTH Velocity and Transform; mutate Transform.
fn move_players(time: Res<Time>, mut query: Query<(&Velocity, &mut Transform)>) {
for (velocity, mut transform) in &mut query {
// delta_secs() is f32 seconds (renamed from delta_seconds() in 0.16).
transform.translation += velocity.0.extend(0.0) * time.delta_secs();
}
}
4. Query filters (With / Without / Changed)
// Only entities tagged Player (the Player component itself isn't read).
fn aim_player(mut q: Query<&mut Transform, With<Player>>) { /* ... */ }
// Disjoint two mutable Transform queries so they don't conflict at runtime.
fn separate(
mut players: Query<&mut Transform, With<Player>>,
mut enemies: Query<&mut Transform, Without<Player>>,
) { /* ... */ }
// React only when Health changed since last run (change detection).
fn on_health_change(q: Query<&Health, Changed<Health>>) {
for health in &q { /* update the HUD, etc. */ }
}
5. Resources: read and write
fn add_points(mut score: ResMut<Score>) {
score.0 += 10; // ResMut = write access
}
fn show_score(score: Res<Score>) {
info!("score: {}", score.0); // Res = read access
}
6. Ordering, run conditions, and plugins
fn main() {
App::new()
.add_plugins((DefaultPlugins, GameplayPlugin))
// .chain() forces order: damage resolves before death is checked.
.add_systems(Update, (apply_damage, check_deaths).chain())
// run_if gates a system on a condition each frame.
.add_systems(Update, spawn_wave.run_if(wave_timer_finished))
.run();
}
struct GameplayPlugin;
impl Plugin for GameplayPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(Score(0))
.add_systems(Startup, setup)
.add_systems(Update, (move_players, add_points));
}
}
Pitfalls
delta_seconds()not found → it was renamed totime.delta_secs()(andelapsed_secs()) in 0.16. Using the old name fails to compile.- Movement speed scales with frame rate → multiply per-frame changes by
time.delta_secs(). Never assume a fixed frame time. - Panic
error[B0001]: "... accesses component(s) Transform in a way that conflicts with a previous system parameter" → twoQuerys in one system both write the same component, or one reads while another writes overlapping entities. Make them disjoint withWith/Without, or useParamSet. Camera2dBundle/SpriteBundlenot found → bundles were deprecated in 0.15 and removed in 0.16. Spawn the components directly (Camera2d,Sprite,Transform); required components fill in the rest.- "trait
Componentis not implemented" → you forgot#[derive(Component)](or#[derive(Resource)]for a resource). - Spawned entity not visible to a later query in the same frame →
Commandsare deferred and applied at the next sync point. Read the entity in a subsequent system, not the one that spawned it. - System order assumed but not enforced → systems run in parallel by default.
If
Bmust followA, add(A, B).chain()or an explicit ordering constraint. To find order dependencies that only work by accident, shuffle the schedule in tests withScheduleBuildSettings::shuffle_seed(0.20,debugfeature; see the reference). - "conflicting implementations of trait
Component" after deriving bothResourceandComponent→ since 0.19ResourceextendsComponent; deriveResourcealone. - "Despawn everything" panics, or
Query<EntityMut>next to aRes<T>panics witherror[B0002](orB0001, depending on parameter order) → since 0.19 every resource lives on an entity taggedIsResource, soQuery<Entity>/EntityRef/EntityMutmatch those entities too. Query your own marker component, or addWithout<IsResource>(use bevy::ecs::resource::IsResource). On<Add, Player>fails with "struct takes 1 generic argument but 2 generic arguments were supplied" → 0.20 moved the component into the lifecycle event: writeOn<Add<Player>>(likewiseInsert<T>,Discard<T>,Remove<T>,Despawn<T>).Pointer<Click>/Pointer<Press>not found in a picking observer → 0.20 flattened pointer events: observeOn<PointerClick>/On<PointerPress>, and readclick.pointer.position(aVec2) instead of the oldpointer_location.OnExit/OnEnterrun again when "switching" to the current state →NextState::setalways runs the transition schedules. Useset_if_differentto skip same-state transitions (renamed fromset_if_neqin 0.20; callingset_if_neqon aResMut<NextState<_>>picks up the unrelated change-detection method and fails with "can't compareNextState").- "
textdoes not live long enough" fromName::new(text.as_str())→ since 0.20Nametakes a&'static strliteral or an ownedString, not a borrowed&str; passName::new(text.clone())orName::new(format!("Enemy {id}")). - Overlapping sprites swap draw order after upgrading to 0.20 → sprites now render
through the
Mesh2dbackend, and draw order at equalzwas never guaranteed. Give sprites that can overlap distinctTransformz values. - Copy-pasting older Bevy snippets → APIs shift between minor versions. The
buffered event system became the message system:
EventReader/EventWriter/add_eventno longer exist, so use#[derive(Message)],MessageReader/MessageWriter, andapp.add_message::<T>(). Verify against the docs and migration guide for your pinned version; don't mix versions.
References
- For schedules and
SystemSetordering (including 0.20 weak ordering and schedule shuffling),States/OnEnter/OnExitand state-scoped despawning, change detection,Commandslifecycle and sync points,ParamSetand resource-entity conflicts,iter_manyresults, and messages/observers in 0.20 syntax, readreferences/queries-and-scheduling.md.
Related skills
game-ai— FSMs/behavior trees/steering as portable concepts to implement in ECS.procedural-gen— noise/RNG/generation algorithms to drive from systems.pygame-core/love2d-core— lighter-weight engines for smaller projects.
FAQ
What does the bevy-ecs skill do?
Structure a Bevy app around its Entity Component System: build the App with plugins, define Component/Resource types, write systems with Query/Res/Commands, filter and order systems, and use the Time resource for frame-rate-independent motion. Use when building or debugging a Bevy game in Rust — when the user mentions Bevy, ECS, App::new, addsystems, Query, Commands, components/systems, or a Cargo.toml depending on bevy.
How do I install bevy-ecs?
Run npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill bevy-ecs in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/bevy-ecs/ (personal) or .claude/skills/bevy-ecs/ (project).
Which AI agents can use bevy-ecs?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is bevy-ecs safe to install?
Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk passed. As with any skill, read the SKILL.md and bundled scripts before installing.
Who maintains bevy-ecs?
It is published by gamedev-skills in gamedev-skills/awesome-gamedev-agent-skills. It has 5,439 recorded installs.
More from gamedev-skills/awesome-gamedev-agent-skills
game-feel
gamedev-skills/awesome-gamedev-agent-skills
Add "juice" and game feel that makes actions satisfying — screen shake, hit-stop/freeze frames, tweened/eased motion, squash & stretch, knockback, and layered audio-visual feedback — as engine-neutral techniques that pair with the detected engine's tween, particle, and camera APIs. Use when the user mentions game feel, juice, "make it feel good/punchy", screen shake, hit stop, screen freeze, easing, squash and stretch, impact frames, or feedback/polish on hits, jumps, pickups, and deaths.
game-ui-ux
gamedev-skills/awesome-gamedev-agent-skills
Design and build game UI/UX — HUDs, menus, and overlays — that survive every screen: anchor- based responsive layout, resolution/aspect scaling and safe areas, keyboard/gamepad focus navigation, a screen/menu state stack, and event-driven (not polled) HUD updates. Engine- neutral patterns that pair with the detected engine's UI skill. Use when the user mentions HUD, health bar, main menu, pause menu, settings screen, UI layout, anchors, UI scaling, aspect ratio, safe area, controller/keyboard menu navigation, or wiring UI to game state.
level-design
gamedev-skills/awesome-gamedev-agent-skills
Design and build playable levels — the blockout/whitebox-to-playable workflow, player metrics and grid layout, pacing and flow (tension/rest curve), gating and the critical path, and encounter design. Engine-neutral practice. Use when the user mentions level design, blockout/whitebox/greybox, level layout, level pacing, encounter design, or the critical path through a level.
performance-optimization
gamedev-skills/awesome-gamedev-agent-skills
Find and fix game performance problems methodically — measure with the engine profiler first, reason about the frame-time budget, locate the CPU-vs-GPU bottleneck, then apply the right fix: object pooling, draw-call batching, fewer allocations/GC spikes, and asset budgets. Engine- neutral method that pairs with each engine's profiler. Use when the user mentions performance, optimize, low/dropping FPS, frame drops, stutter, lag, profiler, frame budget, draw calls, batching, garbage collection/GC spikes, object pooling, or "the game runs slow".
game-ai
gamedev-skills/awesome-gamedev-agent-skills
Design NPC and enemy decision-making with finite state machines, behavior trees, steering behaviors, and A pathfinding — engine-neutral algorithms that pair with the detected engine's navigation API. Use when building enemy AI, an FSM or behavior tree, steering/flocking, or pathfinding, or when the user mentions state machine, behavior tree, blackboard, A, navmesh, seek, or patrol/chase.
audio-design
gamedev-skills/awesome-gamedev-agent-skills
Implement game audio practice — bus/mixer architecture and gain in decibels, ducking (sidechain), adaptive/dynamic music via layering and re-sequencing, SFX variation, and beat synchronization. Engine-neutral. Use when the user mentions audio mixing, audio buses, adaptive/dynamic music, ducking, SFX variation, music layers, or syncing gameplay to the beat.
Popular frontend & design skills
setup-matt-pocock-skills
mattpocock/skills
Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.
frontend-design
anthropics/skills
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.
hyperframes-animation
heygen-com/hyperframes
All animation knowledge for HyperFrames — atomic motion rules, multi-phase scene blueprints, scene transitions, broader motion-design techniques, AND the seven runtime adapters (GSAP default, plus Lottie, Three.js, Anime.js, CSS keyframes, Web Animations API, TypeGPU). Use for any motion or animation task: pick 2-4 rules and compose, or load a blueprint, or look up runtime-specific API (e.g. GSAP eases / Lottie player / Three.js mixer). Also covers auditing an existing composition's choreography (animation map) and 24 named text-animation effects. HyperFrames-native: single paused timeline, seek-safe, deterministic.
prototype
mattpocock/skills
Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
hyperframes-core
heygen-com/hyperframes
The HyperFrames composition contract — build one renderable project. Use for composition structure, the data- timing attributes, class="clip", tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Read before writing composition HTML.
vercel-react-best-practices
vercel-labs/agent-skills
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.