bounded-sh/skill

bounded-backend

- Author a Bounded backend: policy.json rules and invariants (rollingSum/windowSum/flowBound/conserve/tenantTag/tenantEdge/bound), functions (ctx.user/ctx.bounded/ctx.ai/ ctx.services/ctx.secrets), the actor and identity model (@user, runAs/actAs, @origin,…

View source
Original skill document

Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.

Bounded backend

The server side of a Bounded app: the policy that governs documented supported mutation surfaces, the proof-backed and runtime-enforced invariants, the functions that run trusted code, and the actor model that decides who is acting. The proof loop is bounded verify; treat PROVED differently from a non-blocking runtime advisory with proof status UNKNOWN. bounded deploy compiles and pushes; runtime rule and invariant checks reject violations before commit on their documented supported mutation surfaces. Do not generalize that coverage to an unsupported plane, undocumented storage path, or inherited corpus. For CLI/deploy see the bounded-deploy skill; for the client SDK and auth UI see bounded-frontend; to route across the family, see the root bounded skill.

Write the actor model in mind from the start: know who @user is, which principal a function acts as (runAs/actAs), and where authorization comes from (@origin) before you write a rule.

Reference Router

Building one of the five most common app shapes? Take the quick path - one target page per build - instead of scanning this table. Otherwise read only the row matching the current task or term.

Task or termRead
One-screen syntax: field types, tiers, variables, operators, where logic goespolicy cheat sheet
Generate or repair a policy from an app descriptionpolicy generation
Complete policy examples by intent (marketplace, escrow, vaults, staking, tokens, ...)examples index
Worked multi-collection policies (team SaaS, marketplace, realtime game)examples
Rule recipes: owner-only, admin-or-owner, membership, time windows, validation, immutable fields, atomic batchesaccess patterns
Rules, fields, expressions, @user, @data, @newData, @time, get(), getAfter(), transferAuthoritypolicy reference
Caps, balances, supply, tenant isolation, hard bounds; rollingSum, windowSum, flowBound, conserve, tenantTag, tenantEdge, boundinvariants
Trending feeds, leaderboards, ranked windowSum readstrending feeds
Browser CSP / restrict what app pages may reachbrowser boundary
Constants, reusable rules, @const, @defconstants and defs
Choose rule vs invariant vs hook vs functionwhen to use functions
Functions; declare, auth, entry, secrets, actAs, ctx.user, ctx.bounded, ctx.env, ctx.secrets, invoke, deployfunctions
Public functions: HTTP routes without a Bounded session at <slug>-api.bounded.page, public, methods, cors, public JWKS, machine callers, webhook and browser-public modespublic functions
ctx.ai.run, ctx.ai.generateImage, ctx.ai.generateVideo, getJob, AI without API keysctx.ai
ctx.services, managed third-party APIs, bounded servicesctx.services
ctx.browser, headless browser from a function, driving your own app signed in, @const.AGENT, agent identityctx.browser
ctx.enqueue, background jobs, queues, replay identityctx.enqueue
ctx.build, functions that originate governed app buildsctx.build
Start simple and graduate to functionsfunction graduation
User-owned provider API keyssecrets
Schedules, dueRows, hooks, webhooks, verifyWebhookscheduled hooks and webhooks
Recurring fleet sweeps without full scansscheduled sweeps
Anti-cheat proof limitshooks and anti-cheat
Atomic writes, subset attacks, requiresInBatch, incomplete_batchdata plane
Queries, pagination, queryAggregate, count, filters, sort, cursorqueries
Files, setFile, storage, full-text searchfiles and search
Realtime rooms; session.tick, settleTo, settleFrom, fog-of-war viewsrealtime and games
Native live modules; session.live, tick, views, @effect, live.intentlive runtime
Input cadence, interpolation, predictionrealtime netcode
AI NPCs / AI playersAI NPCs
Long-running backend runtime or managed servicesbackend runtime
Multi-step Flue agentsFlue agents
Owners, collaborators, scoped adminsadmin and ownership
Top-level roles, members, read:"*", read/write scopesroles
access, custom/external roles, __owners__, __admins__, __developers__, __viewers__access control · identity and logs
Service keys, payout bots, backend identities, runAs, actAs, @origin, ctx.originservice keys · principals and origins
Proof coverage, PROVED / DISPROVED, counterexamplesproof coverage · verify and counterexamples
Concrete allow/deny tests; policy-tests/*.json, bounded tests run/push/list/pullpolicy tests
End-to-end tests for authenticated appstesting authed apps
Completion reviewquality checklist
Agent-facing or backend-only appbuilding for agents · building a backend

Error Router

Error/statusMeaning
403A write or function invoke failed a rule. Check auth, ownership, roles, or function auth. Denied reads are hidden as 200 with empty data, not 403.
500 rule_evaluation_failedThe rule was reached and could NOT be evaluated - no rule denied you, and nothing was read or written. Not a denial, not a retryable conflict. Read bounded decisions for the cause; the row is recorded with decision: error.
409 + invariant nameThe transaction would violate an invariant. Fix state or policy.
403 incomplete_batchA collection's requiresInBatch declaration names companion paths missing from the atomic batch. Submit the complete setMany.
DISPROVED + counterexampleThe proof found a breaking assignment. Fix every blocking result and verify again; only non-blocking advisories are reviewable.
Static validation errorFix policy syntax, field types, tier/invariant pairing, constants, or expression use.

Rules Of Thumb

  • Use @user.id for normal ownership and membership checks; @user.address only for wallet/onchain semantics.
  • Denied reads return empty 200 responses. Test read denial with a different permitted identity, not by waiting for a read 403.
  • Use conserve for fixed totals, rollingSum for caps over time, and flowBound for cumulative per-partition outflow ≤ inflow; use one atomic set-many when correctness spans multiple writes.
  • When one write is invalid without companion writes, declare requiresInBatch so a hostile client cannot submit only the individually valid subset.
  • Put provider API keys in Bounded secrets, not frontend code.
  • Know the acting principal before writing a rule: a function's runAs/actAs and @origin decide who @user is and whether the call is authorized.
from this repository

More skills

All skills
bounded-sh
Community

bounded

- Build and use Bounded (bounded.sh), the full-stack app platform and policy-enforced realtime runtime for coding agents. Start here for a complete app, then load the focused Bounded skill for backend, frontend, deployment, or onchain work.

installs
1
GitHub stars
0
Updated
Sep 3
bounded-sh
Community

bounded-deploy

- Ship and configure a Bounded app: CLI setup, browser-backed developer login, verify and deploy, hosted frontend publishing, environments, source sync, domains, bounded.json, collaborators, and release recovery. Part of the Bounded skill family.

installs
1
GitHub stars
0
Updated
Sep 3
bounded-sh
Community

bounded-frontend

- Wire a web or React Native frontend to Bounded: the @bounded-sh/client SDK (reads, writes, subscriptions, queries), hosted static frontends, and end-user auth UI (email OTP, OAuth, browser guest/anonymous accounts and upgrade). Use when building the client of a Bounded app or handling how end users sign in. Part of the Bounded skill family; server-side rules, functions, and the actor model live in the bounded-backend skill, and deploy/hosting config in bounded-deploy.

installs
1
GitHub stars
0
Updated
Sep 3
bounded-sh
Community

bounded-onchain

- Add onchain to a Bounded app: Solana collections, embedded non-custodial wallets for email/social users (@user.address, Turnkey by default), client- and server-signed transactions, DEX/perps trading patterns, and crypto payments (accept USDC/crypto non-custodially). Use for wallet, token, on-chain transaction, or crypto payment work. Part of the Bounded skill family; policy and the actor model live in bounded-backend.

installs
1
GitHub stars
0
Updated
Sep 3