@crewpilot/agent 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -107
- package/dist-npm/cli.js +0 -0
- package/dist-npm/index.js +160 -127
- package/package.json +69 -69
- package/prompts/agent.md +282 -266
- package/prompts/catalyst.config.json +72 -72
- package/prompts/copilot-instructions.md +36 -36
- package/prompts/skills/assure-code-quality/SKILL.md +112 -112
- package/prompts/skills/assure-pr-intelligence/SKILL.md +148 -148
- package/prompts/skills/assure-review-functional/SKILL.md +114 -0
- package/prompts/skills/assure-review-standards/SKILL.md +106 -0
- package/prompts/skills/assure-threat-model/SKILL.md +182 -0
- package/prompts/skills/assure-vulnerability-scan/SKILL.md +146 -146
- package/prompts/skills/autopilot-meeting/SKILL.md +434 -407
- package/prompts/skills/autopilot-worker/SKILL.md +737 -623
- package/prompts/skills/daily-digest/SKILL.md +188 -167
- package/prompts/skills/deliver-change-management/SKILL.md +132 -132
- package/prompts/skills/deliver-deploy-guard/SKILL.md +144 -144
- package/prompts/skills/deliver-doc-governance/SKILL.md +130 -130
- package/prompts/skills/engineer-feature-builder/SKILL.md +270 -270
- package/prompts/skills/engineer-root-cause-analysis/SKILL.md +150 -150
- package/prompts/skills/engineer-test-first/SKILL.md +148 -148
- package/prompts/skills/insights-knowledge-base/SKILL.md +202 -181
- package/prompts/skills/insights-pattern-detection/SKILL.md +142 -142
- package/prompts/skills/strategize-architecture-planner/SKILL.md +141 -141
- package/prompts/skills/strategize-solution-design/SKILL.md +118 -118
- package/scripts/postinstall.js +108 -108
|
@@ -1,181 +1,202 @@
|
|
|
1
|
-
# Knowledge Base
|
|
2
|
-
|
|
3
|
-
> **Pillar**: Insights | **ID**: `insights-knowledge-base`
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
Persistent cross-session memory system. Stores decisions, patterns, lessons learned, and context so the team's knowledge compounds over time instead of resetting every conversation.
|
|
8
|
-
|
|
9
|
-
## Activation Triggers
|
|
10
|
-
|
|
11
|
-
- "remember this", "recall", "what did we decide about"
|
|
12
|
-
- "history", "past decisions", "context from last time"
|
|
13
|
-
- "save this insight", "knowledge base"
|
|
14
|
-
- Implicitly used by other skills to check for prior context
|
|
15
|
-
|
|
16
|
-
## Methodology
|
|
17
|
-
|
|
18
|
-
### Process Flow
|
|
19
|
-
|
|
20
|
-
```dot
|
|
21
|
-
digraph knowledge_base {
|
|
22
|
-
rankdir=TB;
|
|
23
|
-
node [shape=box];
|
|
24
|
-
|
|
25
|
-
subgraph cluster_store {
|
|
26
|
-
label="Store Operations";
|
|
27
|
-
decision [label="Store Decision"];
|
|
28
|
-
lesson [label="Store Lesson"];
|
|
29
|
-
pattern [label="Store Pattern"];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
subgraph cluster_retrieve {
|
|
33
|
-
label="Retrieve Operations";
|
|
34
|
-
query [label="Direct Query"];
|
|
35
|
-
contextual [label="Contextual Retrieval\n(by other skills)"];
|
|
36
|
-
timeline [label="Timeline View"];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
subgraph cluster_maintain {
|
|
40
|
-
label="Maintenance";
|
|
41
|
-
consolidate [label="Pattern Consolidation"];
|
|
42
|
-
export [label="Knowledge Export", shape=doublecircle];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
decision -> query [style=dotted];
|
|
46
|
-
lesson -> query [style=dotted];
|
|
47
|
-
pattern -> query [style=dotted];
|
|
48
|
-
contextual -> consolidate [style=dotted, label="periodic"];
|
|
49
|
-
consolidate -> export;
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Store Operations
|
|
54
|
-
|
|
55
|
-
#### Store a Decision
|
|
56
|
-
When a significant decision is made during any skill:
|
|
57
|
-
1. Extract: decision, rationale, alternatives rejected, date, related files
|
|
58
|
-
2. Tag with categories: `architecture`, `technology`, `process`, `convention`
|
|
59
|
-
3. Store via `catalyst_knowledge_store`
|
|
60
|
-
|
|
61
|
-
Entry format:
|
|
62
|
-
```json
|
|
63
|
-
{
|
|
64
|
-
"type": "decision",
|
|
65
|
-
"title": "{short title}",
|
|
66
|
-
"content": "{decision and rationale}",
|
|
67
|
-
"tags": ["{category}", "{technology}"],
|
|
68
|
-
"related_files": ["{paths}"],
|
|
69
|
-
"timestamp": "{ISO date}"
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
#### Store a Lesson Learned
|
|
74
|
-
When debugging reveals a non-obvious insight:
|
|
75
|
-
1. Extract: what happened, why, prevention measure
|
|
76
|
-
2. Tag with: `bug`, `performance`, `security`, `gotcha`
|
|
77
|
-
3. Link to the fix commit if available
|
|
78
|
-
|
|
79
|
-
#### Store a Pattern
|
|
80
|
-
When `pattern-detection` identifies a codebase convention:
|
|
81
|
-
1. Document the pattern with a code example
|
|
82
|
-
2. Tag with: `pattern`, `convention`, `style`
|
|
83
|
-
3. Reference canonical implementation files
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
###
|
|
107
|
-
|
|
108
|
-
####
|
|
109
|
-
|
|
110
|
-
1.
|
|
111
|
-
2.
|
|
112
|
-
3.
|
|
113
|
-
|
|
114
|
-
####
|
|
115
|
-
|
|
116
|
-
1.
|
|
117
|
-
2.
|
|
118
|
-
3.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
##
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
1
|
+
# Knowledge Base
|
|
2
|
+
|
|
3
|
+
> **Pillar**: Insights | **ID**: `insights-knowledge-base`
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Persistent cross-session memory system. Stores decisions, patterns, lessons learned, and context so the team's knowledge compounds over time instead of resetting every conversation.
|
|
8
|
+
|
|
9
|
+
## Activation Triggers
|
|
10
|
+
|
|
11
|
+
- "remember this", "recall", "what did we decide about"
|
|
12
|
+
- "history", "past decisions", "context from last time"
|
|
13
|
+
- "save this insight", "knowledge base"
|
|
14
|
+
- Implicitly used by other skills to check for prior context
|
|
15
|
+
|
|
16
|
+
## Methodology
|
|
17
|
+
|
|
18
|
+
### Process Flow
|
|
19
|
+
|
|
20
|
+
```dot
|
|
21
|
+
digraph knowledge_base {
|
|
22
|
+
rankdir=TB;
|
|
23
|
+
node [shape=box];
|
|
24
|
+
|
|
25
|
+
subgraph cluster_store {
|
|
26
|
+
label="Store Operations";
|
|
27
|
+
decision [label="Store Decision"];
|
|
28
|
+
lesson [label="Store Lesson"];
|
|
29
|
+
pattern [label="Store Pattern"];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
subgraph cluster_retrieve {
|
|
33
|
+
label="Retrieve Operations";
|
|
34
|
+
query [label="Direct Query"];
|
|
35
|
+
contextual [label="Contextual Retrieval\n(by other skills)"];
|
|
36
|
+
timeline [label="Timeline View"];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
subgraph cluster_maintain {
|
|
40
|
+
label="Maintenance";
|
|
41
|
+
consolidate [label="Pattern Consolidation"];
|
|
42
|
+
export [label="Knowledge Export", shape=doublecircle];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
decision -> query [style=dotted];
|
|
46
|
+
lesson -> query [style=dotted];
|
|
47
|
+
pattern -> query [style=dotted];
|
|
48
|
+
contextual -> consolidate [style=dotted, label="periodic"];
|
|
49
|
+
consolidate -> export;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Store Operations
|
|
54
|
+
|
|
55
|
+
#### Store a Decision
|
|
56
|
+
When a significant decision is made during any skill:
|
|
57
|
+
1. Extract: decision, rationale, alternatives rejected, date, related files
|
|
58
|
+
2. Tag with categories: `architecture`, `technology`, `process`, `convention`
|
|
59
|
+
3. Store via `catalyst_knowledge_store`
|
|
60
|
+
|
|
61
|
+
Entry format:
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"type": "decision",
|
|
65
|
+
"title": "{short title}",
|
|
66
|
+
"content": "{decision and rationale}",
|
|
67
|
+
"tags": ["{category}", "{technology}"],
|
|
68
|
+
"related_files": ["{paths}"],
|
|
69
|
+
"timestamp": "{ISO date}"
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### Store a Lesson Learned
|
|
74
|
+
When debugging reveals a non-obvious insight:
|
|
75
|
+
1. Extract: what happened, why, prevention measure
|
|
76
|
+
2. Tag with: `bug`, `performance`, `security`, `gotcha`
|
|
77
|
+
3. Link to the fix commit if available
|
|
78
|
+
|
|
79
|
+
#### Store a Pattern
|
|
80
|
+
When `pattern-detection` identifies a codebase convention:
|
|
81
|
+
1. Document the pattern with a code example
|
|
82
|
+
2. Tag with: `pattern`, `convention`, `style`
|
|
83
|
+
3. Reference canonical implementation files
|
|
84
|
+
|
|
85
|
+
#### Store a Meeting Reference
|
|
86
|
+
When a meeting produces decisions or requirements that influence code:
|
|
87
|
+
1. Extract: meeting subject, date, attendees, key decisions, action items, linked documents
|
|
88
|
+
2. Tag with: `meeting`, `decision`, `requirements`, and relevant feature/module tags
|
|
89
|
+
3. Link to the board items created from the meeting (if any)
|
|
90
|
+
4. Store via `catalyst_knowledge_store`
|
|
91
|
+
|
|
92
|
+
Entry format:
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"type": "meeting-reference",
|
|
96
|
+
"title": "{meeting subject} — {date}",
|
|
97
|
+
"content": "Decisions: {list}. Requirements: {list}. Action items: {list}.",
|
|
98
|
+
"tags": ["meeting", "{feature}", "{module}"],
|
|
99
|
+
"related_files": ["{board item URLs or issue numbers}"],
|
|
100
|
+
"timestamp": "{ISO date}"
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This creates a link between decisions and their source meetings — enabling other skills to trace why a requirement exists and who stated it. The `autopilot-meeting` skill should automatically store meeting references after creating board items.
|
|
105
|
+
|
|
106
|
+
### Retrieve Operations
|
|
107
|
+
|
|
108
|
+
#### Direct Query
|
|
109
|
+
User asks "what did we decide about X":
|
|
110
|
+
1. Search knowledge base via `catalyst_knowledge_search`
|
|
111
|
+
2. Return matching entries with context
|
|
112
|
+
3. If multiple matches, rank by relevance and recency
|
|
113
|
+
|
|
114
|
+
#### Contextual Retrieval (by other skills)
|
|
115
|
+
Skills query the knowledge base before starting:
|
|
116
|
+
1. `solution-design` checks for prior decisions on the same topic
|
|
117
|
+
2. `architecture-planner` retrieves existing ADRs
|
|
118
|
+
3. `root-cause-analysis` checks if similar bugs were solved before
|
|
119
|
+
4. `code-quality` retrieves documented conventions
|
|
120
|
+
|
|
121
|
+
#### Timeline View
|
|
122
|
+
User asks "what happened this week/sprint":
|
|
123
|
+
1. Retrieve entries within the time range via `catalyst_knowledge_timeline`
|
|
124
|
+
2. Group by type (decisions, lessons, patterns)
|
|
125
|
+
3. Present as a chronological narrative
|
|
126
|
+
|
|
127
|
+
### Maintenance Operations
|
|
128
|
+
|
|
129
|
+
#### Pattern Consolidation
|
|
130
|
+
Periodically:
|
|
131
|
+
1. Identify related entries that can be merged
|
|
132
|
+
2. Archive stale entries (decisions reversed, patterns abandoned)
|
|
133
|
+
3. Flag contradictory entries for resolution
|
|
134
|
+
|
|
135
|
+
#### Knowledge Export
|
|
136
|
+
Generate a summary document:
|
|
137
|
+
1. Active decisions and their current status
|
|
138
|
+
2. Team conventions with code examples
|
|
139
|
+
3. Common gotchas and their solutions
|
|
140
|
+
|
|
141
|
+
## Tools Required
|
|
142
|
+
|
|
143
|
+
- `catalyst_knowledge_store` — Write entries to the knowledge base
|
|
144
|
+
- `catalyst_knowledge_search` — Full-text search across entries
|
|
145
|
+
- `catalyst_knowledge_timeline` — Time-range queries
|
|
146
|
+
- `catalyst_knowledge_patterns` — Pattern frequency analysis
|
|
147
|
+
- `catalyst_knowledge_export` — Generate summary documents
|
|
148
|
+
|
|
149
|
+
## Output Format
|
|
150
|
+
|
|
151
|
+
### For Storage
|
|
152
|
+
```
|
|
153
|
+
## [Catalyst → Knowledge Base: Stored]
|
|
154
|
+
|
|
155
|
+
✓ Stored: {type} — "{title}"
|
|
156
|
+
Tags: {tags}
|
|
157
|
+
Related: {files}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### For Retrieval
|
|
161
|
+
```
|
|
162
|
+
## [Catalyst → Knowledge Base: Retrieved]
|
|
163
|
+
|
|
164
|
+
### Results for "{query}"
|
|
165
|
+
Found {N} entries:
|
|
166
|
+
|
|
167
|
+
#### {title} ({type}, {date})
|
|
168
|
+
{content}
|
|
169
|
+
**Tags**: {tags}
|
|
170
|
+
**Related files**: {paths}
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
(repeat per entry)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### For Timeline
|
|
177
|
+
```
|
|
178
|
+
## [Catalyst → Knowledge Base: Timeline]
|
|
179
|
+
|
|
180
|
+
### {date range}
|
|
181
|
+
|
|
182
|
+
**Decisions**
|
|
183
|
+
- {title}: {summary}
|
|
184
|
+
|
|
185
|
+
**Lessons Learned**
|
|
186
|
+
- {title}: {summary}
|
|
187
|
+
|
|
188
|
+
**Patterns**
|
|
189
|
+
- {title}: {summary}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Chains To
|
|
193
|
+
|
|
194
|
+
- Any skill can chain TO knowledge-base to store findings
|
|
195
|
+
- Knowledge-base is queried BY other skills, but doesn't chain outward
|
|
196
|
+
|
|
197
|
+
## Anti-Patterns
|
|
198
|
+
|
|
199
|
+
- Do NOT store trivial information — only decisions, lessons, and patterns
|
|
200
|
+
- Do NOT store ephemeral state (what files are open, current branch)
|
|
201
|
+
- Do NOT return raw database entries — synthesize into readable summaries
|
|
202
|
+
- Do NOT store sensitive data (credentials, tokens, personal info)
|
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
# Pattern Detection
|
|
2
|
-
|
|
3
|
-
> **Pillar**: Insights | **ID**: `insights-pattern-detection`
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
Codebase-wide pattern mining and anti-pattern identification. Analyzes structural health, detects recurring issues, tracks technical debt, and identifies emerging trends across the project.
|
|
8
|
-
|
|
9
|
-
## Activation Triggers
|
|
10
|
-
|
|
11
|
-
- "codebase health", "find patterns", "anti-patterns", "tech debt"
|
|
12
|
-
- "what patterns are we using", "code trends", "structural analysis"
|
|
13
|
-
- Automatically triggered when `root-cause-analysis` finds a systemic issue
|
|
14
|
-
|
|
15
|
-
## Methodology
|
|
16
|
-
|
|
17
|
-
### Process Flow
|
|
18
|
-
|
|
19
|
-
```dot
|
|
20
|
-
digraph pattern_detection {
|
|
21
|
-
rankdir=TB;
|
|
22
|
-
node [shape=box];
|
|
23
|
-
|
|
24
|
-
structure [label="Phase 1\nStructure Scan"];
|
|
25
|
-
mining [label="Phase 2\nPattern Mining"];
|
|
26
|
-
antipattern [label="Phase 3\nAnti-Pattern Detection"];
|
|
27
|
-
debt [label="Phase 4\nTechnical Debt Inventory"];
|
|
28
|
-
trends [label="Phase 5\nTrend Analysis", shape=diamond];
|
|
29
|
-
report [label="Report", shape=doublecircle];
|
|
30
|
-
|
|
31
|
-
structure -> mining;
|
|
32
|
-
mining -> antipattern;
|
|
33
|
-
antipattern -> debt;
|
|
34
|
-
debt -> trends;
|
|
35
|
-
trends -> report [label="historical\ndata available"];
|
|
36
|
-
debt -> report [label="no historical data"];
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Phase 1 — Structure Scan
|
|
41
|
-
1. Map the project structure: directories, modules, layers
|
|
42
|
-
2. Identify architectural patterns in use:
|
|
43
|
-
- MVC, MVVM, Clean Architecture, Hexagonal
|
|
44
|
-
- Microservices vs. monolith vs. modular monolith
|
|
45
|
-
- API patterns: REST, GraphQL, RPC
|
|
46
|
-
3. Detect organizational patterns: feature-based vs. layer-based vs. hybrid
|
|
47
|
-
|
|
48
|
-
### Phase 2 — Pattern Mining
|
|
49
|
-
Scan for recurring code patterns:
|
|
50
|
-
|
|
51
|
-
| Category | Patterns to Detect |
|
|
52
|
-
|---|---|
|
|
53
|
-
| **Error handling** | Try-catch styles, error propagation, error types |
|
|
54
|
-
| **Data access** | ORM patterns, raw queries, repository pattern |
|
|
55
|
-
| **State management** | Global state, dependency injection, singletons |
|
|
56
|
-
| **API design** | Route organization, middleware chains, validation |
|
|
57
|
-
| **Testing** | Test structure, mock strategies, fixture patterns |
|
|
58
|
-
| **Configuration** | Env vars, config objects, feature flags |
|
|
59
|
-
|
|
60
|
-
For each pattern found:
|
|
61
|
-
- **Frequency**: How often it appears
|
|
62
|
-
- **Consistency**: Are there deviations from the pattern?
|
|
63
|
-
- **Quality**: Is this a good pattern for this context?
|
|
64
|
-
|
|
65
|
-
### Phase 3 — Anti-Pattern Detection
|
|
66
|
-
Flag known anti-patterns:
|
|
67
|
-
|
|
68
|
-
| Anti-Pattern | Symptoms |
|
|
69
|
-
|---|---|
|
|
70
|
-
| **God Object/File** | Single file > 500 lines with mixed responsibilities |
|
|
71
|
-
| **Circular Dependencies** | Module A imports B imports A |
|
|
72
|
-
| **Shotgun Surgery** | Small change requires touching 5+ files |
|
|
73
|
-
| **Feature Envy** | Function uses more of another module's data than its own |
|
|
74
|
-
| **Dead Code** | Unreachable functions, unused exports |
|
|
75
|
-
| **Copy-Paste** | Near-duplicate code blocks across files |
|
|
76
|
-
| **Primitive Obsession** | Strings/numbers used where domain types belong |
|
|
77
|
-
| **Configuration Drift** | Same setting configured differently in multiple places |
|
|
78
|
-
|
|
79
|
-
### Phase 4 — Technical Debt Inventory
|
|
80
|
-
For each anti-pattern or inconsistency:
|
|
81
|
-
1. Estimate effort to fix (T-shirt size)
|
|
82
|
-
2. Assess impact on team velocity
|
|
83
|
-
3. Rate urgency: address now vs. track vs. accept
|
|
84
|
-
|
|
85
|
-
### Phase 5 — Trend Analysis
|
|
86
|
-
If `catalyst_knowledge_search` has historical data:
|
|
87
|
-
1. Compare current patterns vs. previous scans
|
|
88
|
-
2. Identify patterns that are spreading (good or bad)
|
|
89
|
-
3. Flag entropy increase — growing inconsistency over time
|
|
90
|
-
|
|
91
|
-
## Tools Required
|
|
92
|
-
|
|
93
|
-
- `codebase` — Full project scan
|
|
94
|
-
- `terminal` — Run static analysis tools
|
|
95
|
-
- `catalyst_metrics_complexity` — Complexity metrics per module
|
|
96
|
-
- `catalyst_knowledge_search` — Historical pattern data
|
|
97
|
-
- `catalyst_knowledge_store` — Record findings for future comparison
|
|
98
|
-
|
|
99
|
-
## Output Format
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
## [Catalyst → Pattern Detection]
|
|
103
|
-
|
|
104
|
-
### Architecture
|
|
105
|
-
{detected patterns and organization style}
|
|
106
|
-
|
|
107
|
-
### Code Patterns
|
|
108
|
-
| Pattern | Category | Frequency | Consistency | Quality |
|
|
109
|
-
|---|---|---|---|---|
|
|
110
|
-
| {pattern} | {category} | {count} | {high/medium/low} | {good/acceptable/poor} |
|
|
111
|
-
|
|
112
|
-
### Anti-Patterns
|
|
113
|
-
| Anti-Pattern | Locations | Severity | Fix Effort |
|
|
114
|
-
|---|---|---|---|
|
|
115
|
-
| {anti-pattern} | {files/modules} | {high/med/low} | {T-shirt} |
|
|
116
|
-
|
|
117
|
-
### Technical Debt
|
|
118
|
-
| Item | Impact | Urgency | Effort |
|
|
119
|
-
|---|---|---|---|
|
|
120
|
-
| {debt item} | {velocity/quality/security} | {now/track/accept} | {T-shirt} |
|
|
121
|
-
|
|
122
|
-
### Trends (if historical data available)
|
|
123
|
-
{getting better / getting worse / stable}
|
|
124
|
-
|
|
125
|
-
### Summary
|
|
126
|
-
Codebase health: {score}/10
|
|
127
|
-
Top concern: {most impactful issue}
|
|
128
|
-
Quick wins: {list of low-effort improvements}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Chains To
|
|
132
|
-
|
|
133
|
-
- `code-quality` — Deep review of flagged anti-pattern locations
|
|
134
|
-
- `architecture-planner` — Restructure if systemic issues found
|
|
135
|
-
- `knowledge-base` — Store scan results for trend tracking
|
|
136
|
-
|
|
137
|
-
## Anti-Patterns (meta)
|
|
138
|
-
|
|
139
|
-
- Do NOT flag patterns as anti-patterns based on ideology — evaluate in context
|
|
140
|
-
- Do NOT report dead code without verifying it's truly unreachable
|
|
141
|
-
- Do NOT recommend rewrites for working code with manageable debt
|
|
142
|
-
- Do NOT present a massive list without prioritization
|
|
1
|
+
# Pattern Detection
|
|
2
|
+
|
|
3
|
+
> **Pillar**: Insights | **ID**: `insights-pattern-detection`
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Codebase-wide pattern mining and anti-pattern identification. Analyzes structural health, detects recurring issues, tracks technical debt, and identifies emerging trends across the project.
|
|
8
|
+
|
|
9
|
+
## Activation Triggers
|
|
10
|
+
|
|
11
|
+
- "codebase health", "find patterns", "anti-patterns", "tech debt"
|
|
12
|
+
- "what patterns are we using", "code trends", "structural analysis"
|
|
13
|
+
- Automatically triggered when `root-cause-analysis` finds a systemic issue
|
|
14
|
+
|
|
15
|
+
## Methodology
|
|
16
|
+
|
|
17
|
+
### Process Flow
|
|
18
|
+
|
|
19
|
+
```dot
|
|
20
|
+
digraph pattern_detection {
|
|
21
|
+
rankdir=TB;
|
|
22
|
+
node [shape=box];
|
|
23
|
+
|
|
24
|
+
structure [label="Phase 1\nStructure Scan"];
|
|
25
|
+
mining [label="Phase 2\nPattern Mining"];
|
|
26
|
+
antipattern [label="Phase 3\nAnti-Pattern Detection"];
|
|
27
|
+
debt [label="Phase 4\nTechnical Debt Inventory"];
|
|
28
|
+
trends [label="Phase 5\nTrend Analysis", shape=diamond];
|
|
29
|
+
report [label="Report", shape=doublecircle];
|
|
30
|
+
|
|
31
|
+
structure -> mining;
|
|
32
|
+
mining -> antipattern;
|
|
33
|
+
antipattern -> debt;
|
|
34
|
+
debt -> trends;
|
|
35
|
+
trends -> report [label="historical\ndata available"];
|
|
36
|
+
debt -> report [label="no historical data"];
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Phase 1 — Structure Scan
|
|
41
|
+
1. Map the project structure: directories, modules, layers
|
|
42
|
+
2. Identify architectural patterns in use:
|
|
43
|
+
- MVC, MVVM, Clean Architecture, Hexagonal
|
|
44
|
+
- Microservices vs. monolith vs. modular monolith
|
|
45
|
+
- API patterns: REST, GraphQL, RPC
|
|
46
|
+
3. Detect organizational patterns: feature-based vs. layer-based vs. hybrid
|
|
47
|
+
|
|
48
|
+
### Phase 2 — Pattern Mining
|
|
49
|
+
Scan for recurring code patterns:
|
|
50
|
+
|
|
51
|
+
| Category | Patterns to Detect |
|
|
52
|
+
|---|---|
|
|
53
|
+
| **Error handling** | Try-catch styles, error propagation, error types |
|
|
54
|
+
| **Data access** | ORM patterns, raw queries, repository pattern |
|
|
55
|
+
| **State management** | Global state, dependency injection, singletons |
|
|
56
|
+
| **API design** | Route organization, middleware chains, validation |
|
|
57
|
+
| **Testing** | Test structure, mock strategies, fixture patterns |
|
|
58
|
+
| **Configuration** | Env vars, config objects, feature flags |
|
|
59
|
+
|
|
60
|
+
For each pattern found:
|
|
61
|
+
- **Frequency**: How often it appears
|
|
62
|
+
- **Consistency**: Are there deviations from the pattern?
|
|
63
|
+
- **Quality**: Is this a good pattern for this context?
|
|
64
|
+
|
|
65
|
+
### Phase 3 — Anti-Pattern Detection
|
|
66
|
+
Flag known anti-patterns:
|
|
67
|
+
|
|
68
|
+
| Anti-Pattern | Symptoms |
|
|
69
|
+
|---|---|
|
|
70
|
+
| **God Object/File** | Single file > 500 lines with mixed responsibilities |
|
|
71
|
+
| **Circular Dependencies** | Module A imports B imports A |
|
|
72
|
+
| **Shotgun Surgery** | Small change requires touching 5+ files |
|
|
73
|
+
| **Feature Envy** | Function uses more of another module's data than its own |
|
|
74
|
+
| **Dead Code** | Unreachable functions, unused exports |
|
|
75
|
+
| **Copy-Paste** | Near-duplicate code blocks across files |
|
|
76
|
+
| **Primitive Obsession** | Strings/numbers used where domain types belong |
|
|
77
|
+
| **Configuration Drift** | Same setting configured differently in multiple places |
|
|
78
|
+
|
|
79
|
+
### Phase 4 — Technical Debt Inventory
|
|
80
|
+
For each anti-pattern or inconsistency:
|
|
81
|
+
1. Estimate effort to fix (T-shirt size)
|
|
82
|
+
2. Assess impact on team velocity
|
|
83
|
+
3. Rate urgency: address now vs. track vs. accept
|
|
84
|
+
|
|
85
|
+
### Phase 5 — Trend Analysis
|
|
86
|
+
If `catalyst_knowledge_search` has historical data:
|
|
87
|
+
1. Compare current patterns vs. previous scans
|
|
88
|
+
2. Identify patterns that are spreading (good or bad)
|
|
89
|
+
3. Flag entropy increase — growing inconsistency over time
|
|
90
|
+
|
|
91
|
+
## Tools Required
|
|
92
|
+
|
|
93
|
+
- `codebase` — Full project scan
|
|
94
|
+
- `terminal` — Run static analysis tools
|
|
95
|
+
- `catalyst_metrics_complexity` — Complexity metrics per module
|
|
96
|
+
- `catalyst_knowledge_search` — Historical pattern data
|
|
97
|
+
- `catalyst_knowledge_store` — Record findings for future comparison
|
|
98
|
+
|
|
99
|
+
## Output Format
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
## [Catalyst → Pattern Detection]
|
|
103
|
+
|
|
104
|
+
### Architecture
|
|
105
|
+
{detected patterns and organization style}
|
|
106
|
+
|
|
107
|
+
### Code Patterns
|
|
108
|
+
| Pattern | Category | Frequency | Consistency | Quality |
|
|
109
|
+
|---|---|---|---|---|
|
|
110
|
+
| {pattern} | {category} | {count} | {high/medium/low} | {good/acceptable/poor} |
|
|
111
|
+
|
|
112
|
+
### Anti-Patterns
|
|
113
|
+
| Anti-Pattern | Locations | Severity | Fix Effort |
|
|
114
|
+
|---|---|---|---|
|
|
115
|
+
| {anti-pattern} | {files/modules} | {high/med/low} | {T-shirt} |
|
|
116
|
+
|
|
117
|
+
### Technical Debt
|
|
118
|
+
| Item | Impact | Urgency | Effort |
|
|
119
|
+
|---|---|---|---|
|
|
120
|
+
| {debt item} | {velocity/quality/security} | {now/track/accept} | {T-shirt} |
|
|
121
|
+
|
|
122
|
+
### Trends (if historical data available)
|
|
123
|
+
{getting better / getting worse / stable}
|
|
124
|
+
|
|
125
|
+
### Summary
|
|
126
|
+
Codebase health: {score}/10
|
|
127
|
+
Top concern: {most impactful issue}
|
|
128
|
+
Quick wins: {list of low-effort improvements}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Chains To
|
|
132
|
+
|
|
133
|
+
- `code-quality` — Deep review of flagged anti-pattern locations
|
|
134
|
+
- `architecture-planner` — Restructure if systemic issues found
|
|
135
|
+
- `knowledge-base` — Store scan results for trend tracking
|
|
136
|
+
|
|
137
|
+
## Anti-Patterns (meta)
|
|
138
|
+
|
|
139
|
+
- Do NOT flag patterns as anti-patterns based on ideology — evaluate in context
|
|
140
|
+
- Do NOT report dead code without verifying it's truly unreachable
|
|
141
|
+
- Do NOT recommend rewrites for working code with manageable debt
|
|
142
|
+
- Do NOT present a massive list without prioritization
|