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
blecsd for typical apps.
- Import from
blecsd/terminal for low-level terminal control.
- Import from
blecsd/components and blecsd/systems for custom pipelines.
- Create the world and screen.
- Call
createWorld and createScreenEntity for ECS API.
- Call
createGame for 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
VirtualizedList for 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.md
references/ROOT_DOCS.md
references/ROOT_DOCS_SUMMARY.md
references/GETTING_STARTED_INDEX.md
references/GETTING_STARTED_SUMMARY.md
references/GUIDES_INDEX.md
references/GUIDES_SUMMARY.md
references/TUTORIALS_INDEX.md
references/TUTORIALS_SUMMARY.md
references/EXAMPLES_INDEX.md
references/EXAMPLES_SUMMARY.md
references/ARCHITECTURE_INDEX.md
references/ARCHITECTURE_SUMMARY.md
references/PERFORMANCE_INDEX.md
references/PERFORMANCE_SUMMARY.md
references/CONTRIBUTING_INDEX.md
references/CONTRIBUTING_SUMMARY.md
references/EXPLORATION_INDEX.md
references/EXPLORATION_SUMMARY.md
API indexes:
references/API_INDEX.md
references/API_CORE.md
references/API_COMPONENTS.md
references/API_WIDGETS.md
references/API_SYSTEMS.md
references/API_TERMINAL.md
references/API_UTILS.md
references/API_3D.md
references/API_DEBUG.md
references/API_INPUT.md
references/API_TEXT.md
Focused deep dives:
references/MODULES.md
references/BEST_PRACTICES.md
references/PERFORMANCE.md
references/SYSTEMS.md
references/LAYOUT.md
references/WIDGETS.md
references/COMPONENTS.md
references/TERMINAL.md
references/TERMINAL_PROTOCOLS.md
references/UTILS.md
references/THREE_D.md
references/ERRORS.md
references/SCHEMAS.md
references/TESTING.md
references/GAME_API.md
references/ECS_API.md
references/ARCHITECTURE.md
Enforce Guardrails
- Never introduce classes or
new (except built-in collections like Map, 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();
1---2name: blecsd-codex-skill3description: Best practices and module map for blECSd (TypeScript terminal UI). Use when building, reviewing, or refactoring blECSd apps, widgets, systems, or ECS/game-loop code.4---56# blECSd Codex Skill78Use this skill to build, review, or refactor blECSd applications and libraries.910## Follow Core Principles1112- Treat blECSd as a library, not a framework.13- Use functional style only: pure functions, plain data, no classes.14- Use ECS patterns: entities as IDs, components as SoA data, systems as pure transforms.15- Keep input responsive: INPUT phase runs first and drains events.1617## Choose an API1819- Use Game API for games and real-time apps.20- Use ECS API for full control and performance tuning.2122## Apply the Recommended Workflow23241. Pick the API surface.25- Import from `blecsd` for typical apps.26- Import from `blecsd/terminal` for low-level terminal control.27- Import from `blecsd/components` and `blecsd/systems` for custom pipelines.28292. Create the world and screen.30- Call `createWorld` and `createScreenEntity` for ECS API.31- Call `createGame` for Game API.32333. Build UI with the right abstraction.34- Use widgets for rapid development.35- Use entity factories for composable primitives.36- Use components directly for full control.37384. Handle input first.39- Keep input logic in INPUT/EARLY_UPDATE.40- Avoid input processing in RENDER.41425. Render after layout.43- Run LAYOUT before RENDER.44- Keep RENDER read-only.45466. Optimize only when measured.47- Use frame budget tooling and benchmarks.48- Apply virtualization and dirty tracking for large UIs.4950## Keep Best Practices in Mind5152- Cache queries outside hot loops.53- Keep hierarchies shallow.54- Use `VirtualizedList` for lists > 1000 items.55- Mark entities dirty only when state changes.56- Use visibility culling for large scenes.57- Batch updates and render once per frame.58- Store large data outside ECS; keep ECS for UI state.59- Access component arrays directly in tight loops.6061## Read Deep Dives as Needed6263Indexes and summaries for full coverage:64- `references/DOCS_INDEX.md`65- `references/ROOT_DOCS.md`66- `references/ROOT_DOCS_SUMMARY.md`67- `references/GETTING_STARTED_INDEX.md`68- `references/GETTING_STARTED_SUMMARY.md`69- `references/GUIDES_INDEX.md`70- `references/GUIDES_SUMMARY.md`71- `references/TUTORIALS_INDEX.md`72- `references/TUTORIALS_SUMMARY.md`73- `references/EXAMPLES_INDEX.md`74- `references/EXAMPLES_SUMMARY.md`75- `references/ARCHITECTURE_INDEX.md`76- `references/ARCHITECTURE_SUMMARY.md`77- `references/PERFORMANCE_INDEX.md`78- `references/PERFORMANCE_SUMMARY.md`79- `references/CONTRIBUTING_INDEX.md`80- `references/CONTRIBUTING_SUMMARY.md`81- `references/EXPLORATION_INDEX.md`82- `references/EXPLORATION_SUMMARY.md`8384API indexes:85- `references/API_INDEX.md`86- `references/API_CORE.md`87- `references/API_COMPONENTS.md`88- `references/API_WIDGETS.md`89- `references/API_SYSTEMS.md`90- `references/API_TERMINAL.md`91- `references/API_UTILS.md`92- `references/API_3D.md`93- `references/API_DEBUG.md`94- `references/API_INPUT.md`95- `references/API_TEXT.md`9697Focused deep dives:98- `references/MODULES.md`99- `references/BEST_PRACTICES.md`100- `references/PERFORMANCE.md`101- `references/SYSTEMS.md`102- `references/LAYOUT.md`103- `references/WIDGETS.md`104- `references/COMPONENTS.md`105- `references/TERMINAL.md`106- `references/TERMINAL_PROTOCOLS.md`107- `references/UTILS.md`108- `references/THREE_D.md`109- `references/ERRORS.md`110- `references/SCHEMAS.md`111- `references/TESTING.md`112- `references/GAME_API.md`113- `references/ECS_API.md`114- `references/ARCHITECTURE.md`115116## Enforce Guardrails117118- Never introduce classes or `new` (except built-in collections like `Map`, `Set`, `Error`).119- Keep nesting shallow with guard clauses.120- Use Zod validation at system boundaries.121- Prefer ECS systems for behavior; keep state in components.122123## Use a Quick ECS Example124125```typescript126import {127 createWorld,128 createScreenEntity,129 createBoxEntity,130 createGameLoop,131 LoopPhase,132 inputSystem,133 layoutSystem,134 renderSystem,135} from 'blecsd';136137const world = createWorld();138createScreenEntity(world, { width: 80, height: 24 });139createBoxEntity(world, { x: 2, y: 1, width: 30, height: 10, title: 'Hello' });140141const loop = createGameLoop(world, { targetFPS: 60 });142loop.registerSystem(LoopPhase.INPUT, inputSystem);143loop.registerSystem(LoopPhase.LAYOUT, layoutSystem);144loop.registerSystem(LoopPhase.RENDER, renderSystem);145loop.start();146```