# APEX Shared — SmartStack Detection & MCP References

> **Loaded by:** step-00-init (always), other steps as needed

---

## SmartStack Project Detection

### Scan Pattern

1. `*.sln` → .NET backend confirmed
2. `docs/business/` → BA artifacts exist
3. `.ralph/prd-*.json` → PRDs exist
4. `src/pages/` → React frontend exists

### Context-to-Folder Mapping

| Context | Backend | Controller | Frontend Layout |
|---------|---------|------------|----------------|
| `business` | `Business` | `Business` | `BusinessLayout` |
| `platform.administration` | `Platform/Administration` | `Admin` | `AdminLayout` |
| `platform.support` | `Platform/Support` | `Support` | `AdminLayout` |
| `personal` | `Personal` | `User` | `UserLayout` |

---

## MCP Tools Reference

### Mandatory (every execution)

| Tool | Purpose | Step |
|------|---------|------|
| `validate_conventions` | Validate SmartStack conventions | 00 (check), 04 (validate) |

### Generation (step-03)

| Tool | Purpose | Condition |
|------|---------|-----------|
| `scaffold_extension` | Generate entities, services, controllers | New code creation |
| `suggest_migration` | Get standardized migration name | EF Core changes |
| `generate_permissions` | Generate RBAC permissions + seed data | New module/section |
| `scaffold_api_client` | Generate TypeScript API client | Frontend changes |
| `scaffold_routes` | Generate React Router routes | Frontend changes |

### Validation (step-04)

| Tool | Purpose | Condition |
|------|---------|-----------|
| `check_migrations` | Validate EF Core migrations | Migration created |
| `validate_frontend_routes` | Validate route/layout alignment | Frontend changes |
| `validate_security` | Check security patterns | API changes |

### Analysis (step-01)

| Tool | Purpose |
|------|---------|
| `api_docs` | Existing API documentation |
| `analyze_extension_points` | React extension points |

### Tests (step-07, if -t)

| Tool | Purpose |
|------|---------|
| `scaffold_tests` | Generate tests (domain, app, api, security) |
| `suggest_test_scenarios` | Suggest test scenarios |
| `analyze_test_coverage` | Check coverage percentage |

### Review (step-05, if -x)

| Tool | Purpose |
|------|---------|
| `review_code` | Adversarial code review |
| `analyze_code_quality` | Code quality metrics |

---

## Existing Skills Delegation

| Skill | When to delegate |
|-------|-----------------|
| `/controller` | Complex controller with custom routes |
| `/application` | New context/application/module structure |
| `/ui-components` | Complex React pages (tables, grids, dashboards) |
| `/efcore` | Complex EF Core configurations |
| `/notification` | In-app or email notifications |
| `/workflow` | Automated workflow triggers |
