portals-sdk

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

A JavaScript software kit for connecting a hosted web game to the Portals platform. It provides access to player identity, usernames, avatars, saved progress, scores, leaderboards, game closing, and the space reserved for host controls.

In plain words
What is it for?
Use it to add Portals sign-in, save progress, record or read scores, show player information, access avatars and leaderboards, close the game, and keep game controls clear of the host UI area.
Why use it?
It defines how a game uses Portals-managed player and host features without bundling or modifying the platform's managed SDK file.

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 Use it to add Portals sign-in, save progress, record or read scores, show player information, access avatars and leaderboards, close the game, and keep game controls clear of the host UI area.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/portals-labs/portals-plugin-claude/portals-sdk
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-sdk
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-sdk

README.md
[![agentmods](https://agentmods.dev/badge/skills/portals-labs/portals-plugin-claude/portals-sdk/github.svg)](https://agentmods.dev/skills/portals-labs/portals-plugin-claude/portals-sdk)
Your own site
<a href="https://agentmods.dev/skills/portals-labs/portals-plugin-claude/portals-sdk"><img src="https://agentmods.dev/badge/skills/portals-labs/portals-plugin-claude/portals-sdk/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-sdk

Your own site · 80×15
<a href="https://agentmods.dev/skills/portals-labs/portals-plugin-claude/portals-sdk"><img src="https://agentmods.dev/badge/skills/portals-labs/portals-plugin-claude/portals-sdk.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 120 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,261 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.00120 $0.01261
Opus 5 $0.00060 $0.00630
Sonnet 5 $0.00024 $0.00252
Haiku 4.5 $0.00012 $0.00126

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

Security

Grade A, and why

portals-sdk 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 4d 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-sdk/SKILL.md · 50 lines

How it starts

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

Portals SDK

The Portals global connects a hosted web game to the Portals player and host: identity, the player's public username and playable avatar, saved progress, casual scores, leaderboard reads, and closing the game.

Read references/portals-sdk.md for the full API, code examples, and the method reference table. It is the official documentation, copied verbatim.

Wiring

Portals stamps the SDK into every processed preview and published bundle. Include it from the game's own origin, before game code:

<script src="./_portals/sdk.js"></script>
<script src="./game.js"></script>

Never download, edit, or bundle _portals/sdk.js — Portals replaces the managed copy on every process and publish. TypeScript declarations live at https://portals.to/portals-sdk/portals.d.ts; they are not part of the game's files.

Host UI reserve

Every launched game keeps a trusted Portals controls trigger above the game iframe. The current closed trigger is 44×44 CSS pixels at left: max(12px, env(safe-area-inset-left)) and top: max(12px, env(safe-area-inset-top)); a party badge may extend 4px beyond it. Keep essential and interactive HUD UI outside that top-left footprint. For a top HUD, use padding-left: calc(max(12px, env(safe-area-inset-left)) + 56px); for a left HUD, use the equivalent top inset. A full-bleed non-interactive playfield is fine.

The host control is outside and above untrusted game code. Never try to hide, restyle, intercept, or out-z-index it. Its expanded panel may temporarily cover more of the game and owns focus while open, so pause or otherwise keep gameplay safe until focus returns.

Rules that are easy to get wrong

  • await Portals.ready() before reading the player or using any hosted capability. session.context is standalone on a game page, room inside a Portals room.
  • Call Portals.identity.requestLogin() only from a direct player action such as a button click. Portals owns the sign-in UI — never ask for a Portals password or account credential in-game.
  • playerId is stable per player within one game and deliberately different across games. It is not a Portals account ID and must not be used to correlate a player across games. It is null for signed-out players, so always render a fallback name.
  • Portals.player.get() reads the current public profile — username without the @, and avatar, the playable look saved on the Portals /avatar screen. avatarUrl is only a 2D profile image; never load it as a 3D character. Both are null for a guest. The first signed-in read is cached for the game load, so call it again after requestLogin().
  • Portals.avatar.openPicker() opens the trusted global avatar UI from a direct click and resolves to the refreshed profile once the player saves; Cancel rejects. It is unavailable in the editor preview — catch the rejection, keep the preview playable, and verify the flow in a published host. Games never read inventory or equip items by ID; avatar.wearables is render data, not ownership proof.
  • Saved state must be JSON-serializable and at most 64 KB encoded. Signed-out players cannot save; loadState() returns null when nothing is saved. Version the shape (schemaVersion) when it may change.
  • Scores and saves require sign-in. A score mode is lowercase letters, numbers, and hyphens, max 32 characters, defaulting to default. getLeaderboard takes a limit of 1–100, default 10.
  • submitScore keeps the player's highest score for a mode. Pass { replace: true } as the third argument — Portals.submitScore(score, mode, { replace: true }) — only when the game's score can legitimately go down and the new value must replace a higher stored one.
  • Scores are client-reported. Never use them to award currency, paid prizes, access, or any other valuable entitlement.
  • The leaderboard works in draft play too — submitScore and getLeaderboard are live in the editor preview and behind a shared ?draft= link. Draft play uses a separate draft board, so test a leaderboard before publishing; those scores never reach the published game's ranking, and the published board starts empty.
  • Every async method can reject — no host, invalid request, missing access, network failure. Catch at the player action that caused it and keep the game playable when an optional Portals feature is unavailable.
  • Never put API keys, Firebase tokens, payment details, or signed asset URLs in game code, saved state, score modes, logs, or leaderboard UI.

Read the full file on GitHub · 50 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. 4d ago Changed · +1 lines d30d3ca4c6a6
  2. 12d ago First seen · 49 lines · 120 tokens per session scan A 8917654feb7c

Subscribe to this mod's changes

portals-sdk is a skill published in the GitHub repository portals-labs/portals-plugin-claude (4 stars, last pushed 3d ago), licensed ISC. It adds 120 tokens to every session and 1,261 once invoked, about $0.0006 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

worker-visualizer

A real-time data/particle/simulation visualizer whose heavy compute runs in a Web Worker (off the main thread), optionally sharing memory with the UI via SharedArrayBuffer, and renders to a canvas at 60fps. Produced as a single self-contained index.html. Use when the brief asks for a "web worker", "simulation"…

nexu-io/open-design · 123 tokens

react-three-fiber

React Three Fiber 3D renderer for json-render. Use when working with @json-render/react-three-fiber, building 3D scenes from JSON specs, rendering meshes/lights/models/environments, or integrating Three.js with json-render catalogs.

vercel-labs/json-render · 54 tokens

vgpu

Build, debug, test, and optimize WebGPU projects using vgpu, its CLI, or @vgpu packages. Use for vgpu API questions, WGSL workflows, browser or Node rendering, integrations, testing, and performance work.

vercel-labs/vgpu · 51 tokens

matterjs

Use when implementing 2D physics interactions with Matter.js, including Engine/World setup, Render/Runner configuration, adding bodies and constraints, and scroll/interaction-friendly canvas scenes.

MengTo/Skills · 39 tokens

html-to-ugui

A pipeline for turning HTML interface prototypes into Unity UGUI Prefabs, which are reusable Unity interface objects. It uses browser-rendered layout data to preserve positions, images, text, controls, and device-adaptation intentions.

Alex-Rachel/TEngine · 150 tokens

threejs-game-director

Entrypoint for building, upgrading, and finishing Three.js browser games. Routes work across the sibling threejs- skills for gameplay, graphics, UI, 3D/image/audio asset generation, debugging, and release. Use for build-a-game, upgrade, polish, premium, AAA, high-fidelity, showcase, from-scratch, endless runner…

majidmanzarpour/threejs-game-skills · 86 tokens