agentleFS
d-o-hubd-o-hub/do-harness/.agents/skills/event-modeler/SKILL.md

event-modeler

Skill1 starsChanged 30 days agoMITView on GitHub

Design deterministic, type-safe event-sourced slices following Event Modeling paradigms (Commands, Events, Projections) with a hard 500 LOC per file ceiling. Use when defining domain commands, events, handlers, or projections, writing Given-When-Then contracts, or modeling state-change versus state-view slices.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All domain events must implement serde::Serialize/serde::Deserialize for libSQL persistence.

    line 81
  2. Distinctive:

    Keep event payloads flat and serde-compatible — nested types complicate libSQL persistence and versioning.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Event Modeler Skill

Purpose

Design deterministic, type-safe event-sourced slices following Event Modeling paradigms (Commands, Events, Projections) with a hard constraint of 500 LOC per file. Apply this skill only when the change introduces or modifies durable domain state transitions and projections. Stateless, mechanical, or prose changes do not need an event schema; model the behavior directly. Completing a modeled slice does not itself require updating this skill — review the outcome for reusable learning, and distill only when evidence justifies it (see .agents/skills/skill-distiller).

Schema Guidelines

1. State-Change Slice (Write Side)

// In src/domain/<slice_name>/commands.rs
#[derive(Debug, Clone, PartialEq)]
pub struct CreateUserCommand {
    pub user_id: String,
    pub email: String,
}

// In src/domain/<slice_name>/events.rs
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub enum UserEvent {
    UserCreated { user_id: String, email: String, created_at: i64 },
}

2. State-View Slice (Read Side)

// In src/domain/<slice_name>/projections.rs
pub struct UserSummaryView {
    pub total_users: usize,
    pub last_registered_user: Option<String>,
}

impl UserSummaryView {
    pub fn apply(&mut self, event: &UserEvent) {
        match event {
            UserEvent::UserCreated { user_id, .. } => {
                self.total_users += 1;
                self.last_registered_user = Some(user_id.clone());
            }
        }
    }
}

Typed Errors

Define typed error enums with thiserror before writing handlers:

// In src/domain/<slice_name>/errors.rs
#[derive(Debug, thiserror::Error)]
pub enum UserError {
    #[error("user {user_id} already exists")]
    AlreadyExists { user_id: String },
    #[error("invalid email: {0}")]
    InvalidEmail(String),
}

Quality Checklist

  • Command handlers must be pure functions or stateless orchestrators.
  • All domain events must implement serde::Serialize/serde::Deserialize for libSQL persistence; add #[serde(deny_unknown_fields)] to reject stale or unexpected payloads.
  • Errors: thiserror enums in libraries; anyhow only in binaries. No unwrap() in library code.
  • #![forbid(unsafe_code)] at crate roots.
  • Maximum file size: 500 LOC. Split files across commands.rs, events.rs, handlers.rs, and projections.rs if needed.

Gotchas

  • Events are immutable facts: never mutate an emitted event after the fact; correct via a new event.
  • Keep event payloads flat and serde-compatible — nested types complicate libSQL persistence and versioning.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.