mindsystem-cc 3.22.0 → 3.22.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.
- package/agents/ms-debugger.md +196 -880
- package/commands/ms/debug.md +24 -24
- package/mindsystem/workflows/diagnose-issues.md +0 -1
- package/package.json +1 -1
- package/skills/senior-review/AGENTS.md +531 -0
- package/skills/senior-review/SKILL.md +216 -0
- package/skills/senior-review/principles/dependencies-api-boundary-design.md +32 -0
- package/skills/senior-review/principles/dependencies-data-not-flags.md +32 -0
- package/skills/senior-review/principles/dependencies-temporal-coupling.md +32 -0
- package/skills/senior-review/principles/pragmatism-consistent-error-handling.md +32 -0
- package/skills/senior-review/principles/pragmatism-speculative-generality.md +32 -0
- package/skills/senior-review/principles/state-invalid-states.md +33 -0
- package/skills/senior-review/principles/state-single-source-of-truth.md +32 -0
- package/skills/senior-review/principles/state-type-hierarchies.md +32 -0
- package/skills/senior-review/principles/structure-composition-over-config.md +32 -0
- package/skills/senior-review/principles/structure-feature-isolation.md +32 -0
- package/skills/senior-review/principles/structure-module-cohesion.md +32 -0
- package/mindsystem/references/debugging/debugging-mindset.md +0 -11
- package/mindsystem/references/debugging/hypothesis-testing.md +0 -11
- package/mindsystem/references/debugging/investigation-techniques.md +0 -11
- package/mindsystem/references/debugging/verification-patterns.md +0 -11
- package/mindsystem/references/debugging/when-to-research.md +0 -11
- package/mindsystem/references/git-integration.md +0 -254
- package/mindsystem/references/verification-patterns.md +0 -558
- package/mindsystem/workflows/debug.md +0 -14
package/commands/ms/debug.md
CHANGED
|
@@ -10,11 +10,7 @@ allowed-tools:
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
<objective>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
**Orchestrator role:** Gather symptoms, spawn ms-debugger agent, handle checkpoints, spawn continuations.
|
|
16
|
-
|
|
17
|
-
**Why subagent:** Investigation burns context fast (reading files, forming hypotheses, testing). Fresh 200k context per investigation. Main context stays lean for user interaction.
|
|
13
|
+
Gather symptoms from user, spawn ms-debugger agent, handle returns and checkpoints.
|
|
18
14
|
</objective>
|
|
19
15
|
|
|
20
16
|
<context>
|
|
@@ -31,27 +27,28 @@ ls .planning/debug/*.md 2>/dev/null | grep -v resolved | head -5
|
|
|
31
27
|
## 1. Check Active Sessions
|
|
32
28
|
|
|
33
29
|
If active sessions exist AND no $ARGUMENTS:
|
|
34
|
-
-
|
|
30
|
+
- Read each debug file's frontmatter (status, hypothesis from Current Focus, next_action)
|
|
31
|
+
- Display as numbered list: `{N}. {slug} — status: {status}, focus: {hypothesis}`
|
|
35
32
|
- User picks number to resume OR describes new issue
|
|
36
33
|
|
|
37
34
|
If $ARGUMENTS provided OR user describes new issue:
|
|
38
35
|
- Continue to symptom gathering
|
|
39
36
|
|
|
40
|
-
## 2. Gather Symptoms
|
|
37
|
+
## 2. Gather Symptoms
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
Extract what you can from $ARGUMENTS first. Only use AskUserQuestion for missing categories:
|
|
43
40
|
|
|
44
41
|
1. **Expected behavior** - What should happen?
|
|
45
42
|
2. **Actual behavior** - What happens instead?
|
|
46
|
-
3. **Error messages** - Any errors?
|
|
43
|
+
3. **Error messages** - Any errors?
|
|
47
44
|
4. **Timeline** - When did this start? Ever worked?
|
|
48
|
-
5. **Reproduction** - How
|
|
45
|
+
5. **Reproduction** - How to trigger it?
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
If the user's description covers most categories, proceed directly.
|
|
51
48
|
|
|
52
49
|
## 3. Spawn ms-debugger Agent
|
|
53
50
|
|
|
54
|
-
Fill prompt and spawn:
|
|
51
|
+
Fill prompt template and spawn:
|
|
55
52
|
|
|
56
53
|
```markdown
|
|
57
54
|
<objective>
|
|
@@ -88,12 +85,16 @@ Task(
|
|
|
88
85
|
|
|
89
86
|
## 4. Handle Agent Return
|
|
90
87
|
|
|
91
|
-
**If `##
|
|
88
|
+
**If `## DEBUG COMPLETE`:**
|
|
89
|
+
- Display root cause, fix applied, and verification summary
|
|
90
|
+
- Done — the agent already committed the fix
|
|
91
|
+
|
|
92
|
+
**If `## ROOT CAUSE FOUND`** (from `find_root_cause_only` mode):
|
|
92
93
|
- Display root cause and evidence summary
|
|
93
94
|
- Offer options:
|
|
94
|
-
- "Fix now"
|
|
95
|
-
- "Plan fix"
|
|
96
|
-
- "
|
|
95
|
+
- "Fix now" — spawn ms-debugger with `goal: find_and_fix` and the debug file
|
|
96
|
+
- "Plan fix" — suggest /ms:plan-phase --gaps
|
|
97
|
+
- "Done" — leave the diagnosis
|
|
97
98
|
|
|
98
99
|
**If `## CHECKPOINT REACHED`:**
|
|
99
100
|
- Present checkpoint details to user
|
|
@@ -103,9 +104,9 @@ Task(
|
|
|
103
104
|
**If `## INVESTIGATION INCONCLUSIVE`:**
|
|
104
105
|
- Show what was checked and eliminated
|
|
105
106
|
- Offer options:
|
|
106
|
-
- "Continue investigating"
|
|
107
|
-
- "
|
|
108
|
-
- "
|
|
107
|
+
- "Continue investigating" — spawn new agent with additional context
|
|
108
|
+
- "Add more context" — gather more symptoms, spawn again
|
|
109
|
+
- "Done" — stop investigation
|
|
109
110
|
|
|
110
111
|
## 5. Spawn Continuation Agent (After Checkpoint)
|
|
111
112
|
|
|
@@ -147,9 +148,8 @@ ms-tools set-last-command "ms:debug $ARGUMENTS"
|
|
|
147
148
|
</process>
|
|
148
149
|
|
|
149
150
|
<success_criteria>
|
|
150
|
-
- [ ]
|
|
151
|
-
- [ ] Symptoms
|
|
152
|
-
- [ ]
|
|
153
|
-
- [ ]
|
|
154
|
-
- [ ] Root cause confirmed before fixing
|
|
151
|
+
- [ ] All 4 return types handled (DEBUG COMPLETE, ROOT CAUSE FOUND, CHECKPOINT, INCONCLUSIVE)
|
|
152
|
+
- [ ] Symptoms extracted from $ARGUMENTS first — only ask for gaps
|
|
153
|
+
- [ ] Continuation agent spawned after checkpoint response
|
|
154
|
+
- [ ] Last command updated after completion
|
|
155
155
|
</success_criteria>
|
package/package.json
CHANGED
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
# Senior Review
|
|
2
|
+
|
|
3
|
+
**Version 1.0.0**
|
|
4
|
+
Roland Tolnay
|
|
5
|
+
February 2026
|
|
6
|
+
|
|
7
|
+
> This document is optimized for AI agents and LLMs. Principles are organized by category and prioritized by structural impact. No code examples — detection signals and reasoning only.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Abstract
|
|
12
|
+
|
|
13
|
+
Tech-agnostic code review framework focused on structural improvements that typical reviews miss. Uses 3 core lenses (State Modeling, Responsibility Boundaries, Abstraction Timing) backed by 11 detailed principles organized into 4 categories. Each principle includes detection signals, evolution impact reasoning, and self-review questions. Optimized for web/fullstack (Next.js, React, Node) but applicable to any language or stack.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Table of Contents
|
|
18
|
+
|
|
19
|
+
1. [Core Lenses](#1-core-lenses)
|
|
20
|
+
- 1.1 [State Modeling](#11-state-modeling)
|
|
21
|
+
- 1.2 [Responsibility Boundaries](#12-responsibility-boundaries)
|
|
22
|
+
- 1.3 [Abstraction Timing](#13-abstraction-timing)
|
|
23
|
+
|
|
24
|
+
2. [State & Type Safety](#2-state--type-safety) - **CRITICAL**
|
|
25
|
+
- 2.1 [Make Invalid States Unrepresentable](#21-make-invalid-states-unrepresentable)
|
|
26
|
+
- 2.2 [Explicit Type Hierarchies](#22-explicit-type-hierarchies)
|
|
27
|
+
- 2.3 [Single Source of Truth](#23-single-source-of-truth)
|
|
28
|
+
|
|
29
|
+
3. [Structure & Composition](#3-structure--composition) - **HIGH**
|
|
30
|
+
- 3.1 [Isolate Feature Responsibility](#31-isolate-feature-responsibility)
|
|
31
|
+
- 3.2 [Composition Over Configuration](#32-composition-over-configuration)
|
|
32
|
+
- 3.3 [Module Cohesion](#33-module-cohesion)
|
|
33
|
+
|
|
34
|
+
4. [Dependencies & Flow](#4-dependencies--flow) - **MEDIUM-HIGH**
|
|
35
|
+
- 4.1 [Data Objects Over Flag Parades](#41-data-objects-over-flag-parades)
|
|
36
|
+
- 4.2 [Temporal Coupling](#42-temporal-coupling)
|
|
37
|
+
- 4.3 [API Boundary Design](#43-api-boundary-design)
|
|
38
|
+
|
|
39
|
+
5. [Pragmatism](#5-pragmatism) - **MEDIUM**
|
|
40
|
+
- 5.1 [Speculative Generality](#51-speculative-generality)
|
|
41
|
+
- 5.2 [Consistent Error Handling](#52-consistent-error-handling)
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Senior Mindset
|
|
46
|
+
|
|
47
|
+
Junior and mid-level engineers ask: **"Does this code work?"**
|
|
48
|
+
Senior engineers ask: **"How will this code change? What happens when requirements shift?"**
|
|
49
|
+
|
|
50
|
+
This distinction drives everything. Code that "works" today becomes a liability when:
|
|
51
|
+
- A new state is added and 5 files need coordinated updates
|
|
52
|
+
- A feature toggle requires touching code scattered across the codebase
|
|
53
|
+
- A bug fix in one place breaks assumptions elsewhere
|
|
54
|
+
|
|
55
|
+
Focus on **structural issues that compound over time** - the kind that turn "add a simple feature" into "refactor half the codebase first."
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 1. Core Lenses
|
|
60
|
+
|
|
61
|
+
Apply these three lenses to every review. They catch 80% of structural issues.
|
|
62
|
+
|
|
63
|
+
### 1.1 State Modeling
|
|
64
|
+
|
|
65
|
+
**Question:** Can this code represent invalid states?
|
|
66
|
+
|
|
67
|
+
Look for:
|
|
68
|
+
- Multiple boolean flags (2^n possible states, many invalid)
|
|
69
|
+
- Primitive obsession (stringly-typed status, magic numbers)
|
|
70
|
+
- Same decision logic repeated in multiple places
|
|
71
|
+
|
|
72
|
+
**Senior pattern:** Discriminated unions/enums where each variant is a valid state. Factory functions that encapsulate decision logic. Compiler-enforced exhaustive handling.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### 1.2 Responsibility Boundaries
|
|
77
|
+
|
|
78
|
+
**Question:** If I remove/modify feature X, how many files change?
|
|
79
|
+
|
|
80
|
+
Look for:
|
|
81
|
+
- Optional feature logic scattered throughout a parent component
|
|
82
|
+
- Components/modules with 6+ parameters (doing too much)
|
|
83
|
+
- Deep callback chains passing flags through layers
|
|
84
|
+
|
|
85
|
+
**Senior pattern:** Wrapper/decorator components for optional features. Typed data objects instead of flag parades. Each module has one job.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### 1.3 Abstraction Timing
|
|
90
|
+
|
|
91
|
+
**Question:** Is this abstraction earned or speculative?
|
|
92
|
+
|
|
93
|
+
Look for:
|
|
94
|
+
- Interfaces with only one implementation
|
|
95
|
+
- Factories that create only one type
|
|
96
|
+
- "Flexible" config that's never varied
|
|
97
|
+
- BUT ALSO: Duplicated code that should be unified
|
|
98
|
+
|
|
99
|
+
**Senior pattern:** Abstract when you have 2-3 concrete cases, not before. Extract when duplication causes bugs or drift, not for aesthetics.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 2. State & Type Safety
|
|
104
|
+
|
|
105
|
+
**Impact: CRITICAL**
|
|
106
|
+
|
|
107
|
+
Issues with state modeling compound rapidly. Invalid state combinations cause bugs that are hard to reproduce and fix.
|
|
108
|
+
|
|
109
|
+
### 2.1 Make Invalid States Unrepresentable
|
|
110
|
+
|
|
111
|
+
**Impact: CRITICAL (Eliminates entire class of bugs)**
|
|
112
|
+
|
|
113
|
+
Multiple boolean flags that create 2^n possible states, where many combinations are invalid or nonsensical.
|
|
114
|
+
|
|
115
|
+
**Detection signals:**
|
|
116
|
+
- 3+ boolean parameters passed together
|
|
117
|
+
- Same boolean checks repeated in multiple places
|
|
118
|
+
- if/else chains checking flag combinations
|
|
119
|
+
- Some flag combinations would cause undefined behavior
|
|
120
|
+
- State represented as string literals compared with `===`
|
|
121
|
+
|
|
122
|
+
**Why it matters:**
|
|
123
|
+
- Compiler/type checker enforces exhaustive handling of all states
|
|
124
|
+
- New states are added explicitly, not as boolean combinations
|
|
125
|
+
- Impossible to create invalid state combinations at the type level
|
|
126
|
+
- Self-documenting: the union/enum shows all possible states in one place
|
|
127
|
+
|
|
128
|
+
**Senior pattern:** Define a discriminated union (TypeScript), enum with associated data (Rust/Swift), or sealed interface (Kotlin/Java) where each variant carries only the data relevant to that state. Use exhaustive pattern matching (switch/match) so the compiler flags unhandled cases when a new variant is added.
|
|
129
|
+
|
|
130
|
+
**Detection questions:**
|
|
131
|
+
- Are there 3+ boolean parameters being passed together?
|
|
132
|
+
- Do you see the same boolean checks repeated in multiple places?
|
|
133
|
+
- Are there if/else chains checking combinations of flags?
|
|
134
|
+
- Could some flag combinations cause undefined behavior?
|
|
135
|
+
- Would adding a new state require updating multiple scattered conditionals?
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### 2.2 Explicit Type Hierarchies
|
|
140
|
+
|
|
141
|
+
**Impact: HIGH (Centralizes decision logic)**
|
|
142
|
+
|
|
143
|
+
Complex if/else chains determining behavior scattered across components rather than encoded in the type system.
|
|
144
|
+
|
|
145
|
+
**Detection signals:**
|
|
146
|
+
- Complex if/else chains determining which component to render or which path to take
|
|
147
|
+
- Same decision logic duplicated across multiple modules
|
|
148
|
+
- Components receive data they only use to make decisions (not to display or process)
|
|
149
|
+
- New requirement would add another boolean parameter
|
|
150
|
+
- Switch statements on string values or numeric codes
|
|
151
|
+
|
|
152
|
+
**Why it matters:**
|
|
153
|
+
- Decision logic lives in one place (the factory)
|
|
154
|
+
- Consumers receive pre-computed decisions, not raw data to interpret
|
|
155
|
+
- Adding new variants is explicit and type-checked
|
|
156
|
+
- Testing is clearer: test the factory, then test each variant's behavior
|
|
157
|
+
|
|
158
|
+
**Senior pattern:** Create a factory function or static method that takes raw inputs and returns a typed variant. The factory is the single place where decision logic lives. Consumers pattern-match on the result and handle each variant — they never inspect raw data to make decisions themselves.
|
|
159
|
+
|
|
160
|
+
**Detection questions:**
|
|
161
|
+
- Are there complex if/else chains determining behavior scattered across components?
|
|
162
|
+
- Is the same decision logic duplicated in multiple places?
|
|
163
|
+
- Do components receive data they only use to decide what to do?
|
|
164
|
+
- Would a new requirement add another boolean parameter to existing interfaces?
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### 2.3 Single Source of Truth
|
|
169
|
+
|
|
170
|
+
**Impact: HIGH (Prevents stale data bugs)**
|
|
171
|
+
|
|
172
|
+
Same state tracked in multiple places — local component state duplicating global state, components caching derived values.
|
|
173
|
+
|
|
174
|
+
**Detection signals:**
|
|
175
|
+
- Same data stored in both global state and local component state
|
|
176
|
+
- Effect hooks syncing local state from global state
|
|
177
|
+
- Two sources of truth that could disagree
|
|
178
|
+
- Derived data being cached in state instead of computed on access
|
|
179
|
+
- Manual synchronization logic between stores or contexts
|
|
180
|
+
|
|
181
|
+
**Why it matters:**
|
|
182
|
+
- No "which value is authoritative?" confusion
|
|
183
|
+
- State updates propagate automatically through derivations
|
|
184
|
+
- Easier debugging: one place to inspect each piece of state
|
|
185
|
+
- Eliminates stale data bugs caused by desynchronized copies
|
|
186
|
+
|
|
187
|
+
**Senior pattern:** Identify the single authoritative owner for each piece of state. All other consumers read from that owner or derive values from it. Local component state is reserved for truly ephemeral UI concerns (focus, hover, animation progress) that no other component needs. If two components need the same state, lift it to a shared owner rather than syncing copies.
|
|
188
|
+
|
|
189
|
+
**Detection questions:**
|
|
190
|
+
- Is the same data stored in both a global store and local component state?
|
|
191
|
+
- Are there effect hooks whose sole purpose is syncing one state source to another?
|
|
192
|
+
- Could two sources of truth disagree? What happens when they do?
|
|
193
|
+
- Is derived data being cached in state instead of computed from the source?
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 3. Structure & Composition
|
|
198
|
+
|
|
199
|
+
**Impact: HIGH**
|
|
200
|
+
|
|
201
|
+
Structural issues make features hard to add, remove, or modify independently.
|
|
202
|
+
|
|
203
|
+
### 3.1 Isolate Feature Responsibility
|
|
204
|
+
|
|
205
|
+
**Impact: HIGH (Features become removable)**
|
|
206
|
+
|
|
207
|
+
A feature's logic is woven throughout a parent component rather than encapsulated.
|
|
208
|
+
|
|
209
|
+
**Detection signals:**
|
|
210
|
+
- More than 30% of a component's code dedicated to one optional feature
|
|
211
|
+
- Removing a feature requires deleting scattered lines throughout the file
|
|
212
|
+
- Multiple `if (featureEnabled)` checks spread across the component
|
|
213
|
+
- State variables only used by one feature mixed with core state
|
|
214
|
+
- Feature-specific imports polluting the core module
|
|
215
|
+
|
|
216
|
+
**Why it matters:**
|
|
217
|
+
- Feature can be disabled/removed by removing one wrapper
|
|
218
|
+
- Core component remains focused and testable
|
|
219
|
+
- Feature logic is cohesive and isolated in one place
|
|
220
|
+
- Multiple features compose without polluting each other
|
|
221
|
+
|
|
222
|
+
**Senior pattern:** Move all feature-specific state, effects, and rendering into a wrapper/decorator component that wraps the core. The wrapper provides feature context to the core through a render prop, slot, or composition pattern. The core component has zero awareness of the feature — it renders its own concern and accepts optional enhancement points.
|
|
223
|
+
|
|
224
|
+
**Detection questions:**
|
|
225
|
+
- Is more than 30% of a component's code dedicated to one optional feature?
|
|
226
|
+
- Would removing a feature require deleting scattered lines throughout the file?
|
|
227
|
+
- Are there multiple `if (featureEnabled)` checks spread across the component?
|
|
228
|
+
- Does the component have state variables only used by one feature?
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
### 3.2 Composition Over Configuration
|
|
233
|
+
|
|
234
|
+
**Impact: MEDIUM (Simplifies component APIs)**
|
|
235
|
+
|
|
236
|
+
Giant components with dozens of boolean flags — "god components" that handle every case through configuration.
|
|
237
|
+
|
|
238
|
+
**Detection signals:**
|
|
239
|
+
- Component has more than 6-8 parameters/props
|
|
240
|
+
- Boolean parameters that are mutually exclusive
|
|
241
|
+
- Component is really 3 different components pretending to be 1
|
|
242
|
+
- Adding a new variant would require another boolean flag
|
|
243
|
+
- Conditionals inside the component that render entirely different structures
|
|
244
|
+
|
|
245
|
+
**Why it matters:**
|
|
246
|
+
- Each component has one job and is easy to understand
|
|
247
|
+
- New variants don't bloat existing components
|
|
248
|
+
- Easier to test: focused inputs and outputs
|
|
249
|
+
- Flexible: compose for custom needs, use shortcuts for common ones
|
|
250
|
+
|
|
251
|
+
**Senior pattern:** Split the god component into focused units, each handling one variant or concern. Provide composition points (children/slots/render props) for flexibility. For common combinations, offer convenience wrappers that compose the focused units — but the building blocks remain available for custom needs.
|
|
252
|
+
|
|
253
|
+
**Detection questions:**
|
|
254
|
+
- Does this component have more than 6-8 parameters?
|
|
255
|
+
- Are there boolean parameters that are mutually exclusive?
|
|
256
|
+
- Is this component really multiple components pretending to be one?
|
|
257
|
+
- Would adding a new variant require another boolean flag?
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
### 3.3 Module Cohesion
|
|
262
|
+
|
|
263
|
+
**Impact: MEDIUM-HIGH (Changes stay contained to one module)**
|
|
264
|
+
|
|
265
|
+
Related logic spread across modules by technical layer rather than grouped by feature/domain.
|
|
266
|
+
|
|
267
|
+
**Detection signals:**
|
|
268
|
+
- A feature's logic is spread across 4+ directories by technical layer (routes/, models/, services/, utils/)
|
|
269
|
+
- Changing one feature requires touching files in many unrelated folders
|
|
270
|
+
- Related types, helpers, and constants live far from the code that uses them
|
|
271
|
+
- Shared utility files that grow unbounded because "everything needs it"
|
|
272
|
+
- Circular dependencies between modules
|
|
273
|
+
|
|
274
|
+
**Why it matters:**
|
|
275
|
+
- Feature changes are contained: one module to understand, one module to test
|
|
276
|
+
- Dependencies between modules are explicit and minimal
|
|
277
|
+
- Easier to extract, replace, or delete a feature entirely
|
|
278
|
+
- New developers can navigate by feature, not by guessing which technical layer holds what
|
|
279
|
+
|
|
280
|
+
**Senior pattern:** Organize by feature/domain first, technical layer second. Each feature module contains its types, logic, and tests colocated. Shared utilities exist only when genuinely used across 3+ features — otherwise the "utility" belongs in the feature that uses it. Module boundaries are enforced by explicit public APIs (barrel files, index exports) that hide internal structure.
|
|
281
|
+
|
|
282
|
+
**Detection questions:**
|
|
283
|
+
- Does changing one feature require touching files in many unrelated directories?
|
|
284
|
+
- Is related logic (types, helpers, constants) colocated with the code that uses it?
|
|
285
|
+
- Are there shared utility files that grow unbounded?
|
|
286
|
+
- Can you describe what each module "owns" in one sentence?
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## 4. Dependencies & Flow
|
|
291
|
+
|
|
292
|
+
**Impact: MEDIUM-HIGH**
|
|
293
|
+
|
|
294
|
+
Coupling and dependency issues make code changes ripple unexpectedly.
|
|
295
|
+
|
|
296
|
+
### 4.1 Data Objects Over Flag Parades
|
|
297
|
+
|
|
298
|
+
**Impact: MEDIUM-HIGH (Stabilizes APIs between layers)**
|
|
299
|
+
|
|
300
|
+
Parent components/callers pass many flags and control parameters to children, creating tight coupling.
|
|
301
|
+
|
|
302
|
+
**Detection signals:**
|
|
303
|
+
- Functions/components have 4+ boolean or primitive parameters beyond core data
|
|
304
|
+
- Boolean flags being passed through multiple layers unchanged
|
|
305
|
+
- Changing a child's behavior requires changing every intermediate caller's signature
|
|
306
|
+
- Parameters that are only used in some conditions
|
|
307
|
+
- Same group of parameters appears in multiple function signatures
|
|
308
|
+
|
|
309
|
+
**Why it matters:**
|
|
310
|
+
- Consumer's API is stable even as internal requirements change
|
|
311
|
+
- Callers don't need to know the consumer's internal decision logic
|
|
312
|
+
- Data dependencies are explicit in the object's type
|
|
313
|
+
- Easier to test: create data objects directly without reconstructing call chains
|
|
314
|
+
|
|
315
|
+
**Senior pattern:** Group related parameters into a typed data object (interface, type, struct, record). The object carries everything the consumer needs to make its own decisions. The caller constructs the object from available context — if construction is complex, use a factory. The consumer's public API accepts the data object, not individual flags.
|
|
316
|
+
|
|
317
|
+
**Detection questions:**
|
|
318
|
+
- Are there 4+ boolean/primitive parameters being passed alongside core data?
|
|
319
|
+
- Are flags being threaded through multiple layers without being used in intermediate ones?
|
|
320
|
+
- Would changing a child's behavior require updating every caller's signature?
|
|
321
|
+
- Do the same parameter groups appear in multiple function signatures?
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### 4.2 Temporal Coupling
|
|
326
|
+
|
|
327
|
+
**Impact: MEDIUM (Catches misuse at compile time)**
|
|
328
|
+
|
|
329
|
+
Operations must happen in a specific order, but nothing enforces that order.
|
|
330
|
+
|
|
331
|
+
**Detection signals:**
|
|
332
|
+
- Methods that must be called before others
|
|
333
|
+
- Comments like "must call X first" or "call after Y"
|
|
334
|
+
- Objects can be in an "invalid" state between operations
|
|
335
|
+
- Tests have setup steps that could be forgotten
|
|
336
|
+
- Init/setup methods that must run before the object is usable
|
|
337
|
+
|
|
338
|
+
**Why it matters:**
|
|
339
|
+
- Compiler catches misuse, not runtime errors
|
|
340
|
+
- Self-documenting: types show valid sequences
|
|
341
|
+
- Impossible to forget required steps
|
|
342
|
+
- Easier onboarding: the API guides you through the correct order
|
|
343
|
+
|
|
344
|
+
**Senior pattern:** Use the builder pattern (fluent API that accumulates required state before producing the final object) or the type-state pattern (each step returns a different type that only exposes the next valid operation). For simpler cases, require all necessary data in the constructor so an object is always valid from creation.
|
|
345
|
+
|
|
346
|
+
**Detection questions:**
|
|
347
|
+
- Are there methods that must be called before others?
|
|
348
|
+
- Are there comments like "must call X first" or "call after Y"?
|
|
349
|
+
- Can objects be in an "invalid" state between operations?
|
|
350
|
+
- Do tests have setup steps that could be forgotten?
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
### 4.3 API Boundary Design
|
|
355
|
+
|
|
356
|
+
**Impact: HIGH (Prevents invalid data from propagating)**
|
|
357
|
+
|
|
358
|
+
Loose API contracts where unvalidated data flows deep into the system before failing.
|
|
359
|
+
|
|
360
|
+
**Detection signals:**
|
|
361
|
+
- API handlers that accept `any` or untyped request bodies
|
|
362
|
+
- Validation logic scattered across business logic instead of at the boundary
|
|
363
|
+
- No shared type between client and server for the same endpoint
|
|
364
|
+
- Error responses that leak internal details (stack traces, database errors)
|
|
365
|
+
- Different endpoints handling the same entity with inconsistent field names
|
|
366
|
+
|
|
367
|
+
**Why it matters:**
|
|
368
|
+
- Invalid data is caught at the boundary before it reaches business logic
|
|
369
|
+
- Internal code operates on validated, typed data — no defensive checks everywhere
|
|
370
|
+
- Client and server stay in sync through shared types or generated contracts
|
|
371
|
+
- Error responses are consistent and safe for consumers
|
|
372
|
+
|
|
373
|
+
**Senior pattern:** Validate and parse at the boundary: incoming data is unknown until validated, then flows as typed objects through internal layers. Define request/response types explicitly (schema validation, codegen, or shared type packages). Internal functions receive validated types and trust them — they don't re-validate. Error responses follow a consistent shape with safe, user-facing messages.
|
|
374
|
+
|
|
375
|
+
**Detection questions:**
|
|
376
|
+
- Do API handlers accept untyped or `any` request bodies?
|
|
377
|
+
- Is validation scattered across business logic instead of concentrated at boundaries?
|
|
378
|
+
- Is there a shared type contract between client and server?
|
|
379
|
+
- Do error responses leak internal details like stack traces?
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 5. Pragmatism
|
|
384
|
+
|
|
385
|
+
**Impact: MEDIUM**
|
|
386
|
+
|
|
387
|
+
Over-engineering and inconsistency create unnecessary complexity.
|
|
388
|
+
|
|
389
|
+
### 5.1 Speculative Generality
|
|
390
|
+
|
|
391
|
+
**Impact: MEDIUM (Reduces unnecessary complexity)**
|
|
392
|
+
|
|
393
|
+
Abstractions added for hypothetical future needs that may never materialize.
|
|
394
|
+
|
|
395
|
+
**Detection signals:**
|
|
396
|
+
- Interface with only one implementation
|
|
397
|
+
- Factory that only creates one type
|
|
398
|
+
- Configuration options no one uses
|
|
399
|
+
- Abstraction added "in case we need it later"
|
|
400
|
+
- Generic type parameters that are always the same concrete type
|
|
401
|
+
|
|
402
|
+
**Why it matters:**
|
|
403
|
+
- Less code to maintain and less indirection to trace
|
|
404
|
+
- Abstractions based on real needs fit better than guesses
|
|
405
|
+
- Easier to understand: concrete code is simpler than abstract code
|
|
406
|
+
- When you do need the abstraction, you'll know the right shape because you have concrete examples
|
|
407
|
+
|
|
408
|
+
**Senior pattern:** Write concrete code for the first case. When the second or third case appears, you'll see the real variation axis and can extract the right abstraction. The refactoring from concrete to abstract is straightforward — but the reverse (removing a premature abstraction) is painful because code depends on the abstraction's shape.
|
|
409
|
+
|
|
410
|
+
**Detection questions:**
|
|
411
|
+
- Is there an interface with only one implementation?
|
|
412
|
+
- Is there a factory that only creates one type?
|
|
413
|
+
- Are there configuration options no one uses?
|
|
414
|
+
- Was this abstraction added "in case we need it later"?
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
### 5.2 Consistent Error Handling
|
|
419
|
+
|
|
420
|
+
**Impact: MEDIUM (Improves UX and debugging)**
|
|
421
|
+
|
|
422
|
+
Ad-hoc try/catch scattered across the codebase, inconsistent error UX.
|
|
423
|
+
|
|
424
|
+
**Detection signals:**
|
|
425
|
+
- Errors appear differently across screens (toasts vs dialogs vs inline vs nothing)
|
|
426
|
+
- try/catch blocks scattered in component/handler code with different recovery strategies
|
|
427
|
+
- Inconsistent error messaging (raw exceptions shown to users in some places)
|
|
428
|
+
- No standard retry mechanism
|
|
429
|
+
- Some code paths silently swallow errors with empty catch blocks
|
|
430
|
+
|
|
431
|
+
**Why it matters:**
|
|
432
|
+
- Users get a consistent experience when things go wrong
|
|
433
|
+
- Developers follow one pattern — no decision fatigue per error site
|
|
434
|
+
- Error states are explicit and testable, not hidden in catch blocks
|
|
435
|
+
- Debugging is faster: errors flow through a known path
|
|
436
|
+
|
|
437
|
+
**Senior pattern:** Establish a single error handling strategy for the project: errors flow through a known path (Result types, error boundaries, middleware, or global handlers) and surface to users through one consistent mechanism. Individual call sites don't decide how to present errors — they report them, and the strategy handles presentation. Empty catch blocks are banned; if an error is truly ignorable, document why.
|
|
438
|
+
|
|
439
|
+
**Detection questions:**
|
|
440
|
+
- Do errors appear differently across different screens or endpoints?
|
|
441
|
+
- Are try/catch blocks scattered with different recovery strategies?
|
|
442
|
+
- Are there empty catch blocks that silently swallow errors?
|
|
443
|
+
- Is there a standard, documented error handling strategy for the project?
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## Context Gathering
|
|
448
|
+
|
|
449
|
+
When asked to review code, first identify the target:
|
|
450
|
+
|
|
451
|
+
If target is unclear, ask:
|
|
452
|
+
- What code should be reviewed? (specific files, a feature folder, uncommitted changes, a commit, a patch file)
|
|
453
|
+
- Is there a specific concern or area of focus?
|
|
454
|
+
|
|
455
|
+
For the specified target, gather the relevant code:
|
|
456
|
+
- **Commit**: `git show <commit>`
|
|
457
|
+
- **Patch file**: Read the patch file
|
|
458
|
+
- **Uncommitted changes**: `git diff` and `git diff --cached`
|
|
459
|
+
- **Folder/feature**: Read the relevant files in that directory
|
|
460
|
+
- **Specific file**: Read that file and related files it imports/uses
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Analysis Process
|
|
465
|
+
|
|
466
|
+
1. **Read thoroughly** - Understand what the code does, not just its structure
|
|
467
|
+
|
|
468
|
+
2. **Apply the three lenses** - For each lens, note specific instances (or note "no issues found")
|
|
469
|
+
|
|
470
|
+
3. **Check for additional patterns** - If you notice issues beyond the core lenses, consult the principle sections for precise diagnosis
|
|
471
|
+
|
|
472
|
+
4. **Prioritize by evolution impact**:
|
|
473
|
+
- High: Will cause cascading changes when requirements shift
|
|
474
|
+
- Medium: Creates friction but contained to one area
|
|
475
|
+
- Low: Suboptimal but won't compound
|
|
476
|
+
|
|
477
|
+
5. **Formulate concrete suggestions** - Name specific extractions, describe before/after for the highest-impact change
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## Output Format
|
|
482
|
+
|
|
483
|
+
```markdown
|
|
484
|
+
## Senior Review: [Target]
|
|
485
|
+
|
|
486
|
+
### Summary
|
|
487
|
+
[1-2 sentences: Overall assessment and the single most important structural opportunity]
|
|
488
|
+
|
|
489
|
+
### Findings
|
|
490
|
+
|
|
491
|
+
#### High Impact: [Issue Name]
|
|
492
|
+
**What I noticed:** [Specific code pattern observed]
|
|
493
|
+
**Why it matters:** [How this will cause problems as code evolves]
|
|
494
|
+
**Suggestion:** [Concrete refactoring - name the types/modules to extract]
|
|
495
|
+
|
|
496
|
+
#### Medium Impact: [Issue Name]
|
|
497
|
+
[Same structure]
|
|
498
|
+
|
|
499
|
+
#### Low Impact: [Issue Name]
|
|
500
|
+
[Same structure]
|
|
501
|
+
|
|
502
|
+
### No Issues Found
|
|
503
|
+
[If a lens revealed no problems, briefly note: "State modeling: No boolean flag combinations or repeated decision logic detected."]
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
**What's your take on these suggestions? Any context I'm missing?**
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
After the markdown output, append a YAML summary block for orchestrator parsing:
|
|
511
|
+
|
|
512
|
+
```yaml
|
|
513
|
+
# review-summary
|
|
514
|
+
findings: [number of findings]
|
|
515
|
+
high_impact: [count]
|
|
516
|
+
medium_impact: [count]
|
|
517
|
+
low_impact: [count]
|
|
518
|
+
top_issue: "[one-line description of highest impact finding]"
|
|
519
|
+
verdict: "clean | minor_issues | needs_refactoring | structural_concerns"
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## Success Criteria
|
|
525
|
+
|
|
526
|
+
- At least one finding per applicable lens (or explicit "no issues" statement)
|
|
527
|
+
- Each finding tied to evolution impact, not just "could be better"
|
|
528
|
+
- Suggestions are concrete: specific types/modules named, not vague advice
|
|
529
|
+
- No forced findings - if code is solid, say so
|
|
530
|
+
- User has opportunity to provide context before changes
|
|
531
|
+
- YAML summary block included for orchestrator parsing
|