HomeDeveloper docsHow to use AI to create a browser module
How to use AI 2 min read

How to use AI to create a browser module

Add a useful interface feature using the scoped browser API, permissions and the module lifecycle.

Replace bracketed values before sending the prompt. Give the assistant the relevant public files from the exact target release; use synthetic examples and keep credentials, private campaigns and proprietary material out of its context.

What you will build

Create a small actor-directory addition that counts only the actors readable by the signed-in user. This is a concrete first module with a visible result and no game-specific rules.

Context to give the assistant

  • The minimal Actor counter package in docs/en/modules.md.

  • The browser domain API, events and cancellation behavior in docs/en/api.md.

  • The target release contract, especially frontend.json and the manifest schema.

Step by step

  1. Choose an existing documented extension surface, such as actor.directory.

  2. Give the assistant the actual minimal package example and ask it to explain every lifecycle hook it uses.

  3. Start with a read-only feature; subscribe through the scoped API rather than polling the whole page.

  4. Verify repeated mount/unmount and activation changes before packaging.

Copy and adapt this prompt

text
Repository: [local checkout or public repository]
Target host release: [installed/requested version; preserve it]
Task scope and authorization: [what may be changed/published]

Create example.actor-counter as a browser module on the requested host release.
Use the documented actor.directory surface and the supplied api.actors.list() / api.events.on("actors.changed", ...) interfaces after verifying their signatures. Show a visible count of readable actors.
Use start/register/stop and the host lifecycle as documented. Avoid global window handles when a scoped context is supplied. Respect signal.aborted and dispose resources.
Scope CSS to the module root, keep text at least 12px, use existing design tokens and translation hooks, and use DOM textContent for untrusted labels.
Produce manifest.json, main.js, styles.css and a license file with exact signing/install instructions. There is no assumed npm SDK or unsigned upload endpoint.

Inspect the actual files and supported APIs before proposing code. Do not invent commands, fields, endpoints or package capabilities.
Use disposable test data and installation-local tools/caches. Explain any unsupported requirement and validate the result with the project’s real tools.
Deliver concrete files or editor steps, the checks performed and any unresolved limits.

How to validate

  • Add/remove a readable actor and check that the count follows committed state.

  • Verify a player does not count hidden actors.

  • Open/close repeatedly and deactivate the module during a pending request; check for duplicate listeners and stale updates.

  • Run the focused module/browser checks documented by the project in isolated data.

Ready when

The feature updates from authorized state, survives repeated mounting and stops cleanly when its context is disposed.

Continue with the module reference, public API and testing guide.