원클릭으로
write-game-tests
Write the three required test levels for game logic — unit, property-based, and deterministic replay/snapshot
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Write the three required test levels for game logic — unit, property-based, and deterministic replay/snapshot
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | write-game-tests |
| description | Write the three required test levels for game logic — unit, property-based, and deterministic replay/snapshot |
Use when writing tests for packages/game. Three levels are required depending on what is being tested.
Use the current test harness vocabulary:
advanceGameState(state, inputs) is the pure logical step. Empty inputs returns the same state; queued input advances exactly one logical tick, applies player input first, then the tick action.frameIndex counts logical ticks, not rendered frames. Render-only stepFrames(n) calls with no queued input must not move enemies or increment frameIndex.cell and board occupancy invariants; actors must not carry xPos / yPos.createFrameStepDriver / stepFrames(n) exercise the effects-layer driver with a manualClock; they may render and advance animation time even when state does not tick.projectRenderCommands(state) is the pure foreground draw plan. It should be tested with literal GameState values and exact ReadonlyArray<RenderCommand> expectations.executeRenderCommand / executeRenderCommands are effects-layer Canvas executors. They are tested with the browser provider and a real CanvasRenderingContext2D spy, not from pure render tests.window.__bruffTestApi is browser-facing only and is tested through effects tests or Playwright, never from pure state tests.Co-locate as *.test.ts next to the source file. Run via Vitest.
Rules:
RenderCommand and RenderStats data rather than Canvas calls.import { describe, expect, it } from "vitest";
import type { GameState } from "../core/types.ts";
import updatePlayer from "./update-player.js";
describe("updatePlayer", () => {
it("moves north when input is arrowup", () => {
const state: GameState = /* … */;
expect(updatePlayer(state, { type: "move-up" })).toStrictEqual({
...state,
player: { ...state.player, cell: { column: 3, row: 2 } },
playerMoved: true,
});
});
});
Use Vitest + @fast-check/vitest.
Properties to test:
frameIndex never decreases, increments only for logical ticks with input, actors stay inside board, and no two actors occupy the same cell after valid transitions.frameIndex.import { test, fc } from "@fast-check/vitest";
import { expect } from "vitest";
test.prop([fc.integer()])(
"PRNG produces same sequence for same seed",
(seed) => {
const seq1 = runPrng(seed, 10);
const seq2 = runPrng(seed, 10);
expect(seq1).toStrictEqual(seq2);
},
);
Capture a full deterministic run and assert the final state (or a hash of it) matches a stored snapshot.
Pattern:
seed in a replay fixture.runReplay(fixture).GameState matches a committed JSON snapshot.packages/game/tests/fixtures/; snapshots live in packages/game/tests/snapshots/.import { expect, it } from "vitest";
import fixtureJson from "../../tests/fixtures/canonical-replay.json";
import snapshotJson from "../../tests/snapshots/canonical-replay.json";
import { parseReplayFixture } from "./replay-fixture.js";
import { runReplay } from "./run-replay.js";
it("produces deterministic output for fixed seed and input sequence", () => {
const fixture = parseReplayFixture(fixtureJson);
expect(fixture.type).toBe("ok");
if (fixture.type === "error") {
return;
}
expect(runReplay(fixture.value)).toStrictEqual({
type: "ok",
value: snapshotJson,
});
});
RenderCommand branch and command ordering.getState() / getRenderStats() return clones, dispatchInput() normalises raw input, and attachment is gated by __BRUFF_TEST_MODE__.await expect(locator).toHaveScreenshot("name.png") with an @snapshot test title tag; never leave raw locator.screenshot() captures unasserted. Update Arcade E2E screenshot baselines with pnpm run --filter @bruff/arcade test:e2e:update-snapshots.core/, state/, input/, or render/ tests; effects tests may use browser APIs deliberately.Math.random(), Date.now(), or raw performance.now() inside any test (seed and clock everything).Write cutting-edge and modern native CSS. Apply this skill whenever writing, reviewing, or refactoring CSS for components, layouts, design systems, or theming, even if the user doesn't say "modern CSS" explicitly. Covers a self-contained design-token scale (color, size, shadow, ease, type), cascade layers (@layer), @scope for component isolation (donut scopes, :scope specificity, scoping proximity), container queries, :has(), OKLCH/color-mix, native nesting, subgrid, fluid typography via clamp(), scroll-driven animations, logical properties, and concrete native replacements for SCSS mixins, maps, and variables.
Apply this skill whenever the task involves web security: writing or auditing HTTP security headers, configuring CSP, CORS, HSTS, or Permissions-Policy, sanitising untrusted HTML (Sanitizer API / DOMPurify), implementing Trusted Types to prevent DOM-XSS, setting up the Reporting API to capture CSP/COEP/deprecation violations, hardening cookies (SameSite, HttpOnly, Secure, Partitioned), implementing WebAuthn / Credential Management, using Web Crypto for client-side cryptography, or auditing code for XSS, CSRF, clickjacking, MIME-sniffing, mixed content, or cross-origin data leakage. Triggers on keywords: XSS, CSRF, CSP, CORS, HSTS, SameSite, innerHTML, eval, Trusted Types, Sanitizer, ReportingObserver, WebAuthn, cross-origin, clickjacking, Content-Security-Policy, Referrer-Policy, Permissions-Policy, subresource integrity, cookie security, secure context, same-origin, mixed content.
Patterns for invoking the GitHub CLI (gh) from agents. Covers structured output, pagination, repo targeting, search vs list, gh api fallback.
Audit and update durable architecture guidance after a cross-layer implementation, file move, package boundary change, coverage config change, or SDTE feature. Use when agent needs to reconcile AGENTS.md, package AGENTS.md files, local .agents/skills, older specs, dynamic imports, and test or coverage configuration with the architecture that was actually implemented.
Run the Spec → Design → Tasks → Execution workflow for non-trivial work — produces /specs/<feature>/{spec,design,tasks}.md, drives atomic per-task execution, and ends with a Review phase. Invoke when starting a new package, new game system, GameState shape change, or any change touching > 3 files or crossing a layer boundary.
Best practices for building scalable plain Web Components without turning custom elements into “god objects”. Provides patterns that keep Web Components modular, reusable, maintainable, and focused on UI concerns.