Engineering & Agent Conventions Starter PackTypeScript & HTTP API Conventions
conventionunverifiedstable1 min read

TypeScript & HTTP API Conventions

Type Safety

  • No implicit any: Prefer unknown at untrusted I/O boundaries (HTTP request bodies, queue messages, external webhooks) and narrow with explicit schema validation.
  • Shared contracts: Keep request/response types and entitlement constants in shared/ so worker routes and frontend hooks cannot drift.
  • Exhaustive switches: Use discriminated unions for status and state machines (status: "pending" | "completed" | "failed").

HTTP Error Envelopes

All API error responses must return a consistent JSON structure with an appropriate HTTP status code and Cache-Control: no-store on authenticated routes:

{
  "error": {
    "code": "QUOTA_EXCEEDED",
    "message": "Workspace share limit reached. Upgrade to Pro for up to 500 active shares."
  }
}

Idempotency & Concurrency

  • Mutating publish and revision endpoints accept an explicit Idempotency-Key or --expected-revision guard so retried CI jobs never create duplicate shares or overwrite concurrent edits silently.
Knowledge mapSee how this bundle connects4 concepts · 3 internal linksOpen mapHide map
Reading TypeScript & HTTP API Conventions
overviewguiderunbookconvention

Click a node to open it. The highlighted node is the concept you are reading.

FOCUS READER

Speed read

Paused

Ready

300 wpm

Space play/pause · arrows step or change rate · Escape closes