Skip to main content
skill CX Codex

puzzle — Claude Code skill: what it does, how to install

A playbook for grid puzzles: board model, move resolution, cascades, scoring and undo. Useful when the fun is planning the move.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill puzzle -a claude-code
Open on GitHub

What puzzle does

The skill walks through building a grid puzzle: board model, move input, rule resolution (matches, pushes, tile logic), scoring, undo and level progression. Its author calls it compositional because it defines the resolution loop and the correctness rules, then leaves grid rendering to godot-tilemap or unity-tilemap-2d.

Inside are the systems a fair puzzle needs: the board as single source of truth, legality checks before a move lands, cascades that loop until nothing changes, objectives and move or time limits. Code patterns cover match detection, the resolve → collapse → refill loop, and snapshot undo that restores the board, score, counters and RNG state.

Generation is where it usually breaks. A sliding puzzle filled by random shuffle comes out unsolvable half the time, and match-3 without deadlock detection softlocks. So the skill asks for a seeded refill RNG — skip that and undo hands back different pieces, which teaches players to reroll a move by undoing it.

What it helps with

  • model board state separately from rendering
  • resolve cascades until the board stops changing
  • make undo restore score and RNG state
  • detect deadlocks in match-3 and reshuffle
  • verify generated levels are actually solvable

Example prompts for the agent

  • Build a match-3 where logic is separate from rendering and cascades resolve until the board is stable.
  • Add exact undo to my sokoban, restoring board, score and move counter.
  • Check my level generator: are the boards guaranteed solvable or can it deal a deadlock?

How to install puzzle

1Skills CLI (Vercel)

npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill puzzle -a claude-code

2Manually: put the files in place

~/.claude/skills/puzzle/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/puzzle/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about puzzle

How do I install puzzle in Claude Code?

Run npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill puzzle -a claude-code. The skill file lands at ~/.claude/skills/puzzle/SKILL.md.

What does the puzzle skill do?

It describes board state, move input, rule resolution, scoring and undo for match-3, sokoban and logic grids. You get pseudocode patterns plus a list of the failure modes that hit these games.

When should I not use it?

Not for real-time grid action with permadeath, card zones with turns, or a physics-driven puzzle platformer. The same collection ships skills for those.

Source text

SKILL.md · Apache-2.0
---
name: puzzle
description: >
  Build a puzzle game: grid/board state, move input, rule-based resolution (match-3 cascades, sokoban
  pushes, tile logic), scoring, and undo. Use for a match-3, sokoban, or grid-logic puzzle.
---

# Puzzle

A playbook for grid/board puzzle games — the board model, move input, rule resolution
(matching, pushing, logic), scoring, undo, and level progression. This is a **compositional**
skill: it models board state and rules and presents them through a tilemap/UI. It does not
re-teach tilemaps; it defines the resolution loop and the correctness rules (clean state,
deterministic resolution, undo) that keep a puzzle fair and bug-free.

## When to use

- Use when the game is a **discrete board** the player changes with moves, and the board
  **resolves by rules**: match-3/tile-matching, sokoban/block-pusher, sliding puzzle, logic grid.
- Use when designing match/cascade resolution, undo, level progression, or solvability.

**When *not* to use:** real-time grid action with permadeath → `roguelike`. Card zones/turns →
`card-game`. Physics-based "puzzle platformer" → `platformer` + `physics-tuning`. For the tile
rendering, use `godot-tilemap` / `unity-tilemap-2d`.

## Core loop

**Read the board → plan a move → make the move → the board resolves by its rules (match, push,
fall, fill, cascade) → see progress toward the objective → repeat until solved/failed.** The
fun is the *planning*; the engine's job is to resolve each move **deterministically** and
present it clearly.

## Must-have systems

1. **Board model** — a grid of cells holding pieces; the single source of truth (logic, not visuals).
2. **Move input** — swap, push, drag, rotate, or place; validate legality before applying.
3. **Rule resolution** — detect and apply the genre's rule (matches, pushes, logic) until stable.
4. **Cascades/chains** — when resolution changes the board, re-resolve until no more changes.
5. **Objectives + scoring** — win/lose conditions (score, clear all, reach goal); move/time limits.
6. **Undo** — revert the last move (and its resolution) exactly; essential for thinky puzzles.
7. **Level progression + (often) generation** — hand-authored or generated **solvable** boards.
8. **Feedback ("juice")** — clear, satisfying animation/sound for matches, falls, and chains.

## Design knobs

| Knob | Effect | Notes |
|------|--------|-------|
| Grid size / shape | complexity | Square is standard; hex/irregular change feel. |
| Match/push rule | genre identity | 3-in-a-row, shapes, push-into-goal, etc. |
| Cascade scoring | reward depth | Bigger chains = exponential payoff. |
| Move / time limit | pressure | Move-limited = puzzly; time = arcade. |
| Difficulty curve | learning | Introduce one mechanic at a time. |
| Undo depth | forgiveness | Single-step vs. full history. |
| Solvability guarantee | fairness | Generated boards must be solvable. |
| Deadlock handling | no dead ends | Detect no-moves; shuffle or end (refs). |

## Patterns

### 1. Board model + match detection (logic separate from visuals)

```python
# Pseudocode. The board is the truth; rendering reads from it. (0,0) top-left, y grows down.
board = [[piece_or_empty for _ in range(W)] for _ in range(H)]

def find_matches(board):
    matched = set()
    for y in range(H):                       # horizontal runs of >= 3 equal pieces
        run = 1
        for x in range(1, W):
            if board[y][x] and board[y][x] == board[y][x-1]: run += 1
            else:
                if run >= 3: matched |= {(y, k) for k in range(x-run, x)}
                run = 1
        if run >= 3: matched |= {(y, k) for k in range(W-run, W)}
    # ... repeat the same scan vertically (columns) ...
    return matched
```

### 2. Resolve → collapse → refill → cascade (repeat to stability)

```python
# Pseudocode. One player move can trigger a chain; loop until the board stops changing.
def resolve(board):
    chain = 0
    while True:
        matches = find_matches(board)
        if not matches: break                 # stable: resolution complete
        chain += 1
        score += score_for(matches, chain)    # later chain steps score more (see refs)
        clear(board, matches)                  # remove matched pieces
        apply_gravity(board)                   # pieces fall into the gaps
        refill(board, rng)                      # spawn new pieces at the top (seeded RNG)
    return chain
```

### 3. Undo via state snapshot or command

```python
# Pseudocode. Snapshot before each move; undo restores it exactly (board + score + counters + RNG).
def make_move(move):
    history.append(snapshot(board, score, moves_left, rng.state))   # push BEFORE applying
    apply(move); resolve(board); moves_left -= 1

def undo():
    if history:
        board, score, moves_left, rng.state = history.pop()   # exact revert, including refills
```

For large boards prefer the **command** pattern (store the move + enough to invert it) over full
snapshots to save memory; snapshots are simplest and fine for small boards.

## Pitfalls / failure modes

- **Mixing logic and visuals** → animations desync from state and cause bugs. The board model is
  the single source of truth; the view only renders it.
- **Resolving only once** → cascades/chains are missed. Loop resolution until the board is stable
  (Pattern 2).
- **Undo that doesn't restore everything** → score/move-count/random-state drift. Snapshot *all*
  state, or make the move fully invertible. If undo skips the RNG state, redoing the same move
  refills different pieces and players learn to "reroll" by undoing.
- **Unseeded refill RNG** → can't reproduce a level / no deterministic undo or daily puzzle. Seed it.
- **Generated boards that aren't solvable** → unfair dead ends. Generate-and-verify, or generate
  from a known solution backward (refs). A sliding-tile puzzle filled by a random shuffle is
  unsolvable half the time; check the parity rule in refs §7.
- **No deadlock detection** (match-3) → board with no valid moves softlocks. Detect "no moves"
  and shuffle or end the level (refs).
- **Difficulty spikes** → too many mechanics at once. Teach one mechanic per level before combining.
- **Resolution mid-animation accepts input** → double-moves/corruption. Lock input until the
  board is stable.

## Composition (build it from these skills)

- **Board rendering:** `godot-tilemap` / `unity-tilemap-2d` for the grid; `godot-ui-control` for HUD, score, and menus.
- **Levels:** `level-design` for hand-authored puzzles and difficulty pacing; `procedural-gen` for solvable generated boards.
- **Persistence:** `save-systems` for level progress, high scores, and seeded daily puzzles.
- **Juice:** `game-feel` for match/cascade pop, screen shake, and chain feedback; the engine animation/`Tween` skill for swaps/falls/clears; `audio-design` for match and chain cues.
- **Scripting:** `godot-gdscript` / `unity-csharp-scripting` for the resolution loop and rules.

## References

- For match-3 detection/gravity/refill/cascade detail, deadlock detection and reshuffles,
  sokoban/rule-based puzzles, undo strategies, solvable generation, and scoring, read
  `references/board-and-resolution.md`.

© gamedev-skills · Apache-2.0 · gamedev-skills/awesome-gamedev-agent-skills

Similar skills

Everything for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set77

godot-3d-essentials Skill for quickly building 3D scenes in Godot 4.7: place cameras, add lights, set up environment and materials. Use it when you're building 3D levels or configuring lighting and post-processing effects. CX Codex +1 6,200installs godot-export Configures and automates Godot 4.7 exports for desktop and web targets. Helpful for headless CI pipelines and export preset setup. CX Codex +1 6,200installs godot-audio Sets up playback, mixing and beat-aware timing for Godot 4.7 audio. Use it when a project needs music, SFX, audio buses or positional sound. CX Codex +1 6,200installs platformer Guides 2D platformer mechanics: tunes jump feel with coyote time, input buffering, variable height, and sets up one-way platforms. CX Codex +1 6,000installs card-game A skill for card games that keeps deck, hand and discard straight, then wires draw, turn phases and effect resolution. CX Codex +1 6,100installs godot-tilemap Builds 2D levels in Godot 4.7 with TileMapLayer, sets up collision and terrain sets, and manipulates cells from GDScript. Helps migrate away from deprecated TileMap. CX Codex +1 6,100installs fps-shooter Builds the design for a first-person shooter with movement, aiming, weapons, health and enemy AI. Use it when tuning aim feel, recoil, spread or time-to-kill. CX Codex +1 6,100installs roblox-luau A skill that teaches Claude Code to write Luau scripts for Roblox: work with services, create Instances, handle events, and build secure client-server communication via RemoteEvents. CX Codex +1 6,100installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor