---
name: step-00-init
description: Parse flags, detect project structure, resolve paths for APEX verification
next_step: steps/step-01-nav-audit.md
---

# Step 0: Initialization

## MANDATORY EXECUTION RULES:
- NEVER skip project detection
- ALWAYS resolve actual filesystem paths before proceeding
- YOU ARE AN INITIALIZER, not a scanner

## YOUR TASK:
Parse the flags, detect the SmartStack project structure, and locate all files needed for auditing.

---

## EXECUTION SEQUENCE:

### 1. Parse Input

```
Arguments from $ARGUMENTS:
  --scope=nav       -> {scope} = "nav"
  --scope=crud      -> {scope} = "crud"
  --scope=perm      -> {scope} = "perm"
  --scope=route     -> {scope} = "route"
  --scope=all       -> {scope} = "all" (default)
  --fix             -> {fix_mode} = true (default: false)

No arguments -> {scope} = "all", {fix_mode} = false
```

### 2. Detect Project Structure

Use Glob to locate all required files:

```
Backend paths:
  {api_root} = src/*/Api/ or src/*.Api/
  Verify: *.sln exists at project root

Frontend paths:
  {web_root} = web/*/src/ or web/*-web/src/
  Verify: package.json exists in web/*/

Key files to locate:
  {seed_files}:
    Glob "**/Seeding/Data/**/*NavigationSeedData.cs"
    Glob "**/Seeding/Data/**/*NavigationModuleSeedData.cs"

  {controller_files}:
    Glob "**/Controllers/**/*Controller.cs"

  {page_files}:
    Glob "web/**/src/pages/**/*Page.tsx"

  {registry_file}:
    Glob "**/componentRegistry.generated.ts" or "**/componentRegistry*.ts"

  {permissions_file}:
    Glob "**/Authorization/Permissions.cs" or "**/Common/Authorization/Permissions.cs"

  {perm_seed_files}:
    Glob "**/Seeding/Data/**/*PermissionsSeedData.cs"
    Glob "**/Seeding/Data/**/*SeedDataProvider.cs"

  {role_seed_files}:
    Glob "**/Seeding/Data/**/*RolesSeedData.cs"
```

### 3. Validate Paths

For each required file set:
- If empty: record as CRITICAL warning (cannot audit that category)
- If found: record paths for next steps

### 4. Show Summary and Proceed

Display:

```
APEX Verification — Initialization
====================================

| Setting | Value |
|---------|-------|
| Scope | {scope} |
| Fix mode | {fix_mode} |

Project Structure:
| Category | Files Found |
|----------|-------------|
| Navigation seed data | {count} files |
| Controllers | {count} files |
| Frontend pages | {count} files |
| Component registry | {found/MISSING} |
| Permissions.cs | {found/MISSING} |
| Permission seed data | {count} files |
| Role seed data | {count} files |

-> Proceeding to audits...
```

---

## SUCCESS METRICS:
- Scope and flags correctly parsed
- All filesystem paths resolved and validated
- Summary displayed with file counts
- Ready for audit steps

## NEXT STEP:
Based on {scope}:
- `all` or `nav` → proceed to `./step-01-nav-audit.md`
- `crud` → skip to `./step-02-crud-audit.md`
- `perm` → skip to `./step-03-perm-audit.md`
- `route` → skip to `./step-04-route-audit.md`
