flecs-dylib-modules

Hot-reloadable Flecs modules as Rust dylibs. Covers module architecture, component vs system modules, and inter-module dependencies.

8 stars

Best use case

flecs-dylib-modules is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Hot-reloadable Flecs modules as Rust dylibs. Covers module architecture, component vs system modules, and inter-module dependencies.

Teams using flecs-dylib-modules should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/flecs-dylib-modules/SKILL.md --create-dirs "https://raw.githubusercontent.com/andrewgazelka/rgb/main/.claude/skills/flecs-dylib-modules/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/flecs-dylib-modules/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How flecs-dylib-modules Compares

Feature / Agentflecs-dylib-modulesStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Hot-reloadable Flecs modules as Rust dylibs. Covers module architecture, component vs system modules, and inter-module dependencies.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Flecs Dylib Modules

Hot-reloadable Flecs modules as Rust dylibs.

## When to Use

Use this skill when you need to:
- Create a new hot-reloadable module
- Understand how modules depend on each other
- Debug singleton/component registration issues

## Idiomatic Flecs: Separate Components from Systems

In Flecs, it's idiomatic to separate:
- **Component modules** - define components/singletons only, no systems
- **System modules** - import component modules, define systems that use them

This separation enables:
- Hot-reload systems without breaking component data
- Multiple system modules sharing the same components
- Cleaner dependency graphs

### Example Structure

```
crates/module/
├── time-components/     # WorldTime, TpsTracker (components only)
├── time-systems/        # Systems that tick WorldTime (imports time-components)
├── network-components/  # Connection, PacketBuffer, etc.
├── network-systems/     # Ingress/egress systems
└── play/                # Game systems (imports time-components, network-components)
```

## Component Module Pattern

```rust
// crates/module/time-components/src/lib.rs
use flecs_ecs::prelude::*;

#[derive(Component, Debug)]
pub struct WorldTime {
    pub world_age: i64,
    pub time_of_day: i64,
}

#[derive(Component)]
pub struct TimeComponentsModule;

impl Module for TimeComponentsModule {
    fn module(world: &World) {
        world.module::<TimeComponentsModule>("time::components");

        // Register component and singleton
        world.component::<WorldTime>().add_trait::<flecs::Singleton>();
        world.set(WorldTime::default());

        // NO SYSTEMS HERE - just components
    }
}
```

## System Module Pattern

```rust
// crates/module/time-systems/src/lib.rs
use flecs_ecs::prelude::*;
use module_time_components::{TimeComponentsModule, WorldTime};

#[derive(Component)]
pub struct TimeSystemsModule;

impl Module for TimeSystemsModule {
    fn module(world: &World) {
        world.module::<TimeSystemsModule>("time::systems");

        // Import component module (ensures components exist)
        world.import::<TimeComponentsModule>();

        // Define systems
        world.system_named::<&mut WorldTime>("TickWorldTime")
            .each(|time| {
                time.world_age += 1;
                time.time_of_day = (time.time_of_day + 1) % 24000;
            });
    }
}
```

## Module Dependencies via Cargo

System modules depend on component modules via Cargo:

```toml
# crates/module/time-systems/Cargo.toml
[lib]
crate-type = ["dylib"]

[dependencies]
flecs_ecs.workspace = true
module-time-components = { path = "../time-components" }
```

## Module Interface (Rust ABI)

Each module dylib exports:

```rust
#[unsafe(no_mangle)]
pub fn module_load(world: &World) {
    world.import::<MyModule>();
}

#[unsafe(no_mangle)]
pub fn module_unload(world: &World) {
    if let Some(e) = world.try_lookup("::my_module") {
        e.destruct();
    }
}

#[unsafe(no_mangle)]
pub fn module_name() -> &'static str { "my_module" }

#[unsafe(no_mangle)]
pub fn module_version() -> u32 { 1 }
```

## Critical: Singleton Setup

```rust
// WRONG - just registers component
world.component::<WorldTime>();

// RIGHT - register as singleton AND set value
world.component::<WorldTime>().add_trait::<flecs::Singleton>();
world.set(WorldTime::default());
```

## Critical: world.import() for Dependencies

`world.import::<Module>()` is idempotent - safe to call multiple times:

```rust
impl Module for PlayModule {
    fn module(world: &World) {
        world.import::<TimeComponentsModule>();  // Ensures components exist
        world.import::<NetworkComponentsModule>();
        // Now safe to query WorldTime, PacketBuffer, etc.
    }
}
```

## Shared Libraries Required

All modules must link to the SAME shared flecs libraries:
- `libflecs.dylib` (C library)
- `libflecs_ecs.dylib` (Rust wrapper)

## Development Workflow

Symlink dylibs to modules/ directory:

```bash
ln -s target/debug/libmodule_time_components.dylib modules/
ln -s target/debug/libmodule_time_systems.dylib modules/
```

Rebuild updates dylib, file watcher triggers hot-reload.

## Hot-Reload Benefits

With component/system separation:
- Reload `time-systems` → systems restart with existing component data
- Reload `time-components` → resets singletons (use sparingly)
- Add new system module → extends functionality without touching existing modules

Related Skills

nbt

8
from andrewgazelka/rgb

Use the nbt! macro from mc_protocol for creating NBT (Named Binary Tag) data for Minecraft protocol encoding.

terraform-aws-modules

6
from netbarros/psique

Terraform module creation for AWS — reusable modules, state management, and HCL best practices. Use when building or reviewing Terraform AWS infrastructure.

terraform-aws-modules

5
from Eduard22222222/claude-skill-stack

Terraform module creation for AWS — reusable modules, state management, and HCL best practices. Use when building or reviewing Terraform AWS infrastructure.

dspy-2-modules

5
from vamseeachanta/workspace-hub

Sub-skill of dspy: 2. Modules.

terraform-aws-modules

5
from ratnesh-maurya/cursor-claude-personas

Terraform module creation for AWS — reusable modules, state management, and HCL best practices. Use when building or reviewing Terraform AWS infrastructure.

terraform-aws-modules

5
from FrancoStino/opencode-skills-collection

Terraform module creation for AWS — reusable modules, state management, and HCL best practices. Use when building or reviewing Terraform AWS infrastructure.

swe-cli-skills

12
from SylphAI-Inc/skills

Senior engineer CLI expertise for AI agents — workflows, safety guardrails, gotchas, and anti-patterns across cloud, IaC, containers, databases, dev tools, and platforms

DevOps & Infrastructure

PicoClaw Fleet

11
from EricGrill/agents-skills-plugins

Orchestrate a fleet of remote PicoClaw workers over SSH for fast, ephemeral one-shot tasks.

DevOps & Infrastructure

VibeCollab — Setup Instructions for AI Assistants

9
from flashpoint493/VibeCollab

You are helping a user set up VibeCollab in their project.

Workflow & Productivity

raycast-extension-docs

9
from lemikeone/Codex-skill-raycast-extension

Guidance for building, debugging, and publishing Raycast extensions using the Raycast documentation set. Use when Codex needs to create or modify Raycast extensions (React/TypeScript/Node), consult Raycast API reference or UI components, build AI extensions, handle manifest/lifecycle/preferences, troubleshoot issues, or prepare/publish extensions to the Raycast Store or Teams.

Coding & Development

evomap

9
from hyz0906/paper

Connect to the EvoMap collaborative evolution marketplace. Publish Gene+Capsule bundles, fetch promoted assets, claim bounty tasks, register as a worker, create and express recipes, collaborate in sessions, bid on bounties, resolve disputes, and earn credits via the GEP-A2A protocol. Use when the user mentions EvoMap, evolution assets, A2A protocol, capsule publishing, agent marketplace, worker pool, recipe, organism, session collaboration, or service marketplace.

AI Agent Marketplace

maestro

8
from Viniciuscarvalho/maestro

Intelligent skill knowledge gateway. Routes tasks to the right knowledge without loading all skills into context. MUST be consulted before any coding task — call the search_skills MCP tool to retrieve relevant expertise from 100+ indexed skills covering Swift, SwiftUI, concurrency, testing, architecture, performance, and security.

Coding & Development