agentleFS
openchamberopenchamber/openchamber/.agents/skills/ui-api-decoupling/SKILL.md

ui-api-decoupling

Skill12k starsChanged yesterdayMITView on GitHub

Use when creating or modifying OpenChamber shared UI data access, OpenCode SDK calls, `RuntimeAPIs`, runtime fetch/auth/URLs, authenticated browser assets, bridges/proxies, runtime switching, or server API routes.

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat runtime adapters as the imperative shell: they own transport, auth, serialization, and platform mechanics.

    line 14
  2. Distinctive:

    Before writing code that changes what a user can reach or do, write the surface list: every runtime this behavior exists on, and one line …

    line 29
  3. Distinctive:

    Resolve runtime state at call time: Do not cache runtime base URLs, resolver output, credentials, or SDK clients across endpoint switches.

    line 52
  4. Distinctive:

    Never put long-lived client credentials in URLs: Do not manually append URL tokens.

    line 54
  5. Distinctive:

    Parse at the boundary: Treat external, persisted, bridge, IPC, and network payloads as unknown until a schema, parser, or narrow …

    line 57
  6. Very specific:

    Model the real contract: Prefer precise result/state unions and required dependencies over loose strings, boolean combinations, optional …

    line 58
  7. Very specific:

    Do not immediately fetch a URL produced by getRuntimeUrlResolver().

    line 72
  8. Distinctive:

    Every applicable runtime has implementation or explicit unsupported behavior, and the surface list written before editing has a line for …

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

UI API Decoupling

Core Boundary

  • Official OpenCode API calls use @opencode/client (OpenCode 2.x, /api/* routes) through opencodeClient; only packages/ui/src/lib/opencode/ sees wire types, everything else uses the domain model in lib/opencode/model.ts.
  • OpenChamber-owned HTTP capabilities use RuntimeAPIs where runtime-specific behavior exists, otherwise explicit OpenChamber routes through runtimeFetch.
  • Browser/realtime consumers use shared runtime URL/socket helpers.
  • Shared UI never hardcodes localhost, ports, API origins, credentials, or one runtime's transport assumptions.
  • Treat runtime adapters as the imperative shell: they own transport, auth, serialization, and platform mechanics. Shared feature code receives trusted contracts and owns domain decisions.

Classify First

NeedCorrect path
Official OpenCode endpointopencodeClient or its SDK client
SDK gap for official OpenCodeNarrow documented wrapper in opencodeClient preserving request fidelity
OpenChamber HTTP routeruntimeFetch('/api/...')
Runtime-owned capabilityExtend RuntimeAPIs and implement each applicable runtime
Browser-owned authenticated URLRuntime URL resolver and scoped URL auth
SSE/WebSocketOwning realtime transport; also load relay-transport

Name The Surfaces Before Editing

Before writing code that changes what a user can reach or do, write the surface list: every runtime this behavior exists on, and one line per runtime saying what happens there. Runtimes are web, Electron desktop, VS Code, hosted mobile, and Capacitor mobile.

The step is done when no runtime is missing a line. "Not applicable" is a line; silence is not. A stable unsupported response is a valid outcome, an accidental fallthrough is not.

Carry the list into the pull request Affected surfaces table. A runtime you cannot answer for goes in the list as unknown.

This applies to any user-reachable behavior, not only shared UI data access. A sequence that spans native shell, server, and renderer has surfaces too; so does a capability that only one runtime implements today.

Load References By Task

TaskRequired reference
Iframes, downloads, raw images, object URLs, URL tokensreferences/browser-assets-and-auth.md
Adding runtime capabilities, VS Code behavior, Electron privilege/security, unsupported runtime behaviorreferences/runtime-parity.md
Locating implementations, route registration, runtime switching, or focused testsreferences/implementation-map.md

Load every matching reference before editing.

Rules

  1. Call official OpenCode APIs through the SDK, preserving its method, body, headers, query, auth, and abort signal.
  2. Keep OpenChamber routes explicit. Register them before the generic OpenCode proxy.
  3. Use runtime APIs for runtime-owned capabilities. Components consume hooks/providers, not runtime globals.
  4. Resolve runtime state at call time. Do not cache runtime base URLs, resolver output, credentials, or SDK clients across endpoint switches.
  5. Let transport own auth. HTTP uses runtime bearer handling; browser/realtime URLs use scoped short-lived URL auth where headers are impossible.
  6. Never put long-lived client credentials in URLs. Do not manually append URL tokens.
  7. Authoritative fetches signal failure. Adapters return a distinct failure result (sync-state-invariants, Failure Is Not Empty).
  8. Keep privileges at the native/runtime boundary. UI visibility and prompts are not authorization.
  9. Parse at the boundary. Treat external, persisted, bridge, IPC, and network payloads as unknown until a schema, parser, or narrow constructor produces the trusted type consumed by shared code. Do not validate fields and then continue passing the raw payload.
  10. Model the real contract. Prefer precise result/state unions and required dependencies over loose strings, boolean combinations, optional callback bags, any, or repeated casts. Make unsupported runtime behavior and failure distinct from valid empty success.
  11. Keep adapters deep and bridges thin. Hide meaningful protocol or platform mechanics behind an intention-revealing runtime operation; do not add pass-through layers that only rename SDK, fetch, or bridge calls.
  12. Scope every OpenCode read to the directory being worked in. Each such read starts that location with all its MCP servers, so one read per known project is a fan-out (opencode-v2, Every directory-scoped read starts a location).

HTTP Decision Rules

Pass route paths directly to runtimeFetch:

await runtimeFetch('/health');
await runtimeFetch('/api/config/settings');
await runtimeFetch('/api/fs/raw', { query: { path } });

Do not immediately fetch a URL produced by getRuntimeUrlResolver(). Use the resolver only when the browser/realtime API itself consumes the URL:

const imageSrc = getRuntimeUrlResolver().authenticatedAsset('/api/fs/raw?path=diagram.png');
const eventUrl = getRuntimeUrlResolver().sse('/api/event');

Plain fetch is reserved for intentional external origins that are not the active OpenChamber/OpenCode runtime.

Runtime Switch Safety

Review runtime base URL, auth, SDK clients, terminal/realtime transports, stores, session memory, and caches. Key caches by runtime identity where IDs, paths, or URLs can collide. Reset or reconnect affected state through the established runtime-switch flow.

Re-parse values obtained after a switch at their owning boundary. A type established for one runtime response does not make cached raw data from another runtime trustworthy.

Verification

  • Official calls use SDK paths or documented SDK-gap wrappers.
  • OpenChamber routes win before generic proxy fallback.
  • Request fidelity, auth, abort, query, and body behavior are tested.
  • Browser/realtime auth uses narrow allowlists and scoped tokens.
  • Every applicable runtime has implementation or explicit unsupported behavior, and the surface list written before editing has a line for each.
  • Runtime switching cannot reuse stale endpoint/auth/cache state.
  • Privileged Electron/extension behavior is enforced outside the renderer.
  • Focused transport, bridge, proxy, auth, and runtime tests pass.

Download now (ZIP)

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 1 mentionMay 2026: 5 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 11 mentionsSep 2026: 10 mentionsOct 2026: 31 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the openchamber/openchamber repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about openchamber/openchamber

The biggest 5 of 61 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 61

Talked about on GitHub, YouTube, Bluesky, the web and Hacker News (61 times).

On GitHub · 47

42 more on GitHub

On YouTube · 5

On Bluesky · 4

On the web · 4

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.