Cross-Layer Contract Audit
Find mismatches between layers. Code and schema evidence outrank documentation.
When To Use
Use this for cross-layer behavior where two or more implementation layers must agree.
Do not use this for a general repo status snapshot; use project-status-dashboard. Do not use it for planning a new feature from scratch; use feature-spec-delivery-pipeline.
Scope
Adapt the layer map to the repo. Common layers include:
- Client models, forms, screens, state, and generated API clients.
- API routes, handlers, serializers, validators, and service methods.
- Database schema, migrations, views, policies, triggers, and seed data.
- Background jobs, queues, webhooks, and third-party integration contracts.
- Documentation and specs as supporting context only.
Input Signals
Start from concrete signals such as changed files, failing tests, route names, migration names, API schemas, generated clients, UI forms, webhook payloads, or user-reported mismatches. If the user gives only a broad area, map the smallest boundary that can be verified end to end.
Workflow
- Identify the user-requested contract or feature area.
- Map callers and callees across layers.
- Compare:
- Field names, types, nullability, defaults, enums, and units.
- Required vs optional values.
- Error formats and status codes.
- Auth, permissions, tenancy, and ownership checks.
- State transitions and side effects.
- Revalidate each suspected mismatch against source files.
- Produce a severity-ranked report.
For sample prompts and report shape, see references/examples.md.
For a compact field-by-field audit checklist, see references/contract-checklist.md.
Output
For each finding:
- Severity: blocker, high, medium, low.
- Contract: the layer boundary that is inconsistent.
- Evidence: file paths, symbols, routes, migrations, or schema names.
- Impact: likely user or data effect.
- Fix Direction: smallest safe repair, noting which layer should change.
- Verification: targeted tests or commands that would prove the fix.
Guardrails
- Do not trust docs as truth when implementation differs.
- Do not fix during the audit unless the user explicitly approves implementation changes.
- Flag unclear product behavior as an open question rather than deciding it.
- Treat auth, payments, sessions, data migration, and destructive changes as high-risk.
Avoid
- Do not report a mismatch without naming both sides of the boundary.
- Do not collapse product uncertainty into an implementation recommendation.
- Do not broaden the audit into unrelated refactors.
Final Checks
- Every finding has source-backed evidence.
- Each impact explains the likely user, data, or operational effect.
- Each fix direction names the layer that should change.
- Unknown product behavior is listed as an open question, not resolved by assumption.
1---
2name: cross-layer-contract-audit
3description: Audit client, API, database, and docs for contract mismatches. Use for schema drift, auth/session/payment changes, migrations, or integration regressions.
4metadata:
5 source: https://skillmd.com/skills/aibot88/cross-layer-contract-audit
6---
7
8# Cross-Layer Contract Audit
9
10Find mismatches between layers. Code and schema evidence outrank documentation.
11
12## When To Use
13
14Use this for cross-layer behavior where two or more implementation layers must agree.
15
16Do not use this for a general repo status snapshot; use `project-status-dashboard`. Do not use it for planning a new feature from scratch; use `feature-spec-delivery-pipeline`.
17
18## Scope
19
20Adapt the layer map to the repo. Common layers include:
21
22- Client models, forms, screens, state, and generated API clients.
23- API routes, handlers, serializers, validators, and service methods.
24- Database schema, migrations, views, policies, triggers, and seed data.
25- Background jobs, queues, webhooks, and third-party integration contracts.
26- Documentation and specs as supporting context only.
27
28## Input Signals
29
30Start from concrete signals such as changed files, failing tests, route names, migration names, API schemas, generated clients, UI forms, webhook payloads, or user-reported mismatches. If the user gives only a broad area, map the smallest boundary that can be verified end to end.
31
32## Workflow
33
341. Identify the user-requested contract or feature area.
352. Map callers and callees across layers.
363. Compare:
37 - Field names, types, nullability, defaults, enums, and units.
38 - Required vs optional values.
39 - Error formats and status codes.
40 - Auth, permissions, tenancy, and ownership checks.
41 - State transitions and side effects.
424. Revalidate each suspected mismatch against source files.
435. Produce a severity-ranked report.
44
45For sample prompts and report shape, see `references/examples.md`.
46For a compact field-by-field audit checklist, see `references/contract-checklist.md`.
47
48## Output
49
50For each finding:
51
52- **Severity:** blocker, high, medium, low.
53- **Contract:** the layer boundary that is inconsistent.
54- **Evidence:** file paths, symbols, routes, migrations, or schema names.
55- **Impact:** likely user or data effect.
56- **Fix Direction:** smallest safe repair, noting which layer should change.
57- **Verification:** targeted tests or commands that would prove the fix.
58
59## Guardrails
60
61- Do not trust docs as truth when implementation differs.
62- Do not fix during the audit unless the user explicitly approves implementation changes.
63- Flag unclear product behavior as an open question rather than deciding it.
64- Treat auth, payments, sessions, data migration, and destructive changes as high-risk.
65
66## Avoid
67
68- Do not report a mismatch without naming both sides of the boundary.
69- Do not collapse product uncertainty into an implementation recommendation.
70- Do not broaden the audit into unrelated refactors.
71
72## Final Checks
73
74- Every finding has source-backed evidence.
75- Each impact explains the likely user, data, or operational effect.
76- Each fix direction names the layer that should change.
77- Unknown product behavior is listed as an open question, not resolved by assumption.