AgentSkillsCN

build-scale-browser-game

以模块化、专业化的代码,打造、重构并扩展这款基于浏览器的生活模拟游戏。在新增游戏玩法系统、扩充内容循环、重新设计架构边界、提升性能与可靠性,或为长期发展强化测试与文档时使用此功能。

SKILL.md
--- frontmatter
name: build-scale-browser-game
description: Build, refactor, and scale this browser-based life simulation game with modular and professional code. Use when adding gameplay systems, expanding content loops, redesigning architecture boundaries, improving performance/reliability, or hardening tests/docs for long-term growth.

Build Scale Browser Game

Goal

Ship incremental game improvements without monolithic code or regressions. Keep domain rules deterministic, boundaries explicit, and every change testable and documented.

Use This Workflow

  1. Define the increment.
  • Classify as feature, refactor, scalability, or stability.
  • Capture expected player impact and non-goals in 3-6 lines.
  1. Map boundaries before coding.
  • Read references/modular-architecture.md.
  • List impacted modules and contracts (types, API, events).
  • Avoid cross-feature imports through internal folders.
  1. Implement contract-first.
  • Update schemas/types first.
  • Implement gameplay rules in pure domain functions.
  • Wire infrastructure adapters last.
  1. Add confidence.
  • Add or update unit tests for rules.
  • Add integration/API tests for state transitions.
  • Verify idempotency for write endpoints and worker handlers.
  1. Update documentation.
  • Update product and technical docs in docs/.
  • Add migration notes for schema/event changes.
  • Document rollout and rollback triggers.
  1. Run quality gates.
  • Run lint, typecheck, and tests.
  • Run changed-feature smoke checks.
  • Fix failures or record justified exceptions.

Non-Negotiable Engineering Rules

  • Keep business rules in a domain layer (packages/game-rules style).
  • Keep shared contracts in one schema package used by client and server.
  • Prefer additive schema changes; deprecate before removal.
  • Guard risky economy/progression changes behind feature flags.
  • Keep worker handlers idempotent and observable.
  • Pair user-visible behavior changes with tests and docs.

Expansion Patterns

For new gameplay systems:

  • Build one vertical slice first (one action, one event branch, one outcome path).
  • Instrument metrics before broad content expansion.
  • Scale content only after loop stability is verified.

For cross-cutting refactors:

  • Introduce compatibility wrappers.
  • Migrate callers module by module.
  • Remove old paths only after parity tests pass.

For scalability work:

  • Set SLO target first.
  • Benchmark baseline.
  • Implement smallest change that moves p95/p99.
  • Re-run benchmark and record deltas.

Use Bundled Resources

  • references/modular-architecture.md: layering, folder layout, and dependency rules.
  • references/expansion-checklist.md: release-safe checklist for each increment.
  • scripts/scaffold_module.ps1: scaffold a new feature module for web app code.

Example scaffold command:

powershell
powershell -ExecutionPolicy Bypass -File skills/build-scale-browser-game/scripts/scaffold_module.ps1 -RootPath . -ModuleName heat-system

Done Criteria

Mark work done only when:

  1. Code, tests, and docs are updated together.
  2. Migration and rollback impact is explicit.
  3. Observability exists for new critical runtime paths.
  4. No unauthorized module coupling was introduced.