/caddis-extras:data-contract-pipelinefrom caddis-extras
Build, audit, and validate DB-to-UI data contracts. Use when the user mentions data mapping, UI lineage, DisplayDTOs, source-to-screen mapping, or asks if a UI is backed by real data.
Ships in caddis-extras. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Build a verified path from data sources to UI fields without leaking raw database or file structure into frontend components.
Requirements + UI demand decide what should be displayed.
DBs / files / APIs decide what can be displayed.
Ingestion model → normalizer → DisplayDTO defines the safe contract between them.
If your organization has a reference scaffold for this pattern, run its tests first to understand it before applying the pipeline below.
Do you have DB schema docs, ERDs, or an existing API spec?
│
├─ YES → documented_workflow.md (Intake → Audit → Reconcile → Generate → Validate)
│
└─ NO → discovery_workflow.md (cold start — introspect DB first, then same 5 stages)
Are you only checking whether an existing UI is backed by data?
└─ YES → Run Stage 2 (Audit) only; produce gap_register in .contracts/
config/.env.api.dev unless you say otherwise."TOP N / OFFSET+FETCH on LIVE tables. Never unbounded SELECT *.Collect or infer:
build | audit | drift-check | lineage-only.Search .env*, settings modules, Docker Compose, and deployment manifests for DB config before asking.
Classify every source column against the D1–D12 drift catalogue.
D1 No fields dropped from embedded JSON/markdown blobs.
D2 Ingestion model has extra="allow" (future columns are captured, not rejected).
D3 DisplayDTO has extra="forbid" (normalizer bugs surface immediately).
D4 DisplayDTO uses camelCase field aliases (serialised output matches frontend expectations).
D5 NULL semantics are preserved, not defaulted (NULL revenue ≠ $0).
D6 Type coercion validated: string → Decimal, string → datetime, string → bool.
D7 Normalizer produces correct status for each null/malformed/full payload variant.
D8 Golden sample round-trip: raw_row → normalizer → model_dump(by_alias=True) matches expected.
D9 Schema drift: live DB columns match ingestion model field list.
D10 API → TypeScript: DisplayDTO aliases match generated TS interface keys.
D11 PII columns classified and not exposed unintentionally via DisplayDTO.
D12 Bounded query: repository enforces page_size ≤ MAX_PAGE, no unbounded SELECT.
For embedded payload columns (NVARCHAR(MAX) / TEXT):
embedded_json_adapter → embedded payload model (extra="allow" at every depth)embedded_markdown_adapter → sections + bold_kv dictcsv_column_adapter (RFC 4180 quoted-comma aware)embedded_text_adapter → paren_ids + linesProduce: annotated column list; flag null semantics, embedded type, and known sub-schema.
Map each source column to a DisplayDTO field. Assign one status per field:
| Status | Meaning |
|---|---|
contract-backed | Source → normalizer → DisplayDTO → FE type tested end-to-end |
partially-backed | Derives from nullable payload; may degrade to blocked at runtime |
blocked | Mandatory source column always NULL in prod — cannot populate |
required-unplaced | Frontend/requirements demand it; source not yet identified |
source-capability-only | Source has it; no requirement or UI demand exists yet |
mockup-only | In UI mockup only — no backend data path |
deferred | Explicitly out of scope for current sprint |
Use the reconcile sub-prompt: assets/prompts/reconcile_mapping.md.
Output: .contracts/feature.contract.json.
Produce layers in this order:
extra="allow", raw payload columns as str | None)extra="allow")frozen=True, extra="forbid", camelCase aliases)text() with named params, schema-qualified, bounded)response_model= on every route, Query bounds with ge/le).contracts/query_catalog.md (see below)/openapi.json via npx openapi-typescript_FLEX = ConfigDict(populate_by_name=True, extra="allow") on ingestion models.
_FROZEN = ConfigDict(frozen=True, extra="forbid", populate_by_name=True) on DisplayDTOs.
pytest tests/unit/ -v # all D1-D12 checks must pass
For mockup-only or required-unplaced fields: generate ui_gap_brief.md and ask the
user to place, promote, or defer — do not silently add to a random screen.
CI rule: frozen contracts fail on unmapped DisplayDTO fields, DTO/type drift, and missing PII classification.
For every DB-backed UI field, produce .contracts/query_catalog.md.
This document must be executable — every SQL block should run as-is against the target DB (substitute
{schema} with the real schema name, e.g. dbo). Its purpose is to make explicit, during data analysis
or debugging, exactly which SQL query populates which UI element.
# Query Catalog — {Feature Name}
# Generated: {date}
# Target: {DB server / environment}
---
## {EntityName} — {repository function name}
**UI fields populated:** `fieldA`, `fieldB`, `fieldC`
**Called by:** `{ServiceClass}.{method}` → `{NormalizerFunction}` → `{DisplayDTO}`
**Paging:** TOP {MAX_PAGE} / OFFSET+FETCH
```sql
-- Fetch {EntityName} rows, paged
-- Parameters: :customer_id (optional filter), :offset (int), :page_size (int)
SELECT
t.column_a AS field_a,
t.column_b AS field_b,
t.payload_column AS payload_column -- NVARCHAR(MAX): parsed by embedded_json_adapter
FROM {schema}.TableName AS t
WHERE (:customer_id IS NULL OR t.customer_id = :customer_id)
ORDER BY t.created_at DESC
OFFSET :offset ROWS FETCH NEXT :page_size ROWS ONLY;
```
**Derived fields from payload_column (not in SQL — extracted by normalizer):**
| UI field | Source path | Adapter |
|---|---|---|
| `summaryStatus` | Derived from NULL check on `payload_column` | n/a |
| `keyIssueCount` | `payload_column → key_issues[].length` | `embedded_json_adapter` |
| `dashboardMetrics` | `payload_column → dashboard_metrics{}` | `embedded_json_adapter` |
## section per repository function (one query per section).:param), not f-string interpolation.OFFSET+FETCH or TOP N bound in every query — never unbounded.{schema}.TableName with a comment showing the default (e.g. -- default: dbo).python fixture/seed_sqlite_fixture.py && sqlite3 fixture/sample_source.db < .contracts/query_catalog_sqlite.sql.SELECT * on large LIVE tables; always boundREADME.md (opens in a new tab)assets/adapter.py.template (opens in a new tab)assets/api-router.py.template (opens in a new tab)assets/contract-test.py.template (opens in a new tab)assets/display-dto.py.template (opens in a new tab)assets/frontend-service.ts.template (opens in a new tab)assets/frontend-types.ts.template (opens in a new tab)assets/ingestion-model.py.template (opens in a new tab)assets/mapping-doc.md.template (opens in a new tab)assets/normalizer.py.template (opens in a new tab)assets/prompts/extract_requirements.md (opens in a new tab)assets/prompts/extract_ui_demand.md (opens in a new tab)assets/prompts/reconcile_mapping.md (opens in a new tab)assets/query-catalog.md.template (opens in a new tab)references/consumer-driven-contracts.md (opens in a new tab)references/drift-check-catalog.md (opens in a new tab)references/layer-responsibilities.md (opens in a new tab)scripts/discover_connections.py (opens in a new tab)scripts/discover_sources.py (opens in a new tab)scripts/drift_check.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub saajunaid/caddis-plugin --plugin caddis-extras81 skills in this plugin
/adopt-rbacPointer to the org's RBAC adoption skill. Use for "add RBAC to this app" or "adopt rbac-kit"./agent-md-refactorRefactor bloated agent instruction files (AGENTS.md, .cursorrules, .github/ files) into linked, progressively disclosed docs./agent-orchestrationBlueprint for orchestrating the agent pipeline from spec to planning, implementation, testing and debugging, plus when a second model is worth it, the intent→model map and cost guardrails./algorithmic-artGenerative and algorithmic art with p5.js: flow fields, particle systems, animations, WebGL, audio-reactive visuals; exports HTML, PNG, GIF, MP4, SVG. Use for creative coding or any p5.js visual./anchor-reviewSingle-model adversarial review technique — 3-lens analysis with confidence scoring and self-challenge/api-client-patternsTyped client-side API consumption: fetch wrappers, zod validation, auth injection, TanStack Query (useQuery, useMutation, optimistic updates), tRPC, OpenAPI codegen, pagination. Use when consuming REST or tRPC APIs.