---
name: ba-audit-pre-dev
description: >
  Pre-development readiness orchestrator for a `.smartstack/ba/` project. Does NOT
  re-run any dimension's rules — it reads the per-dimension verdicts already written
  under `_audit/*.md`, aggregates them across every module and the 9 dimensions, and
  writes a project-readiness summary with an overall GO / NO-GO. Run after the
  `/ba-audit-*` dimension audits, before `/ba-create-prd` + development.
allowed-tools: [Read, Write, Glob, Grep]
---

# ba-audit-pre-dev — Pre-development readiness orchestrator

You are the **readiness orchestrator**. Your job is to answer one business
question: **is this analysis ready to go into PRD generation and development?**

You do **not** re-implement any dimension's rules. Each `/ba-audit-<dim>` skill
already applies its own rule set and writes a verdict file. You **collect** those
verdicts, **aggregate** them across all modules and the 9 dimensions, and emit a
single project-readiness report. The verdict files are the source of truth — never
fabricate a result for a dimension that hasn't been audited yet.

## The 9 readiness dimensions

A module is dev-ready only when every dimension below has a clean (`0 err`)
verdict. Each dimension is audited by its own skill, which writes its verdict to
`<scope>/_audit/<file>` (per `_workflow/ba-files.md` + `_workflow/doc-templates.md`):

| # | Dimension | Audit skill | Verdict file | Fix skill |
|---|-----------|-------------|--------------|-----------|
| 1 | menu | `/ba-audit-menu` | `_audit/menu.md` | `/ba-create-menu` |
| 2 | sections | `/ba-audit-sections` | `_audit/sections.md` | `/ba-create-menu` |
| 3 | actors | `/ba-audit-actors` | `_audit/actors.md` | `/ba-create-actors` |
| 4 | use cases | `/ba-audit-use-cases` | `_audit/use-case.md` | `/ba-create-use-case` |
| 5 | rules | `/ba-audit-rules` | `_audit/règles-métier.md` | `/ba-create-business-rules` |
| 6 | rbac | `/ba-audit-rbac` | `_audit/rbac.md` | `/ba-create-rbac` |
| 7 | data model | `/ba-audit-data-model` | `_audit/entité.md` | `/ba-create-data-model` |
| 8 | screens | `/ba-audit-screens` | `_audit/screen.md` | `/ba-create-screen` |
| 9 | sources | `/ba-audit-sources` | `_audit/sources.md` (project + per-module) | `/ba-create-sources` |

`menu` and `sections` are app/project-scoped (their verdicts live at the app's
`_audit/`); `sources` splits — registry health + citation resolution at the
project root (`_audit/sources.md`, like actors), per-module coverage at the
module's `_audit/sources.md`; the other six are module- or section-scoped
(their verdicts live at the module's — or section's — `_audit/`). Map each
verdict back to its owning module by its folder path. A project with no
sources registry simply has an all-ok sources verdict (« sans objet ») — its
absence never blocks a GO.

## Scope

- **Project** (default): aggregate every `_audit/*.md` under `.smartstack/ba/`.
- **Application**: aggregate only the verdicts under `.smartstack/ba/<APP>/**`.
- **Module / section**: aggregate only the verdicts under that subtree, and the
  app-level `menu`/`sections` verdicts that cover it.

The aggregate report is always written to `.smartstack/ba/_audit/pre-dev.md`.

## Workflow

1. **Collect the verdicts**. `Glob .smartstack/ba/**/_audit/*.md` to list every
   per-dimension verdict in scope. Read each one. Its first line is the anchor
   `<!-- ba:audit dimension=<dim> scope=<code> -->`; the second is the verdict
   header `_<date> · Verdict : <emoji> N warn · M err · K ok_`. Parse the
   dimension, the scope code, and the three counts from that header. Derive the
   owning module from the file's folder path. Verdicts written by the
   deterministic engine (`/ba-audit-run` — anchor carries `engine=audit-ba`
   plus `ruleset=`/`sources=` freshness stamps, and the header MAY append
   `· J à arbitrer` AFTER the three counts) parse identically; a non-zero
   « à arbitrer » count means the dimension's judgment rules are still
   pending — report that (module × dimension) as **non audité (jugement
   requis)** rather than trusting its counters alone. Skip the engine's
   project files (`_audit/audit-ba.json`, `dimension=audit-ba`) — they are
   the run record, not a dimension verdict.
2. **Note the gaps**. For every (module × dimension) pair that has **no**
   `_audit` verdict file, record it as **non audité — lancer `/ba-audit-<dim>`**.
   There is no [ACTION] envelope and no injected state to fall back on, so do not
   invent a count for an un-audited dimension — an absent verdict is itself a
   readiness gap that must be reported.
3. **(Optional) full pass**. If the user asks for a complete audit, first invoke
   each `/ba-audit-*` dimension skill (state in chat that you are running them),
   let them write their `_audit/*.md` verdicts, then aggregate as above.
4. **Aggregate**. Sum `err` and `warn` across all collected verdicts. A module is
   GO when all 8 of its dimensions have a verdict and none reports `err`.
5. **Verdict**. Overall **GO** only when total `err = 0` **and** no dimension is
   un-audited in scope; otherwise **NO-GO**. Any single `err` forces NO-GO.
6. **Write** `.smartstack/ba/_audit/pre-dev.md` (below), then print the chat
   summary.

## Output — `.smartstack/ba/_audit/pre-dev.md`

Write the aggregate per the audit-verdict styling from `_workflow/doc-templates.md`
(anchor + verdict header + severity sections, rule/dimension names in **bold**).
This file replaces the old report envelope entirely — it is plain markdown.

**Who reads this file** (honest since 2026-08, chantier 4.5): its ONE
deterministic reader is `/ba-develop-plan`'s `preflight-develop-plan` CLI —
it parses the verdict header and the module × dimension status table, and
converts a `❌` or `— non audité` cell into **wave blockers** before
development starts. (Until then NO gate read this file: a NO-GO here was a
record nobody consumed. `/ba-develop`'s own preflight is under maintenance
freeze and still reads only the module's `_audit/prd.md` — a single-module
run outside the plan therefore does NOT see this verdict; run it through
`/ba-develop-plan`, or check the file yourself first.) The anchor, the
verdict header and the status-table shape are the PARSING CONTRACT — keep
them stable.

```markdown
<!-- ba:audit dimension=pre-dev scope=project -->
# Pré-développement — Synthèse de préparation
_2026-05-21 · Verdict : ❌ NO-GO · 2 err · 5 warn · 38 ok · 1 dimension non auditée_

## 📊 Statut par module × dimension
| Module | Menu | Sections | Acteurs | Cas d'usage | Règles | RBAC | Données | Écrans |
|--------|------|----------|---------|-------------|--------|------|---------|--------|
| CRM / PIPELINE | ✅ | ✅ | ✅ | ⚠️ 1 | ✅ | ❌ 1 | ✅ | ✅ |
| CRM / CONTACTS | ✅ | ✅ | ✅ | ✅ | ⚠️ 2 | ✅ | ❌ 1 | — non audité |

Légende : ✅ 0 err · ⚠️ N warn · ❌ M err · « — non audité » = lancer `/ba-audit-<dim>`.

## ❌ Bloquants (à corriger avant le PRD)
1. **CRM / PIPELINE · RBAC** — permission d'approbation manquante pour le rôle Manager.
   - → `/ba-create-rbac`
2. **CRM / CONTACTS · Données** — clé étrangère orpheline sur `Contact.OwnerId`.
   - → `/ba-create-data-model`

## ⚠️ Avertissements (non bloquants)
- **CRM / CONTACTS · Règles** — 2 règles sans exemple invalide. → `/ba-create-business-rules`
- **CRM / PIPELINE · Cas d'usage** — 1 cas d'usage sans postcondition. → `/ba-create-use-case`

## 🕳️ Dimensions non auditées
- **CRM / CONTACTS · Écrans** — aucun verdict. → lancer `/ba-audit-screens`

## ✅ Conforme
- 38 vérifications conformes sur l'ensemble du périmètre.
```

- The header verdict line carries the overall **GO / NO-GO** plus the summed
  `err` / `warn` / `ok` counts and the number of un-audited dimensions.
- The status table is **module (rows) × dimension (columns)**; each cell shows
  the dimension's verdict for that module (`✅` / `⚠️ N` / `❌ M` / `— non audité`).
- The blocker list is **prioritized** (errors first) and every blocker names its
  fix skill with a `→`. Drive each blocker straight from a collected verdict —
  never from a rule you re-evaluated here.
- Re-Write the whole file each run (overwrite — it is a fresh aggregate).

## Chat summary

After writing the file, print a concise GO/NO-GO summary in the user's language,
in **business terms** (no rule codes):

1. The verdict — **GO** or **NO-GO** — and the headline counts (modules ready / total).
2. If NO-GO: the top blocking issues (max 5), one line each, naming the module and
   the fix skill to run.
3. Any dimensions still un-audited, with the `/ba-audit-*` to run.
4. State plainly that a **GO (0 err, all dimensions audited)** is the gate for
   `/ba-create-prd` and for development; while NO-GO, fix the blockers first.

Keep it to ~6–10 lines. The `pre-dev.md` file holds the full detail.
