---
name: sketch
description: |
  Transform a vague idea into a precise /apex command in under 5 minutes.
  Use this skill when:
  - User has a vague idea ("I want an HR app with employees and absences")
  - User doesn't know the exact entities, fields, or structure needed
  - User needs help designing a module before running /apex
  Zero MCP, zero file generation — pure domain inference.
model: opus
argument-hint: "<vague idea in natural language>"
---

<objective>
Transform a vague user prompt into a precise, ready-to-run /apex command. /sketch is a rapid design assistant — it infers entities, properties, relationships, labels, and code patterns from minimal input using domain heuristics and LLM knowledge.

**Key principles:**
- MAX 2 questions total (1 subject guard + 1 optional confirmation)
- Zero MCP calls — pure inference (validation is /apex's job)
- Zero file generation — output is text in conversation only
- Domain heuristics ACCELERATE inference, they do NOT limit it
</objective>

<quick_start>

```bash
/sketch une app RH avec employés et absences
/sketch I want to manage customer orders and invoices
/sketch gestion de projets avec tâches et jalons
/sketch stock management
```

</quick_start>

<anti_patterns>
- DO NOT ask more than 2 questions total
- DO NOT generate any files (no JSON, no code, no documents)
- DO NOT call any MCP tools (validation is /apex's job)
- DO NOT scan the entire codebase (max 1 Glob for app detection)
- DO NOT duplicate business analysis logic (no stakeholders, risks, use cases)
- DO NOT output structured syntax — /apex parses natural language, not custom formats
- DO NOT call Skill("apex") directly — instruct the agent to do it based on user choice
</anti_patterns>

<algorithm>

## 1. SUBJECT GUARD

Check if the user prompt contains at least one identifiable business object (noun that could be an entity: employees, orders, projects, invoices, etc.).

```
IF no business object identifiable in prompt:
  → AskUserQuestion: "What do you want to manage? (e.g., employees, orders, projects, invoices...)"
  → Wait for answer, then continue to step 2
  → This is the ONLY mandatory question
```

## 2. LOAD DOMAIN HEURISTICS

Read `references/domain-heuristics.md` — domain pattern table with entities, properties, FK relationships, and i18n labels for 15 common business domains.

## 3. ULTRA THINK — Domain Inference

**ULTRA THINK deeply about the user's domain before proceeding.**

From the user prompt + domain heuristics table:

1. **Extract keywords** from user prompt (nouns, domain terms, action verbs)
2. **Match against heuristics table** — find the closest domain pattern(s)
3. **If no match:** use general LLM knowledge (the table accelerates, it does NOT limit)
4. **Infer entities:** name, key properties, types, nullable flags
5. **Infer FK relationships:** between entities (EmployeeId→Employee, etc.)
6. **Infer sections:** 1 section per main entity, code = plural kebab-case (e.g., "employees")
7. **Infer i18n labels** in 4 languages (fr, en, it, de) — from table or LLM knowledge
8. **Deduce code_patterns:** strategy = "sequential" by default, prefix = first 3 letters of entity name
9. **Deduce tenantMode:** "strict" by default (multi-tenant)
10. **Deduce complexity:**
    - `simple-crud` if ≤ 2 entities with no workflow/status transitions
    - `crud-rules` otherwise (validations, computed fields, status)
    - `crud-workflow` if mentions approval, email, notification
    - `complex` if > 4 entities with specific business logic

## 4. DETECT EXISTING APPLICATION

```
Glob("**/NavigationApplicationSeedData.cs")  ← single scan, MAX 1

IF files found:
  → Extract application names from seed data classes
  → Check if the inferred module fits an existing application
  → If multiple apps match: flag as ambiguity for step 5

IF no files found:
  → New application — infer name from domain
  → app_name = domain-appropriate PascalCase name (e.g., "HumanResources")
```

## 5. CONFIRMATION GATE — MAX 1 optional question

```
IF real ambiguity exists (multiple matching apps, genuinely ambiguous domain):
  → AskUserQuestion with specific options to resolve the ambiguity
  → This is the ONLY optional question

IF no ambiguity:
  → Zero questions — proceed directly to output
```

## 6. OUTPUT — Display result and choices

Display the design summary and generated /apex prompt using the exact format below.

</algorithm>

<output_format>

```
══════════════════════════════════════════════════════════
  /sketch — Module Design Complete
══════════════════════════════════════════════════════════

  Application:  {app_name}
  Module:       {module_code}
  Sections:     {section1_code} ({fr_label}/{en_label}/{it_label}/{de_label})
                {section2_code} ({fr_label}/{en_label}/{it_label}/{de_label})
  Entities:     {Entity1} ({prop1}:{type}, {prop2}:{type}, {fk}:{type} FK→{Target})
                {Entity2} ({prop1}:{type}, {prop2}:{type}, {fk}:{type} FK→{Target})
  Complexity:   {complexity}
  Code:         {Entity1} → {prefix}-{tenant}-00001 | {Entity2} → {prefix}-{tenant}-00001

  Ready to run:
  ──────────────────────────────────────────────────────
  /apex add {sections} sections to {app_name} module with
  {Entity1} entity ({properties with types and FKs}) and
  {Entity2} entity ({properties with types and FKs}),
  code patterns sequential {prefixes}, complexity {complexity}
  ──────────────────────────────────────────────────────

  [1] Run this /apex command now
  [2] Edit before running
  [3] Cancel
```

**Rules for the generated /apex prompt:**
- Natural language, dense but readable
- Include ALL entities with their key properties and types
- Include FK relationships explicitly (e.g., "EmployeeId:Guid FK→Employee")
- Include code pattern prefixes
- Include complexity level
- Mention the target application name

</output_format>

<handoff>

Based on user selection:

```
IF user selects [1]:
  → Call: Skill("apex", args: "{the generated prompt text}")

IF user selects [2]:
  → Display the generated prompt for the user to edit
  → Wait for edited version
  → Re-display choices [1] Run / [3] Cancel

IF user selects [3]:
  → Display: "Cancelled. Run /sketch again when ready."
  → STOP
```

</handoff>
