Skip to content

best-practices: Minigames (register into the host) - #7

Merged
topkoa merged 2 commits into
mainfrom
docs/best-practices-minigames
Jul 6, 2026
Merged

best-practices: Minigames (register into the host)#7
topkoa merged 2 commits into
mainfrom
docs/best-practices-minigames

Conversation

@topkoa

@topkoa topkoa commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a Minigames section to the best-practices guide. Ground-truthed against the bundled minigames plugin — which turns out to be a host + SDK, not a game: a minigame is a plugin that registers a spec into that host, and the host mounts, runs, tears down, and scores it. The section is the practical contract + the gotchas for building one.

Rules (21–26)

  • Register into the host, bind late. The host loads after your plugin (plugins load alphabetically), so window.feedBackMinigames usually isn't there when your script runs. Queue via window.__feedBackMinigamesPending and/or wait for the feedBack-minigames-ready event; registration is idempotent by spec.id.
  • Declare a minigame manifest block; spec.id === plugin id. Divergence misattributes runs and drops your manifest metadata.
  • start/stop — release in stop() everything you open. The host tears you down on navigation mid-run but only cancels its own timers/stage-DOM/summary-listener; your rAF loops, AudioContext, getUserMedia streams, timers, and listeners are yours to release or they leak past the game.
  • Make start supersede-safe (double-tap a tile, or navigate away mid-start): synchronous "starting" flag + a start generation re-checked after every await.
  • Standalone by default; usesPlayer only if you drive the highway. Minigames share the guitar input, not song playback, and are torn down on any screen change — except a usesPlayer game that intentionally hops to the player.
  • Let the host score and persist. Report via the SDK (end({score, durationMs, modifiers, meta})); the host owns runs/profile/XP and writes atomically. Use the SDK's audio helpers (a naive getUserMedia grabs the wrong device on desktop). Assume a single active session — no splitscreen concurrency.

Added a Minigames checklist block; Shipping renumbered to 27–31 (contiguous 1–31).

Scope & stacking

Docs only (spec/best-practices.md + CHANGELOG.md). No version bump. Framed the API names (feedBackMinigames, the minigame block, spec.start/stop) as the current Host contract, principles as stable — same treatment as the Visualizations section.

Stacked on #6. Full stack: #2#4#3#5#6#7. mkdocs build --strict and check_versions.py pass.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e7791e53-02f4-47da-a3f1-a5bab6a63119

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/best-practices-minigames

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Minigames” section to the best-practices guide, documenting the contract for plugins that register a minigame spec into the bundled minigames host (late binding, lifecycle, teardown/cleanup, and reporting results via the SDK).

Changes:

  • Documented the minigame host registration flow (pending queue + ready event) and the spec.start/spec.stop lifecycle expectations.
  • Added guidance on teardown/resource cleanup, supersede-safe start, and usesPlayer vs standalone behavior.
  • Renumbered the Shipping section and added a Minigames checklist block; updated the changelog entry under Unreleased.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
spec/best-practices.md Adds the “Minigames” best-practices section, renumbers Shipping rules, and adds a Minigames checklist block.
CHANGELOG.md Notes the new Minigames best-practices documentation under [Unreleased].

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/best-practices.md Outdated
Comment thread spec/best-practices.md Outdated
@topkoa
topkoa force-pushed the docs/best-practices-id-naming branch from 3897901 to 675d076 Compare July 6, 2026 04:26
topkoa and others added 2 commits July 6, 2026 00:26
Add a "Minigames" section to the best-practices guide, ground-truthed against
the bundled minigames plugin — which is a host + SDK, not a game. A minigame is
a plugin that registers a spec into that host; the host mounts/runs/tears down
and scores it.

Rules (21-26):
- Register into the host and bind late: the host loads after your plugin
  (alphabetical), so window.feedBackMinigames may not exist at eval — queue via
  window.__feedBackMinigamesPending and/or wait for feedBack-minigames-ready.
- Declare a `minigame` manifest block; spec.id MUST equal the plugin id or runs
  misattribute and manifest metadata is dropped.
- Implement start({container, modifiers, sdk})/stop(); release in stop()
  everything the game opens (rAF, AudioContext, getUserMedia, timers, listeners)
  — the host only cancels its own timers/DOM/summary listener.
- Make start supersede-safe (double-tap / navigate-away mid-start races).
- Standalone by default (torn down on any screen change); set usesPlayer only if
  the game drives the highway.
- Report results via the SDK — the host owns runs/profile/XP and persists
  atomically; use the SDK audio helpers (desktop grabs the wrong device
  otherwise); assume a single active session (no splitscreen concurrency).

Renumber the Shipping section to 27-31 and add a Minigames checklist block.
Docs only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: K. O. A. <topkoa@gmail.com>
- Rule 26: qualify the run-end call as sdk.end(...) (the sdk from start()).
- Rule 21: add { once: true } to the feedBack-minigames-ready listener so it
  doesn't linger after firing.

Signed-off-by: K. O. A. <topkoa@gmail.com>
@topkoa
topkoa force-pushed the docs/best-practices-minigames branch from ed41f2c to ee7d269 Compare July 6, 2026 04:27
Base automatically changed from docs/best-practices-id-naming to main July 6, 2026 04:44
@topkoa
topkoa merged commit 8b103ef into main Jul 6, 2026
8 checks passed
@topkoa
topkoa deleted the docs/best-practices-minigames branch July 6, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants