@atlashub/smartstack-cli 3.9.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2544 -2461
- package/dist/index.js.map +1 -1
- package/dist/mcp-entry.mjs +479 -6185
- package/dist/mcp-entry.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/agents/ba-writer.md +178 -0
- package/templates/agents/db-reader.md +149 -0
- package/templates/skills/application/references/application-roles-template.md +227 -0
- package/templates/skills/application/references/provider-template.md +30 -6
- package/templates/skills/application/steps/step-03-roles.md +45 -7
- package/templates/skills/application/steps/step-03b-provider.md +13 -6
- package/templates/skills/business-analyse/SKILL.md +56 -4
- package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +477 -0
- package/templates/skills/business-analyse/references/cache-warming-strategy.md +578 -0
- package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +9 -19
- package/templates/skills/business-analyse/references/consolidation-structural-checks.md +12 -2
- package/templates/skills/business-analyse/references/deploy-data-build.md +36 -25
- package/templates/skills/business-analyse/references/detection-strategies.md +424 -0
- package/templates/skills/business-analyse/references/html-data-mapping.md +4 -0
- package/templates/skills/business-analyse/references/prd-generation.md +258 -0
- package/templates/skills/business-analyse/references/robustness-checks.md +538 -0
- package/templates/skills/business-analyse/references/validate-incremental-html.md +47 -4
- package/templates/skills/business-analyse/references/validation-checklist.md +281 -0
- package/templates/skills/business-analyse/schemas/sections/specification-schema.json +33 -1
- package/templates/skills/business-analyse/steps/step-00-init.md +70 -75
- package/templates/skills/business-analyse/steps/step-01-cadrage.md +8 -22
- package/templates/skills/business-analyse/steps/step-03a-data.md +20 -410
- package/templates/skills/business-analyse/steps/step-03a1-setup.md +356 -0
- package/templates/skills/business-analyse/steps/step-03a2-analysis.md +143 -0
- package/templates/skills/business-analyse/steps/step-03b-ui.md +3 -0
- package/templates/skills/business-analyse/steps/step-03c-compile.md +72 -3
- package/templates/skills/business-analyse/steps/step-03d-validate.md +36 -3
- package/templates/skills/business-analyse/steps/step-04-consolidation.md +21 -440
- package/templates/skills/business-analyse/steps/step-04a-collect.md +304 -0
- package/templates/skills/business-analyse/steps/step-04b-analyze.md +239 -0
- package/templates/skills/business-analyse/steps/step-04c-decide.md +186 -0
- package/templates/skills/business-analyse/steps/step-05a-handoff.md +44 -0
- package/templates/skills/business-analyse/steps/step-05b-deploy.md +42 -2
- package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +518 -0
- package/templates/skills/controller/steps/step-03-generate.md +184 -24
- package/templates/skills/controller/templates.md +11 -2
- package/templates/skills/debug/SKILL.md +156 -53
- package/templates/skills/debug/references/team-protocol.md +232 -0
- package/templates/skills/ralph-loop/references/category-rules.md +46 -0
- package/templates/skills/ralph-loop/references/compact-loop.md +32 -2
- package/templates/skills/ralph-loop/references/core-seed-data.md +233 -21
- package/templates/skills/ralph-loop/steps/step-00-init.md +64 -1
- package/templates/skills/ralph-loop/steps/step-04-check.md +27 -2
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: step-03-roles
|
|
3
|
-
description: Generate role-permission mappings using MCP scaffold_role_permissions (with fallback)
|
|
3
|
+
description: Generate application roles and role-permission mappings using MCP scaffold_role_permissions (with fallback)
|
|
4
4
|
prev_step: steps/step-02-permissions.md
|
|
5
5
|
next_step: steps/step-03b-provider.md
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
# Step 3: Role-Permission Mapping
|
|
8
|
+
# Step 3: Application Roles & Role-Permission Mapping
|
|
9
9
|
|
|
10
10
|
## MANDATORY EXECUTION RULES
|
|
11
11
|
|
|
12
|
+
- For **client projects** (`seeding_strategy = "provider"`): Generate ApplicationRolesSeedData.cs and module role mappings
|
|
13
|
+
- For **core projects** (`seeding_strategy = "hasdata"`): Use RolePermissionConfiguration.cs
|
|
12
14
|
- PREFER MCP `scaffold_role_permissions` tool as the primary method
|
|
13
15
|
- If MCP is unavailable or the call fails, use the FALLBACK PROCEDURE below
|
|
14
16
|
- ALWAYS assign permissions to default roles
|
|
15
17
|
- NEVER leave permissions without role assignments
|
|
16
|
-
- ALWAYS WRITE generated code to the actual
|
|
18
|
+
- ALWAYS WRITE generated code to the actual files
|
|
17
19
|
|
|
18
20
|
## YOUR TASK
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
For **client projects**:
|
|
23
|
+
1. **ApplicationRolesSeedData.cs** (once per application) — defines the 4 application-scoped roles
|
|
24
|
+
2. **{Module}RolePermissionSeedData.cs** (per module) — maps permissions to roles by Code
|
|
25
|
+
|
|
26
|
+
For **core projects**:
|
|
21
27
|
1. RolePermissionConfiguration.cs HasData() entries
|
|
22
28
|
2. Default role assignments (SuperAdmin, PlatformAdmin, TenantAdmin, StandardUser)
|
|
23
29
|
3. Application-scoped role assignments (Admin, Manager, Contributor, Viewer)
|
|
@@ -131,13 +137,38 @@ If MCP call fails or `{mcp_available}` = false:
|
|
|
131
137
|
**For core (`{seeding_strategy}` = "hasdata"):** Write in RolePermissionConfiguration.cs (existing pattern)
|
|
132
138
|
|
|
133
139
|
**For client (`{seeding_strategy}` = "provider"):** DO NOT write in RolePermissionConfiguration.cs (does not exist in client projects).
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
|
|
141
|
+
Instead, create TWO files:
|
|
142
|
+
|
|
143
|
+
### 1. ApplicationRolesSeedData.cs (ONCE per application)
|
|
144
|
+
|
|
145
|
+
**File:** `Infrastructure/Persistence/Seeding/Data/ApplicationRolesSeedData.cs`
|
|
146
|
+
|
|
147
|
+
**Purpose:** Defines the 4 standard application-scoped roles (Admin, Manager, Contributor, Viewer) with valid `Code` values.
|
|
148
|
+
|
|
149
|
+
**CRITICAL:** Without this file, role-permission mappings in `SeedRolePermissionsAsync()` will fail silently because `roles.FirstOrDefault(r => r.Code == mapping.RoleCode)` will return null.
|
|
150
|
+
|
|
151
|
+
See [references/application-roles-template.md](../references/application-roles-template.md) for the complete template.
|
|
152
|
+
|
|
153
|
+
**Key requirements:**
|
|
154
|
+
- Deterministic GUIDs based on `role-{applicationId}-{roleType}`
|
|
155
|
+
- 4 roles: Admin, Manager, Contributor, Viewer
|
|
156
|
+
- Each role has a valid `Code` property ("admin", "manager", "contributor", "viewer")
|
|
157
|
+
- `ApplicationId` references the navigation application GUID
|
|
158
|
+
- `IsSystem = false` (application-scoped, not system roles)
|
|
159
|
+
|
|
160
|
+
**Detection:** Check if ApplicationRolesSeedData.cs exists. If yes, skip creation (already exists from Module 1). If no, create it.
|
|
161
|
+
|
|
162
|
+
### 2. {Module}RolePermissionSeedData.cs (PER module)
|
|
163
|
+
|
|
164
|
+
**File:** `Infrastructure/Persistence/Seeding/Data/{Domain}/{Module}RolePermissionSeedData.cs`
|
|
165
|
+
|
|
166
|
+
**Purpose:** Maps permissions to roles by Code (e.g., "admin" → "{navRoute}.*").
|
|
136
167
|
|
|
137
168
|
Content: static class with method `GetRolePermissionEntries()` that returns the role-permission mapping data.
|
|
138
169
|
These entries will be consumed by the `IClientSeedDataProvider` at step 03b.
|
|
139
170
|
|
|
140
|
-
**After creating
|
|
171
|
+
**After creating both files:** Proceed to step-03b-provider.md (which will skip for core projects).
|
|
141
172
|
|
|
142
173
|
---
|
|
143
174
|
|
|
@@ -280,6 +311,13 @@ If user selects "Custom adjustments", ask which roles/permissions to change and
|
|
|
280
311
|
|
|
281
312
|
## SUCCESS METRICS
|
|
282
313
|
|
|
314
|
+
**For client projects:**
|
|
315
|
+
- ApplicationRolesSeedData.cs created (once per application)
|
|
316
|
+
- {Module}RolePermissionSeedData.cs created with role-permission mappings
|
|
317
|
+
- All 4 application roles defined with valid Code values
|
|
318
|
+
- Proceeded to step-03b-provider.md
|
|
319
|
+
|
|
320
|
+
**For core projects:**
|
|
283
321
|
- Role-permission mappings generated (via MCP or fallback)
|
|
284
322
|
- RolePermissionConfiguration.cs WRITTEN with new entries
|
|
285
323
|
- All default roles have appropriate access
|
|
@@ -50,9 +50,10 @@ From previous steps:
|
|
|
50
50
|
## FILES TO GENERATE
|
|
51
51
|
|
|
52
52
|
See [references/provider-template.md](../references/provider-template.md) for the complete implementation:
|
|
53
|
-
- **
|
|
53
|
+
- **ApplicationRolesSeedData.cs** (once per application) — defines application-scoped roles (Admin, Manager, Contributor, Viewer)
|
|
54
|
+
- **Provider class** (`{AppPascalName}SeedDataProvider.cs`) with 4 seed methods (Navigation, Roles, Permissions, RolePermissions)
|
|
54
55
|
- **DI registration** pattern for `Infrastructure/DependencyInjection.cs`
|
|
55
|
-
- **
|
|
56
|
+
- **7 critical rules** (factory methods, idempotence, execution order, SaveChangesAsync order, deterministic GUIDs, FK by Code, Order property)
|
|
56
57
|
|
|
57
58
|
---
|
|
58
59
|
|
|
@@ -64,9 +65,11 @@ Identify all SeedData files created in previous steps:
|
|
|
64
65
|
|
|
65
66
|
```
|
|
66
67
|
Glob: **/Persistence/Seeding/Data/{Domain}/*SeedData.cs
|
|
68
|
+
Glob: **/Persistence/Seeding/Data/ApplicationRolesSeedData.cs
|
|
67
69
|
```
|
|
68
70
|
|
|
69
71
|
Expected files:
|
|
72
|
+
- `ApplicationRolesSeedData.cs` (application-level, once per app)
|
|
70
73
|
- `{Module}NavigationSeedData.cs` (from step 01)
|
|
71
74
|
- `{Module}NavigationTranslationSeedData.cs` (from step 01)
|
|
72
75
|
- `{Module}PermissionSeedData.cs` (from step 02)
|
|
@@ -96,9 +99,11 @@ Add the `IClientSeedDataProvider` registration.
|
|
|
96
99
|
### 4. Verify
|
|
97
100
|
|
|
98
101
|
Before proceeding to step-04, verify:
|
|
99
|
-
- [ ]
|
|
102
|
+
- [ ] ApplicationRolesSeedData.cs created (once per application)
|
|
103
|
+
- [ ] Provider generated with 4 methods (SeedNavigationAsync, SeedRolesAsync, SeedPermissionsAsync, SeedRolePermissionsAsync)
|
|
104
|
+
- [ ] Execution order: Navigation → Roles → Permissions → RolePermissions
|
|
100
105
|
- [ ] Registered in DI (`services.AddScoped<IClientSeedDataProvider, ...>()`)
|
|
101
|
-
- [ ] Consumes SeedData classes from steps 01-03
|
|
106
|
+
- [ ] Consumes SeedData classes from steps 01-03 + ApplicationRolesSeedData
|
|
102
107
|
- [ ] Idempotent (check existence before insert)
|
|
103
108
|
- [ ] Uses factory methods (no `new Entity()`)
|
|
104
109
|
|
|
@@ -106,9 +111,11 @@ Before proceeding to step-04, verify:
|
|
|
106
111
|
|
|
107
112
|
## SUCCESS METRICS
|
|
108
113
|
|
|
109
|
-
-
|
|
114
|
+
- ApplicationRolesSeedData.cs created (application-level)
|
|
115
|
+
- Provider class generated with all 4 seed methods (Navigation, Roles, Permissions, RolePermissions)
|
|
116
|
+
- Correct execution order enforced
|
|
110
117
|
- DI registration added
|
|
111
|
-
- SeedData classes from steps 01-03 properly consumed
|
|
118
|
+
- SeedData classes from steps 01-03 + ApplicationRolesSeedData properly consumed
|
|
112
119
|
- All methods are idempotent
|
|
113
120
|
- Factory methods used throughout
|
|
114
121
|
- Proceeded to step-04-backend.md
|
|
@@ -75,6 +75,52 @@ docs/business/
|
|
|
75
75
|
**No intermediate markdown files - all state in feature.json**
|
|
76
76
|
</output_structure>
|
|
77
77
|
|
|
78
|
+
<navigation_hierarchy>
|
|
79
|
+
**SmartStack uses a 5-level navigation structure mapped to database tables:**
|
|
80
|
+
|
|
81
|
+
| Level | Entity | Table DB | Created in Step | Description |
|
|
82
|
+
|-------|--------|----------|-----------------|-------------|
|
|
83
|
+
| 1 | Context | `core.nav_Contexts` | N/A | Fixed ("business", "platform", "system") |
|
|
84
|
+
| 2 | Application | `core.nav_Applications` | 00-01 | Top-level application (e.g., "RessourcesHumaines") |
|
|
85
|
+
| 3 | Module | `core.nav_Modules` | 02 | Functional module (e.g., "Employees", "TimeManagement") |
|
|
86
|
+
| 4 | **Section** | **`core.nav_Sections`** | **03a-03c** | **Page within module (e.g., "list", "detail", "create", "dashboard")** |
|
|
87
|
+
| 5 | **Resource** | **`core.nav_Resources`** | **03b-03c** | **React component (SmartTable, SmartForm, Chart, KpiCard, etc.)** |
|
|
88
|
+
|
|
89
|
+
**Hierarchical relationship:**
|
|
90
|
+
- Context → Application → Module → **Section** → **Resource**
|
|
91
|
+
- Each Section MUST have ≥1 Resource
|
|
92
|
+
- Each Section corresponds to 1 React page route
|
|
93
|
+
- Each Resource corresponds to 1 SmartStack UI component
|
|
94
|
+
|
|
95
|
+
**SeedData generation (step-03c):**
|
|
96
|
+
|
|
97
|
+
The `specification.seedDataCore` contains **7 mandatory arrays** for database seeding:
|
|
98
|
+
|
|
99
|
+
| Array | Table | Source | Description |
|
|
100
|
+
|-------|-------|--------|-------------|
|
|
101
|
+
| `navigationModules` | `core.nav_Modules` | Manual (step-03c) | Module entry (Level 3) |
|
|
102
|
+
| **`navigationSections`** | **`core.nav_Sections`** | **Derived from `specification.sections[]`** | **Section entries (Level 4)** |
|
|
103
|
+
| **`navigationResources`** | **`core.nav_Resources`** | **Derived from `specification.sections[].resources[]`** | **Resource entries (Level 5)** |
|
|
104
|
+
| `navigationTranslations` | `core.nav_Translations` | Manual (i18n) | Multi-language labels |
|
|
105
|
+
| `permissions` | `core.Permissions` | Manual (step-03c) | Permission definitions |
|
|
106
|
+
| `rolePermissions` | `core.RolePermissions` | Manual (step-03c) | Role-permission mappings |
|
|
107
|
+
| `permissionConstants` | `PermissionConstants.cs` | Manual (step-03c) | C# permission constants |
|
|
108
|
+
|
|
109
|
+
**Transform algorithm (step-03c section 8f-bis):**
|
|
110
|
+
- `navigationSections` = transform `specification.sections[]` → flatten to { code, label, icon, route, parentCode, permission, sort }
|
|
111
|
+
- `navigationResources` = transform `specification.sections[].resources[]` → flatten to { code, type, entity, parentCode, permission }
|
|
112
|
+
|
|
113
|
+
**Example:**
|
|
114
|
+
- Module: `Employees` (Level 3)
|
|
115
|
+
- Section: `list` (Level 4) → contains resources:
|
|
116
|
+
- Resource: `employees-grid` (SmartTable) (Level 5)
|
|
117
|
+
- Resource: `status-filter` (FilterBar) (Level 5)
|
|
118
|
+
- Section: `detail` (Level 4) → contains resources:
|
|
119
|
+
- Resource: `employee-card` (DetailCard) (Level 5)
|
|
120
|
+
- Resource: `contract-history` (SmartTable) (Level 5)
|
|
121
|
+
|
|
122
|
+
</navigation_hierarchy>
|
|
123
|
+
|
|
78
124
|
<resume_workflow>
|
|
79
125
|
**Update mode (auto-detected):**
|
|
80
126
|
|
|
@@ -104,9 +150,12 @@ When step-00 detects that the description matches an existing application:
|
|
|
104
150
|
- **Step 03c:** Per-module compile: actors, UCs, FRs, permissions, navigation, seed data, i18n
|
|
105
151
|
- **Step 03d:** Per-module validate: completeness checks, write feature.json, incremental HTML, loop
|
|
106
152
|
- Loop: 03a → 03b → 03c → 03d → 03a (next module) until all specified (specified)
|
|
107
|
-
- **Step
|
|
153
|
+
- **Step 04a:** Collect: module summaries, cross-module interactions (FK, events, shared data)
|
|
154
|
+
- **Step 04b:** Analyze: permission coherence, semantic validation, E2E flows, global risks
|
|
155
|
+
- **Step 04c:** Decide: final approval, write consolidation section, proceed to handoff (consolidated)
|
|
108
156
|
- **Step 05a:** Handoff: file mapping (7 categories), BR-to-code mapping, API summary, write to feature.json
|
|
109
157
|
- **Step 05b:** Deploy: prd.json, progress.txt, manifest, ba-interactive.html pre-populated (handed-off)
|
|
158
|
+
- **Step 05c:** Ralph Readiness Check: validation gate before /ralph-loop (optional but recommended)
|
|
110
159
|
|
|
111
160
|
**Update workflow (same phases, delta focus):**
|
|
112
161
|
- **Step 00:** Detection, locate existing feature, create version N+1
|
|
@@ -152,11 +201,14 @@ When step-00 detects that the description matches an existing application:
|
|
|
152
201
|
| 02 | `steps/step-02-decomposition.md` | Opus | Module decomposition, dependency graph, client checkpoint |
|
|
153
202
|
| 03a | `steps/step-03a-data.md` | Opus | Per-module: sections, entities, BRs, questionnaires |
|
|
154
203
|
| 03b | `steps/step-03b-ui.md` | Opus | Per-module: state machines, wireframes, layouts, dashboards |
|
|
155
|
-
| 03c | `steps/step-03c-compile.md` | Opus | Per-module: actors, UCs, FRs, permissions,
|
|
204
|
+
| 03c | `steps/step-03c-compile.md` | Opus | Per-module: actors, UCs, FRs, permissions, navigation, seedDataCore (7 arrays), i18n |
|
|
156
205
|
| 03d | `steps/step-03d-validate.md` | Sonnet | Per-module: validation, write, incremental HTML, loop decision |
|
|
157
|
-
|
|
|
206
|
+
| 04a | `steps/step-04a-collect.md` | Opus | Collect module summaries & cross-module interactions |
|
|
207
|
+
| 04b | `steps/step-04b-analyze.md` | Opus | Analyze permission coherence, semantic validation, E2E flows |
|
|
208
|
+
| 04c | `steps/step-04c-decide.md` | Opus | Final approval, write consolidation, proceed to handoff |
|
|
158
209
|
| 05a | `steps/step-05a-handoff.md` | Sonnet | Handoff: file mapping (7 categories), BR-to-code mapping, API summary, write handoff |
|
|
159
|
-
| 05b | `steps/step-05b-deploy.md` | Sonnet | Deploy: prd.json, progress.txt, manifest, ba-interactive.html
|
|
210
|
+
| 05b | `steps/step-05b-deploy.md` | Sonnet | Deploy: prd.json, progress.txt, manifest, ba-interactive.html |
|
|
211
|
+
| 05c | `steps/step-05c-ralph-readiness.md` | Sonnet | Ralph readiness validation gate (optional but recommended) |
|
|
160
212
|
| 06 | `steps/step-06-review.md` | Opus | Apply review corrections, create new version, regenerate all artifacts |
|
|
161
213
|
|
|
162
214
|
</step_files>
|
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
# Agent Pooling Best Practices
|
|
2
|
+
|
|
3
|
+
> **Objective:** Minimize agent proliferation and token waste by reusing agents strategically.
|
|
4
|
+
|
|
5
|
+
## Problem Statement
|
|
6
|
+
|
|
7
|
+
**Observed issue:** Business-analyse sessions create 20-24 subagents, many of which are ultra-short (4-13 lines) for trivial tasks like summaries or consolidations.
|
|
8
|
+
|
|
9
|
+
**Impact:**
|
|
10
|
+
- Organizational overhead (tracking 24 agents)
|
|
11
|
+
- Token waste (spawning + context setup for each agent)
|
|
12
|
+
- Complexity in debugging and monitoring
|
|
13
|
+
- 1540+ lines of JSONL logs for a single session
|
|
14
|
+
|
|
15
|
+
**Goal:** Reduce to 5-7 agents per session while maintaining quality and parallelism.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Agent Pooling Strategy
|
|
20
|
+
|
|
21
|
+
### Core Principle
|
|
22
|
+
|
|
23
|
+
> **Reuse agents for sequential operations, spawn new agents only for genuine parallelism.**
|
|
24
|
+
|
|
25
|
+
### When to Spawn a NEW Agent
|
|
26
|
+
|
|
27
|
+
✅ **Spawn new agent when:**
|
|
28
|
+
1. **Parallel operations** - Multiple independent tasks can run simultaneously
|
|
29
|
+
- Example: Specifying 2+ modules in parallel (step-03)
|
|
30
|
+
- Example: Reading multiple PRD files concurrently (step-05)
|
|
31
|
+
|
|
32
|
+
2. **Domain separation** - Task requires fundamentally different expertise
|
|
33
|
+
- Example: ba-writer for JSON writes, Explore for codebase search
|
|
34
|
+
- Example: MCP healthcheck vs. code generation
|
|
35
|
+
|
|
36
|
+
3. **Long-running tasks** - Task will take multiple turns and could block main flow
|
|
37
|
+
- Example: Deep codebase exploration with 10+ searches
|
|
38
|
+
- Example: Complex validation requiring many file reads
|
|
39
|
+
|
|
40
|
+
### When to REUSE Existing Agent
|
|
41
|
+
|
|
42
|
+
✅ **Reuse agent when:**
|
|
43
|
+
1. **Sequential operations** - Tasks depend on previous results
|
|
44
|
+
- Example: Read module 1 → process → read module 2 → process
|
|
45
|
+
- Example: Validate → fix → re-validate
|
|
46
|
+
|
|
47
|
+
2. **Same domain** - Task uses same tools and context as previous
|
|
48
|
+
- Example: Multiple ba-writer calls in step-05 module loop
|
|
49
|
+
- Example: Multiple ba-reader calls for different modules
|
|
50
|
+
|
|
51
|
+
3. **Short tasks** - Task will complete in 1-2 turns
|
|
52
|
+
- Example: Generate summary (inline, not separate agent)
|
|
53
|
+
- Example: Format output (inline, not separate agent)
|
|
54
|
+
|
|
55
|
+
4. **Consolidation** - Aggregating results from multiple sources
|
|
56
|
+
- Example: Combine module summaries into master (inline)
|
|
57
|
+
- Example: Build dependency graph from module data (inline)
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Anti-Patterns to Avoid
|
|
62
|
+
|
|
63
|
+
### ❌ Anti-Pattern 1: Ultra-Short Summary Agents
|
|
64
|
+
|
|
65
|
+
**Bad:**
|
|
66
|
+
```
|
|
67
|
+
FOR each module:
|
|
68
|
+
Spawn agent "summarize-module-{i}"
|
|
69
|
+
Agent reads module → generates 4-line summary → exits
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Result:** 5 agents created for 20 total lines of output
|
|
73
|
+
|
|
74
|
+
**Good:**
|
|
75
|
+
```
|
|
76
|
+
Main agent reads all modules sequentially
|
|
77
|
+
Generates summaries inline
|
|
78
|
+
Returns consolidated result
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Result:** 1 agent, same output, 80% fewer tokens
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### ❌ Anti-Pattern 2: Spawning for Every Step Transition
|
|
86
|
+
|
|
87
|
+
**Bad:**
|
|
88
|
+
```
|
|
89
|
+
Step 03a: Spawn agent-data
|
|
90
|
+
→ Agent completes → exits
|
|
91
|
+
Step 03b: Spawn agent-ui
|
|
92
|
+
→ Agent completes → exits
|
|
93
|
+
Step 03c: Spawn agent-compile
|
|
94
|
+
→ Agent completes → exits
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Result:** 3 agents per module, 15 agents for 5 modules
|
|
98
|
+
|
|
99
|
+
**Good:**
|
|
100
|
+
```
|
|
101
|
+
Step 03: Spawn ONE agent-module-spec
|
|
102
|
+
→ Agent executes 03a → 03b → 03c internally
|
|
103
|
+
→ Agent exits after module complete
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Result:** 5 agents for 5 modules (1 per module)
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### ❌ Anti-Pattern 3: Parallel Agents for Sequential Dependency
|
|
111
|
+
|
|
112
|
+
**Bad:**
|
|
113
|
+
```
|
|
114
|
+
Spawn agent-read-master (reads master feature.json)
|
|
115
|
+
Spawn agent-read-module-1 (reads module 1 feature.json)
|
|
116
|
+
Spawn agent-consolidate (waits for both, then merges)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Result:** 3 agents when 2 have sequential dependency
|
|
120
|
+
|
|
121
|
+
**Good:**
|
|
122
|
+
```
|
|
123
|
+
Spawn agent-consolidate
|
|
124
|
+
→ Reads master
|
|
125
|
+
→ Reads module 1
|
|
126
|
+
→ Merges inline
|
|
127
|
+
→ Returns result
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Result:** 1 agent, same output, faster execution
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Implementation Patterns
|
|
135
|
+
|
|
136
|
+
### Pattern 1: Module Loop with Single Agent
|
|
137
|
+
|
|
138
|
+
**Scenario:** Step 03 - Specify 5 modules sequentially
|
|
139
|
+
|
|
140
|
+
**Recommended:**
|
|
141
|
+
```
|
|
142
|
+
1. Main flow spawns ONE agent: "ba-module-orchestrator"
|
|
143
|
+
2. Agent receives: modules[], currentModuleIndex
|
|
144
|
+
3. Agent executes loop:
|
|
145
|
+
FOR i = 0; i < modules.length; i++:
|
|
146
|
+
Execute step-03a (data)
|
|
147
|
+
Execute step-03b (ui)
|
|
148
|
+
Execute step-03c (compile)
|
|
149
|
+
Execute step-03d (validate)
|
|
150
|
+
Write module feature.json
|
|
151
|
+
Advance to next module
|
|
152
|
+
4. Agent exits when all modules specified
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Result:** 1 agent for all 5 modules (vs. 20 agents in current implementation)
|
|
156
|
+
|
|
157
|
+
**Exception:** If modules have NO dependencies and can be specified in parallel:
|
|
158
|
+
- Spawn 2-3 agents maximum
|
|
159
|
+
- Each agent handles 1-2 modules
|
|
160
|
+
- Results merged by main flow
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### Pattern 2: Batch Operations with Checkpoints
|
|
165
|
+
|
|
166
|
+
**Scenario:** Step 05a - Generate handoff for 5 modules
|
|
167
|
+
|
|
168
|
+
**Recommended:**
|
|
169
|
+
```
|
|
170
|
+
1. Main flow spawns ONE agent: "ba-handoff-generator"
|
|
171
|
+
2. Agent receives: modules[], master feature.json
|
|
172
|
+
3. Agent executes batch:
|
|
173
|
+
FOR each module:
|
|
174
|
+
Calculate complexity
|
|
175
|
+
Map files to create (7 categories)
|
|
176
|
+
Map business rules to code
|
|
177
|
+
Generate API endpoint summary
|
|
178
|
+
Write to module feature.json
|
|
179
|
+
CHECKPOINT: Display progress "✓ Module {i+1}/5 complete"
|
|
180
|
+
4. After ALL modules: Write master handoff
|
|
181
|
+
5. Agent exits
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Result:** 1 agent for all handoff generation (vs. 5-10 agents in current)
|
|
185
|
+
|
|
186
|
+
**Checkpoint benefits:**
|
|
187
|
+
- User sees progress
|
|
188
|
+
- Agent can be interrupted/resumed if needed
|
|
189
|
+
- Failures isolated to specific module
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### Pattern 3: Parallel Domain Operations
|
|
194
|
+
|
|
195
|
+
**Scenario:** Step 00 - Initialize schemas + scan existing features + create config
|
|
196
|
+
|
|
197
|
+
**Recommended:**
|
|
198
|
+
```
|
|
199
|
+
1. Spawn agent-deploy-schemas (deploy 9 schema files)
|
|
200
|
+
2. Spawn agent-scan-features (glob + read existing features)
|
|
201
|
+
3. Main flow waits for both
|
|
202
|
+
4. Main flow creates config (inline)
|
|
203
|
+
5. Main flow creates master feature.json (inline via ba-writer)
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Result:** 2 agents for genuinely parallel tasks
|
|
207
|
+
|
|
208
|
+
**Why parallel:**
|
|
209
|
+
- Schema deployment and feature scanning are independent
|
|
210
|
+
- Both are I/O-bound (file operations)
|
|
211
|
+
- No shared state until merge
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Metrics & Monitoring
|
|
216
|
+
|
|
217
|
+
### Target Metrics (per BA session)
|
|
218
|
+
|
|
219
|
+
| Metric | Current | Target | Improvement |
|
|
220
|
+
|--------|---------|--------|-------------|
|
|
221
|
+
| Total agents | 24 | 5-7 | 71-79% reduction |
|
|
222
|
+
| Ultra-short agents (<20 lines) | 4 | 0 | 100% elimination |
|
|
223
|
+
| Agents per module loop | 4-5 | 1 | 80% reduction |
|
|
224
|
+
| JSONL log lines | 1540 | <500 | 68% reduction |
|
|
225
|
+
|
|
226
|
+
### Agent Spawn Decision Checklist
|
|
227
|
+
|
|
228
|
+
Before spawning a new agent, ask:
|
|
229
|
+
|
|
230
|
+
1. ☐ Can this be done inline in current agent? (80% of cases: YES)
|
|
231
|
+
2. ☐ Can I reuse an existing agent? (10% of cases: YES)
|
|
232
|
+
3. ☐ Is this truly parallel? (5% of cases: YES)
|
|
233
|
+
4. ☐ Is this a different domain? (5% of cases: YES)
|
|
234
|
+
|
|
235
|
+
If ALL answers are NO → spawn new agent.
|
|
236
|
+
Otherwise → inline or reuse.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Step-by-Step Migration Guide
|
|
241
|
+
|
|
242
|
+
### Step 00: Init
|
|
243
|
+
|
|
244
|
+
**Current:** 3-4 agents (schema deploy, scan, config, create)
|
|
245
|
+
**Target:** 1-2 agents
|
|
246
|
+
|
|
247
|
+
**Changes:**
|
|
248
|
+
- Inline config creation
|
|
249
|
+
- Inline master feature.json creation via ba-writer
|
|
250
|
+
- Keep schema deployment as separate agent (parallel with scan)
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
### Step 01: Cadrage
|
|
255
|
+
|
|
256
|
+
**Current:** 2-3 agents (questionnaire, suggestions, write)
|
|
257
|
+
**Target:** 1 agent
|
|
258
|
+
|
|
259
|
+
**Changes:**
|
|
260
|
+
- ONE agent executes entire cadrage
|
|
261
|
+
- Inline questionnaire processing
|
|
262
|
+
- Inline suggestion generation
|
|
263
|
+
- Single ba-writer call at end
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
### Step 02: Decomposition
|
|
268
|
+
|
|
269
|
+
**Current:** 3-4 agents (analysis, dependency graph, client checkpoint, write)
|
|
270
|
+
**Target:** 1 agent
|
|
271
|
+
|
|
272
|
+
**Changes:**
|
|
273
|
+
- ONE agent for decomposition
|
|
274
|
+
- Inline dependency graph calculation
|
|
275
|
+
- Inline client checkpoint (AskUserQuestion)
|
|
276
|
+
- Single ba-writer call for modules + dependencyGraph
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
### Step 03: Module Specification (BIGGEST IMPACT)
|
|
281
|
+
|
|
282
|
+
**Current:** 4-5 agents PER module × 5 modules = 20-25 agents
|
|
283
|
+
**Target:** 1 agent per module (5 total) OR 1 agent for all modules (1 total)
|
|
284
|
+
|
|
285
|
+
**Changes:**
|
|
286
|
+
- **Option A:** ONE agent for ALL modules (sequential)
|
|
287
|
+
- Agent loops through modules
|
|
288
|
+
- Executes 03a → 03b → 03c → 03d internally
|
|
289
|
+
- Displays progress checkpoints
|
|
290
|
+
|
|
291
|
+
- **Option B:** ONE agent PER module (if parallel possible)
|
|
292
|
+
- Max 2-3 modules in parallel
|
|
293
|
+
- Each agent handles 1 module end-to-end
|
|
294
|
+
|
|
295
|
+
**Recommended:** Option A (sequential) for most cases, Option B only if modules truly independent
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
### Step 04: Consolidation
|
|
300
|
+
|
|
301
|
+
**Current:** 2-3 agents (cross-module validation, E2E flows, write)
|
|
302
|
+
**Target:** 1 agent
|
|
303
|
+
|
|
304
|
+
**Changes:**
|
|
305
|
+
- ONE agent for consolidation
|
|
306
|
+
- Inline cross-module interaction detection
|
|
307
|
+
- Inline E2E flow generation
|
|
308
|
+
- Single ba-writer call
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
### Step 05: Handoff & Deploy
|
|
313
|
+
|
|
314
|
+
**Current:** 5-7 agents (handoff per module + master + PRD generation + HTML deploy)
|
|
315
|
+
**Target:** 2-3 agents
|
|
316
|
+
|
|
317
|
+
**Changes:**
|
|
318
|
+
- ONE agent for all handoff generation (modules + master)
|
|
319
|
+
- ONE agent for artifact deployment (PRD + HTML + manifest)
|
|
320
|
+
- Optional: ONE agent for validation (step-05c)
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Cache Warming Strategy
|
|
325
|
+
|
|
326
|
+
> **Complement to agent pooling:** Pre-load frequently-used files to reduce redundant reads.
|
|
327
|
+
|
|
328
|
+
### Step 00: Pre-Load Core Context
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
At Step-00 initialization:
|
|
332
|
+
1. Read + cache all 9 schemas
|
|
333
|
+
2. Read + cache master feature template
|
|
334
|
+
3. Read + cache questionnaire templates
|
|
335
|
+
4. Read + cache suggestion catalog
|
|
336
|
+
|
|
337
|
+
Result: 90% of Step-01 context pre-loaded, no re-reads needed
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Step 03: Pre-Load Module Context
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
At start of module loop:
|
|
344
|
+
1. Read + cache application context (from master)
|
|
345
|
+
2. Read + cache completed module summaries (via ba-reader)
|
|
346
|
+
3. Read + cache shared patterns and templates
|
|
347
|
+
|
|
348
|
+
Result: 70% of per-module context pre-loaded
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Benefits
|
|
352
|
+
|
|
353
|
+
- 15-20% token savings across session
|
|
354
|
+
- Faster agent execution (no wait for file reads)
|
|
355
|
+
- Reduced risk of file read failures
|
|
356
|
+
- Better cache hit rates (98.5% cache read in analysis → 50% reduction with warming)
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Rollout Plan
|
|
361
|
+
|
|
362
|
+
### Phase 1: Quick Wins (Week 1)
|
|
363
|
+
|
|
364
|
+
1. ✅ Eliminate ultra-short summary agents
|
|
365
|
+
- Make summaries inline in calling agent
|
|
366
|
+
- Remove dedicated "summary-request" agents
|
|
367
|
+
|
|
368
|
+
2. ✅ Consolidate Step 01 + 02 to 1 agent each
|
|
369
|
+
- Combine questionnaire + suggestions + write
|
|
370
|
+
- Combine decomposition + dependency + write
|
|
371
|
+
|
|
372
|
+
**Expected impact:** 30% reduction in agent count
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
### Phase 2: Module Loop Optimization (Week 2)
|
|
377
|
+
|
|
378
|
+
1. ✅ Refactor Step 03 to use 1 agent per module (or 1 for all)
|
|
379
|
+
- Agent executes 03a → 03b → 03c → 03d internally
|
|
380
|
+
- Display progress checkpoints
|
|
381
|
+
- Single ba-writer call per module
|
|
382
|
+
|
|
383
|
+
**Expected impact:** 60% reduction in agent count
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
### Phase 3: Handoff & Deploy Optimization (Week 3)
|
|
388
|
+
|
|
389
|
+
1. ✅ Consolidate Step 05a to 1 agent for all modules
|
|
390
|
+
- Batch handoff generation
|
|
391
|
+
- Progress checkpoints
|
|
392
|
+
|
|
393
|
+
2. ✅ Consolidate Step 05b to 1 agent for all artifacts
|
|
394
|
+
- PRD generation + HTML deploy + manifest
|
|
395
|
+
|
|
396
|
+
**Expected impact:** 70% reduction in agent count
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
### Phase 4: Cache Warming (Week 4)
|
|
401
|
+
|
|
402
|
+
1. ✅ Implement pre-loading in Step 00
|
|
403
|
+
2. ✅ Implement context caching in Step 03
|
|
404
|
+
3. ✅ Monitor cache hit rates
|
|
405
|
+
|
|
406
|
+
**Expected impact:** 15-20% token savings
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## Monitoring & Success Criteria
|
|
411
|
+
|
|
412
|
+
### Before Optimization (Baseline)
|
|
413
|
+
|
|
414
|
+
```
|
|
415
|
+
Session: Business-analyse for HumanResources application
|
|
416
|
+
- Total agents: 24
|
|
417
|
+
- Ultra-short agents: 4
|
|
418
|
+
- JSONL lines: 1540
|
|
419
|
+
- Tokens (largest agent): 106,881
|
|
420
|
+
- Cache efficiency: 98.5% read (inefficient)
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### After Optimization (Target)
|
|
424
|
+
|
|
425
|
+
```
|
|
426
|
+
Session: Business-analyse for HumanResources application
|
|
427
|
+
- Total agents: 5-7
|
|
428
|
+
- Ultra-short agents: 0
|
|
429
|
+
- JSONL lines: <500
|
|
430
|
+
- Tokens (largest agent): <80,000
|
|
431
|
+
- Cache efficiency: 50-60% read (optimal)
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Success Metrics
|
|
435
|
+
|
|
436
|
+
- ✅ Agent count reduced by 70-79%
|
|
437
|
+
- ✅ Ultra-short agents eliminated
|
|
438
|
+
- ✅ JSONL complexity reduced by 68%
|
|
439
|
+
- ✅ Token usage reduced by 15-20%
|
|
440
|
+
- ✅ Same output quality (no regressions)
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## References
|
|
445
|
+
|
|
446
|
+
- **Analysis Report:** Session 03b76b8b-ea1c-4f1e-a636-bd46b0c33e02
|
|
447
|
+
- **File Size Management:** See ba-writer.md § File Size Management
|
|
448
|
+
- **Cache Strategy:** See MEMORY.md § Cache Warming Strategy
|
|
449
|
+
- **Agent Types:** See Task tool documentation
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## Quick Reference Card
|
|
454
|
+
|
|
455
|
+
### ✅ DO
|
|
456
|
+
|
|
457
|
+
- Reuse agents for sequential operations
|
|
458
|
+
- Spawn 1 agent per logical phase (not per sub-step)
|
|
459
|
+
- Do summaries/formatting inline
|
|
460
|
+
- Pre-load context at phase start
|
|
461
|
+
- Display progress checkpoints
|
|
462
|
+
- Use ba-writer for all JSON operations
|
|
463
|
+
|
|
464
|
+
### ❌ DON'T
|
|
465
|
+
|
|
466
|
+
- Spawn agents for trivial tasks (<20 lines output)
|
|
467
|
+
- Spawn new agent for each step transition
|
|
468
|
+
- Spawn agents for sequential dependencies
|
|
469
|
+
- Re-read same files multiple times
|
|
470
|
+
- Create summary-only agents
|
|
471
|
+
- Spawn more than 7 agents per BA session
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
**Last Updated:** 2026-02-08
|
|
476
|
+
**Version:** 1.0
|
|
477
|
+
**Author:** SmartStack CLI Team
|