# Game rules engine

> Game rules engine is an open-source agent skill for developer tools. Builds deterministic, seeded game rules engines for React Native games. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/zakariaf/ReactNative-Skills/tree/main/skills/game-rules-engine
- **Repository:** https://github.com/zakariaf/reactnative-skills
- **GitHub stars:** 16
- **License:** MIT
- **Skill name:** game-rules-engine
- **Collection:** https://github.com/zakariaf/ReactNative-Skills
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill sets up a pure, deterministic TypeScript rules engine for each game, behind a single shared contract of create, listMoves, applyMove and outcome functions. Because the same seed and moves produce the same states on every platform and in tests, bots, solvers, saves, undo and replays can rely on the engine.

The workflow installs a core kit (contract types, a difficulty scale and test helpers), a seeded RNG with pinned golden values, and a template game based on Lights Out. A checker script verifies the kit, the RNG outputs and each game's rules by running them, and reports failures with file and fix guidance.

It expects a Node-based project with Jest, fast-check, ESLint, Prettier and TypeScript, plus an app with i18n catalogs for player-facing messages. It relies on companion skills for gestures, rendering and level generation.

## When your agent uses it

> Builds game rules as a pure seeded engine: create, listMoves, applyMove, outcome, events, property tests. Use when writing game rules, moves, scoring or in-game randomness. Not for levels (level-generation-and-solvers).

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Runs JavaScript and TypeScript scripts](https://github.com/zakariaf/ReactNative-Skills/tree/HEAD/skills/game-rules-engine)
- [No network calls found in its scripts](https://github.com/zakariaf/ReactNative-Skills/tree/HEAD/skills/game-rules-engine)
- [License: MIT](https://github.com/zakariaf/ReactNative-Skills/tree/HEAD/skills/game-rules-engine)

## Features

- **Seeded deterministic RNG:** Provides a 32-bit seeded generator whose golden outputs are pinned so levels and replays match across devices.
- **Shared engine contract:** Defines the game contract with create, listMoves, applyMove, outcome, events and difficulty scaling.
- **Template game:** Includes a complete small game, Lights Out with a move budget, to copy and adapt.
- **Property-based test guidance:** Describes example tests, fast-check properties and pinned golden values for every rules folder.
- **Persistence and saves:** Covers JSON-safe state, parsing saved runs back into typed values and migrating older shapes.
- **Engine checker script:** Runs a checker that validates kit files, purity, determinism, events and the seeded play of each game.

## Good for

- Write rules and scoring for a new puzzle game in React Native
- Add seeded randomness to a game so daily levels match on every device
- Check that a game's engine never lets an illegal move through
- Set up a shared rules kit and test helpers for a mobile game project
- Make saved game runs reload reliably after an app update

## Install

### Claude Code

This skill ships in the `react-native-games` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add zakariaf/ReactNative-Skills
/plugin install react-native-games@react-native-skills
```

Or copy only this skill to `~/.claude/skills/game-rules-engine`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/game-rules-engine &&
cp -R "$tmp/skills/game-rules-engine" ~/.claude/skills/game-rules-engine &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/game-rules-engine` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/game-rules-engine` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/game-rules-engine &&
cp -R "$tmp/skills/game-rules-engine" ~/.agents/skills/game-rules-engine &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/game-rules-engine` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/game-rules-engine` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/game-rules-engine &&
cp -R "$tmp/skills/game-rules-engine" ~/.cursor/skills/game-rules-engine &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/game-rules-engine` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/zakariaf/ReactNative-Skills.git --path skills/game-rules-engine
```

Or copy the folder to `~/.gemini/skills/game-rules-engine` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/game-rules-engine`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/game-rules-engine &&
cp -R "$tmp/skills/game-rules-engine" ~/.copilot/skills/game-rules-engine &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/game-rules-engine` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git
```

Then copy `ReactNative-Skills/skills/game-rules-engine` into your agent's skills folder as `game-rules-engine`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does the skill need before Game rules engine runs?

It expects an app with Jest, TypeScript and i18n catalogs, and it pins fast-check as a dev dependency during setup.

### Which parts of the rules code are restricted?

Rules may use only basic arithmetic, bitwise operators and a short list of Math functions, with no Math.random, Date, locale APIs or other non-deterministic calls.

### Where does randomness come from in a game?

All randomness comes from the sfc32 generator, stored as state in the game and advanced on each draw.

### Does Game rules engine change how the game looks on screen?

No. Rendering, gestures and level generation are handled by related skills; this one covers the rules engine.

### How do I install Game rules engine in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/game-rules-engine to use it in all your projects, or to .claude/skills/game-rules-engine in one project. Or install the react-native-games plugin, which includes it: /plugin marketplace add zakariaf/ReactNative-Skills, then /plugin install react-native-games@react-native-skills.

### Does Game rules engine run scripts?

Yes. It runs JavaScript and TypeScript scripts. No network calls were found in its scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Game rules engine?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Game rules engine?

The closest alternatives to Game rules engine are Game balance and bots, Game session host, Vercel react native skills, React patterns and Debug menu and test hooks.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Game balance and bots](https://ai-powered.com/skills/game-balance-and-bots): Game balance and bots is an open-source agent skill for developer tools.
- [Game session host](https://ai-powered.com/skills/game-session-host): Game session host is an open-source agent skill for developer tools.
- [Vercel react native skills](https://ai-powered.com/skills/vercel-react-native-skills): Vercel react native skills is an open-source agent skill for cloud and infrastructure.
- [React patterns](https://ai-powered.com/skills/react-patterns-tonyghiani): React patterns is an open-source agent skill for developer tools.
- [Debug menu and test hooks](https://ai-powered.com/skills/debug-menu-and-test-hooks): Debug menu and test hooks is an open-source agent skill for developer tools.
- [Golden and snapshot tests](https://ai-powered.com/skills/golden-and-snapshot-tests): Golden and snapshot tests is an open-source agent skill for developer tools.
- [Game engine](https://ai-powered.com/skills/game-engine): Game engine is an open-source agent skill for design and media.
- [Frontend react](https://ai-powered.com/skills/frontend-react): Frontend react is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/game-rules-engine
