portals-server-sim

portals-server-sim is a skill for Claude Code from portals-labs/portals-plugin-claude. It costs 101 tokens per session (1,734 once invoked), scanned A, original, ISC.

A design pattern for real-time multiplayer games in which a server simulates the shared game world and sends updates to players.

In plain words
What is it for?
Building server-controlled physics, sending game snapshots and player inputs, measuring delay, predicting movement on clients, and falling back to host control when the server is unavailable.
Why use it?
It reduces dependence on one player’s browser and supports fairer shared outcomes when players have different connection delays.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the portals-plugin-claude plugin — 8 skills, 1 MCP server shipped together

Good fit Building server-controlled physics, sending game snapshots and player inputs, measuring delay, predicting movement on clients, and falling back to host control when the server is unavailable.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/portals-labs/portals-plugin-claude/portals-server-sim
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add portals-labs/portals-plugin-claude --skill portals-server-sim
Clone the repo
git clone --depth 1 https://github.com/portals-labs/portals-plugin-claude

Made for: Claude Code.

Or install portals-plugin-claude, the plugin that ships this one along with the rest of its 8 skills, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for portals-server-sim

README.md
[![agentmods](https://agentmods.dev/badge/skills/portals-labs/portals-plugin-claude/portals-server-sim/github.svg)](https://agentmods.dev/skills/portals-labs/portals-plugin-claude/portals-server-sim)
Your own site
<a href="https://agentmods.dev/skills/portals-labs/portals-plugin-claude/portals-server-sim"><img src="https://agentmods.dev/badge/skills/portals-labs/portals-plugin-claude/portals-server-sim/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for portals-server-sim

Your own site · 80×15
<a href="https://agentmods.dev/skills/portals-labs/portals-plugin-claude/portals-server-sim"><img src="https://agentmods.dev/badge/skills/portals-labs/portals-plugin-claude/portals-server-sim.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,734 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00101 $0.01734
Opus 5 $0.00051 $0.00867
Sonnet 5 $0.00020 $0.00347
Haiku 4.5 $0.00010 $0.00173

Measured 11d ago against content hash 44d4336890a4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

portals-server-sim scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/portals-plugin-claude/skills/portals-server-sim/SKILL.md · 48 lines

How it starts

The opening of the file, as written. The whole thing — 48 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Server-simulated games

The portals-server-scripts skill covers the contract — a root server.js that Portals runs as an invisible authoritative participant. This is the next level: the server script simulates the game itself, stepping the same physics the clients ship and broadcasting the result, so nobody's tab owns the world.

Read references/server-sim.md for the full pattern with the worked FUTBOL example — protocol, tick, prediction, fallback ladder, measured budgets, and the virtual-clock test harness. It is the official documentation, copied verbatim.

The default for multiplayer games

If the game is multiplayer, build it server-simulated. Host-authoritative multiplayer (one tab simulates, the rest follow) is not the starting point — it is the fallback rung a server sim keeps underneath for the moments the server is away. The server sim buys fairness (games are continuous and contested more often than they first look — a shared ball, ramming, racing, even a grabbed pickup — and a host's zero self-latency is a real competitive advantage), witnessed outcomes rather than claims, and symmetry — the server sits at the relay, ~25 ms from everyone on a regional channel.

The exceptions are narrow: purely cosmetic shared spaces (a co-op drawing canvas, an emote wall) and slow turn-based games whose pace hides latency, with a plain server script as referee where anything needs deciding. When in doubt, take the server sim — retrofitting authority into a shipped host-authoritative game is much harder than building on it, while the host-authority fallback comes with the server sim for free.

The rules that make or break it

  • One simulation, shared byte-identically. The client and server must run the same game rules from one module. A ball simulated two slightly different ways is a desync nobody can debug.
  • The sim module stays plain. Pure data in, pure data out ({ x, z } fields, no THREE.js, no DOM, no clock of its own). Side effects go through hooks so each authority decides what a goal or a sound means.
  • Integration must be step-rate independent. The server ticks at 20 Hz against the sandbox's 50 ms timer floor; clients render at 60–120 Hz. Solve movement exactly over dt (vel = settle + (vel - settle) * Math.exp(-dt * k)) instead of accumulating per-frame adds, or the two ends settle at different speeds and prediction argues with its authority for as long as a key is held.
  • The sandbox takes one file — no import, no require — so share at build time. Bundle the referee entry plus the sim module into dist/server.js with esbuild (format: "iife", unminified so it reads next to its logs); that bundle is what a push ships.
  • The server marks its snapshots. One field (sv: 1) is the entire handshake: the first marked snapshot flips every tab, host included, into a follower; when the marked stream goes quiet the host resumes simulating. One protocol, two places it can run.
  • Inputs go up on change, not on a metronome — no faster than every 60 ms, and every 100 ms regardless so a held key stays alive. Carry a sequence number. On the server an input drives whatever seat the team sheet assigned that player, never whatever the packet asks for, and a stale input stops driving its actor after ~700 ms.
  • The clock ticks on the server, never as a published deadline — a deadline is read against each player's own clock, and a wrong device clock would show a wrong match.
  • Predict yourself, dead-reckon everyone else, replay contested moments from events. Ease your own actor onto the authority's version rather than snapping. Dead-reckon others on the sim's own drag constants — extrapolating at snapshot velocity in a straight line walks a released actor well past where the physics stopped it. Never predict a contested outcome; play it when ev says so.
  • Subtract the ocean. A snapshot is already a round trip old. Echo the last acted-on sequence number in each actor's row; the gap between sending q and reading it back — both ends off the guest's own clock — is the whole loop. Project the ball and opponents forward by one downlink, your own actor by the full trip.
  • The fallback ladder must stay walkable. A server sim that takes the game down with it has failed. Three rungs, each a working game: server simulates → server referees only while the host simulates → no server at all (peer-run, which is the ordinary state of every unpublished game). Silence is the signal: guests fall back after a beat and a half, the host starts simulating half a beat later, both measured from the same last-marked snapshot so guests are listening before the host talks.
  • Boot resumes shared state. Shared state outlives the script. A hot-swapped server reads its own server:* keys back, prunes them against the live roster, and carries on — being swapped mid-match must not hand anybody a fresh 0-0.
  • Coalesce state writes. Scoreboard once a second, directory-style state on a ~120 ms timer; the smooth clock rides the snapshots. Keep every value inside 8 KB: packed arrays over objects, two-decimal rounding, capped list sizes.

Read the full file on GitHub · 48 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 48 lines · 101 tokens per session scan A 44d4336890a4

Subscribe to this mod's changes

portals-server-sim is a skill published in the GitHub repository portals-labs/portals-plugin-claude (4 stars, last pushed 2d ago), licensed ISC. It adds 101 tokens to every session and 1,734 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

gameobject-component-destroy

Destroy one or more Components from a target GameObject. Missing (null) components are skipped — they cannot be destroyed. Use 'gameobject-find' and 'gameobject-component-get' to identify the components first.

IvanMurzak/Unity-MCP · 49 tokens

unity-version-split

Split a C# file into Unity 6.5+ and pre-Unity 6.5 variants. Use when a file needs different implementations for different Unity versions due to API changes (e.g., EntityId vs int, GetEntityId vs GetInstanceID).

IvanMurzak/Unity-MCP · 59 tokens

godot-signals-groups

Build event-driven, decoupled Godot 4.7 gameplay with signals and node groups: declare and emit custom signals, connect with Callables (incl. bind/one-shot), and broadcast to many nodes via groups and callgroup. Use when wiring node communication in a Godot project, replacing tight references with signals…

gamedev-skills/awesome-gamedev-agent-skills · 95 tokens

unity-addressables

Manage Addressables groups, entries, profiles and content builds (com.unity.addressables, reflection-based).

Besty0728/Unity-Skills · 25 tokens

motion

How an agent turns a character mesh into a usable animated FBX — and how to judge whether the result is shippable.

OpenDCAI/GameFactory-3A · 0 tokens

threejs-exposure-color-grading

Build a measured exposure and grading path in Three.js. Use for a 64x36 encoded luminance meter, asynchronous readback, weighted log-average exposure, asymmetric adaptation, single tone-map ownership, and a generated 32-cube post-tone-map LUT.

scottstts/Threejs-Awesome-Graphics-Agent-Skills · 60 tokens