---
name: apex-verify
description: |
  Audit a generated SmartStack APEX application for common generation issues.
  Use this skill when:
  - Verifying a generated app has no missing CRUD pages or buttons
  - Checking navigation seed data for reserved section codes in menu
  - Auditing permission coverage (controllers vs Permissions.cs vs seed data)
  - Validating route alignment (frontend vs backend vs seed)
  - After /apex or /business-analyse-develop completes
argument-hint: "[--scope=all|nav|crud|perm|route] [--fix]"
model: sonnet
allowed-tools: "Read, Grep, Glob, Bash, ToolSearch"
entry_point: steps/step-00-init.md
---

<objective>
Audit a SmartStack application generated by /apex or /business-analyse-develop for common post-generation issues:

1. **Navigation** — Reserved section codes (detail, create, edit) seeded as visible menu items
2. **CRUD** — Missing page types, missing "New" buttons on list pages, incomplete componentRegistry
3. **Permissions** — Cross-reference controllers, Permissions.cs, PermissionsSeedData, RolesSeedData
4. **Routes** — Alignment between seed data routes, PageRegistry keys, and controller NavRoutes

The audit is **read-only** by default. Use `--fix` to display actionable fix commands.
</objective>

<quick_start>

```bash
/apex-verify                    # Full audit (all 4 categories)
/apex-verify --scope=nav        # Navigation menu audit only
/apex-verify --scope=crud       # CRUD completeness audit only
/apex-verify --scope=perm       # Permission cross-reference only
/apex-verify --scope=route      # Route alignment only
/apex-verify --fix              # Full audit + fix suggestions
```

</quick_start>

<parameters>

<flags>
| Flag | Description |
|------|-------------|
| `--scope=all` | Audit all 4 categories (default) |
| `--scope=nav` | Navigation audit only (reserved section codes) |
| `--scope=crud` | CRUD completeness only (pages, buttons, registry) |
| `--scope=perm` | Permission cross-reference only |
| `--scope=route` | Route alignment only |
| `--fix` | Display actionable fix commands for each finding |
</flags>
</parameters>

<workflow>
1. **Initialize** — Detect project structure, locate seed data, controllers, pages
2. **Navigation Audit** — Check for reserved section codes seeded as menu items
3. **CRUD Audit** — Verify 4 page types per section, create buttons, componentRegistry
4. **Permission Audit** — Cross-reference controllers, Permissions.cs, seed data, roles
5. **Route Audit** — Verify frontend/backend/seed alignment
6. **Report** — Consolidated findings with severity and fix suggestions
</workflow>

<state_variables>
| Variable | Type | Description |
|----------|------|-------------|
| `{scope}` | string | all, nav, crud, perm, route |
| `{fix_mode}` | boolean | Display fix commands |
| `{api_root}` | string | Path to backend src/ |
| `{web_root}` | string | Path to frontend web/ |
| `{seed_files}` | string[] | All *NavigationSeedData.cs files |
| `{controller_files}` | string[] | All *Controller.cs files |
| `{page_files}` | string[] | All *.tsx page files |
| `{registry_file}` | string | componentRegistry.generated.ts path |
| `{permissions_file}` | string | Permissions.cs path |
| `{findings}` | object[] | All findings with ID, severity, message, fix |
</state_variables>

<entry_point>

**FIRST ACTION:** Load `steps/step-00-init.md`

</entry_point>

<step_files>
| Step | File | Purpose |
|------|------|---------|
| 00 | `steps/step-00-init.md` | Parse flags, detect project structure, resolve paths |
| 01 | `steps/step-01-nav-audit.md` | Audit navigation seed data for reserved section codes |
| 02 | `steps/step-02-crud-audit.md` | Audit CRUD completeness (pages, buttons, registry) |
| 03 | `steps/step-03-perm-audit.md` | Audit permissions cross-reference |
| 04 | `steps/step-04-route-audit.md` | Audit route alignment |
| 05 | `steps/step-05-report.md` | Generate consolidated report |
</step_files>

<execution_rules>
- **Read-only** — This skill NEVER modifies code (unless --fix is used, and even then only displays commands)
- **Evidence-based** — Every finding must reference a specific file:line
- **Comprehensive** — Check ALL files, not a sample
- **Actionable** — Every finding must include a fix suggestion
- **Scoped** — Only run audits matching {scope}
- **SmartStack-aware** — Respect SmartStack conventions (PageRegistry, DynamicRouter, NavRoute, SeedData patterns)
</execution_rules>

<success_criteria>
- All applicable audits completed with zero false positives
- Each finding has: ID, severity (BLOCKING/CRITICAL/WARNING), file:line, description, fix
- Consolidated report with category totals
- Executive summary with pass/fail per category
</success_criteria>
