mcpField
B
bounded-backend

bounded-backend

github.com/bounded-shDevelopment075 installsUpdated 2d ago
Repository

About bounded-backend

A backend policy authoring skill for Bounded apps, covering rules, invariants, functions, actor identity, and policy tests. It is intended for developers building or maintaining Bounded backends and routes them to task-specific references.

Key features

  1. 01Write access rules and runtime invariants
  2. 02Define functions, identity, and authorization
  3. 03Consult policy examples and access patterns
  4. 04Run concrete policy tests and inspect failures
  5. 05Route tasks to relevant backend references

Use cases

  1. 01Set ownership and membership access rules
  2. 02Constrain balances, supply, or tenant data
  3. 03Configure function identity, authorization, and invocation
  4. 04Test which operations policies allow or deny

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/bounded-sh/skill --skill bounded-backend

After installing, type/bounded-backendin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

docs/
access-control.md
access-patterns.md
admin-and-ownership.md
agents-flue.md
ai-npcs.md
backend-runtime.md
browser-boundary.md
building-a-backend.md
building-for-agents.md
constants-and-defs.md
data-plane.md
examples.md
files-and-search.md
formal-verification.md
functions-ctx-ai.md
functions-ctx-browser.md
functions-ctx-build.md
functions-ctx-enqueue.md
functions-ctx-services.md
functions-graduation.md
functions-when-to-use.md
functions.md
hooks-and-anti-cheat.md
hooks-scheduled-webhooks.md
identity-and-logs.md
invariants.md
live-runtime.md
policy-cheat-sheet.md
policy-examples.md
docs/examples/
marketplace.md

Details

From the project README

Bounded backend

The server side of a Bounded app: the policy that governs documented supported mutation surfaces, the runtime-enforced invariants, the functions that run trusted code, and the actor model that decides who is acting. bounded deploy validates, compiles, and pushes; runtime rule and invariant checks reject violations before commit on their documented supported mutation surfaces. Check a policy with concrete policy tests (bounded tests run) and by deploying it. 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
Require or copy a user's verified X account in a rule, get(/__connections__/@user.id).xHandle, testing linked-X rules, handles typed before linking, onchain appsconnected accounts
Rules, fields, expressions, @user, @data, @newData, @time, get(), getAfter(), ownership fieldspolicy 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 builds, image and video builds, mediaSlotsctx.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, missing versus null, $exists, 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
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.
Deploy validation errorDeploy refused the policy before anything changed. Fix policy syntax, field types, tier/invariant pairing, constants, or expression use as the message names.

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. get() inside a policy-test expect reads sandbox state with read rules skipped, so prove a denied read with a second real session. Write and delete denials stay on shouldFail.

  • 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.

  • For authenticated app actions, use the client SDK functions.invoke, declare the function auth rule, and use ctx.user. Do not send a Bounded session token in function arguments or build a JWT verifier inside a public HTTP function. Keep intentionally public data, such as today's prompt, in a separate public function without user-state access.

  • Verify private function flows as a non-owner user, including an anonymous session when the app supports guests. Save state, reload, and resume it; owner CLI calls can mask data-read permission failures. A denied read may appear as missing data, so investigate authorization before recreating state or weakening rules.

Comments

Markdown supported