---
name: application
description: |
  Creates SmartStack full-stack applications/modules.
  Use this skill when:
  - User asks to create an application, module, or context
  - User mentions "new module", "new application", "add a feature"
  - User wants to extend navigation with new entries
  Scope: Context → Application → Module → Section (all levels)
---

# Skill Application SmartStack

**Reference:** [_shared.md](../_shared.md) for architecture, permissions, i18n

## ENTRY POINT

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

This skill uses progressive step loading. Each step calls MCP tools for generation.

## STEP FILES

| Step | File | MCP Tool Called | Condition |
|------|------|-----------------|-----------|
| 00 | `steps/step-00-init.md` | `validate_conventions` (MCP check) | Always |
| 01 | `steps/step-01-navigation.md` | `scaffold_navigation` | Always |
| 02 | `steps/step-02-permissions.md` | `generate_permissions` | Always |
| 03 | `steps/step-03-roles.md` | `scaffold_role_permissions` | Always |
| 03b | `steps/step-03b-provider.md` | (none - direct generation) | Client projects only |
| 04 | `steps/step-04-backend.md` | `scaffold_extension` | Always |
| 05 | `steps/step-05-frontend.md` | `scaffold_api_client`, `scaffold_routes` | Always |
| 06 | `steps/step-06-migration.md` | `suggest_migration` | Always |
| 07 | `steps/step-07-tests.md` | `scaffold_tests` | Always |
| 08 | `steps/step-08-documentation.md` | `/documentation` skill | If userDocRequired |

## MCP INTEGRATION

> **CRITICAL:** This skill MUST use MCP tools for all generation.
> Templates in this folder are for REFERENCE ONLY - never use them directly.

| MCP Tool | Purpose |
|----------|---------|
| `mcp__smartstack__scaffold_navigation` | Navigation entity + translations |
| `mcp__smartstack__generate_permissions` | Permissions.cs + HasData |
| `mcp__smartstack__scaffold_role_permissions` | Role-permission mappings |
| `mcp__smartstack__scaffold_extension` | Entity, Service, Controller, DTOs |
| `mcp__smartstack__scaffold_api_client` | TypeScript API client |
| `mcp__smartstack__scaffold_routes` | React Router configuration |
| `mcp__smartstack__suggest_migration` | Migration name suggestion |
| `mcp__smartstack__scaffold_tests` | Test suite generation (backend) |
| `mcp__smartstack__scaffold_frontend_tests` | Test suite generation (frontend React) |
| `mcp__smartstack__validate_conventions` | Post-generation convention check |
| `mcp__smartstack__review_code` | Code quality audit |

## WHEN THIS SKILL ACTIVATES

| Trigger | Example |
|---------|---------|
| Explicit request | "Create a module to manage products" |
| New feature | "We need to add order management" |
| Navigation extension | "Add a CRM application in business" |
| Keywords | "new module", "new application", "add a context" |

## FLOW ARCHITECTURE

```
WEB (React) → API (.NET) → Application → Infrastructure → Database
```

**FORBIDDEN:** WEB → Infrastructure (direct DB access), WEB → Domain

## WORKFLOW

### 1. Level Detection

| Hint | → Level |
|------|---------|
| "context", "workspace" | Context |
| "application", "app" | Application |
| "module", "feature" | Module |
| "section", "tab" | Section |

### 2. Parameter Extraction
`$LEVEL`, `$PARENT` (platform/business/personal), `$CODE` (kebab-case), `$LABEL_EN`, `$ICON` (Lucide)

### 3. Full-Stack Generation
```
1. DB SEED (Navigation + Translations 4 languages)
2. PERMISSIONS (Permissions.cs + PermissionConfiguration.cs) ← 2 files!
3. ROLES (RolePermission mappings)
3b. CLIENT SEED PROVIDER (client projects only - IClientSeedDataProvider)
4. API (Controller + DTOs via /controller:create)
   4b. VALIDATE (/validate - convention check on generated backend)
5. SERVICES (Interface + Implementation)
6. FRONTEND (Page + Components + Hooks)
7. I18N (fr, en, it, de)
8. ROUTES (nested routes mandatory)
9. PREFERENCES (Hook pattern)
10. MIGRATION (/efcore:migration)
11. TESTS - Backend (scaffold_tests - 7 categories including real integration)
12. TESTS - Frontend (scaffold_frontend_tests - Vitest + Testing Library + MSW)
13. REVIEW (/review-code - security + architecture + quality audit)
14. DOCUMENTATION (in-app user doc via /documentation - if userDocRequired)
```

### 3b. Client Seed Provider (client projects only)
Generates `IClientSeedDataProvider` implementation that wires navigation + permissions + roles
into the SmartStack Core seeding pipeline. Only runs when `{seeding_strategy}` = "provider".
Core projects skip this step entirely.

### 4. Automatic Chaining
- `/controller:create` → API Controllers
- `/efcore:migration` → DB Migrations
- `/ui-components` → EntityCard, DataTable

## USER PREFERENCES

| Preference | Storage |
|------------|---------|
| pageSize | `user.preferences.{module}.pageSize` |
| sortColumn/Direction | `user.preferences.{module}.sort*` |
| filters | `user.preferences.{module}.filters` |
| visibleColumns | `user.preferences.{module}.visibleColumns` |
| viewMode | `user.preferences.{module}.viewMode` |

```typescript
export function use{Module}Preferences() {
  const { preferences, updatePreference } = useUserPreferences();
  return {
    pageSize: preferences.{module}?.pageSize ?? 10,
    setPageSize: (size: number) => updatePreference('{module}.pageSize', size),
    // ... others
  };
}
```

## ROUTING (React Router v7)

```tsx
// ✅ CORRECT - Nested routes
<Route path="$APPLICATION">
  <Route index element={<Navigate to="$DEFAULT_MODULE" replace />} />
  <Route path="$MODULE1" element={<Module1Page />} />
</Route>

// ❌ FORBIDDEN - Flat routes (cause redirect to Home)
<Route path="$APPLICATION" element={<Navigate ... />} />
<Route path="$APPLICATION/$MODULE1" element={...} />
```

## INTEGRATIONS

| Skill | When | Action |
|-------|------|--------|
| `/notification` | User alerts | INotificationService + SignalR |
| `/workflow` | Automated emails | IWorkflowService.TriggerAsync |
| `/ai-prompt` | AI assistance | IAiCompletionService |
| `/feature-full` | Complete feature | Orchestration all skills |
| `/validate` | After step-04 (backend) | MCP `validate_conventions` on generated code |
| `/review-code` | After step-07 (tests) | Security (OWASP), architecture, SOLID, performance audit |
| `/validate-feature` | After step-07 (tests) | Compile + test + API smoke test |
| `/documentation` | In-app user doc | Documentation page via doc-data.ts + DocRenderer |

### Notification Integration Pattern
```csharp
await _notificationService.SendNotificationAsync(
    userId, NotificationType.{Entity}Created, title, message,
    relatedEntityType: nameof({Entity}), relatedEntityId: entity.Id);
```

### Workflow Integration Pattern
```csharp
await _workflowService.TriggerAsync("{entity}.created", new Dictionary<string, object>
{
    ["entityId"] = entity.Id,
    ["creatorEmail"] = _currentUser.Email
});
```

## ABSOLUTE RULES

| DO | DON'T |
|----|-------|
| 4 languages (FR, EN, IT, DE) | Import Infrastructure in frontend |
| Permissions: 2 files | Direct SQL in frontend |
| Nested routes | Flat routes (flat siblings) |
| EntityCard for cards | Manual cards with divs |
| DataTable for tables | Sequential GUIDs |

### FORBIDDEN ACTIONS (BLOCKING)

> **NEVER create temporary files, scripts, or helper files of any kind.**

| FORBIDDEN | USE INSTEAD |
|-----------|-------------|
| Creating `.ps1` scripts | `Grep` tool to search `.cs` files |
| Creating `.sh` / `.bat` scripts | `Glob` tool to find files by pattern |
| Creating `temp-*` files | `Read` tool to inspect file contents |
| Scanning DLLs / assemblies | Search source `.cs` files directly |
| Running `dotnet` reflection commands | MCP `validate_conventions` tool |
| Any file not part of the final deliverable | Ask the user if information is missing |

**Type Discovery Rules:**
- To find base classes: `Grep` for `class BaseEntity` or `class {Name}` in `*.cs` files
- To find existing services: `Glob` for `**/I*Service.cs` in the Application layer
- To find NuGet packages: `Read` the `.csproj` files directly
- To find existing entities: `Glob` for `**/*.cs` in the Domain layer
- If a type cannot be found after 2 search attempts: **ASK the user**, do NOT create scripts

## ASSOCIATED FILES

### Step Files (ACTIVE - Use These)
- [steps/step-00-init.md](steps/step-00-init.md) - Initialize parameters
- [steps/step-01-navigation.md](steps/step-01-navigation.md) - Generate navigation
- [steps/step-02-permissions.md](steps/step-02-permissions.md) - Generate permissions
- [steps/step-03-roles.md](steps/step-03-roles.md) - Assign roles
- [steps/step-03b-provider.md](steps/step-03b-provider.md) - Client seed provider (client projects only)
- [steps/step-04-backend.md](steps/step-04-backend.md) - Generate backend
- [steps/step-05-frontend.md](steps/step-05-frontend.md) - Generate frontend
- [steps/step-06-migration.md](steps/step-06-migration.md) - Create migration
- [steps/step-07-tests.md](steps/step-07-tests.md) - Generate test suite
- [steps/step-08-documentation.md](steps/step-08-documentation.md) - Generate in-app documentation

### Templates (REFERENCE ONLY - Do Not Use Directly)
> These templates are kept for documentation purposes.
> All generation is done via MCP tools in step files.

- [templates-backend.md](templates-backend.md) - Backend patterns reference
- [templates-frontend.md](templates-frontend.md) - Frontend patterns reference
- [templates-i18n.md](templates-i18n.md) - i18n structure reference
- [templates-seed.md](templates-seed.md) - Seed data patterns reference

<success_criteria>
- Navigation entries created with correct hierarchy (Context/Application/Module)
- Permissions generated via MCP with 2-file pattern (constants + seed)
- Roles assigned with appropriate permission sets
- Backend layers follow SmartStack conventions (validated by MCP)
- Frontend pages in correct path structure with i18n
- EF Core migration created and applied successfully
- Test suite generated and passing
</success_criteria>
