skills/backend-integration/SKILL.md
Use this skill when converting a generated Customware client-only SPA into the standard backend-enabled stack, especially for the canonical task "Wire backend integration" or any task that replaces localStorage/browser storage with Hono + tRPC + Zod + neverthrow + SQLite/Drizzle, adds backend-focused unit and end-to-end tests, preserves the app's existing implemented behavior, and adapts files, configs, packages, and test patterns from the Customware `template-be-setup` reference repo.
npx skillsauth add customware-ai/skills backend-integrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill for the full backend-integration workflow. This skill is intentionally self-contained.
Wire backend integration.playwright-interactive-sandbox, and only for baseline/final interactive QA passes.plan.md on every compaction before continuing.Convert the app toward the Customware reference stack:
Result / ResultAsyncbetter-sqlite3The backend reference repo is:
[email protected]:customware-ai/template-be-setup.githttps://github.com/customware-ai/template-be-setup.gitUse the same clone pattern/runtime approach already known to work for Customware repos in the execution environment.
client-only-spaWhen migrating from the standard client-only-spa starter toward the backend-enabled stack, treat the following as the minimum baseline delta that must be accounted for.
hono@hono/node-server@hono/trpc-server@trpc/server@trpc/client@trpc/react-query@tanstack/react-querybetter-sqlite3drizzle-ormdotenvvitestjsdom@playwright/test@testing-library/dom@testing-library/jest-dom@testing-library/react@testing-library/user-eventdrizzle-kittsxtypescript@types/better-sqlite3build:clientbuild:serverteste2e:installe2edb:generatedb:migrate.env.exampledrizzle.config.tsplaywright.config.tsvitest.config.tsserver/tsconfig.jsonserver/index.tsserver/start.tsserver/utils/env.tsserver/db/index.tsserver/db/schemas.tsserver/db/migrate.tsserver/trpc/router.tstests/e2e/database.tstests/e2e/global-setup.tstests/unit/setup.tstests/unit/helpers.tslatest, next, floating ranges, or ad hoc newer versions for Playwright or any other backend/runtime/testing package during this task.plan.md in the project root using the exact section contract in this skill.AGENTS.md with the AGENTS.md from the backend reference repo.AGENTS.md before continuing.playwright-interactive-sandbox for a baseline interactive audit of the current app behavior and record the findings in plan.md.npm run build and npm run start.plan.md.playwright-interactive-sandbox again for final interactive verification of behavior parity after backend migration.plan.md as the final successful step.Do not skip a prerequisite step because the later action seems obvious.
The purpose of backend integration is:
This task does not need domain knowledge files to decide scope.
DOMAIN.md / domain.md to redefine the product.AGENTS.md ReplacementAGENTS.md with the AGENTS.md from the backend reference repo is a required step.AGENTS.md in place.AGENTS.md becomes the new governing repo instructions for the migrated app.AGENTS.md before continuing any migration work.npm run build and npm run start.start.js or any old startup-script path once the backend server startup flow takes over.plan.md must exist for the duration of the backend integration task.plan.md must use the exact top-level section headings defined in this skill.Storage Migration Inventory section.Coverage Mapping section.plan.md is a working checklist, not a narrative document.plan.md continuously as work progresses.playwright-interactive-sandbox in exactly two intentional passes unless a special failure requires another pass:
plan.md, especially in:
Current App AuditCoverage Mappinginterface / type declarations as the primary definition for backend contract shapes.better-sqlite3Use the template-be-setup repo as the canonical reference for stack, file layout, package choices, test setup, and migration patterns.
package.json
.env.examplevite.config.tsreact-router.config.tstsconfig.jsonserver/index.ts
/trpc/*server/start.ts
server/utils/env.ts
server/db/index.ts
server/db/schemas.tsserver/db/migrate.tsdrizzle.config.tsserver/db/migrations/*server/contracts/*
server/db/queries/*
server/services/*
server/trpc/router.ts
app/lib/trpc-provider.tsx
tests/e2e/database.ts
tests/e2e/global-setup.ts
playwright.config.ts
vitest.config.ts
tests/unit/setup.ts
tests/unit/helpers.ts
tests/e2e/README_FIRST_BEFORE_ADDING_E2E_TESTS.spec.ts
tests/unit/services/estimate.test.ts
plan.md ContractUse this exact top-level section order in plan.md.
# Backend Integration Plan
## Context Reload
- [ ] Re-read project `AGENTS.md`
- [ ] Re-read backend integration skill
- [ ] Re-read current `plan.md`
- [ ] Re-read the specific backend reference files needed for this app
## Reference Intake
- [ ] Clone or refresh the backend reference repo in a temp location if needed
- [ ] Identify the exact reference files to adapt
- [ ] Identify required package/config deltas
- [ ] Note app-specific differences from the reference
## Current App Audit
- [ ] Inventory current localStorage/browser-storage backed flows
- [ ] Inventory current routes/pages and key interactions
- [ ] Inventory current implemented behavior that must be preserved exactly
- [ ] Inventory current domain entities that need persistence
- [ ] Inventory current tests and test gaps
- [ ] Inventory stale mocks/fixtures/storage helpers to remove or replace
## Package And Runtime Alignment
- [ ] Align required backend/runtime dependencies
- [ ] Align backend/runtime/testing package versions to the backend reference repo
- [ ] Align required npm scripts
- [ ] Align required config files
- [ ] Replace frontend-only build/start behavior with the backend reference flow while keeping `npm run build` and `npm run start`
- [ ] Remove or adapt obsolete frontend-only startup paths
- [ ] Align runtime port/server startup assumptions
## Server Skeleton
- [ ] Establish/adapt `server/` structure
- [ ] Establish/adapt Hono app setup
- [ ] Establish/adapt tRPC mounting
- [ ] Preserve static asset + SPA fallback behavior
- [ ] Confirm server startup and health path works
## Database And Migration Setup
- [ ] Establish/adapt sqlite path handling
- [ ] Establish/adapt Drizzle schema files
- [ ] Establish/adapt migration runner
- [ ] Generate/apply migrations as needed
- [ ] Account for local runtime DB path and E2E DB path
## Contract Query Service Router Chain
- [ ] Define/adapt Zod contracts for the first migrated domain area
- [ ] Implement/adapt query layer for that area
- [ ] Implement/adapt service layer for that area
- [ ] Implement/adapt router procedures for that area
- [ ] Repeat until every migrated domain area has a complete chain
## Frontend Data Wiring
- [ ] Add or align tRPC provider/client wiring
- [ ] Replace localStorage-backed reads for migrated flows
- [ ] Replace localStorage-backed writes for migrated flows
- [ ] Preserve existing page behavior and navigation
- [ ] Remove stale localStorage-only helpers or mark retained helpers with justification
## Storage Migration Inventory
- [ ] List every old localStorage/browser-storage path
- [ ] Mark each path as migrated / intentionally retained / deleted
- [ ] Confirm no storage path is left unaccounted for
## Seed Fixture And Test Data Setup
- [ ] Establish deterministic backend test-data setup
- [ ] Align Playwright DB reset/setup pattern
- [ ] Align unit-test setup/helpers from the backend reference repo
- [ ] Add or adapt seed/fixture helpers as needed
- [ ] Replace template sample data assumptions with app-specific test data
## Coverage Mapping
- [ ] Map significant routes/pages/flows to automated coverage
- [ ] Map backend modules to service/query/unit coverage
- [ ] Map E2E user journeys to Playwright coverage
- [ ] List app-specific edge cases requiring coverage
## Automated Tests
- [ ] Create/update unit tests for migrated client/server behavior
- [ ] Create/update service/query/backend tests
- [ ] Create/update Playwright E2E tests
- [ ] Remove or update tests that only validate the old localStorage mode
## Verification
- [ ] Run required validation commands
- [ ] Run required migration/setup commands
- [ ] Run targeted unit/service tests
- [ ] Run targeted Playwright E2E tests
- [ ] Confirm the app works end-to-end in backend mode
## Cleanup
- [ ] Remove temp backend reference clone/assets
- [ ] Remove temporary execution-only files
- [ ] Remove demo/template-only backend code and placeholder test artifacts once real replacements exist
- [ ] Remove `plan.md` as the final successful step
Add these only when the current generated app actually needs them:
## Additional Domain Modules## Logging And Runtime Diagnostics## Complex Import Or Fixture Backfill## Advanced Query Or Reporting Shapesplan.md Rulesplan.md on every compaction before continuing work.Backend integration is not complete until tests and verification are done.
Use the reference repo's patterns for:
The reference example is:
tests/unit/services/estimate.test.tsAdapt the pattern to the app's real domain modules.
Use the reference repo's deterministic E2E DB setup pattern:
tests/e2e/database.tstests/e2e/global-setup.tsplaywright.config.tsThis means:
This is a required rule:
Do not keep the demo E2E example as product coverage. Replace it with real flow coverage.
Map tests to real migrated behavior:
Do not satisfy this with shallow "page renders" tests alone.
Run verification in this order unless higher-priority repo instructions override it:
Before final completion:
plan.md complete and fully checked off?plan.md removed as the final successful step?plan.md.On successful completion, remove:
plan.mdDo this only after validation is complete.
development
This skill is strict implementation instruction, not advisory reference text. The skill treats the HTML as discovery-only input, forces interactive Playwright route/state capture, then moves through scored gates for source acceptance, implementation planning, authored UI reproduction, implementation integrity, visual verification, and adversarial proof before signoff.
development
Use this skill for Customware existing-project migration tasks that move uploaded customer apps from other builders into the standard Customware stack while preserving the source product's routes, workflows, UI, UX, and styling with no intentional user-facing changes while replacing only the runtime foundation. This skill covers both `Migration build` and `Migration verify` and includes self-grading quality gates that must pass before the task can complete.
development
Primary Playwright governance skill for sandbox browser verification and deterministic end-to-end authoring or rewrite work.
development
Universal visual quality skill for every Customware build. Encodes layout philosophy, hierarchy, restraint, rhythm, brand theming mechanics, the template contract, BrandMark rendering, archetype catalog, component recipes, and aesthetic anti-patterns. Read on every UI build. The first task agent (mitb-initial-agent) runs the vision pass once; this skill is the implementation contract that turns vision into a coherent app. Trigger signals: any UI build, improving visual quality, aesthetic balance, polished design, hierarchy, restraint, taste, component design, layout principles, premium feel, brand theming, template contract, light-mode default, BrandMark.