---
name: step-01-screens
description: Define sections and resources with detailed UI specs per module
model: opus
next_step: steps/step-02-wireframes.md
---

# Step 01 — Screens (Define Sections & Resources)

## Objective

For each module, define all sections and resources with detailed interface specifications: SmartTable columns, SmartForm fields with types, SmartDashboard KPIs, SmartKanban columns, SmartFilter filters, SmartCard layouts.

## Context Recovery

Re-read session variables (do NOT rely on LLM memory from prior skill invocation):
```javascript
const config = readJSON('.business-analyse/config.json').currentFeature;
const { id: feature_id, docsDir: docs_dir, projectSlug, application: application_name,
        applicationCode, language } = config;

// Path helpers (ba-006)
function toKebabCase(code) {
  return code.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2').toLowerCase();
}
function resolveModuleDir(appCode, moduleCode) {
  return `${docs_dir}/${toKebabCase(appCode)}/${toKebabCase(moduleCode)}`;
}
```

> **screens.json output (ba-006):** Written to `resolveModuleDir(appCode, moduleCode)/screens.json`
> Example: `docs/projet-rh/v1.0/human-resources/employees/screens.json`

## Prerequisites

- `/business-analyse` completed (entities, usecases, permissions exist)
- Module index.json accessible via ba-reader

## Execution

### 1. Load Analysis Data

For each module (in dependency order from index.json):

```
Load via ba-reader:
  - entities.json → entity attributes with types, relationships
  - usecases.json → actor actions, CRUD operations
  - permissions.json → role matrix, permission paths
  - index.json → anticipatedSections from step-02
```

### 2. Define Sections & Resources

For each module, transform anticipatedSections into detailed screen specs.

> **SmartComponent templates & canonical output format:**
> Load: `/references/smartcomponents-templates.md`
> - All SmartComponent JSON examples (SmartTable, SmartForm, SmartDashboard, SmartKanban, SmartFilter, SmartCard)
> - Canonical screens.json output format with `sections[]` wrapper

### 3. Column/Field Type Mapping & Business Rules

Map entity attribute types to UI component types and apply business rules for computed fields, lookups, and workflows.

> **Type mapping, readonly rules, computed attribute handling, lookup detection, and workflow auto-detection:**
> Load: `/references/screens-type-mapping.md`
> - Column/field type mapping table
> - Computed attribute rules (readonly on edit, absent on create)
> - Readonly field rules (boolean only, no string values)
> - SmartForm section location rules (list vs detail)
> - Lookup field entity requirement (SmartForm + SmartFilter)
> - SmartKanban auto-detection rule for workflow entities (status enum >= 3 options)
> - SmartFilter mandatory rule for list sections with SmartTable

### 4. Write screens.json

For each module, write via ba-writer using the canonical `sections[]` format:

> **CANONICAL FORMAT (MANDATORY):** screens.json MUST use the `sections[]` wrapper with `sectionCode`, `sectionLabel`, and `resources[]`.
> The flat `screens[]` format is **DEPRECATED**.
> All downstream consumers (business-analyse-html, business-analyse-handoff, business-analyse-develop) expect `sections[]`.
>
> Load full format with examples: `/references/smartcomponents-templates.md`

Update `index.json` with screens.json hash and status.

## Validation Summary

Run POST-CHECK validation after writing ALL screens.json files:

> Load: `/references/screens-post-check.md`
> - Complete validation script (10 checks: 8 BLOCKING + 2 WARNING)
> - CHECK 1: Section resources (at least 1 per section)
> - CHECK 2-3: Entity + permission references
> - CHECK 4-5: SmartTable/SmartForm attribute references
> - CHECK 6: Lookup field entity requirement
> - CHECK 7: Computed attribute readonly handling
> - CHECK 8: SmartFilter lookup entity requirement
> - CHECK 9: SmartFilter mandatory for list sections with SmartTable
> - CHECK 10: SmartKanban auto-detection for workflow entities

**BLOCKING** errors must be fixed before proceeding to step-02.
**WARNING** errors should be reviewed but do not block progress.

## Transition

-> Step 02 (wireframes) — Generate visual mockups for each screen
