---
name: step-02-crud-audit
description: Audit CRUD completeness - 4 page types per section, create buttons, componentRegistry
next_step: steps/step-03-perm-audit.md
---

# Step 2: CRUD Audit

## YOUR TASK:
Verify that every section in the application has complete CRUD support: 4 page types, create button on list pages, and proper componentRegistry registration.

---

## EXECUTION SEQUENCE:

### 1. Identify Sections to Audit

From {seed_files}, extract all section codes that represent CRUD entities.

**Exclude from audit:**
- Sections with code: "dashboard", "calendar", "import-export", "approve", "balances" (these are specialized views, not CRUD entities)
- Sections with reserved codes: "detail", "create", "edit" (these shouldn't exist as sections)

**Include in audit:**
- "list" sections → audit as the main entity section
- "departments", "absence-types", or any other entity section → audit for CRUD completeness

For each auditable section, determine the entity name:
- Section code → PascalCase entity name (e.g., "departments" → "Department", "absence-types" → "AbsenceType")

### 2. Check 4 Page Types per Section

For each entity, search in {page_files} for:

```
Required page types (at least 3 naming conventions per type):
  ListPage:   {Entity}ListPage.tsx OR {Entity}sPage.tsx OR {Entities}Page.tsx
  DetailPage: {Entity}DetailPage.tsx OR {Entity}Page.tsx
  CreatePage: Create{Entity}Page.tsx OR {Entity}CreatePage.tsx OR {Entity}FormPage.tsx
  EditPage:   Edit{Entity}Page.tsx OR {Entity}EditPage.tsx OR {Entity}FormPage.tsx (shared)
```

Note: Create and Edit may share a single `{Entity}FormPage.tsx` — this is acceptable.

**Findings:**

| ID | Severity | Rule |
|----|----------|------|
| CRUD-001 | BLOCKING | ListPage missing for entity |
| CRUD-002 | BLOCKING | DetailPage missing for entity |
| CRUD-003 | BLOCKING | Create/Edit page missing for entity (no CreatePage, EditPage, or FormPage) |

### 3. Check Create Button on List Pages

For each ListPage found:

Grep for navigate patterns:
```
navigate('create')
navigate(`create`)
navigate('new')
navigate(`${basePath}/create`)
navigate(`create`)
```

Also check for link patterns:
```
<Link to="create"
to={`create`}
to="new"
```

If NONE found → **BLOCKING finding** (users cannot access create form)

| ID | Severity | Rule |
|----|----------|------|
| CRUD-004 | BLOCKING | ListPage has no Create/New button (no navigate to create route) |

### 4. Check componentRegistry Registration

Read {registry_file} and extract all `PageRegistry.register()` calls.

For each entity section:
- Check for list page registration: key matching `*.{section}` or `*.{module}.{section}`
- Check for detail page registration: key matching `*.{section}.detail` or the `:id` route
- Check for create page registration: key matching `*.{section}.create`
- Check for edit page registration: key matching `*.{section}.edit`

| ID | Severity | Rule |
|----|----------|------|
| CRUD-005 | BLOCKING | Page exists on disk but NOT registered in componentRegistry |
| CRUD-006 | WARNING | componentRegistry entry has no matching page file on disk |

### 5. Check Form Submit Handlers

For each Create/Edit/Form page:

Grep for submit patterns:
```
onSubmit
handleSubmit
api.create(
api.post(
api.update(
api.put(
apiClient.post(
apiClient.put(
```

If NONE found → WARNING (form exists but may not submit data)

| ID | Severity | Rule |
|----|----------|------|
| CRUD-007 | WARNING | Form page has no visible submit handler |

---

## SUCCESS METRICS:
- All entity sections identified from seed data
- 4 page types checked per entity
- Create button presence verified on all list pages
- componentRegistry cross-referenced with page files
- Form submit handlers checked

## NEXT STEP:
If {scope} is `all` or `perm` → proceed to `./step-03-perm-audit.md`
If {scope} is `crud` → skip to `./step-05-report.md`
