code-ai-installer 4.0.1-b → 4.0.1-c
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/LICENSE +1 -1
- package/README.md +5 -5
- package/dist/catalog.js +1 -1
- package/dist/contentTransformer.d.ts +1 -1
- package/dist/contentTransformer.js +39 -0
- package/dist/index.js +10 -5
- package/dist/mcp/cli.js +4 -4
- package/dist/mcp/scorecard.d.ts +2 -2
- package/dist/mcp/task_state.d.ts +2 -2
- package/dist/mcp/tools/advance_gate.js +1 -1
- package/dist/mcp/tools/classify_gate.d.ts +2 -2
- package/dist/mcp/tools/classify_gate.js +2 -2
- package/dist/mcp/tools/load_role.d.ts +2 -2
- package/dist/mcp/tools/load_role.js +2 -2
- package/dist/mcp/tools/report_exception.d.ts +3 -3
- package/dist/mcp/tools/report_exception.js +4 -4
- package/dist/mcp/tools/request_decision.d.ts +3 -3
- package/dist/mcp/tools/request_decision.js +5 -5
- package/dist/mcp/tools/review_proposal.d.ts +1 -1
- package/dist/mcp/tools/review_proposal.js +6 -6
- package/dist/mcp/tools/sign_off.d.ts +2 -2
- package/dist/mcp/tools/sign_off.js +7 -7
- package/dist/mcp/tools/verify_claim.d.ts +1 -1
- package/dist/mcp/tools/verify_claim.js +1 -1
- package/dist/mcp_setup.d.ts +84 -31
- package/dist/mcp_setup.js +182 -66
- package/dist/platforms/adapters.js +54 -19
- package/dist/shared/frontmatter.js +1 -1
- package/dist/shared/persona.d.ts +1 -1
- package/dist/shared/persona.js +1 -1
- package/dist/shared/pipeline.d.ts +10 -10
- package/dist/shared/pipeline.js +7 -7
- package/dist/shared/tools.d.ts +15 -15
- package/dist/shared/tools.js +3 -3
- package/dist/shared/vocabulary.d.ts +4 -4
- package/dist/shared/vocabulary.js +4 -4
- package/dist/types.d.ts +1 -1
- package/domains/analytics/.agents/workflows/analytics-pipeline-rules.md +13 -3
- package/domains/analytics/.agents/workflows/analyze.md +1 -0
- package/domains/analytics/.agents/workflows/quick-insight.md +1 -0
- package/domains/analytics/locales/en/.agents/workflows/analytics-pipeline-rules.md +13 -3
- package/domains/analytics/locales/en/.agents/workflows/analyze.md +1 -0
- package/domains/analytics/locales/en/.agents/workflows/quick-insight.md +1 -0
- package/domains/analytics/locales/en/agents/interviewer.md +2 -1
- package/domains/analytics/locales/en/agents/layouter.md +2 -1
- package/domains/analytics/locales/en/agents/mediator.md +2 -1
- package/domains/analytics/locales/en/agents/researcher.md +2 -1
- package/domains/analytics/locales/en/agents/strategist.md +2 -1
- package/domains/analytics/pipeline.yaml +10 -10
- package/domains/content/.agents/skills/content-release-gate/SKILL.md +3 -5
- package/domains/content/.agents/workflows/content-pipeline-rules.md +14 -11
- package/domains/content/.agents/workflows/edit-content.md +0 -1
- package/domains/content/.agents/workflows/quick-post.md +0 -1
- package/domains/content/.agents/workflows/start-content.md +0 -1
- package/domains/content/agents/conductor.md +1 -2
- package/domains/content/locales/en/.agents/skills/content-release-gate/SKILL.md +3 -5
- package/domains/content/locales/en/.agents/workflows/content-pipeline-rules.md +14 -11
- package/domains/content/locales/en/.agents/workflows/edit-content.md +0 -1
- package/domains/content/locales/en/.agents/workflows/quick-post.md +0 -1
- package/domains/content/locales/en/.agents/workflows/start-content.md +0 -1
- package/domains/content/locales/en/agents/conductor.md +1 -2
- package/domains/content/pipeline.yaml +8 -8
- package/domains/development/.agents/skills/handoff/SKILL.md +276 -276
- package/domains/development/.agents/skills/lava-flow-legacy-detection/SKILL.md +197 -197
- package/domains/development/.agents/skills/mcp-integration/SKILL.md +211 -211
- package/domains/development/.agents/skills/qa-test-data-management/SKILL.md +250 -250
- package/domains/development/.agents/workflows/bugfix.md +16 -82
- package/domains/development/.agents/workflows/hotfix.md +16 -66
- package/domains/development/.agents/workflows/pipeline-rules.md +49 -132
- package/domains/development/.agents/workflows/start-task.md +17 -121
- package/domains/development/AGENTS.md +8 -3
- package/domains/development/agents/architect.md +247 -247
- package/domains/development/agents/conductor.md +363 -363
- package/domains/development/agents/devops.md +297 -297
- package/domains/development/agents/reviewer.md +293 -293
- package/domains/development/agents/senior_full_stack.md +295 -295
- package/domains/development/agents/tester.md +395 -395
- package/domains/development/locales/en/.agents/skills/handoff/SKILL.md +276 -276
- package/domains/development/locales/en/.agents/skills/lava-flow-legacy-detection/SKILL.md +197 -197
- package/domains/development/locales/en/.agents/skills/mcp-integration/SKILL.md +211 -211
- package/domains/development/locales/en/.agents/skills/qa-test-data-management/SKILL.md +250 -250
- package/domains/development/locales/en/.agents/workflows/bugfix.md +16 -82
- package/domains/development/locales/en/.agents/workflows/hotfix.md +15 -65
- package/domains/development/locales/en/.agents/workflows/pipeline-rules.md +48 -131
- package/domains/development/locales/en/.agents/workflows/start-task.md +17 -121
- package/domains/development/locales/en/AGENTS.md +15 -0
- package/domains/development/locales/en/agents/architect.md +247 -247
- package/domains/development/locales/en/agents/conductor.md +363 -363
- package/domains/development/locales/en/agents/devops.md +297 -297
- package/domains/development/locales/en/agents/reviewer.md +293 -293
- package/domains/development/locales/en/agents/senior_full_stack.md +295 -295
- package/domains/development/locales/en/agents/tester.md +395 -395
- package/domains/development/locales/en/prompt-examples.md +34 -120
- package/domains/development/pipeline.yaml +150 -135
- package/domains/development/prompt-examples.md +33 -119
- package/domains/product/.agents/workflows/product-pipeline-rules.md +13 -2
- package/domains/product/.agents/workflows/quick-pm.md +1 -1
- package/domains/product/.agents/workflows/shape-prioritize.md +1 -0
- package/domains/product/.agents/workflows/ship-right-thing.md +1 -0
- package/domains/product/.agents/workflows/spec.md +1 -0
- package/domains/product/agents/tech_lead.md +1 -1
- package/domains/product/locales/en/.agents/workflows/product-pipeline-rules.md +13 -2
- package/domains/product/locales/en/.agents/workflows/quick-pm.md +1 -1
- package/domains/product/locales/en/.agents/workflows/shape-prioritize.md +1 -0
- package/domains/product/locales/en/.agents/workflows/ship-right-thing.md +1 -0
- package/domains/product/locales/en/.agents/workflows/spec.md +1 -0
- package/domains/product/locales/en/agents/conductor.md +2 -2
- package/domains/product/locales/en/agents/data_analyst.md +2 -1
- package/domains/product/locales/en/agents/designer.md +2 -1
- package/domains/product/locales/en/agents/discovery.md +2 -1
- package/domains/product/locales/en/agents/layouter.md +2 -1
- package/domains/product/locales/en/agents/mediator.md +2 -1
- package/domains/product/locales/en/agents/pm.md +2 -1
- package/domains/product/locales/en/agents/product_strategist.md +2 -1
- package/domains/product/locales/en/agents/tech_lead.md +3 -2
- package/domains/product/locales/en/agents/ux_designer.md +2 -1
- package/domains/product/pipeline.yaml +12 -12
- package/package.json +5 -5
- package/domains/analytics/CONTEXT.md +0 -25
- package/domains/analytics/locales/en/CONTEXT.md +0 -25
- package/domains/content/CONTEXT.md +0 -19
- package/domains/content/locales/en/CONTEXT.md +0 -19
- package/domains/development/.agents/workflows/auto-restart-containers.md +0 -56
- package/domains/development/CONTEXT.md +0 -62
- package/domains/development/locales/en/.agents/workflows/auto-restart-containers.md +0 -24
- package/domains/development/locales/en/CONTEXT.md +0 -62
- package/domains/product/CONTEXT.md +0 -40
- package/domains/product/locales/en/CONTEXT.md +0 -40
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: lava-flow-legacy-detection
|
|
3
|
-
description: Checklist of "lava flow" signs in legacy/brownfield code — dead code surrounding live paths, unremoved feature flags, fossilized workarounds, duplicates left over from migrations. Use during current-state analysis of a repo, before refactoring, and when reviewing PRs in a mature codebase. Activate on mentions of "legacy", "technical debt", "brownfield", "why is this code here".
|
|
4
|
-
type: reference
|
|
5
|
-
domain: development
|
|
6
|
-
owners:
|
|
7
|
-
- architect
|
|
8
|
-
- reviewer
|
|
9
|
-
- senior_full_stack
|
|
10
|
-
gates:
|
|
11
|
-
- ARCH
|
|
12
|
-
- DEV
|
|
13
|
-
- REV
|
|
14
|
-
tech: []
|
|
15
|
-
topic:
|
|
16
|
-
- architecture
|
|
17
|
-
- refactoring
|
|
18
|
-
- legacy
|
|
19
|
-
triggers:
|
|
20
|
-
- legacy code
|
|
21
|
-
- dead code
|
|
22
|
-
- lava flow
|
|
23
|
-
- unremoved feature flag
|
|
24
|
-
- brownfield refactor
|
|
25
|
-
- fossilized workaround
|
|
26
|
-
- unused code
|
|
27
|
-
related:
|
|
28
|
-
- current-state-analysis
|
|
29
|
-
- architecture-compliance-review
|
|
30
|
-
- architecture-doc-reference
|
|
31
|
-
- design-patterns-reference
|
|
32
|
-
- adr-log
|
|
33
|
-
- adr-log-reference
|
|
34
|
-
- threat-model-baseline
|
|
35
|
-
- security-baseline-dev
|
|
36
|
-
- code-review-checklist
|
|
37
|
-
- system-design-checklist
|
|
38
|
-
budget_lines: 250
|
|
39
|
-
schema_version: 1
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
# Skill: Lava Flow Legacy Detection
|
|
44
|
-
|
|
45
|
-
The "lava flow" anti-pattern (Brown et al., *AntiPatterns*, 1998) — a hardened mass of code that flowed unchecked into production. Nobody remembers why it's there, deleting feels risky (no tests), rewriting is expensive. Every release thickens the layer.
|
|
46
|
-
|
|
47
|
-
> **When to apply:** ARCH (current-state analysis), DEV (before touching an old module), REV (PR review in a mature codebase). Reference skill — activation via frontmatter triggers; see § MCP integration below for cross-gate consumption.
|
|
48
|
-
|
|
49
|
-
**Sections:**
|
|
50
|
-
1. [Signs of lava flow](#1-signs)
|
|
51
|
-
2. [Detection checklist](#2-checklist)
|
|
52
|
-
3. [What to do with a finding](#3-what-to-do)
|
|
53
|
-
4. [What NOT to do](#4-pitfalls)
|
|
54
|
-
5. [Report template](#5-report)
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## 1. Signs
|
|
59
|
-
|
|
60
|
-
### 1.1 Structural
|
|
61
|
-
|
|
62
|
-
| # | Sign | How to detect |
|
|
63
|
-
|---|------|---------------|
|
|
64
|
-
| LF-01 | Commented-out blocks in production files | grep for `//` / `/*` blocks >5 lines |
|
|
65
|
-
| LF-02 | Code branches that never execute | coverage report shows 0% on the branch |
|
|
66
|
-
| LF-03 | Functions/classes with no inbound references | static analysis (ts-prune, knip, unimport) |
|
|
67
|
-
| LF-04 | Parallel "versions" of the same logic (v1/v2/legacy/new) | grep by name suffixes |
|
|
68
|
-
| LF-05 | Duplicates left over from unfinished migrations | diff `old/`, `legacy/`, `deprecated/` dirs |
|
|
69
|
-
| LF-06 | Files untouched longer than half the repo's age | `git log -1 --format=%cd -- <file>` or `find <dir> -name '*.ts' -mtime +<days>` |
|
|
70
|
-
|
|
71
|
-
### 1.2 Configurational
|
|
72
|
-
|
|
73
|
-
| # | Sign | How to detect |
|
|
74
|
-
|---|------|---------------|
|
|
75
|
-
| LF-07 | Feature flags permanently `false` (or permanently `true`) | grep `flag.*= false`, verify usage in code |
|
|
76
|
-
| LF-08 | Config keys nobody reads | grep key value across codebase |
|
|
77
|
-
| LF-09 | Env vars not present in `.env.example` | diff `process.env.X` against `.env.example` |
|
|
78
|
-
| LF-10 | Hardcoded mock/stub data in production paths | grep `MOCK_`, `STUB_`, `fake_`, `dummy_` |
|
|
79
|
-
|
|
80
|
-
### 1.3 Behavioural
|
|
81
|
-
|
|
82
|
-
| # | Sign | How to detect |
|
|
83
|
-
|---|------|---------------|
|
|
84
|
-
| LF-11 | Workarounds that became permanent | grep `TODO`, `FIXME`, `HACK`, `XXX` older than 6 mo |
|
|
85
|
-
| LF-12 | Hardcoded version/environment checks against a dead target | grep `if.*IE`, `if.*v1`, `if.*LEGACY` where the right side no longer exists |
|
|
86
|
-
| LF-13 | Inactive cron jobs / scheduled tasks | `crontab -l` + grep logs over past 3 mo; `systemctl list-timers --all`; `kubectl get cronjob -o wide` (lastScheduleTime) |
|
|
87
|
-
| LF-14 | Endpoints with no callers from frontend/other services | grep route paths across the monorepo |
|
|
88
|
-
| LF-15 | Router routes leading to 404s or empty components | unit test walks all routes |
|
|
89
|
-
|
|
90
|
-
### 1.4 Code examples
|
|
91
|
-
|
|
92
|
-
**Lava** — commented-out fallback to a removed system:
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
// Old auth flow before the Auth0 migration (2024)
|
|
96
|
-
// if (legacyAuth.enabled) {
|
|
97
|
-
// const session = await legacyAuth.login(creds);
|
|
98
|
-
// return mapLegacySession(session);
|
|
99
|
-
// }
|
|
100
|
-
const session = await auth0.login(creds);
|
|
101
|
-
```
|
|
102
|
-
> The `legacyAuth` module was removed 18 months ago. The comment is fossil; the history already lives in git. **Decision:** delete.
|
|
103
|
-
|
|
104
|
-
**Not lava** — comment explains the non-obvious (Chesterton's fence):
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
// +1 because Date.getMonth() returns 0-11.
|
|
108
|
-
// If someone "fixes" this to getMonth(), January reports will break.
|
|
109
|
-
const month = date.getMonth() + 1;
|
|
110
|
-
```
|
|
111
|
-
> The comment carries meaning and protects the code from a falsely-obvious "fix". **Decision:** keep.
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## 2. Checklist
|
|
116
|
-
|
|
117
|
-
Apply before refactoring a module or when first onboarding into a legacy repo.
|
|
118
|
-
|
|
119
|
-
- [ ] Run `ts-prune` / `knip` / equivalent → collect unreachable list
|
|
120
|
-
- [ ] Run coverage on the targeted files → flag 0%-branches
|
|
121
|
-
- [ ] `git log --since=24.months.ago -- <file>` → identify "fossilized" files
|
|
122
|
-
- [ ] Find all `TODO/FIXME/HACK` older than 6 months → decide: fix or delete
|
|
123
|
-
- [ ] Enumerate feature flags in the project → for each, check if the value ever changes
|
|
124
|
-
- [ ] Enumerate env vars → flag unused
|
|
125
|
-
- [ ] For each suspicious function — find all usages → if 0, mark for deletion
|
|
126
|
-
- [ ] Record findings in the report (template below) before any refactor
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## 3. What to do
|
|
131
|
-
|
|
132
|
-
**Principle:** removing lava flow is its own task — never part of a feature PR. **Before any deletion, `git blame` the block.** If the author is still on the team — ask for context (it routinely saves hours and prevents the deletion of something quietly important). If the author left or the code is older than ~24 months, `git blame` is just archaeology — proceed down the checklist.
|
|
133
|
-
|
|
134
|
-
1. **Report BEFORE changes.** List findings in a dedicated doc (`docs/reports/architect/lava-flow-<module>.md`). Do not delete without architect sign-off.
|
|
135
|
-
2. **Test coverage BEFORE deletion.** If the branch lacks tests — write characterization tests first (M. Feathers, *Working Effectively with Legacy Code*), then delete.
|
|
136
|
-
3. **Small PRs.** One PR = one finding. Don't "delete all of deprecated/". Atomicity gives a clean rollback point.
|
|
137
|
-
4. **Feature flag → delete the "off" side.** If a flag has been 100% in one position for more than a release, delete the opposing branch. **BUT:** if the flag has been toggled at least once in the last release window, it's live config, not lava; leave it alone (Chesterton's fence — someone is actively using it).
|
|
138
|
-
5. **ADR when in doubt.** If you can't tell why the code exists — open `$adr-log` with options "delete / keep / rewrite", escalate to Architect.
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## 4. Pitfalls
|
|
143
|
-
|
|
144
|
-
- ❌ **"While I'm in here, I'll clean this up"** — lava flow is never removed ad-hoc inside a feature PR. It pollutes the diff and breaks review.
|
|
145
|
-
- ❌ **Mass deletion without tests** — characterization tests are mandatory for uncovered branches.
|
|
146
|
-
- ❌ **Renaming instead of deleting** — `_old`, `_deprecated_v2` create a new lava layer.
|
|
147
|
-
- ❌ **A "we'll deal with it later" comment** — that's lava in seed form. Decide now: delete or ADR.
|
|
148
|
-
- ❌ **Keeping it "just in case"** — git history *is* the archive.
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## 5. Report
|
|
153
|
-
|
|
154
|
-
```markdown
|
|
155
|
-
# Lava Flow Report — <module-name>
|
|
156
|
-
|
|
157
|
-
**Date:** <YYYY-MM-DD>
|
|
158
|
-
**Author:** <agent>
|
|
159
|
-
**Context:** <why we looked — refactor / current-state / review>
|
|
160
|
-
|
|
161
|
-
## Findings
|
|
162
|
-
|
|
163
|
-
| # | ID | File:line | Sign | Decision |
|
|
164
|
-
|---|----|-----------|------|----------|
|
|
165
|
-
| 1 | LF-01 | src/foo.ts:120-180 | 60-line commented block | DELETE (PR #N) |
|
|
166
|
-
| 2 | LF-07 | src/config/flags.ts:42 | Flag `useNewAuth` = false for 8 mo | DELETE old branch (PR #N+1) |
|
|
167
|
-
| 3 | LF-04 | src/api/users-v1.ts | Duplicate of users-v2.ts, no callers | DELETE (ADR-DEV-XXX) |
|
|
168
|
-
|
|
169
|
-
## Escalations
|
|
170
|
-
- <cases that need Architect/
|
|
171
|
-
|
|
172
|
-
## Close-out plan
|
|
173
|
-
- <PR breakdown with order>
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
## Related skills
|
|
178
|
-
|
|
179
|
-
- `$current-state-analysis` — repo-wide audit; lava flow is one of its outputs
|
|
180
|
-
- `$architecture-compliance-review` — verify architecture compliance after deletion
|
|
181
|
-
- `$design-patterns-reference` — what to use INSTEAD of the removed lava
|
|
182
|
-
- `$code-review-checklist` — for reviewing the deletion PRs
|
|
183
|
-
- `$system-design-checklist` — so the new code doesn't become next year's lava
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## MCP integration (cross-gate activation)
|
|
188
|
-
|
|
189
|
-
Reference skill with cross-gate consumption:
|
|
190
|
-
|
|
191
|
-
- **ARCH (primary)** — `architect` uses it during current-state analysis before proposing refactoring
|
|
192
|
-
- **DEV (secondary)** — `senior_full_stack` consults before touching an old module
|
|
193
|
-
- **REV (secondary)** — `reviewer` applies during PR review in a mature codebase
|
|
194
|
-
|
|
195
|
-
Activation via frontmatter triggers (`legacy code`, `dead code`, `lava flow`, `unremoved feature flag`, `brownfield refactoring`, etc.). See `$mcp-integration` for general MCP flow, gate ritual and recording discipline.
|
|
196
|
-
|
|
197
|
-
Section IDs (`LF-01..LF-25`) are stable anchors: cite them inline in ARCH/REV artifacts instead of copying content. Keeps the audit trail compact and provides a backlink to the canonical source.
|
|
1
|
+
---
|
|
2
|
+
name: lava-flow-legacy-detection
|
|
3
|
+
description: Checklist of "lava flow" signs in legacy/brownfield code — dead code surrounding live paths, unremoved feature flags, fossilized workarounds, duplicates left over from migrations. Use during current-state analysis of a repo, before refactoring, and when reviewing PRs in a mature codebase. Activate on mentions of "legacy", "technical debt", "brownfield", "why is this code here".
|
|
4
|
+
type: reference
|
|
5
|
+
domain: development
|
|
6
|
+
owners:
|
|
7
|
+
- architect
|
|
8
|
+
- reviewer
|
|
9
|
+
- senior_full_stack
|
|
10
|
+
gates:
|
|
11
|
+
- ARCH
|
|
12
|
+
- DEV
|
|
13
|
+
- REV
|
|
14
|
+
tech: []
|
|
15
|
+
topic:
|
|
16
|
+
- architecture
|
|
17
|
+
- refactoring
|
|
18
|
+
- legacy
|
|
19
|
+
triggers:
|
|
20
|
+
- legacy code
|
|
21
|
+
- dead code
|
|
22
|
+
- lava flow
|
|
23
|
+
- unremoved feature flag
|
|
24
|
+
- brownfield refactor
|
|
25
|
+
- fossilized workaround
|
|
26
|
+
- unused code
|
|
27
|
+
related:
|
|
28
|
+
- current-state-analysis
|
|
29
|
+
- architecture-compliance-review
|
|
30
|
+
- architecture-doc-reference
|
|
31
|
+
- design-patterns-reference
|
|
32
|
+
- adr-log
|
|
33
|
+
- adr-log-reference
|
|
34
|
+
- threat-model-baseline
|
|
35
|
+
- security-baseline-dev
|
|
36
|
+
- code-review-checklist
|
|
37
|
+
- system-design-checklist
|
|
38
|
+
budget_lines: 250
|
|
39
|
+
schema_version: 1
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Skill: Lava Flow Legacy Detection
|
|
44
|
+
|
|
45
|
+
The "lava flow" anti-pattern (Brown et al., *AntiPatterns*, 1998) — a hardened mass of code that flowed unchecked into production. Nobody remembers why it's there, deleting feels risky (no tests), rewriting is expensive. Every release thickens the layer.
|
|
46
|
+
|
|
47
|
+
> **When to apply:** ARCH (current-state analysis), DEV (before touching an old module), REV (PR review in a mature codebase). Reference skill — activation via frontmatter triggers; see § MCP integration below for cross-gate consumption.
|
|
48
|
+
|
|
49
|
+
**Sections:**
|
|
50
|
+
1. [Signs of lava flow](#1-signs)
|
|
51
|
+
2. [Detection checklist](#2-checklist)
|
|
52
|
+
3. [What to do with a finding](#3-what-to-do)
|
|
53
|
+
4. [What NOT to do](#4-pitfalls)
|
|
54
|
+
5. [Report template](#5-report)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 1. Signs
|
|
59
|
+
|
|
60
|
+
### 1.1 Structural
|
|
61
|
+
|
|
62
|
+
| # | Sign | How to detect |
|
|
63
|
+
|---|------|---------------|
|
|
64
|
+
| LF-01 | Commented-out blocks in production files | grep for `//` / `/*` blocks >5 lines |
|
|
65
|
+
| LF-02 | Code branches that never execute | coverage report shows 0% on the branch |
|
|
66
|
+
| LF-03 | Functions/classes with no inbound references | static analysis (ts-prune, knip, unimport) |
|
|
67
|
+
| LF-04 | Parallel "versions" of the same logic (v1/v2/legacy/new) | grep by name suffixes |
|
|
68
|
+
| LF-05 | Duplicates left over from unfinished migrations | diff `old/`, `legacy/`, `deprecated/` dirs |
|
|
69
|
+
| LF-06 | Files untouched longer than half the repo's age | `git log -1 --format=%cd -- <file>` or `find <dir> -name '*.ts' -mtime +<days>` |
|
|
70
|
+
|
|
71
|
+
### 1.2 Configurational
|
|
72
|
+
|
|
73
|
+
| # | Sign | How to detect |
|
|
74
|
+
|---|------|---------------|
|
|
75
|
+
| LF-07 | Feature flags permanently `false` (or permanently `true`) | grep `flag.*= false`, verify usage in code |
|
|
76
|
+
| LF-08 | Config keys nobody reads | grep key value across codebase |
|
|
77
|
+
| LF-09 | Env vars not present in `.env.example` | diff `process.env.X` against `.env.example` |
|
|
78
|
+
| LF-10 | Hardcoded mock/stub data in production paths | grep `MOCK_`, `STUB_`, `fake_`, `dummy_` |
|
|
79
|
+
|
|
80
|
+
### 1.3 Behavioural
|
|
81
|
+
|
|
82
|
+
| # | Sign | How to detect |
|
|
83
|
+
|---|------|---------------|
|
|
84
|
+
| LF-11 | Workarounds that became permanent | grep `TODO`, `FIXME`, `HACK`, `XXX` older than 6 mo |
|
|
85
|
+
| LF-12 | Hardcoded version/environment checks against a dead target | grep `if.*IE`, `if.*v1`, `if.*LEGACY` where the right side no longer exists |
|
|
86
|
+
| LF-13 | Inactive cron jobs / scheduled tasks | `crontab -l` + grep logs over past 3 mo; `systemctl list-timers --all`; `kubectl get cronjob -o wide` (lastScheduleTime) |
|
|
87
|
+
| LF-14 | Endpoints with no callers from frontend/other services | grep route paths across the monorepo |
|
|
88
|
+
| LF-15 | Router routes leading to 404s or empty components | unit test walks all routes |
|
|
89
|
+
|
|
90
|
+
### 1.4 Code examples
|
|
91
|
+
|
|
92
|
+
**Lava** — commented-out fallback to a removed system:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
// Old auth flow before the Auth0 migration (2024)
|
|
96
|
+
// if (legacyAuth.enabled) {
|
|
97
|
+
// const session = await legacyAuth.login(creds);
|
|
98
|
+
// return mapLegacySession(session);
|
|
99
|
+
// }
|
|
100
|
+
const session = await auth0.login(creds);
|
|
101
|
+
```
|
|
102
|
+
> The `legacyAuth` module was removed 18 months ago. The comment is fossil; the history already lives in git. **Decision:** delete.
|
|
103
|
+
|
|
104
|
+
**Not lava** — comment explains the non-obvious (Chesterton's fence):
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
// +1 because Date.getMonth() returns 0-11.
|
|
108
|
+
// If someone "fixes" this to getMonth(), January reports will break.
|
|
109
|
+
const month = date.getMonth() + 1;
|
|
110
|
+
```
|
|
111
|
+
> The comment carries meaning and protects the code from a falsely-obvious "fix". **Decision:** keep.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 2. Checklist
|
|
116
|
+
|
|
117
|
+
Apply before refactoring a module or when first onboarding into a legacy repo.
|
|
118
|
+
|
|
119
|
+
- [ ] Run `ts-prune` / `knip` / equivalent → collect unreachable list
|
|
120
|
+
- [ ] Run coverage on the targeted files → flag 0%-branches
|
|
121
|
+
- [ ] `git log --since=24.months.ago -- <file>` → identify "fossilized" files
|
|
122
|
+
- [ ] Find all `TODO/FIXME/HACK` older than 6 months → decide: fix or delete
|
|
123
|
+
- [ ] Enumerate feature flags in the project → for each, check if the value ever changes
|
|
124
|
+
- [ ] Enumerate env vars → flag unused
|
|
125
|
+
- [ ] For each suspicious function — find all usages → if 0, mark for deletion
|
|
126
|
+
- [ ] Record findings in the report (template below) before any refactor
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 3. What to do
|
|
131
|
+
|
|
132
|
+
**Principle:** removing lava flow is its own task — never part of a feature PR. **Before any deletion, `git blame` the block.** If the author is still on the team — ask for context (it routinely saves hours and prevents the deletion of something quietly important). If the author left or the code is older than ~24 months, `git blame` is just archaeology — proceed down the checklist.
|
|
133
|
+
|
|
134
|
+
1. **Report BEFORE changes.** List findings in a dedicated doc (`docs/reports/architect/lava-flow-<module>.md`). Do not delete without architect sign-off.
|
|
135
|
+
2. **Test coverage BEFORE deletion.** If the branch lacks tests — write characterization tests first (M. Feathers, *Working Effectively with Legacy Code*), then delete.
|
|
136
|
+
3. **Small PRs.** One PR = one finding. Don't "delete all of deprecated/". Atomicity gives a clean rollback point.
|
|
137
|
+
4. **Feature flag → delete the "off" side.** If a flag has been 100% in one position for more than a release, delete the opposing branch. **BUT:** if the flag has been toggled at least once in the last release window, it's live config, not lava; leave it alone (Chesterton's fence — someone is actively using it).
|
|
138
|
+
5. **ADR when in doubt.** If you can't tell why the code exists — open `$adr-log` with options "delete / keep / rewrite", escalate to Architect.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 4. Pitfalls
|
|
143
|
+
|
|
144
|
+
- ❌ **"While I'm in here, I'll clean this up"** — lava flow is never removed ad-hoc inside a feature PR. It pollutes the diff and breaks review.
|
|
145
|
+
- ❌ **Mass deletion without tests** — characterization tests are mandatory for uncovered branches.
|
|
146
|
+
- ❌ **Renaming instead of deleting** — `_old`, `_deprecated_v2` create a new lava layer.
|
|
147
|
+
- ❌ **A "we'll deal with it later" comment** — that's lava in seed form. Decide now: delete or ADR.
|
|
148
|
+
- ❌ **Keeping it "just in case"** — git history *is* the archive.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 5. Report
|
|
153
|
+
|
|
154
|
+
```markdown
|
|
155
|
+
# Lava Flow Report — <module-name>
|
|
156
|
+
|
|
157
|
+
**Date:** <YYYY-MM-DD>
|
|
158
|
+
**Author:** <agent>
|
|
159
|
+
**Context:** <why we looked — refactor / current-state / review>
|
|
160
|
+
|
|
161
|
+
## Findings
|
|
162
|
+
|
|
163
|
+
| # | ID | File:line | Sign | Decision |
|
|
164
|
+
|---|----|-----------|------|----------|
|
|
165
|
+
| 1 | LF-01 | src/foo.ts:120-180 | 60-line commented block | DELETE (PR #N) |
|
|
166
|
+
| 2 | LF-07 | src/config/flags.ts:42 | Flag `useNewAuth` = false for 8 mo | DELETE old branch (PR #N+1) |
|
|
167
|
+
| 3 | LF-04 | src/api/users-v1.ts | Duplicate of users-v2.ts, no callers | DELETE (ADR-DEV-XXX) |
|
|
168
|
+
|
|
169
|
+
## Escalations
|
|
170
|
+
- <cases that need Architect/user sign-off>
|
|
171
|
+
|
|
172
|
+
## Close-out plan
|
|
173
|
+
- <PR breakdown with order>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
## Related skills
|
|
178
|
+
|
|
179
|
+
- `$current-state-analysis` — repo-wide audit; lava flow is one of its outputs
|
|
180
|
+
- `$architecture-compliance-review` — verify architecture compliance after deletion
|
|
181
|
+
- `$design-patterns-reference` — what to use INSTEAD of the removed lava
|
|
182
|
+
- `$code-review-checklist` — for reviewing the deletion PRs
|
|
183
|
+
- `$system-design-checklist` — so the new code doesn't become next year's lava
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## MCP integration (cross-gate activation)
|
|
188
|
+
|
|
189
|
+
Reference skill with cross-gate consumption:
|
|
190
|
+
|
|
191
|
+
- **ARCH (primary)** — `architect` uses it during current-state analysis before proposing refactoring
|
|
192
|
+
- **DEV (secondary)** — `senior_full_stack` consults before touching an old module
|
|
193
|
+
- **REV (secondary)** — `reviewer` applies during PR review in a mature codebase
|
|
194
|
+
|
|
195
|
+
Activation via frontmatter triggers (`legacy code`, `dead code`, `lava flow`, `unremoved feature flag`, `brownfield refactoring`, etc.). See `$mcp-integration` for general MCP flow, gate ritual and recording discipline.
|
|
196
|
+
|
|
197
|
+
Section IDs (`LF-01..LF-25`) are stable anchors: cite them inline in ARCH/REV artifacts instead of copying content. Keeps the audit trail compact and provides a backlink to the canonical source.
|