Agents --> Agent rules
This page is the human-readable form of AGENTS.md and loki://docs/integration. Installing the package is step one, not the end of the job.
Disclaimer for agents
Do not report the integration complete after npm install, lokiplay connect, or the first lokiplay ship. Each game still requires fine-tuning: inspect the real modes, confirm player counts, teams, and scoring with the creator, run the room flow through client.createLobby() and draw its screens in the game’s own theme, tune the reducer or RealtimeProfile, and exercise reconnect and mobile. If a material field is ambiguous, stop and ask.
Hard rules
- Install
@lokiplay/sdk@0.5.8. Do not import Nakama. - Production multiplayer runs only on a Loki-hosted finished browser build.
- Upload
game.json,index.html, and static assets. No backends, secrets, ad tags, or localhost. - Never override
projectId, player identity, membership, or sequence. createRoom()/joinRoom({ inviteCode }). No invented room keys.- Run the room flow through
client.createLobby()and build every screen in the game’s own theme. The overlay is not that flow. - Loki’s SDK does not add a public lobby screen. Every game builds the room browser, a Create private room control and a Create public room control, a Match control, and a Leaderboard, with loading, empty, joining, full-room, waiting, readiness, and error states. Do not make every room public.
- Do not invent
game.jsonfields. - Synchronized vs realtime by state progression, not animation.
- Hosted games:
createHostedLokiClient({ projectId })at boot. - Realtime: calibrate; do not copy
snapshotHzintotickRate. - Let the SDK own lifecycle. Never leave on hide/offline.
dispatch()only whileconnected.- For a synchronized room, a control that commits a match action calls
dispatch(), and the result is drawn from the snapshot that comes back. Aim, hover, and animation stay local. If the player cannot act, ordispatch()rejects, the control says so. - CSP: no inline script, no remote fonts/CSS, no
<form>. - Leave
@lokiplay/sdkexternal in the production build; Loki serves it at/loki/sdk.js. Runlokiplay previewbeforeship. validatebeforeship. Do not claim device testing you did not do.
Workflow
npm install @lokiplay/sdk@0.5.8
LOKI_API_URL=https://api.lokiplay.cc npx lokiplay@0.5.8 login
npx lokiplay@0.5.8 connect --project <uuid>
npx lokiplay@0.5.8 ship
Package install does not need Loki credentials. Login does. Stop on auth or deploy errors.
Machine-readable: MCP, /llms.txt, /llms-full.txt.