Build Standards

Reference material for every Mandantis package author — integration patterns, build-package scaffolding, governance conventions, kill-switch discipline. 4 locked patterns · 3 build-package tiers · 6 monorepo commands.

01 · Integration Patterns (DEC-003)

4 locked patterns

Every system interaction uses one of these patterns. No new pattern without a DEC-NNN register entry — pattern discipline is the governance mechanism.

  • mgp-api

    System/automation caller. Service principal. All DB/Xero/Stripe calls. No UI touches data stores directly.

  • mgp-mcp

    AI model caller. OBO/delegated auth. Explicit tool allow list. Class 3 default.

  • mgp-webhook

    Inbound event ingress. HMAC verified. Sub-pattern of mgp-api.

  • mgp-portal-api

    Authenticated human REST. WorkOS AuthKit / CF Access. No AI. Define before portal build.

02 · Build Package Standard

Tier 1 / 2 / 3 file checklist

Every package scaffold starts from templates/new-package/. Tier 1 is mandatory; Tier 2 & 3 apply when the package deploys an agent or integrates external systems.

Tier 1

Mandatory — every package
  • CLAUDE.mdsession brief · read first
  • README.md
  • build-sequence.mdordered steps per Feature
  • package.jsonmandantis.ba_capability declared
  • wrangler.toml
  • tsconfig.jsonextends ../../tsconfig.base.json
  • docs/decision-log.md

Tier 2

If the package deploys an agent
  • docs/agent-brief.md
  • docs/data-flow.md
  • docs/tool-manifest.md
  • docs/test-plan.md

Tier 3

If the package integrates external systems
  • docs/integration-register.md
Download templates/new-package/ →

03 · GitHub Projects Lifecycle

Work-item conventions

Shared vocabulary across every Mandantis repo. Principal-only actions highlighted.

States

  • Open
  • In Progress
  • In Review
  • Closed (Principal only)

Labels

  • [epic]
  • [feature]
  • [story]
  • [task]
  • [decision]

Comment prefixes

  • [QUESTION]
  • [DECISION-REQUIRED]
  • [DEVIATION]
  • [BLOCKER]
  • [ESCALATION-PROPOSED]
  • [ESCALATION-CONFIRMED]
  • [PRINCIPAL-MERGE]

Milestones

  • 2026-S## (sprint) or 2026-W## (week)

04 · Kill-switch Pattern (DEC-004)

Every Worker has a kill switch

Read-only check against a Cloudflare KV key. The key lives in the shared mandantis-platform namespace; the Worker never writes to it. /health is exempt so oncall can probe during maintenance.

// src/middleware/kill-switch.ts
import type { Context, Next } from 'hono'

export const KILL_SWITCH_KEY = 'service:<package>:enabled'

export interface KVGetter {
  get(key: string): Promise<string | null>
}

export async function killSwitchMiddleware(
  c: Context<{ Bindings: { KILL_SWITCHES: KVGetter } }>,
  next: Next,
): Promise<Response | undefined> {
  if (c.req.path === '/health') {
    await next()
    return
  }
  const value = await c.env.KILL_SWITCHES.get(KILL_SWITCH_KEY)
  if (value === 'false') {
    return c.html(maintenanceHtml(), 503)
  }
  await next()
}

05 · Monorepo Commands

Run from repo root

Installpnpm installinstall + link workspace deps
Typecheckpnpm typechecktsc --noEmit across all packages
Lintpnpm linteslint with --max-warnings=0
Testpnpm testvitest across all projects
Buildpnpm buildturbo build — tsc emits to dist/
Format checkpnpm format:checkprettier --check (CI-gated)