legacy-squad 1.0.0-beta.8 β†’ 1.0.1

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.
Files changed (3) hide show
  1. package/README.md +471 -408
  2. package/README.pt-br.md +471 -408
  3. package/package.json +58 -58
package/README.md CHANGED
@@ -1,408 +1,471 @@
1
- <p align="center">
2
- <h1 align="center">Legacy Squad Framework</h1>
3
- <p align="center"><strong>AI-Powered Legacy Modernization Platform</strong></p>
4
- <p align="center"><em>Understand. Plan. Modernize.</em></p>
5
- <p align="center">
6
- <a href="README.pt-br.md">πŸ‡§πŸ‡· PortuguΓͺs</a> Β· <strong>πŸ‡ΊπŸ‡Έ English</strong>
7
- </p>
8
- </p>
9
-
10
- ---
11
-
12
- Legacy Squad is an open-source framework that installs inside your legacy project with a single command, automatically analyzes the codebase, and provides specialized AI agents in your IDE to produce a complete diagnostic β€” without changing a single line of code.
13
-
14
- ```bash
15
- npx legacy-squad install
16
- ```
17
-
18
- ---
19
-
20
- ## The Problem
21
-
22
- Legacy systems support critical processes, but frequently suffer from:
23
-
24
- - Missing or outdated documentation
25
- - Hardcoded credentials in source code
26
- - Business rules buried in conditionals no one documented
27
- - Coupling that makes any change risky
28
- - Fear of modifying production code
29
- - Dependency on 1-2 developers who "know the system"
30
-
31
- Traditional approaches (full rewrites, unstructured refactoring) are expensive, slow, and risky.
32
-
33
- ## The Solution
34
-
35
- Legacy Squad combines **deterministic analysis** (scanner + compliance engine with OWASP/CWE rules) with **specialized AI agents** that run in your IDE (Claude Code, Codex, Cursor) to produce:
36
-
37
- | Artifact | What it does |
38
- |----------|-------------|
39
- | **Repo Index** | Full inventory: stack, modules, dependencies, integrations, hotspots |
40
- | **Findings** | Security findings with evidence, impact, OWASP reference and recommendation |
41
- | **Security Assessment** | Deep analysis of auth, secrets, LGPD/GDPR, API security |
42
- | **Architecture Assessment** | C4 diagrams, coupling analysis, structural risks, target architecture |
43
- | **Legacy Code Assessment** | Hotspots, JS→TS migration, duplication, test coverage |
44
- | **Business Rules Assessment** | 60+ rules extracted from code, preservation checklist |
45
- | **Modernization Plan** | Incremental phased roadmap with rollback and scores |
46
- | **PRS** | Product Refactor Specification β€” consolidated report for decision makers |
47
-
48
- ---
49
-
50
- ## Quick Start
51
-
52
- ### Prerequisites
53
-
54
- - Node.js β‰₯ 18
55
- - An AI-enabled IDE: [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Codex CLI](https://github.com/openai/codex), or [Cursor](https://cursor.sh)
56
-
57
- ### Installation
58
-
59
- ```bash
60
- cd your-legacy-project
61
- npx legacy-squad install
62
- ```
63
-
64
- The command:
65
- 1. Detects the stack (React Native, PHP, .NET, Java, Node β€” via manifest)
66
- 2. Scans the repository and generates the inventory
67
- 3. Runs the Compliance Engine (OWASP/CWE rules)
68
- 4. Generates Context Packs per module
69
- 5. Installs agents as slash commands in your IDE
70
- 6. Verifies the installation (8 checks)
71
-
72
- ### Usage with Claude Code
73
-
74
- ```bash
75
- claude # Open Claude Code in the project
76
- /legacy-squad-security # Run Security Agent
77
- /legacy-squad-architecture # Run Architecture Agent
78
- /legacy-squad-legacy-code # Run Legacy Code Agent
79
- /legacy-squad-business-rules # Run Business Rules Agent
80
- /legacy-squad-modernization # Run Modernization Agent
81
- /legacy-squad-generate-prs # Consolidate everything into the final PRS
82
- ```
83
-
84
- ### Usage with Codex CLI
85
-
86
- ```bash
87
- codex # Open Codex in the project
88
- # AGENTS.md at the root defines available agents
89
- @legacy-squad-security # Activate Security Agent
90
- ```
91
-
92
- ### Other Commands
93
-
94
- ```bash
95
- npx legacy-squad scan # Re-scan without reinstalling agents
96
- npx legacy-squad doctor # Verify installation health
97
- ```
98
-
99
- ---
100
-
101
- ## How It Works
102
-
103
- ```
104
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
105
- β”‚ npx legacy-squad β”‚
106
- β”‚ install β”‚
107
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
108
- β”‚
109
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
110
- β–Ό β–Ό β–Ό
111
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
112
- β”‚ Scanner β”‚ β”‚ Compliance β”‚ β”‚ Context β”‚
113
- β”‚ (stack, β”‚ β”‚ Engine β”‚ β”‚ Manager β”‚
114
- β”‚ modules) β”‚ β”‚ (OWASP) β”‚ β”‚ (packs) β”‚
115
- β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
116
- β”‚ β”‚ β”‚
117
- β–Ό β–Ό β–Ό
118
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
119
- β”‚ .legacy-squad/memory/ β”‚
120
- β”‚ repo-index.json | findings.json | β”‚
121
- β”‚ context-packs.json β”‚
122
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
123
- β”‚
124
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
125
- β–Ό β–Ό β–Ό
126
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
127
- β”‚ .claude/ β”‚ β”‚ AGENTS.mdβ”‚ β”‚ .cursor/ β”‚
128
- β”‚ commands/β”‚ β”‚ (Codex) β”‚ β”‚ rules/ β”‚
129
- β”‚ (Claude) β”‚ β”‚ β”‚ β”‚ (Cursor) β”‚
130
- β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
131
- β”‚ β”‚ β”‚
132
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
133
- β”‚
134
- β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
135
- β”‚ IDE + AI β”‚
136
- β”‚ (Claude Codeβ”‚
137
- β”‚ Codex, β”‚
138
- β”‚ Cursor) β”‚
139
- β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
140
- β”‚
141
- β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
142
- β”‚ Assessments β”‚
143
- β”‚ + Final PRS β”‚
144
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
145
- ```
146
-
147
- **The framework prepares data and installs agents. AI runs in the dev's IDE.**
148
-
149
- Zero API keys required. Zero external server calls. Everything runs locally.
150
-
151
- ---
152
-
153
- ## Installed Structure
154
-
155
- After `npx legacy-squad install`:
156
-
157
- ```
158
- your-project/
159
- β”œβ”€β”€ .legacy-squad/
160
- β”‚ β”œβ”€β”€ config/
161
- β”‚ β”‚ └── project.yaml # Detected configuration
162
- β”‚ β”œβ”€β”€ memory/
163
- β”‚ β”‚ β”œβ”€β”€ repo-index.json # Repository inventory
164
- β”‚ β”‚ β”œβ”€β”€ findings.json # Compliance engine findings
165
- β”‚ β”‚ └── context-packs.json # Context per module
166
- β”‚ β”œβ”€β”€ outputs/
167
- β”‚ β”‚ β”œβ”€β”€ assessments/ # Agent assessments
168
- β”‚ β”‚ └── reports/ # Consolidated PRS
169
- β”‚ └── logs/
170
- β”‚ └── install.log
171
- β”œβ”€β”€ .claude/
172
- β”‚ └── commands/
173
- β”‚ └── legacy-squad/
174
- β”‚ β”œβ”€β”€ security.md # /legacy-squad-security
175
- β”‚ β”œβ”€β”€ architecture.md # /legacy-squad-architecture
176
- β”‚ β”œβ”€β”€ legacy-code.md # /legacy-squad-legacy-code
177
- β”‚ β”œβ”€β”€ business-rules.md # /legacy-squad-business-rules
178
- β”‚ β”œβ”€β”€ modernization.md # /legacy-squad-modernization
179
- β”‚ β”œβ”€β”€ generate-prs.md # /legacy-squad-generate-prs
180
- β”‚ └── scan.md # /legacy-squad-scan
181
- └── AGENTS.md # Codex compatibility
182
- ```
183
-
184
- ---
185
-
186
- ## Agents
187
-
188
- ### Security Agent (`/legacy-squad-security`)
189
-
190
- Analyzes authentication, secrets, insecure storage, PII exposure, and privacy compliance (LGPD, GDPR).
191
-
192
- **References:** OWASP MASVS V2, OWASP ASVS, CWE Top 25, LGPD, GDPR, NIST SSDF
193
-
194
- ### Architecture Agent (`/legacy-squad-architecture`)
195
-
196
- Maps current architecture with C4 diagrams, identifies coupling, structural risks, and proposes incremental target architecture.
197
-
198
- **References:** C4 Model, Clean Architecture, arc42, ADR
199
-
200
- ### Legacy Code Agent (`/legacy-squad-legacy-code`)
201
-
202
- Identifies hotspots, duplication, JS→TS migration progress, test coverage, and refactoring priorities.
203
-
204
- **References:** Clean Code, Sonar Rules, Cognitive Complexity
205
-
206
- ### Business Rules Agent (`/legacy-squad-business-rules`)
207
-
208
- Extracts business rules hidden in code β€” validations, permissions, flows, magic numbers, implicit rules in catch blocks.
209
-
210
- **References:** DDD, Event Storming
211
-
212
- ### Modernization Agent (`/legacy-squad-modernization`)
213
-
214
- Synthesizes all assessments into an incremental plan with phases, rollback, Deployability Score (1-10), and Execution Readiness Score (0-100).
215
-
216
- **References:** Strangler Fig, Branch by Abstraction, Progressive Delivery
217
-
218
- ### PRS Generator (`/legacy-squad-generate-prs`)
219
-
220
- Consolidates all assessments into the PRS (Product Refactor Specification) β€” the final document for decision makers.
221
-
222
- ---
223
-
224
- ## Supported Stacks
225
-
226
- ### Manifest Detection (Layer 1 β€” deterministic)
227
-
228
- | Manifest | Stack |
229
- |----------|-------|
230
- | `package.json` | Node.js, React, React Native, Expo, Next.js |
231
- | `composer.json` | PHP, Laravel |
232
- | `.csproj` | C#, .NET |
233
- | `pom.xml` | Java, Spring Boot |
234
-
235
- ### Extension Detection (Layer 2 β€” heuristic)
236
-
237
- TypeScript, JavaScript, PHP, C#, Java, Python, Dart
238
-
239
- ---
240
-
241
- ## Compliance Engine
242
-
243
- The scanner automatically runs deterministic rules based on OWASP and CWE:
244
-
245
- | Rule | Detects | Reference |
246
- |------|---------|-----------|
247
- | SEC-CRED-001 | Hardcoded credentials | OWASP MASVS, CWE-798 |
248
- | SEC-CRED-002 | Keystores/certificates in repository | OWASP MASVS, CWE-312 |
249
- | SEC-LOG-001 | Active console.log in production | CWE-532 |
250
- | SEC-LOG-002 | PII (CPF, SSN, IDs) in logs/external services | CWE-532, LGPD/GDPR |
251
- | SEC-ERR-001 | Empty catch blocks | CWE-390 |
252
- | SEC-STORE-001 | Token in AsyncStorage | OWASP MASVS |
253
- | CQ-MIX-001 | Mixed JS and TS files | Clean Code |
254
- | CQ-DEP-001 | Transitive dependencies | Clean Code |
255
-
256
- Every finding includes: evidence (file, line, snippet), impact, technical reference, and recommendation.
257
-
258
- ---
259
-
260
- ## Principles
261
-
262
- | Principle | Description |
263
- |-----------|-------------|
264
- | **Install-First** | One command installs everything. No manual setup. |
265
- | **IDE-Native** | Agents are IDE slash commands. AI comes from the dev's environment. |
266
- | **Evidence-Driven** | Every finding has concrete evidence (file, line, snippet). |
267
- | **Context-First** | No LLM receives the entire repository β€” only context packs. |
268
- | **Read-Only** | The framework does not modify code. It only reads and generates reports. |
269
- | **Production-First** | Every recommendation assumes the system is in production. |
270
- | **Incremental** | Every modernization step is incremental, reversible, and deployable. |
271
-
272
- ---
273
-
274
- ## Validated in Production
275
-
276
- The framework was validated against a **production mobile app** (~18k lines of code, 98 dependencies, real financial transactions):
277
-
278
- **Compliance Engine (deterministic):** 7 findings via pattern matching
279
-
280
- **AI Agents (via Claude Code):** +43 additional findings, including:
281
- - Service account credentials decoded from Base64 in source code
282
- - Remote config flag capable of bypassing all authentication in production
283
- - User passwords logged in plaintext to a cloud database
284
- - PII used as primary key in a cloud database (enumerable)
285
- - Session recording capturing sensitive data without user consent
286
- - 63 business rules extracted from code (11 implicit, never documented)
287
- - Potential bug in a date calculation affecting core business logic
288
- - 36-week modernization roadmap with scores: Deployability 3β†’9/10, Readiness 22β†’87/100
289
-
290
- **Total:** 50 findings across 5 pillars, from a single `npx legacy-squad install` + 6 agent activations.
291
-
292
- ---
293
-
294
- ## Open Core
295
-
296
- ### Community Edition (V1) β€” Open Source
297
-
298
- Focus: **Understand + Plan**
299
-
300
- - Scanner, Compliance Engine, Context Manager
301
- - 7 agents as slash commands
302
- - PRS, assessments, modernization plan
303
- - Claude Code, Codex, Cursor support
304
-
305
- ### Enterprise Edition (V2) β€” In development
306
-
307
- Focus: **Modernize**
308
-
309
- - Execution Engine (AI-assisted refactoring)
310
- - Pull Request Engine
311
- - QA Gates
312
- - CI/CD Integration
313
- - Custom Rule Packs
314
- - Dashboard + Team Collaboration
315
-
316
- ---
317
-
318
- ## Roadmap
319
-
320
- - [x] Sprint 1 β€” Scanner + Compliance Engine
321
- - [x] Sprint 2 β€” Install command + IDE integration
322
- - [x] Sprint 3 β€” Context Manager (basic)
323
- - [x] Sprint 4 β€” End-to-end validation with real project
324
- - [ ] Sprint 5 β€” Multi-IDE (Cursor, Gemini CLI)
325
- - [ ] Sprint 6 β€” Rules for PHP, .NET, Java
326
- - [ ] Sprint 7 β€” SDD + MMP agents
327
- - [ ] Sprint 8 β€” Execution Specs agent + npm publish
328
-
329
- ---
330
-
331
- ## Development
332
-
333
- ```bash
334
- git clone https://github.com/hrpimenta/legacy-squad.git
335
- cd legacy-squad
336
- pnpm install
337
- pnpm approve-builds esbuild
338
-
339
- # Tests
340
- npx vitest run
341
-
342
- # Dev mode (no build)
343
- npx tsx apps/cli/src/index.ts install -p /path/to/project
344
-
345
- # Build
346
- node build.mjs
347
-
348
- # Test bundled version
349
- node dist/cli.mjs install -p /path/to/project
350
- ```
351
-
352
- ### Monorepo Structure
353
-
354
- ```
355
- legacy-squad/
356
- β”œβ”€β”€ packages/
357
- β”‚ β”œβ”€β”€ core/ # Domain types, ports (Clean Architecture)
358
- β”‚ β”œβ”€β”€ scanner/ # Stack detection, repo index generation
359
- β”‚ β”œβ”€β”€ context/ # Context packs builder
360
- β”‚ β”œβ”€β”€ rules/ # Compliance engine, rule catalog
361
- β”‚ β”œβ”€β”€ agents/ # Agent definitions, installer, doctor
362
- β”‚ └── output/ # PRS generator
363
- β”œβ”€β”€ apps/
364
- β”‚ └── cli/ # CLI entry point (Commander.js)
365
- β”œβ”€β”€ templates/
366
- β”‚ └── claude-commands/ # Slash command templates
367
- └── docs/
368
- └── plans/ # Architecture decisions, plans
369
- ```
370
-
371
- ### Tests
372
-
373
- ```bash
374
- npx vitest run # 28 tests (domain, scanner, compliance, agents)
375
- npx vitest --watch # Watch mode
376
- ```
377
-
378
- ---
379
-
380
- ## Contributing
381
-
382
- 1. Fork the repository
383
- 2. Create a branch (`git checkout -b feature/my-feature`)
384
- 3. Follow the standards: TDD (Red→Green→Refactor), SOLID, Clean Architecture
385
- 4. Run tests (`npx vitest run`)
386
- 5. Open a PR
387
-
388
- ### Ways to contribute
389
-
390
- - New rules for the Compliance Engine (PHP, .NET, Java)
391
- - Agent template improvements
392
- - New IDE support
393
- - Documentation and translation
394
- - Tests and fixtures for other stacks
395
-
396
- ---
397
-
398
- ## License
399
-
400
- MIT β€” see [LICENSE](LICENSE) for details.
401
-
402
- ---
403
-
404
- <p align="center">
405
- <strong>Understand. Plan. Modernize.</strong>
406
- <br>
407
- <em>Legacy Squad Framework</em>
408
- </p>
1
+ <p align="center">
2
+ <h1 align="center">Legacy Squad Framework</h1>
3
+ <p align="center"><strong>AI-Powered Legacy Modernization Platform</strong></p>
4
+ <p align="center"><em>Understand. Plan. Modernize.</em></p>
5
+ <p align="center">
6
+ <a href="README.pt-br.md">πŸ‡§πŸ‡· PortuguΓͺs</a> Β· <strong>πŸ‡ΊπŸ‡Έ English</strong>
7
+ </p>
8
+ </p>
9
+
10
+ ---
11
+
12
+ Legacy Squad is an open-source framework that installs inside your legacy project with a single command, automatically analyzes the codebase, and provides specialized AI agents in your IDE to produce a complete diagnostic β€” without changing a single line of code.
13
+
14
+ ```bash
15
+ npx legacy-squad install
16
+ ```
17
+
18
+ ---
19
+
20
+ ## The Problem
21
+
22
+ Legacy systems support critical processes, but frequently suffer from:
23
+
24
+ - Missing or outdated documentation
25
+ - Hardcoded credentials in source code
26
+ - Business rules buried in conditionals no one documented
27
+ - Coupling that makes any change risky
28
+ - Fear of modifying production code
29
+ - Dependency on 1-2 developers who "know the system"
30
+
31
+ Traditional approaches (full rewrites, unstructured refactoring) are expensive, slow, and risky.
32
+
33
+ ## The Solution
34
+
35
+ Legacy Squad combines **deterministic analysis** (scanner + compliance engine with OWASP/CWE rules) with **specialized AI agents** that run in your IDE (Claude Code, Codex, Cursor) to produce:
36
+
37
+ | Artifact | What it does |
38
+ |----------|-------------|
39
+ | **Repo Index** | Full inventory: stack, modules, dependencies, integrations, hotspots |
40
+ | **Findings** | Security findings with evidence, impact, OWASP reference and recommendation |
41
+ | **Security Assessment** | Deep analysis of auth, secrets, LGPD/GDPR, API security |
42
+ | **Architecture Assessment** | C4 diagrams, coupling analysis, structural risks, target architecture |
43
+ | **Legacy Code Assessment** | Hotspots, JS→TS migration, duplication, test coverage |
44
+ | **Business Rules Assessment** | 60+ rules extracted from code, preservation checklist |
45
+ | **Modernization Assessment** | Incremental phased roadmap with rollback and scores |
46
+ | **PRS** | Product Refactor Specification β€” consolidated diagnostic report |
47
+ | **SDD** | Software Design Document β€” current/target architecture with ADRs |
48
+ | **MMP** | Modernization Master Plan β€” phased roadmap with Execution Readiness + Deployability scores |
49
+ | **Execution Specs** | Atomic, individually deployable units of work with binary acceptance criteria and rollback |
50
+
51
+ ---
52
+
53
+ ## Quick Start
54
+
55
+ ### Prerequisites
56
+
57
+ - Node.js β‰₯ 18
58
+ - An AI-enabled IDE: [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Codex CLI](https://github.com/openai/codex), or [Cursor](https://cursor.sh)
59
+
60
+ ### Installation
61
+
62
+ ```bash
63
+ cd your-legacy-project
64
+ npx legacy-squad install
65
+ ```
66
+
67
+ The command:
68
+ 1. Detects the stack (React Native, PHP, .NET, Java, Node β€” via manifest)
69
+ 2. Scans the repository and generates the inventory
70
+ 3. Runs the Compliance Engine (OWASP/CWE rules)
71
+ 4. Generates Context Packs per module
72
+ 5. Installs agents as slash commands in your IDE
73
+ 6. Verifies the installation (8 checks)
74
+
75
+ ### Usage with Claude Code
76
+
77
+ ```bash
78
+ claude # Open Claude Code in the project
79
+
80
+ # Step 1 β€” Analysis (5 agents, run in order)
81
+ /legacy-squad-security # Security Agent
82
+ /legacy-squad-architecture # Architecture Agent
83
+ /legacy-squad-legacy-code # Legacy Code Agent
84
+ /legacy-squad-business-rules # Business Rules Agent
85
+ /legacy-squad-modernization # Modernization Agent
86
+
87
+ # Step 2 β€” Consolidated artifacts (4 generators, run after analysis)
88
+ /legacy-squad-generate-prs # Product Refactor Specification
89
+ /legacy-squad-generate-sdd # Software Design Document
90
+ /legacy-squad-generate-mmp # Modernization Master Plan
91
+ /legacy-squad-generate-specs # Execution Specs (one YAML per unit of work)
92
+ ```
93
+
94
+ ### Usage with Codex CLI
95
+
96
+ ```bash
97
+ codex # Open Codex in the project
98
+ # AGENTS.md at the root defines available agents
99
+ @legacy-squad-security # Activate Security Agent
100
+ ```
101
+
102
+ ### Other Commands
103
+
104
+ ```bash
105
+ npx legacy-squad scan # Re-scan without reinstalling agents
106
+ npx legacy-squad doctor # Verify installation health
107
+ ```
108
+
109
+ ---
110
+
111
+ ## How It Works
112
+
113
+ ```
114
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
115
+ β”‚ npx legacy-squad β”‚
116
+ β”‚ install β”‚
117
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
118
+ β”‚
119
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
120
+ β–Ό β–Ό β–Ό
121
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
122
+ β”‚ Scanner β”‚ β”‚ Compliance β”‚ β”‚ Context β”‚
123
+ β”‚ (stack, β”‚ β”‚ Engine β”‚ β”‚ Manager β”‚
124
+ β”‚ modules) β”‚ β”‚ (OWASP) β”‚ β”‚ (packs) β”‚
125
+ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
126
+ β”‚ β”‚ β”‚
127
+ β–Ό β–Ό β–Ό
128
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
129
+ β”‚ .legacy-squad/memory/ β”‚
130
+ β”‚ repo-index.json | findings.json | β”‚
131
+ β”‚ context-packs.json β”‚
132
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
133
+ β”‚
134
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
135
+ β–Ό β–Ό β–Ό
136
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
137
+ β”‚ .claude/ β”‚ β”‚ AGENTS.mdβ”‚ β”‚ .cursor/ β”‚
138
+ β”‚ commands/β”‚ β”‚ (Codex) β”‚ β”‚ rules/ β”‚
139
+ β”‚ (Claude) β”‚ β”‚ β”‚ β”‚ (Cursor) β”‚
140
+ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
141
+ β”‚ β”‚ β”‚
142
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
143
+ β”‚
144
+ β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
145
+ β”‚ IDE + AI β”‚
146
+ β”‚ (Claude Codeβ”‚
147
+ β”‚ Codex, β”‚
148
+ β”‚ Cursor) β”‚
149
+ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
150
+ β”‚
151
+ β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
152
+ β”‚ Assessments β”‚
153
+ β”‚ + Final PRS β”‚
154
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
155
+ ```
156
+
157
+ **The framework prepares data and installs agents. AI runs in the dev's IDE.**
158
+
159
+ Zero API keys required. Zero external server calls. Everything runs locally.
160
+
161
+ ---
162
+
163
+ ## Installed Structure
164
+
165
+ After `npx legacy-squad install`:
166
+
167
+ ```
168
+ your-project/
169
+ β”œβ”€β”€ .legacy-squad/
170
+ β”‚ β”œβ”€β”€ config/
171
+ β”‚ β”‚ └── project.yaml # Detected configuration
172
+ β”‚ β”œβ”€β”€ memory/
173
+ β”‚ β”‚ β”œβ”€β”€ repo-index.json # Repository inventory
174
+ β”‚ β”‚ β”œβ”€β”€ findings.json # Compliance engine findings
175
+ β”‚ β”‚ └── context-packs.json # Context per module
176
+ β”‚ β”œβ”€β”€ outputs/
177
+ β”‚ β”‚ β”œβ”€β”€ assessments/ # Agent assessments (5 .md files)
178
+ β”‚ β”‚ β”œβ”€β”€ reports/ # PRS.md + PRS.json
179
+ β”‚ β”‚ β”œβ”€β”€ sdd/ # SDD.md + SDD.json
180
+ β”‚ β”‚ β”œβ”€β”€ mmp/ # MMP.md + MMP.json
181
+ β”‚ β”‚ └── specs/ # SPEC-*.yaml + INDEX.md
182
+ β”‚ └── logs/
183
+ β”‚ └── install.log
184
+ β”œβ”€β”€ .claude/
185
+ β”‚ └── commands/
186
+ β”‚ └── legacy-squad/
187
+ β”‚ β”œβ”€β”€ security.md # /legacy-squad-security
188
+ β”‚ β”œβ”€β”€ architecture.md # /legacy-squad-architecture
189
+ β”‚ β”œβ”€β”€ legacy-code.md # /legacy-squad-legacy-code
190
+ β”‚ β”œβ”€β”€ business-rules.md # /legacy-squad-business-rules
191
+ β”‚ β”œβ”€β”€ modernization.md # /legacy-squad-modernization
192
+ β”‚ β”œβ”€β”€ generate-prs.md # /legacy-squad-generate-prs
193
+ β”‚ β”œβ”€β”€ generate-sdd.md # /legacy-squad-generate-sdd
194
+ β”‚ β”œβ”€β”€ generate-mmp.md # /legacy-squad-generate-mmp
195
+ β”‚ β”œβ”€β”€ generate-specs.md # /legacy-squad-generate-specs
196
+ β”‚ └── scan.md # /legacy-squad-scan
197
+ └── AGENTS.md # Codex compatibility
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Agents
203
+
204
+ ### Security Agent (`/legacy-squad-security`)
205
+
206
+ Analyzes authentication, secrets, insecure storage, PII exposure, and privacy compliance (LGPD, GDPR).
207
+
208
+ **References:** OWASP MASVS V2, OWASP ASVS, CWE Top 25, LGPD, GDPR, NIST SSDF
209
+
210
+ ### Architecture Agent (`/legacy-squad-architecture`)
211
+
212
+ Maps current architecture with C4 diagrams, identifies coupling, structural risks, and proposes incremental target architecture.
213
+
214
+ **References:** C4 Model, Clean Architecture, arc42, ADR
215
+
216
+ ### Legacy Code Agent (`/legacy-squad-legacy-code`)
217
+
218
+ Identifies hotspots, duplication, JS→TS migration progress, test coverage, and refactoring priorities.
219
+
220
+ **References:** Clean Code, Sonar Rules, Cognitive Complexity
221
+
222
+ ### Business Rules Agent (`/legacy-squad-business-rules`)
223
+
224
+ Extracts business rules hidden in code β€” validations, permissions, flows, magic numbers, implicit rules in catch blocks.
225
+
226
+ **References:** DDD, Event Storming
227
+
228
+ ### Modernization Agent (`/legacy-squad-modernization`)
229
+
230
+ Synthesizes all assessments into an incremental plan with phases, rollback, Deployability Score (1-10), and Execution Readiness Score (0-100).
231
+
232
+ **References:** Strangler Fig, Branch by Abstraction, Progressive Delivery
233
+
234
+ ### PRS Generator (`/legacy-squad-generate-prs`)
235
+
236
+ Consolidates all assessments into the PRS (Product Refactor Specification) β€” the diagnostic report for decision makers.
237
+
238
+ ### SDD Generator (`/legacy-squad-generate-sdd`)
239
+
240
+ Produces the Software Design Document with current and target architecture (Mermaid C4 diagrams), component inventory, integrations, cross-cutting concerns (security, observability, error handling, configuration), constraints, and Architecture Decision Records (ADRs) with alternatives considered.
241
+
242
+ **References:** C4 Model, arc42, ADR, Clean Architecture
243
+
244
+ ### MMP Generator (`/legacy-squad-generate-mmp`)
245
+
246
+ Produces the Modernization Master Plan with phase roadmap (Foundation β†’ Core β†’ Evolution, with optional Emergency phase when critical findings exist), stack upgrade plan, risk matrix, rollback strategy per phase, Execution Readiness Score (0-100) justified dimension by dimension, Deployability Score per phase, and success metrics across security, code quality, test coverage, and architecture.
247
+
248
+ **References:** Strangler Fig, Branch by Abstraction, Progressive Delivery
249
+
250
+ ### Execution Specs Generator (`/legacy-squad-generate-specs`)
251
+
252
+ Decomposes the MMP into atomic Execution Specs β€” one YAML file per unit of work, each individually deployable, with binary acceptance criteria, mandatory rollback strategy, evidence traceability (compliance finding IDs + assessment references), dependency graph between specs, and explicit `human_approval_required` flag for high-risk changes.
253
+
254
+ **References:** FRAMEWORK_SPECIFICATION Section 8 (Execution Spec schema)
255
+
256
+ ---
257
+
258
+ ## Supported Stacks
259
+
260
+ ### Manifest Detection (Layer 1 β€” deterministic)
261
+
262
+ | Manifest | Stack |
263
+ |----------|-------|
264
+ | `package.json` | Node.js, React, React Native, Expo, Next.js |
265
+ | `composer.json` | PHP, Laravel |
266
+ | `.csproj` | C#, .NET |
267
+ | `pom.xml` | Java, Spring Boot |
268
+
269
+ ### Extension Detection (Layer 2 β€” heuristic)
270
+
271
+ TypeScript, JavaScript, PHP, C#, Java, Python, Dart
272
+
273
+ ---
274
+
275
+ ## Compliance Engine
276
+
277
+ The scanner automatically runs deterministic rules based on OWASP and CWE:
278
+
279
+ | Rule | Detects | Stacks | Reference |
280
+ |------|---------|--------|-----------|
281
+ | SEC-CRED-001 | Hardcoded credentials (passwords, API keys, tokens) | all | OWASP MASVS, CWE-798 |
282
+ | SEC-CRED-002 | Keystores/certificates committed to repository | mobile, all | OWASP MASVS, CWE-312 |
283
+ | SEC-SQL-001 | SQL injection (string concatenation in queries) | PHP, .NET, Java, Node | OWASP A03, CWE-89 |
284
+ | SEC-CRYPTO-001 | Weak cryptography (MD5, SHA1) | PHP, .NET, Java, Node | OWASP A02, CWE-327 |
285
+ | SEC-DESER-001 | Insecure deserialization (BinaryFormatter, `unserialize`, `readObject`) | .NET, PHP, Java | OWASP A08, CWE-502 |
286
+ | SEC-CMD-001 | Command injection (`exec`, `Runtime.exec`, `shell_exec` with user input) | PHP, .NET, Java, Node | OWASP A03, CWE-78 |
287
+ | SEC-PATH-001 | Path traversal (unvalidated file paths) | PHP, .NET, Java, Node | OWASP A01, CWE-22 |
288
+ | SEC-XSS-001 | XSS via unescaped output (`echo $_GET`, `Html.Raw`) | PHP, .NET | OWASP A03, CWE-79 |
289
+ | SEC-LOG-001 | Active `console.log` in production | JS/TS, mobile | CWE-532 |
290
+ | SEC-LOG-002 | PII (CPF, SSN, IDs) in logs/external services | all | CWE-532, LGPD/GDPR |
291
+ | SEC-ERR-001 | Empty catch blocks | all | CWE-390 |
292
+ | SEC-STORE-001 | Token in AsyncStorage (insecure storage) | mobile | OWASP MASVS |
293
+ | CQ-MIX-001 | Mixed JS and TS files (incomplete TS migration) | JS/TS | Clean Code |
294
+ | CQ-DEPRECATED-001 | Deprecated APIs (`mysql_*`, `ereg`, `Vector`) | PHP, Java | CVE-classified |
295
+
296
+ Every finding includes: evidence (file, line, snippet), impact, technical reference, and recommendation.
297
+
298
+ ---
299
+
300
+ ## Principles
301
+
302
+ | Principle | Description |
303
+ |-----------|-------------|
304
+ | **Install-First** | One command installs everything. No manual setup. |
305
+ | **IDE-Native** | Agents are IDE slash commands. AI comes from the dev's environment. |
306
+ | **Evidence-Driven** | Every finding has concrete evidence (file, line, snippet). |
307
+ | **Context-First** | No LLM receives the entire repository β€” only context packs. |
308
+ | **Read-Only** | The framework does not modify code. It only reads and generates reports. |
309
+ | **Production-First** | Every recommendation assumes the system is in production. |
310
+ | **Incremental** | Every modernization step is incremental, reversible, and deployable. |
311
+
312
+ ---
313
+
314
+ ## Validated in Production
315
+
316
+ The framework was validated against a **production mobile app** (~18k lines of code, 98 dependencies, real financial transactions):
317
+
318
+ **Compliance Engine (deterministic):** 7 findings via pattern matching
319
+
320
+ **AI Agents (via Claude Code):** +43 additional findings, including:
321
+ - Service account credentials decoded from Base64 in source code
322
+ - Remote config flag capable of bypassing all authentication in production
323
+ - User passwords logged in plaintext to a cloud database
324
+ - PII used as primary key in a cloud database (enumerable)
325
+ - Session recording capturing sensitive data without user consent
326
+ - 63 business rules extracted from code (11 implicit, never documented)
327
+ - Potential bug in a date calculation affecting core business logic
328
+
329
+ **Generated artifacts (4 official deliverables of V1):**
330
+ - **PRS** β€” Product Refactor Specification consolidating the diagnostic
331
+ - **SDD** β€” Software Design Document with current/target architecture and 8 ADRs
332
+ - **MMP** β€” Modernization Master Plan with 4-phase roadmap (Emergency β†’ Foundation β†’ Core β†’ Evolution), Execution Readiness Score 38β†’88/100, Deployability scores per phase, and concrete rollback strategies
333
+ - **37 Execution Specs** β€” atomic, individually deployable units of work with binary acceptance criteria, mandatory rollback, evidence traceability, and dependency graph
334
+
335
+ **Total:** 50 findings + 4 consolidated artifacts + 37 executable specs from a single `npx legacy-squad install` followed by 9 slash command activations.
336
+
337
+ ---
338
+
339
+ ## Open Core
340
+
341
+ ### Community Edition (V1) β€” Open Source
342
+
343
+ Focus: **Understand + Plan**
344
+
345
+ - Scanner with multi-stack detection (PHP/Laravel/Symfony, .NET/ASP.NET, Java/Spring, Node, React Native/Expo)
346
+ - Compliance Engine with 14 deterministic rules (OWASP MASVS, ASVS, CWE Top 25)
347
+ - Context Manager (basic)
348
+ - **5 analysis agents** as slash commands: security, architecture, legacy-code, business-rules, modernization
349
+ - **4 artifact generators** as slash commands: PRS, SDD, MMP, Execution Specs
350
+ - Claude Code, Codex CLI support (Cursor / Gemini CLI on the roadmap)
351
+
352
+ ### Enterprise Edition (V2) β€” In development
353
+
354
+ Focus: **Modernize**
355
+
356
+ - Execution Engine (AI-assisted refactoring)
357
+ - Pull Request Engine
358
+ - QA Gates
359
+ - CI/CD Integration
360
+ - Custom Rule Packs
361
+ - Dashboard + Team Collaboration
362
+
363
+ ---
364
+
365
+ ## Roadmap
366
+
367
+ ### V1 β€” Discovery Platform (Community Edition) βœ…
368
+
369
+ - [x] Scanner + Compliance Engine
370
+ - [x] Install command + IDE integration
371
+ - [x] Context Manager (basic)
372
+ - [x] End-to-end validation with real project (mobile, ~18k LoC)
373
+ - [x] Multi-stack rule catalog (PHP, .NET, Java, Node, mobile)
374
+ - [x] Language-agnostic agent templates (stack-aware analysis)
375
+ - [x] 4 official artifacts (PRS, SDD, MMP, Execution Specs)
376
+
377
+ ### V1 β€” Continuous improvements
378
+
379
+ - [ ] Cursor + Gemini CLI support
380
+ - [ ] Framework-specific rule packs (Eloquent raw queries, EF Core, Hibernate HQL)
381
+ - [ ] AST-based scanner (current is regex-based)
382
+
383
+ ### V2 β€” Execution Platform (Enterprise Edition) β€” In development
384
+
385
+ - [ ] Execution Engine (AI-assisted refactoring from Execution Specs)
386
+ - [ ] Pull Request Engine
387
+ - [ ] QA Gates
388
+ - [ ] CI/CD Integration
389
+ - [ ] Custom Rule Packs
390
+ - [ ] Dashboard + Team Collaboration
391
+
392
+ ---
393
+
394
+ ## Development
395
+
396
+ ```bash
397
+ git clone https://github.com/hrpimenta/legacy-squad.git
398
+ cd legacy-squad
399
+ pnpm install
400
+ pnpm approve-builds esbuild
401
+
402
+ # Tests
403
+ npx vitest run
404
+
405
+ # Dev mode (no build)
406
+ npx tsx apps/cli/src/index.ts install -p /path/to/project
407
+
408
+ # Build
409
+ node build.mjs
410
+
411
+ # Test bundled version
412
+ node dist/cli.mjs install -p /path/to/project
413
+ ```
414
+
415
+ ### Monorepo Structure
416
+
417
+ ```
418
+ legacy-squad/
419
+ β”œβ”€β”€ packages/
420
+ β”‚ β”œβ”€β”€ core/ # Domain types, ports (Clean Architecture)
421
+ β”‚ β”œβ”€β”€ scanner/ # Stack detection, repo index generation
422
+ β”‚ β”œβ”€β”€ context/ # Context packs builder
423
+ β”‚ β”œβ”€β”€ rules/ # Compliance engine, rule catalog
424
+ β”‚ β”œβ”€β”€ agents/ # Agent definitions, installer, doctor
425
+ β”‚ └── output/ # PRS generator
426
+ β”œβ”€β”€ apps/
427
+ β”‚ └── cli/ # CLI entry point (Commander.js)
428
+ β”œβ”€β”€ templates/
429
+ β”‚ └── claude-commands/ # Slash command templates
430
+ └── docs/
431
+ └── plans/ # Architecture decisions, plans
432
+ ```
433
+
434
+ ### Tests
435
+
436
+ ```bash
437
+ npx vitest run # 93 tests (domain, scanner, compliance, agents, installer)
438
+ npx vitest --watch # Watch mode
439
+ ```
440
+
441
+ ---
442
+
443
+ ## Contributing
444
+
445
+ 1. Fork the repository
446
+ 2. Create a branch (`git checkout -b feature/my-feature`)
447
+ 3. Follow the standards: TDD (Red→Green→Refactor), SOLID, Clean Architecture
448
+ 4. Run tests (`npx vitest run`)
449
+ 5. Open a PR
450
+
451
+ ### Ways to contribute
452
+
453
+ - New rules for the Compliance Engine (PHP, .NET, Java)
454
+ - Agent template improvements
455
+ - New IDE support
456
+ - Documentation and translation
457
+ - Tests and fixtures for other stacks
458
+
459
+ ---
460
+
461
+ ## License
462
+
463
+ MIT β€” see [LICENSE](LICENSE) for details.
464
+
465
+ ---
466
+
467
+ <p align="center">
468
+ <strong>Understand. Plan. Modernize.</strong>
469
+ <br>
470
+ <em>Legacy Squad Framework</em>
471
+ </p>