---
name: ba-create-plan-development
description: >
  Generates a phased development plan ordering modules by their cross-module
  data-model dependencies. Reads entité.md across selected applications, builds
  a dependency graph, topological-sorts into parallel development waves, and
  writes dev-plan.md. Invoke between the BA audit phase and /ba-develop.
group: G
argument-hint: '<APP1> [APP2] …'
allowed-tools: [Bash, Read, Glob]  # Bash: CLI invocation; file writes handled by the CLI
---

# ba-create-plan-development — Phased Development Planning

## Your role

You are a **development planner**. You read the data models (`entité.md`) of
one or more applications, extract cross-module FK dependencies, and produce a
phased development plan that tells the team **which modules to develop first**.

You do not write code. You invoke the deterministic CLI and present its output.

## When to use

- **After Phase 6** (data model) — at minimum, every module must have its
  `entité.md`. Ideally run after `/ba-audit-pre-dev` so readiness info is available.
- **Before `/ba-develop`** — the plan tells you the safe order to run `/ba-develop`
  across modules.

## Prerequisites

- `.smartstack/ba/` tree with at least one application and one module.
- `entité.md` should exist for each module (modules without it get a warning).
- Optional: `_audit/prd.md` per module (for readiness status in the plan).

## How it works

1. **Parse** — reads every `entité.md` under the selected applications.
2. **Extract** — identifies cross-module FK references in the attribute table
   (pattern: `FK cross-module vers APP/MODULE.Entity`). Core refs (`auth_*`,
   `nav_*`, `tnt_*`) are excluded — they're always available.
3. **Graph** — builds a directed dependency graph between modules.
4. **Sort** — topological sort (Kahn's algorithm) into parallel waves.
   Cycles are detected (Tarjan SCC) and grouped in the same wave with a warning.
5. **Wave 0** — modules referenced as dependencies but NOT in the selected
   applications appear as external prerequisites with a ⚠️ warning.
6. **Write** — outputs `.smartstack/ba/_plan/dev-plan.md` with summary, wave
   tables, Mermaid dependency graph, and next steps.

## Invocation

Ask the user which applications to include, then invoke the CLI:

```bash
npx --prefer-offline tsx skills/business-analyse/create-plan-development/cli/create-plan-development/index.ts \
  --spec '{"baRoot": ".smartstack/ba", "apps": ["CRM", "BILLING"], "includeReadiness": true}'
```

### Input

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `baRoot` | string | yes | Path to `.smartstack/ba/` |
| `apps` | string[] | yes | UPPERCASE application codes |
| `includeReadiness` | boolean | no (default: true) | Read `_audit/prd.md` for GO/NO-GO status |

### Output

`GenerateEnvelope` on stdout. The plan file is written to
`.smartstack/ba/_plan/dev-plan.md`.

## Output format

The plan includes:

1. **Summary table** — app count, module count, wave count, cycle count
2. **Wave 0 — External Prerequisites** — modules not in the selected apps but
   referenced as FK targets
3. **Wave 1+ — Development waves** — modules grouped by dependency level, with
   entity count, dependencies, and PRD readiness status
4. **Mermaid graph** — visual dependency diagram with subgraphs per wave
5. **Warnings** — missing `entité.md`, cycles, undocumented FKs
6. **Next steps** — actionable guidance for running `/ba-develop`

## Cross-module FK convention

This skill relies on the `entité.md` attribute table convention defined in
`create-data-model/levels/relationships.md`:

- **Same-module FK** → declared as a `Relation` (not parsed by this skill)
- **Cross-module FK** → plain `Guid` attribute with description:
  `FK cross-module vers APP/MODULE.Entity`
- **SmartStack Core** → plain `Guid` attribute: `FK Core auth_Users` (excluded)
