blECSd Codex Skill
Use this skill to build, review, or refactor blECSd applications and libraries.
Follow Core Principles
- Treat blECSd as a library, not a framework.
- Use functional style only: pure functions, plain data, no classes.
- Use ECS patterns: entities as IDs, components as SoA data, systems as pure transforms.
- Keep input responsive: INPUT phase runs first and drains events.
Choose an API
- Use Game API for games and real-time apps.
- Use ECS API for full control and performance tuning.
Apply the Recommended Workflow
- Pick the API surface.
- Import from
blecsdfor typical apps. - Import from
blecsd/terminalfor low-level terminal control. - Import from
blecsd/componentsandblecsd/systemsfor custom pipelines.
- Create the world and screen.
- Call
createWorldandcreateScreenEntityfor ECS API. - Call
createGamefor Game API.
- Build UI with the right abstraction.
- Use widgets for rapid development.
- Use entity factories for composable primitives.
- Use components directly for full control.
- Handle input first.
- Keep input logic in INPUT/EARLY_UPDATE.
- Avoid input processing in RENDER.
- Render after layout.
- Run LAYOUT before RENDER.
- Keep RENDER read-only.
- Optimize only when measured.
- Use frame budget tooling and benchmarks.
- Apply virtualization and dirty tracking for large UIs.
Keep Best Practices in Mind
- Cache queries outside hot loops.
- Keep hierarchies shallow.
- Use
VirtualizedListfor lists > 1000 items. - Mark entities dirty only when state changes.
- Use visibility culling for large scenes.
- Batch updates and render once per frame.
- Store large data outside ECS; keep ECS for UI state.
- Access component arrays directly in tight loops.
Read Deep Dives as Needed
Indexes and summaries for full coverage:
references/DOCS_INDEX.mdreferences/ROOT_DOCS.mdreferences/ROOT_DOCS_SUMMARY.mdreferences/GETTING_STARTED_INDEX.mdreferences/GETTING_STARTED_SUMMARY.mdreferences/GUIDES_INDEX.mdreferences/GUIDES_SUMMARY.mdreferences/TUTORIALS_INDEX.mdreferences/TUTORIALS_SUMMARY.mdreferences/EXAMPLES_INDEX.mdreferences/EXAMPLES_SUMMARY.mdreferences/ARCHITECTURE_INDEX.mdreferences/ARCHITECTURE_SUMMARY.mdreferences/PERFORMANCE_INDEX.mdreferences/PERFORMANCE_SUMMARY.mdreferences/CONTRIBUTING_INDEX.mdreferences/CONTRIBUTING_SUMMARY.mdreferences/EXPLORATION_INDEX.mdreferences/EXPLORATION_SUMMARY.md
API indexes:
references/API_INDEX.mdreferences/API_CORE.mdreferences/API_COMPONENTS.mdreferences/API_WIDGETS.mdreferences/API_SYSTEMS.mdreferences/API_TERMINAL.mdreferences/API_UTILS.mdreferences/API_3D.mdreferences/API_DEBUG.mdreferences/API_INPUT.mdreferences/API_TEXT.md
Focused deep dives:
references/MODULES.mdreferences/BEST_PRACTICES.mdreferences/PERFORMANCE.mdreferences/SYSTEMS.mdreferences/LAYOUT.mdreferences/WIDGETS.mdreferences/COMPONENTS.mdreferences/TERMINAL.mdreferences/TERMINAL_PROTOCOLS.mdreferences/UTILS.mdreferences/THREE_D.mdreferences/ERRORS.mdreferences/SCHEMAS.mdreferences/TESTING.mdreferences/GAME_API.mdreferences/ECS_API.mdreferences/ARCHITECTURE.md
Enforce Guardrails
- Never introduce classes or
new(except built-in collections likeMap,Set,Error). - Keep nesting shallow with guard clauses.
- Use Zod validation at system boundaries.
- Prefer ECS systems for behavior; keep state in components.
Use a Quick ECS Example
import {
createWorld,
createScreenEntity,
createBoxEntity,
createGameLoop,
LoopPhase,
inputSystem,
layoutSystem,
renderSystem,
} from 'blecsd';
const world = createWorld();
createScreenEntity(world, { width: 80, height: 24 });
createBoxEntity(world, { x: 2, y: 1, width: 30, height: 10, title: 'Hello' });
const loop = createGameLoop(world, { targetFPS: 60 });
loop.registerSystem(LoopPhase.INPUT, inputSystem);
loop.registerSystem(LoopPhase.LAYOUT, layoutSystem);
loop.registerSystem(LoopPhase.RENDER, renderSystem);
loop.start();
