# Bevy Events Messaging

Bevy ECS skill for messages and observers.

- Repository: https://github.com/thedivergentai/Game-Dev-Agentic-Skills (917 stars)
- Category: Engineering
- License: LGPL-3.0
- Last updated: 2026-10-16
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-events-messaging -g -a claude-code -y`
Codex: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-events-messaging -g -a codex -y`
Cursor: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-events-messaging -g -a cursor -y`
Gemini CLI: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-events-messaging -g -a gemini-cli -y`

## Description

Bevy ECS skill for messages and observers. Keywords: Bevy, Message, Event, Observer.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Bevy events and messaging

## When to use

Load this when one system should notice that something happened without storing that fact on every entity. Pick the mechanism from the pages below. Do not invent a third channel.

## ECS shape

- **Messages (pull).** `Message` is a buffered message for pull-based handling. `MessageWriter` writes. `MessageReader` reads and tracks what it already saw. `Messages` holds what occurred within the last two updates. Register the type with `App::add_message`. The engine updates the buffer; gameplay systems only write and read.
- **Events (push).** Derive `Event`, add an observer, trigger. `Commands::trigger` and `World::trigger` run observers immediately inside the call. `On<E>` is the system parameter. `Event::Trigger` defaults to `GlobalTrigger` for derived events.
- **Observers.** An `Observer` is a component that holds a system. `EntityEvent` targets one entity: the event carries the `entity` field, and `On::event_target` returns it.
- **State transitions.** `StateTransitionEvent<S>` fires when state `S` changes. That type lives with states. See bevy-state-machines.

## Examples

```toml
[dependencies]
bevy = "0.20"
```

A hit is a fact other systems poll. Register the message, write it from the strike system, and read it later in the same schedule. `add_message` keeps the double-buffered queue.

```rust
#[derive(Message)]
struct Hit {
    amount: i32,
}

fn install(app: &mut App) {
    app.add_message::<Hit>()
        .add_systems(Update, (deal, apply).chain());
}

fn deal(mut hits: MessageWriter<Hit>) {
    hits.write(Hit { amount: 12 });
}

fn apply(mut hits: MessageReader<Hit>) {
    for hit in hits.read() {
        info!("hit {}", hit.amount);
    }
}
```

A shout should run listeners now. Derive `Event`, observe with `On<Shout>`, and `trigger`. The observer runs inside `trigger` before the system returns.

```rust
#[derive(Event)]
struct Shout {
    text: String,
}

The rest: https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/HEAD/skills/bevy-events-messaging/SKILL.md
