SKILL.md
---
name: infrastructure-cursor-codex-integration
description: >-
Use when configuring Cursor IDE or OpenAI Codex for game development — .cursorrules files, prompt conventions, context injection. Triggers: cursor, .cursorrules, codex, IDE setup.
---
# Cursor & Codex Integration
## Purpose
Configuration files and prompt conventions for using Cursor IDE and OpenAI Codex with this game development skill ecosystem.
## When to Use
Trigger: cursor, codex, .cursorrules, cursor rules, AI IDE, codex instructions, prompt conventions, context injection, AI coding setup
## Prerequisites
- `claude-code-game-workflow` — understand the skill ecosystem first
## Core Principles
1. **Context is everything** — AI coding tools perform better with clear project context
2. **Rules prevent mistakes** — .cursorrules catches common errors before they happen
3. **Skill references in prompts** — tell the AI which skill to follow for the current task
4. **Genre-agnostic enforcement** — rules should enforce the genre-agnostic constraint
## Stack Rules for .cursorrules
The `.cursorrules` file sits at the repo root and is loaded automatically by Cursor. Use it to enforce the game-dev stack. Key rules to include:
```
# TypeScript strict mode — never `any`
# Runtime: Bun only — no npm/npx/yarn
# Backend: Elysia — never Express, Hapi, or Fastify
# Database: Drizzle ORM — no raw SQL, no Prisma, no TypeORM
# Genre-agnostic: shared engine code must never assume RPG/MMO/FPS
# Server-authoritative: all game logic on server, client is display only
# Narrative: quests/characters/lore require quest-narrative-coherence check FIRST
```
See `templates/game-dev.cursorrules` for the complete file with all ~25 rules.
## Claude Code Integration
How to use Claude Code with this ecosystem:
1. **Reference SKILL.md files with @ mentions** — Claude Code can read skill files directly:
```
@skills/game-dev/engineering/postgres-game-schema/SKILL.md implement the inventory schema
```
2. **Create a project CLAUDE.md** — use the template at `claude-code-game-workflow/templates/game-project-claude.md`. This file tells Claude Code which skills exist, when to use them, and project-specific constraints.
3. **Set up hooks for automated skill routing** — see `claude-code-game-workflow/templates/claude-hooks-config.json` for hooks that trigger the right skill based on file patterns (e.g., editing `db/schema.ts` triggers postgres-game-schema).
4. **Import skill context inline**:
```
"@engineering/postgres-game-schema/SKILL.md implement the inventory schema"
```
Claude Code will read the skill file and apply its patterns to the implementation.
## Prompt Templates
Five concrete prompt templates for common game dev tasks:
**1. New feature:**
```
Read @skills/game-dev/engineering/[relevant-skill]/SKILL.md. Then implement [feature] following the patterns there. Stack: Elysia + Drizzle + Neon. Use Bun runtime. No raw SQL.
```
**2. Narrative content (quests/characters/lore):**
```
Read @skills/game-dev/narrative/quest-narrative-coherence/SKILL.md first. Then create [quest/character]. Follow the 5-step coherence check and output a coherence report before writing any content.
```
**3. Schema change:**
```
Read @skills/game-dev/engineering/postgres-game-schema/SKILL.md. Add [table] following the JSONB + indexes + soft-delete patterns. Include the Drizzle migration command.
```
**4. Bug fix:**
```
Read the game-state-sync boilerplate. The bug is [describe]. Apply a server-authoritative fix only — do not move any game logic to the client.
```
**5. Code review:**
```
Review this [file] against the patterns in @skills/game-dev/engineering/[relevant]/SKILL.md. Flag violations of: server-authoritative architecture, genre-agnostic constraints, TypeScript strict type safety, and Drizzle ORM usage.
```
## Windsurf / GitHub Copilot
The same principles apply across AI IDEs:
- **GitHub Copilot**: `.cursorrules` content works in `.github/copilot-instructions.md`. Copy the rules file there and Copilot will apply them across the repo.
- **Windsurf**: supports `.windsurfrules` at the repo root with identical syntax to `.cursorrules`. Use the same `templates/game-dev.cursorrules` content.
- **Rule priority**: more specific rules override general ones. Put game-specific overrides at the top of the rules file.
## Cross-References
- `claude-code-game-workflow` — ecosystem navigation
- All other skills — referenced in prompt patterns
## Sources
- Cursor documentation
- OpenAI Codex best practices
templates/cursorrules.md
# .cursorrules Template for Game Projects
Save as `.cursorrules` in your project root:
```
# Game Development Rules
## Stack
- TypeScript strict mode, Bun runtime
- Elysia for backend API + WebSocket
- Drizzle ORM with PostgreSQL (Neon)
- Redis for caching, pub/sub, leaderboards
- BullMQ for job queues
- BetterAuth for authentication
- Stripe for payments
## Code Style
- Single quotes, semicolons, trailing commas
- ES modules (import/export), never CommonJS
- Prefer const over let, never var
- Functional style, no classes unless necessary
## Game Architecture
- Server-authoritative: never trust client input
- All game logic runs server-side
- Client sends intentions, server validates and executes
- Use JSONB columns for extensible game data
- All timestamps server-generated
## Genre-Agnostic
- Never hardcode genre-specific mechanics
- Use abstract terms: "entity", "action", "resource", "event"
- Configuration-driven behavior over hardcoded logic
- Extension points for game-specific customization
## Narrative Coherence
- Before creating any quest or story content:
1. Load world-lore.md
2. Check quest-registry.md
3. Validate against existing content
4. Reference existing lore
5. Register new content
## File Structure
- Database schemas in schema/ directory
- API routes in routes/ directory
- Game systems in systems/ directory
- Shared types in types/ directory
## Testing
- Test game logic independently of framework
- Mock Redis and PostgreSQL in unit tests
- Integration tests for API endpoints
- Load tests for WebSocket connections
```
templates/game-dev.cursorrules
# Game Dev Stack Rules
# TypeScript strict, Bun, Elysia, Drizzle ORM, Neon, Redis, BullMQ
## Language & Runtime
- Use TypeScript strict mode. Never use `any` — use proper types or `unknown` with type guards.
- Use ES modules (import/export). Never CommonJS (require).
- Runtime is Bun. Always use `bun`, `bun add`, `bun run`, `bunx`. Never npm, npx, or yarn.
- Use `const` over `let`. Never `var`.
## Backend
- Backend framework is Elysia. Never suggest Express, Hapi, or Fastify.
- Use Elysia's type-safe route handlers with Zod schemas for validation.
- WebSocket connections use Elysia's built-in WebSocket support.
- All game logic runs server-side. Client is display only (server-authoritative).
## Database
- ORM is Drizzle. Never use raw SQL, Prisma, TypeORM, or Sequelize.
- Database is Neon (PostgreSQL). Use Drizzle schemas in `db/schema.ts`.
- Use JSONB columns for flexible entity attributes.
- Always include createdAt, updatedAt timestamps.
- Soft deletes via `deletedAt` nullable timestamp — never hard-delete game data.
- New schemas require migration: `bunx drizzle-kit migrate`.
## Game Architecture
- Game logic is server-authoritative. Never trust client-sent game state.
- State changes happen at discrete tick boundaries — no floating-point time drift.
- Delta compression for state sync — send only changed fields.
- Use Redis for ephemeral state (sessions, presence, leaderboards). Neon for persistent state.
## Game Design Constraints
- All shared code must be genre-agnostic. No hardcoded RPG/MMO/FPS mechanics.
- Use generic type parameters (TState, TInput, TEntity) not game-specific names in engine code.
- Player-facing code may be genre-specific — shared library code must not.
## Narrative Content (MANDATORY)
- NEVER create quests, characters, story beats, or lore without first reading quest-narrative-coherence/SKILL.md.
- All new quests must be registered in quest-registry.md.
- Faction relationships defined in world-lore.md are canonical — never contradict them.
## Skills Reference
- For database: read engineering/postgres-game-schema/SKILL.md
- For game server: read engineering/game-backend-architecture/SKILL.md
- For multiplayer: read engineering/game-state-sync/SKILL.md
- For matchmaking: read engineering/matchmaking-system/SKILL.md
- For analytics: read engineering/gameplay-analytics/SKILL.md
- For quests: read design/quest-mission-design/SKILL.md
- For economy: read design/game-economy-design/SKILL.md
- For narrative: read narrative/quest-narrative-coherence/SKILL.md (ALWAYS FIRST)
## Formatting
- Use Biome (not ESLint/Prettier): `bunx biome check --write .`
- Single quotes, semicolons, trailing commas, 2-space indent.
- Run Biome before finishing any task.