Type Safety Documentation Audit & Update
Audit every file in {{TYPE_DOCS_DIR}}/ against the live codebase and fix any errors, gaps, or stale information so the docs are the authoritative single source of truth for the six-layer type safety chain.
Before Starting
- Read every file in
{{TYPE_DOCS_DIR}}/ (README.md, TYPE_SAFETY.md, all files in layers/, validation/, and any other files present).
- Gather ground truth from the codebase for each layer — use the actual source files, generators, and validators as the authority.
Ground Truth Collection
For each layer, collect the following from the actual codebase (not from existing docs):
Layer 1 — Drizzle Schema
- Read
{{SCHEMA_PATH}} (first ~100 lines for structure, then count pgTable exports)
- Read
{{SCRIPTS_DIR}}/validate-db-alignment.ts to understand what the validator actually checks
- Read
{{SCRIPTS_DIR}}/generate-schema.ts (if it exists) to understand schema generation
- Count:
grep -c "export const .* = pgTable(" {{SCHEMA_PATH}}
- Note any tables with type annotations (e.g.,
PgTableWithColumns<any>)
Layer 2 — Zod Schemas
- Read
{{SCHEMAS_DIR}}/index.ts (first ~80 lines for structure, imports, BaseFiltersSchema)
- List other files in
{{SCHEMAS_DIR}}/ (custom schemas)
- Read
{{SCRIPTS_DIR}}/generate-zod-schemas.ts (first ~100 lines for pattern)
- Read
{{SCRIPTS_DIR}}/validate-semantic-alignment.ts to understand validation logic
- Note the four-schema pattern and type exports
Layer 3 — Services
- Read
{{SERVICES_DIR}}/base.service.ts for the Result pattern, class signature, and methods
- Sample one entity service file for the actual pattern
- List
src/lib/services/custom/ contents
- Read
{{SCRIPTS_DIR}}/generate-services.ts (first ~80 lines)
- Read
{{SCRIPTS_DIR}}/validate-services-alignment.ts
Layer 4 — API Routes
- Sample one route file from
{{API_DIR}}/ for the actual handler pattern
- List
src/app/api/custom/ directories
- Read
{{SCRIPTS_DIR}}/generate-routes.ts (first ~80 lines)
- Read
{{SCRIPTS_DIR}}/validate-routes-alignment.ts
Layer 5 — React Hooks
- Sample one hook file from
{{HOOKS_DIR}}/ for the actual pattern (keys, hooks, fetchApi, buildQueryString)
- List
{{HOOKS_DIR}}/custom/ contents
- Read
{{SCRIPTS_DIR}}/generate-hooks.ts (first ~80 lines)
- Read
{{SCRIPTS_DIR}}/validate-hooks-alignment.ts
- Check
src/app/providers.tsx for QueryClientProvider
Layer 6 — UI Components
- Sample one component from
{{COMPONENTS_DIR}}/simplified/ for the actual pattern
- Read
{{SCRIPTS_DIR}}/generate-ui-components.ts (first ~80 lines)
- Read
{{SCRIPTS_DIR}}/validate-ui-alignment.ts
Cross-Cutting
- Read
{{CONFIG_PATH}} (first ~30 lines) for tenant scoping context
- Read
src/lib/tenant.ts for getTenantOrgId
- Count entities at each layer to verify consistency
Audit Checklist
Compare every claim in the docs against ground truth. Flag and fix:
- Incorrect counts — table counts, entity counts, file counts
- Wrong patterns — code examples that don't match actual generated code
- Missing information — layers, patterns, or conventions not documented
- Stale references — files, paths, or commands that no longer exist
- Naming convention errors — incorrect camelCase/PascalCase/kebab-case mappings
- Validator behavior — what each validator actually checks vs. what docs claim
- Generator behavior — what each generator does (overwrites vs. skips existing) vs. what docs claim
- Custom code gaps — custom services, hooks, routes not mentioned or incorrectly described
- contentCategories discrepancy — verify the 148 vs 147 explanation is still accurate
- Lock-Before-Proceed protocol — ensure the protocol description matches actual validator exit codes and workflow
- Commands — ensure all pnpm commands listed match package.json
- Cross-references — ensure layer docs reference each other correctly
Update Rules
- Fix errors in place — do not create new files unless a section genuinely needs its own file
- Use actual code snippets from the codebase, not invented examples
- Keep the same document structure and voice — just make it accurate
- Update counts, paths, patterns, and examples to match reality
- If a doc file covers something that no longer exists, remove that section
- If the codebase has something undocumented, add it to the appropriate doc
- Update
{{TYPE_DOCS_DIR}}/validation/VALIDATION_STATUS.md with current actual status (run validators if possible)
- Update the README.md index if any files were added or removed
After Updating
- Review each updated file for internal consistency
- Ensure no doc references a pattern that contradicts another doc
- Verify all code examples are syntactically correct
- Confirm the README.md index accurately lists all files in
{{TYPE_DOCS_DIR}}/
1---2name: audit-docs3description: Audits type safety documentation against the live codebase and fixes errors, gaps, or stale information to keep docs authoritative.4metadata:5 source: https://skillmd.com/skills/joshuashepherd/audit-docs6---78# Type Safety Documentation Audit & Update910Audit every file in `{{TYPE_DOCS_DIR}}/` against the live codebase and fix any errors, gaps, or stale information so the docs are the authoritative single source of truth for the six-layer type safety chain.1112## Before Starting13141. Read every file in `{{TYPE_DOCS_DIR}}/` (README.md, TYPE_SAFETY.md, all files in layers/, validation/, and any other files present).152. Gather ground truth from the codebase for each layer — use the actual source files, generators, and validators as the authority.1617## Ground Truth Collection1819For each layer, collect the following from the **actual codebase** (not from existing docs):2021### Layer 1 — Drizzle Schema22- Read `{{SCHEMA_PATH}}` (first ~100 lines for structure, then count pgTable exports)23- Read `{{SCRIPTS_DIR}}/validate-db-alignment.ts` to understand what the validator actually checks24- Read `{{SCRIPTS_DIR}}/generate-schema.ts` (if it exists) to understand schema generation25- Count: `grep -c "export const .* = pgTable(" {{SCHEMA_PATH}}`26- Note any tables with type annotations (e.g., `PgTableWithColumns<any>`)2728### Layer 2 — Zod Schemas29- Read `{{SCHEMAS_DIR}}/index.ts` (first ~80 lines for structure, imports, BaseFiltersSchema)30- List other files in `{{SCHEMAS_DIR}}/` (custom schemas)31- Read `{{SCRIPTS_DIR}}/generate-zod-schemas.ts` (first ~100 lines for pattern)32- Read `{{SCRIPTS_DIR}}/validate-semantic-alignment.ts` to understand validation logic33- Note the four-schema pattern and type exports3435### Layer 3 — Services36- Read `{{SERVICES_DIR}}/base.service.ts` for the Result<T> pattern, class signature, and methods37- Sample one entity service file for the actual pattern38- List `src/lib/services/custom/` contents39- Read `{{SCRIPTS_DIR}}/generate-services.ts` (first ~80 lines)40- Read `{{SCRIPTS_DIR}}/validate-services-alignment.ts`4142### Layer 4 — API Routes43- Sample one route file from `{{API_DIR}}/` for the actual handler pattern44- List `src/app/api/custom/` directories45- Read `{{SCRIPTS_DIR}}/generate-routes.ts` (first ~80 lines)46- Read `{{SCRIPTS_DIR}}/validate-routes-alignment.ts`4748### Layer 5 — React Hooks49- Sample one hook file from `{{HOOKS_DIR}}/` for the actual pattern (keys, hooks, fetchApi, buildQueryString)50- List `{{HOOKS_DIR}}/custom/` contents51- Read `{{SCRIPTS_DIR}}/generate-hooks.ts` (first ~80 lines)52- Read `{{SCRIPTS_DIR}}/validate-hooks-alignment.ts`53- Check `src/app/providers.tsx` for QueryClientProvider5455### Layer 6 — UI Components56- Sample one component from `{{COMPONENTS_DIR}}/simplified/` for the actual pattern57- Read `{{SCRIPTS_DIR}}/generate-ui-components.ts` (first ~80 lines)58- Read `{{SCRIPTS_DIR}}/validate-ui-alignment.ts`5960### Cross-Cutting61- Read `{{CONFIG_PATH}}` (first ~30 lines) for tenant scoping context62- Read `src/lib/tenant.ts` for getTenantOrgId63- Count entities at each layer to verify consistency6465## Audit Checklist6667Compare every claim in the docs against ground truth. Flag and fix:68691. **Incorrect counts** — table counts, entity counts, file counts702. **Wrong patterns** — code examples that don't match actual generated code713. **Missing information** — layers, patterns, or conventions not documented724. **Stale references** — files, paths, or commands that no longer exist735. **Naming convention errors** — incorrect camelCase/PascalCase/kebab-case mappings746. **Validator behavior** — what each validator actually checks vs. what docs claim757. **Generator behavior** — what each generator does (overwrites vs. skips existing) vs. what docs claim768. **Custom code gaps** — custom services, hooks, routes not mentioned or incorrectly described779. **contentCategories discrepancy** — verify the 148 vs 147 explanation is still accurate7810. **Lock-Before-Proceed protocol** — ensure the protocol description matches actual validator exit codes and workflow7911. **Commands** — ensure all pnpm commands listed match package.json8012. **Cross-references** — ensure layer docs reference each other correctly8182## Update Rules8384- Fix errors in place — do not create new files unless a section genuinely needs its own file85- Use actual code snippets from the codebase, not invented examples86- Keep the same document structure and voice — just make it accurate87- Update counts, paths, patterns, and examples to match reality88- If a doc file covers something that no longer exists, remove that section89- If the codebase has something undocumented, add it to the appropriate doc90- Update `{{TYPE_DOCS_DIR}}/validation/VALIDATION_STATUS.md` with current actual status (run validators if possible)91- Update the README.md index if any files were added or removed9293## After Updating94951. Review each updated file for internal consistency962. Ensure no doc references a pattern that contradicts another doc973. Verify all code examples are syntactically correct984. Confirm the README.md index accurately lists all files in `{{TYPE_DOCS_DIR}}/`