---
name: step-00-init
description: Parse flags, detect project structure, resolve paths for routing audit
next_step: steps/step-01-inventory.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 resolve which directories to scan.

---

## EXECUTION SEQUENCE:

### 1. Parse Input

```
Arguments from $ARGUMENTS:
  --scope=frontend  -> {scope} = "frontend" (elements 1-4 only)
  --scope=backend   -> {scope} = "backend" (element 5 only)
  --scope=all       -> {scope} = "all" (default)
  --strict          -> {strict} = true (default: false)

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

### 2. Detect Project Structure

Use Glob and Bash to locate:

```
Frontend paths:
  {web_root} = web/smartstack-web/src/
  Verify: package.json exists in web/smartstack-web/
  Verify: src/ directory exists

Backend paths:
  {api_root} = src/SmartStack.Api/
  {app_root} = src/SmartStack.Application/
  {infra_root} = src/SmartStack.Infrastructure/
  Verify: SmartStack.sln exists at project root

Key files to pre-locate (existence check only):
  - componentRegistry: Glob for "**/componentRegistry*" in {web_root}
  - ProtectedRoute: Glob for "**/ProtectedRoute*" in {web_root}
  - DynamicRouter: Glob for "**/DynamicRouter*" in {web_root}
  - useRouteConfig: Glob for "**/useRouteConfig*" in {web_root}
  - Navigation controller: Glob for "**/Navigation*Controller*" in {api_root}
```

### 3. Validate Paths

For each required path:
- If missing: record as CRITICAL warning
- If found: record path for next steps

### 4. MCP Pre-scan (automated baseline)

Use `ToolSearch` to fetch MCP tools, then call them to get an automated baseline:

```
Step 4a: Fetch MCP tools
  ToolSearch query="select:mcp__smartstack__validate_frontend_routes,mcp__smartstack__validate_conventions"

Step 4b: Call validate_frontend_routes (if available)
  mcp__smartstack__validate_frontend_routes scope="all"
  -> Store full result as {mcp_results.frontend_routes}
  -> This gives: registry status, API client issues, component registry keys, missing keys, recommendations

Step 4c: Call validate_conventions (if available)
  mcp__smartstack__validate_conventions checks=["frontend-routes"]
  -> Store result as {mcp_results.conventions}
  -> This gives: seed data cross-reference, missing PageRegistry entries

If MCP is unavailable: record as WARNING and continue without MCP baseline.
The manual audit in steps 1-2 will still produce a complete report.
```

### 5. Show Summary and Proceed

Display:

```
Routing Audit Configuration:

| Setting | Value |
|---------|-------|
| Scope | {scope} |
| Strict mode | {strict} |
| Web root | {web_root} |
| API root | {api_root} |
| MCP available | {yes/no} |

Pre-scan results:
| Element | File Found |
|---------|-----------|
| componentRegistry | {path or MISSING} |
| ProtectedRoute | {path or MISSING} |
| DynamicRouter | {path or MISSING} |
| useRouteConfig | {path or MISSING} |
| Navigation API | {path or MISSING} |

MCP baseline (if available):
| Check | Result |
|-------|--------|
| validate_frontend_routes | {valid: true/false, issues: N} |
| validate_conventions | {errors: N, warnings: N} |

-> Proceeding to inventory...
```

---

## SUCCESS METRICS:
- Scope and flags correctly parsed
- All filesystem paths resolved and validated
- MCP pre-scan executed (or gracefully skipped if unavailable)
- Pre-scan summary displayed with file existence status
- Ready for detailed inventory in next step

## NEXT STEP:
After showing initialization summary, proceed directly to `./step-01-inventory.md`
