crewkit 0.1.0 → 1.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 +142 -1
- package/package.json +1 -1
- package/skill/SKILL.md +38 -2
- package/skill/adapters/copilot.md +239 -0
- package/skill/adapters/cursor.md +215 -0
- package/skill/templates/skills/dev-metrics/SKILL.md +126 -0
- package/skill/templates/skills/impact/SKILL.md +157 -0
- package/skill/templates/skills/retro/SKILL.md +134 -0
- package/skill/templates/skills/review-pr/SKILL.md +39 -5
- package/skill/templates/skills/security-scan/SKILL.md +157 -0
- package/src/add.js +45 -0
- package/src/cli.js +15 -6
- package/src/install.js +4 -1
- package/src/update.js +28 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-metrics
|
|
3
|
+
description: "Generate development metrics from git history — commit patterns, fix loop frequency, agent usage, file hotspots, and workflow efficiency."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Generate development metrics for: $ARGUMENTS
|
|
7
|
+
|
|
8
|
+
If $ARGUMENTS is empty, analyze the last 90 days of git history.
|
|
9
|
+
If $ARGUMENTS is a number (e.g. `30`), use that many days.
|
|
10
|
+
If $ARGUMENTS is a branch or date range, scope to that.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Steps
|
|
15
|
+
|
|
16
|
+
### 1. Collect raw data
|
|
17
|
+
|
|
18
|
+
Run all commands in parallel:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Commit volume and cadence
|
|
22
|
+
git log --oneline --since="90 days ago" --format="%ad %s" --date=short
|
|
23
|
+
|
|
24
|
+
# File change frequency (hotspots)
|
|
25
|
+
git log --since="90 days ago" --name-only --pretty=format: | sort | uniq -c | sort -rn | head -30
|
|
26
|
+
|
|
27
|
+
# Author breakdown (if multi-contributor)
|
|
28
|
+
git shortlog -sn --since="90 days ago"
|
|
29
|
+
|
|
30
|
+
# Fix/correction commits (heuristic: commit message contains fix, hotfix, correction, revert)
|
|
31
|
+
git log --oneline --since="90 days ago" --grep="fix\|hotfix\|correction\|revert\|bugfix" -i
|
|
32
|
+
|
|
33
|
+
# Merge commits (PR merges)
|
|
34
|
+
git log --oneline --since="90 days ago" --merges
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Adapt the `--since` window to match $ARGUMENTS if provided.
|
|
38
|
+
|
|
39
|
+
### 2. Compute metrics
|
|
40
|
+
|
|
41
|
+
From raw data, derive:
|
|
42
|
+
|
|
43
|
+
#### Commit patterns
|
|
44
|
+
| Metric | Value |
|
|
45
|
+
|--------|-------|
|
|
46
|
+
| Total commits | count |
|
|
47
|
+
| Commits per week (avg) | count |
|
|
48
|
+
| Peak activity day/week | date or range |
|
|
49
|
+
| Fix/correction commit ratio | fix commits / total commits (%) |
|
|
50
|
+
|
|
51
|
+
#### Fix loop frequency
|
|
52
|
+
Estimate fix loop frequency by counting sequential commits on the same file within a 24h window.
|
|
53
|
+
Flag any file with 3+ consecutive fix commits as a **fix loop hotspot**.
|
|
54
|
+
|
|
55
|
+
| File | Fix loop count | Most recent |
|
|
56
|
+
|------|---------------|-------------|
|
|
57
|
+
| ... | ... | ... |
|
|
58
|
+
|
|
59
|
+
#### File hotspots
|
|
60
|
+
Top 10 most-changed files:
|
|
61
|
+
|
|
62
|
+
| File | Change count | Risk level |
|
|
63
|
+
|------|-------------|-----------|
|
|
64
|
+
| ... | ... | HIGH if auth/tenant/migration, MEDIUM if handler/service, LOW otherwise |
|
|
65
|
+
|
|
66
|
+
Apply risk classification using `.ai/memory/conventions.md` if present (read it).
|
|
67
|
+
|
|
68
|
+
#### Workflow efficiency signals
|
|
69
|
+
| Signal | Value | Health |
|
|
70
|
+
|--------|-------|--------|
|
|
71
|
+
| Fix commit ratio | X% | GREEN <15%, YELLOW 15-30%, RED >30% |
|
|
72
|
+
| Revert count | N | GREEN 0, YELLOW 1-2, RED 3+ |
|
|
73
|
+
| Hotfix commits | N | flag if >2 in window |
|
|
74
|
+
| Files changed per commit (avg) | N | GREEN <5, YELLOW 5-10, RED >10 |
|
|
75
|
+
|
|
76
|
+
#### Agent usage (if detectable from commit messages)
|
|
77
|
+
If commit messages contain agent names (coder, tester, reviewer, architect, explorer),
|
|
78
|
+
tally usage per agent. Otherwise, skip this section.
|
|
79
|
+
|
|
80
|
+
### 3. Identify systemic risks
|
|
81
|
+
|
|
82
|
+
Cross-reference hotspot files with risk classification:
|
|
83
|
+
- If a HIGH-risk file (auth, tenant, billing, migration) is in the top 5 hotspots → flag as **systemic risk**
|
|
84
|
+
- If fix commit ratio > 30% → flag as **process health concern**
|
|
85
|
+
- If the same file appears in both hotspots and fix loops → flag as **instability candidate**
|
|
86
|
+
|
|
87
|
+
### 4. Suggest improvements
|
|
88
|
+
|
|
89
|
+
For each systemic risk or process health concern, propose one concrete action:
|
|
90
|
+
- Do not propose vague items ("write more tests")
|
|
91
|
+
- Each suggestion must reference a specific file, module, or metric
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Return Format
|
|
96
|
+
|
|
97
|
+
```markdown
|
|
98
|
+
---
|
|
99
|
+
**Dev Metrics Report**
|
|
100
|
+
**Period:** [date range]
|
|
101
|
+
**Total commits analyzed:** N
|
|
102
|
+
|
|
103
|
+
## Commit Patterns
|
|
104
|
+
[table]
|
|
105
|
+
|
|
106
|
+
## Fix Loop Frequency
|
|
107
|
+
[table or "No fix loop hotspots detected"]
|
|
108
|
+
|
|
109
|
+
## File Hotspots (top 10)
|
|
110
|
+
[table]
|
|
111
|
+
|
|
112
|
+
## Workflow Efficiency
|
|
113
|
+
[table with GREEN/YELLOW/RED indicators]
|
|
114
|
+
|
|
115
|
+
## Agent Usage
|
|
116
|
+
[table or "Not detectable from commit messages"]
|
|
117
|
+
|
|
118
|
+
## Systemic Risks
|
|
119
|
+
[list or "None identified"]
|
|
120
|
+
|
|
121
|
+
## Suggested Improvements
|
|
122
|
+
[numbered list, max 5, concrete and actionable]
|
|
123
|
+
---
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Keep the report structured and scannable. Do not include raw git output.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: impact
|
|
3
|
+
description: "Analyze blast radius of changing a file, handler, entity, or module. Maps callers, tests, endpoints, and UI pages affected."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Analyze blast radius of: $ARGUMENTS
|
|
7
|
+
|
|
8
|
+
$ARGUMENTS must be a file path, handler name, entity name, module name, or endpoint.
|
|
9
|
+
Examples: `src/Orders/OrderHandler.cs`, `OrderEntity`, `POST /api/orders`, `Orders module`
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
Use before starting any MEDIUM or LARGE task to understand the full scope of change.
|
|
16
|
+
Use before `/explore-and-plan` when the target is already known but blast radius is uncertain.
|
|
17
|
+
Use after a production incident to understand what else might be affected by the fix.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Steps
|
|
22
|
+
|
|
23
|
+
### 1. Identify the target
|
|
24
|
+
|
|
25
|
+
From $ARGUMENTS, determine:
|
|
26
|
+
- **Target type:** file / class / handler / entity / endpoint / module
|
|
27
|
+
- **Target location:** resolve to exact file path(s) if not already a path
|
|
28
|
+
- **Stack:** infer from path extension and `.ai/memory/architecture.md`
|
|
29
|
+
|
|
30
|
+
Read `.ai/memory/architecture.md` and `.ai/memory/conventions.md` to understand layer rules
|
|
31
|
+
and naming conventions before searching.
|
|
32
|
+
|
|
33
|
+
### 2. Map direct callers
|
|
34
|
+
|
|
35
|
+
Search for all direct references to the target:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Search for imports, usages, and references
|
|
39
|
+
# Adapt search patterns to the detected stack:
|
|
40
|
+
# - .NET: class name, interface name, constructor injection, handler registration
|
|
41
|
+
# - Node.js: require/import of the file, function call sites
|
|
42
|
+
# - Blazor: component references, @inject, @page routes, event handlers
|
|
43
|
+
# - SQL/migrations: table name, column name in queries and seeders
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Build the direct caller list:
|
|
47
|
+
|
|
48
|
+
| File | Reference type | Layer |
|
|
49
|
+
|------|---------------|-------|
|
|
50
|
+
| ... | import / call / inject / inherit | controller / service / handler / UI / test |
|
|
51
|
+
|
|
52
|
+
### 3. Map transitive impact
|
|
53
|
+
|
|
54
|
+
For each direct caller, check if it is itself called by other files:
|
|
55
|
+
- Go one level deeper if the direct caller is an interface, base class, or shared service
|
|
56
|
+
- Stop at two levels unless the target is a core shared abstraction (entity, base class, shared interface)
|
|
57
|
+
- Flag if the dependency graph is too wide to enumerate (>20 unique callers at any level)
|
|
58
|
+
|
|
59
|
+
### 4. Map tests
|
|
60
|
+
|
|
61
|
+
Find all test files that directly or indirectly test the target:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Search test directories for the target name, class name, or endpoint path
|
|
65
|
+
# Look for test doubles (mocks, fakes, stubs) of the target
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Test file | Tests what | Has mock/fake of target? |
|
|
69
|
+
|-----------|-----------|--------------------------|
|
|
70
|
+
| ... | ... | yes / no |
|
|
71
|
+
|
|
72
|
+
Flag any test file that uses a mock/fake of the target — changing the target's interface or
|
|
73
|
+
exception types will require updating those fakes.
|
|
74
|
+
|
|
75
|
+
### 5. Map API endpoints and UI pages
|
|
76
|
+
|
|
77
|
+
If the target is a handler, service, or entity:
|
|
78
|
+
- Find which API endpoints call it (controller/route → handler)
|
|
79
|
+
- Find which UI pages or components consume those endpoints (if frontend source is available)
|
|
80
|
+
|
|
81
|
+
| Endpoint | Method | UI page/component | Consumer type |
|
|
82
|
+
|----------|--------|------------------|---------------|
|
|
83
|
+
| ... | ... | ... | internal / public API |
|
|
84
|
+
|
|
85
|
+
Mark endpoints as **public API** if they are exposed externally — changes to those have higher blast radius.
|
|
86
|
+
|
|
87
|
+
### 6. Classify blast radius
|
|
88
|
+
|
|
89
|
+
| Dimension | Count | Assessment |
|
|
90
|
+
|-----------|-------|-----------|
|
|
91
|
+
| Direct callers | N | — |
|
|
92
|
+
| Transitive callers | N | — |
|
|
93
|
+
| Test files affected | N | — |
|
|
94
|
+
| API endpoints affected | N | — |
|
|
95
|
+
| UI pages affected | N | — |
|
|
96
|
+
| Public API contracts affected | N | HIGH risk if >0 |
|
|
97
|
+
| Auth/tenant code affected | yes/no | HIGH risk if yes |
|
|
98
|
+
| DB schema affected | yes/no | HIGH risk if yes |
|
|
99
|
+
|
|
100
|
+
**Overall blast radius:**
|
|
101
|
+
- **LOW** — 1-2 files, same layer, no public API, no auth/schema
|
|
102
|
+
- **MEDIUM** — 3-7 files, cross-layer, no public API change
|
|
103
|
+
- **HIGH** — 8+ files, or public API, or auth/tenant, or DB schema change
|
|
104
|
+
|
|
105
|
+
### 7. Identify change categories
|
|
106
|
+
|
|
107
|
+
Classify what types of changes to the target would cause breakage vs. safe changes:
|
|
108
|
+
|
|
109
|
+
| Change type | Breakage risk | Affected consumers |
|
|
110
|
+
|-------------|--------------|-------------------|
|
|
111
|
+
| Add new field (non-breaking) | LOW | none |
|
|
112
|
+
| Rename field or method | HIGH | all callers + test fakes |
|
|
113
|
+
| Change return type | HIGH | all callers |
|
|
114
|
+
| Change exception thrown | MEDIUM | test fakes + callers that catch |
|
|
115
|
+
| Add required parameter | HIGH | all call sites |
|
|
116
|
+
| Add optional parameter | LOW | none |
|
|
117
|
+
| Split into two classes | HIGH | all callers + DI registrations |
|
|
118
|
+
| Change DB column | HIGH | queries + migrations |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Return Format
|
|
123
|
+
|
|
124
|
+
```markdown
|
|
125
|
+
---
|
|
126
|
+
**Impact Analysis: [target name]**
|
|
127
|
+
**Target type:** [file / class / handler / entity / endpoint / module]
|
|
128
|
+
**Stack:** [detected]
|
|
129
|
+
|
|
130
|
+
## Direct Callers
|
|
131
|
+
[table from Step 2]
|
|
132
|
+
|
|
133
|
+
## Transitive Impact
|
|
134
|
+
[table or "None — direct callers are leaf nodes"]
|
|
135
|
+
|
|
136
|
+
## Tests Affected
|
|
137
|
+
[table from Step 4]
|
|
138
|
+
[Flag: "N test files use a mock/fake of this target — update them if interface changes"]
|
|
139
|
+
|
|
140
|
+
## Endpoints and UI Pages
|
|
141
|
+
[table from Step 5, or "Not applicable"]
|
|
142
|
+
|
|
143
|
+
## Blast Radius Summary
|
|
144
|
+
[table from Step 6]
|
|
145
|
+
|
|
146
|
+
**Blast radius: LOW / MEDIUM / HIGH**
|
|
147
|
+
|
|
148
|
+
## Safe vs. Breaking Changes
|
|
149
|
+
[table from Step 7]
|
|
150
|
+
|
|
151
|
+
## Recommendation
|
|
152
|
+
[1-3 sentences: what to do before making this change, and what to watch for]
|
|
153
|
+
---
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
If $ARGUMENTS does not resolve to a known file or name, ask for clarification before proceeding.
|
|
157
|
+
Do not guess at the target.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: retro
|
|
3
|
+
description: "Post-mortem of a completed task or plan — analyzes fix loops, reviewer findings, lessons learned, and suggests process improvements."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Post-mortem for: $ARGUMENTS
|
|
7
|
+
|
|
8
|
+
If $ARGUMENTS is empty, analyze the most recent completed task from git log.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## When to use
|
|
13
|
+
|
|
14
|
+
Use after a task is completed (or after a painful iteration) to extract durable lessons
|
|
15
|
+
and identify process improvements. Not a blame exercise — a signal extraction exercise.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Steps
|
|
20
|
+
|
|
21
|
+
### 1. Gather signals
|
|
22
|
+
|
|
23
|
+
Run in parallel:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git log --oneline -30
|
|
27
|
+
git diff HEAD~10..HEAD --stat
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Also read (if they exist):
|
|
31
|
+
- `.ai/plans/` — any plan file matching $ARGUMENTS
|
|
32
|
+
- `.ai/memory/lessons-*.md` — to avoid duplicating existing lessons
|
|
33
|
+
|
|
34
|
+
If $ARGUMENTS points to a specific plan file, read it directly.
|
|
35
|
+
|
|
36
|
+
### 2. Reconstruct the timeline
|
|
37
|
+
|
|
38
|
+
From git log and plan file, reconstruct:
|
|
39
|
+
|
|
40
|
+
| Phase | What happened | Agent/actor |
|
|
41
|
+
|-------|--------------|-------------|
|
|
42
|
+
| Initial implementation | ... | coder |
|
|
43
|
+
| First test run | PASS / FAIL | tester |
|
|
44
|
+
| First review | APPROVED / NEEDS_CHANGES | reviewer |
|
|
45
|
+
| Fix loop iterations | count + what was fixed | coder |
|
|
46
|
+
| Final state | PASS + APPROVED | — |
|
|
47
|
+
|
|
48
|
+
Flag any phase that repeated more than once.
|
|
49
|
+
|
|
50
|
+
### 3. Analyze fix loops
|
|
51
|
+
|
|
52
|
+
For each fix loop iteration, identify:
|
|
53
|
+
- **Trigger:** what caused the loop (test failure / reviewer finding / build error)
|
|
54
|
+
- **Root cause category:** one of:
|
|
55
|
+
- `spec-gap` — requirement was ambiguous or incomplete
|
|
56
|
+
- `scope-underestimate` — task was classified smaller than it was
|
|
57
|
+
- `missing-context` — coder lacked critical info (architecture, conventions, existing pattern)
|
|
58
|
+
- `test-gap` — test didn't cover the scenario before the fix
|
|
59
|
+
- `review-gap` — reviewer finding could have been caught earlier
|
|
60
|
+
- `execution-error` — correct spec, wrong implementation (typo, off-by-one, wrong field)
|
|
61
|
+
- `external-dependency` — blocked by something outside the task
|
|
62
|
+
|
|
63
|
+
### 4. Classify reviewer findings
|
|
64
|
+
|
|
65
|
+
If reviewer output is available (from PR diff, plan notes, or conversation context), classify findings:
|
|
66
|
+
|
|
67
|
+
| Severity | Count | Recurring? | Category |
|
|
68
|
+
|----------|-------|-----------|----------|
|
|
69
|
+
| CRITICAL | ... | yes/no | ... |
|
|
70
|
+
| IMPORTANT | ... | yes/no | ... |
|
|
71
|
+
| MINOR | ... | yes/no | ... |
|
|
72
|
+
|
|
73
|
+
"Recurring" = same finding appeared in a previous retro or lesson file.
|
|
74
|
+
|
|
75
|
+
### 5. Identify process improvements
|
|
76
|
+
|
|
77
|
+
For each fix loop trigger, propose one concrete process change:
|
|
78
|
+
|
|
79
|
+
| Finding | Proposed change | Target phase |
|
|
80
|
+
|---------|----------------|--------------|
|
|
81
|
+
| e.g. coder missed multi-tenant rule | Add explicit tenant check to coder prompt | Step 0 (classify) |
|
|
82
|
+
| e.g. test missed edge case | Add edge case checklist to tester for this module | tester |
|
|
83
|
+
|
|
84
|
+
Keep proposals concrete and actionable. Do not propose vague "be more careful" items.
|
|
85
|
+
|
|
86
|
+
### 6. Extract durable lessons
|
|
87
|
+
|
|
88
|
+
For each lesson that would prevent future recurrence, format as:
|
|
89
|
+
|
|
90
|
+
```markdown
|
|
91
|
+
### [YYYY-MM-DD] Retro: <short title>
|
|
92
|
+
- **Task:** [what was being built/fixed]
|
|
93
|
+
- **What happened:** [1-2 sentences]
|
|
94
|
+
- **Root cause:** [category from Step 3]
|
|
95
|
+
- **Lesson:** [actionable guidance for next time]
|
|
96
|
+
- **Applies to:** [domain: .NET / gateway / Blazor / process / all]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Append to the correct `.ai/memory/lessons-{domain}.md`.
|
|
100
|
+
If lesson is process-level, append to `lessons-process.md` (create if missing).
|
|
101
|
+
|
|
102
|
+
### 7. Update plan status
|
|
103
|
+
|
|
104
|
+
If a plan file was identified, update its status to **DONE** (if not already).
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Return Format
|
|
109
|
+
|
|
110
|
+
```markdown
|
|
111
|
+
---
|
|
112
|
+
**Retro: [task name or git range]**
|
|
113
|
+
**Period:** [date range from git log]
|
|
114
|
+
**Fix loop count:** [N]
|
|
115
|
+
|
|
116
|
+
**Timeline summary:**
|
|
117
|
+
[reconstructed table from Step 2]
|
|
118
|
+
|
|
119
|
+
**Fix loop analysis:**
|
|
120
|
+
[table from Step 3]
|
|
121
|
+
|
|
122
|
+
**Reviewer findings:**
|
|
123
|
+
[table from Step 4, or "not available"]
|
|
124
|
+
|
|
125
|
+
**Process improvements:**
|
|
126
|
+
[table from Step 5]
|
|
127
|
+
|
|
128
|
+
**Lessons documented:** [N lessons → file(s)]
|
|
129
|
+
|
|
130
|
+
**Top recommendation:** [single most impactful process change]
|
|
131
|
+
---
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
If no fix loops occurred and review was clean on the first pass, state that explicitly — it is a positive signal worth noting.
|
|
@@ -9,7 +9,10 @@ Review pull request: $ARGUMENTS
|
|
|
9
9
|
|
|
10
10
|
### 1. Fetch PR data
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Try each source in order, stopping at the first that succeeds.
|
|
13
|
+
|
|
14
|
+
#### 1a. GitHub (gh CLI)
|
|
15
|
+
|
|
13
16
|
```bash
|
|
14
17
|
gh pr view $ARGUMENTS --json number,title,body,author,baseRefName,headRefName,additions,deletions,changedFiles
|
|
15
18
|
gh pr diff $ARGUMENTS
|
|
@@ -17,6 +20,32 @@ gh pr diff $ARGUMENTS
|
|
|
17
20
|
|
|
18
21
|
If $ARGUMENTS is empty, use `gh pr view` (current branch's PR).
|
|
19
22
|
|
|
23
|
+
If `gh` is not installed or returns an error, proceed to **1b**.
|
|
24
|
+
|
|
25
|
+
#### 1b. GitLab (glab CLI)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
glab mr view $ARGUMENTS --output json
|
|
29
|
+
glab mr diff $ARGUMENTS
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If $ARGUMENTS is empty, use `glab mr view` (current branch's MR).
|
|
33
|
+
|
|
34
|
+
If `glab` is not installed or returns an error, proceed to **1c**.
|
|
35
|
+
|
|
36
|
+
#### 1c. Pure git fallback
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git log main..HEAD --oneline
|
|
40
|
+
git diff main...HEAD
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
When using this fallback:
|
|
44
|
+
- PR metadata (title, description, author, reviewer comments) is **not available**.
|
|
45
|
+
- Communicate this clearly to the reviewer agent.
|
|
46
|
+
- Ask the user to provide context about the changes if possible:
|
|
47
|
+
> "No GitHub/GitLab CLI was found. I'm reviewing based on raw git diff only. PR title, description, and comments are unavailable. If you can share what this change is about, it will improve the review."
|
|
48
|
+
|
|
20
49
|
### 2. Load project context
|
|
21
50
|
|
|
22
51
|
Read `.ai/memory/architecture.md` and `.ai/memory/conventions.md`.
|
|
@@ -24,9 +53,10 @@ Read `.ai/memory/architecture.md` and `.ai/memory/conventions.md`.
|
|
|
24
53
|
### 3. Run reviewer agent
|
|
25
54
|
|
|
26
55
|
Pass to **reviewer** subagent:
|
|
27
|
-
- Full PR diff
|
|
28
|
-
- PR title and description
|
|
29
|
-
- File count and change size
|
|
56
|
+
- Full PR/MR diff (or git diff if fallback)
|
|
57
|
+
- PR/MR title and description (if available; otherwise note "unavailable — git fallback")
|
|
58
|
+
- File count and change size (derive from diff if metadata unavailable)
|
|
59
|
+
- Source used: GitHub / GitLab / git fallback
|
|
30
60
|
- Project context from step 2
|
|
31
61
|
|
|
32
62
|
The reviewer applies all checks from its instructions and `.ai/memory/conventions.md`, including project-specific rules (e.g., multi-tenant enforcement, architecture layer violations, forbidden patterns).
|
|
@@ -37,6 +67,7 @@ The reviewer applies all checks from its instructions and `.ai/memory/convention
|
|
|
37
67
|
---
|
|
38
68
|
**PR #[number] — [title]**
|
|
39
69
|
**Author:** [author] | **Branch:** [head] → [base]
|
|
70
|
+
**Source:** GitHub / GitLab / git fallback (no PR metadata)
|
|
40
71
|
**Size:** +[additions] / -[deletions] in [changedFiles] files
|
|
41
72
|
|
|
42
73
|
**Findings:**
|
|
@@ -50,4 +81,7 @@ The reviewer applies all checks from its instructions and `.ai/memory/convention
|
|
|
50
81
|
---
|
|
51
82
|
```
|
|
52
83
|
|
|
53
|
-
If
|
|
84
|
+
If using git fallback, omit fields that are unavailable (number, author, branch names) and add a note:
|
|
85
|
+
> "Review based on git diff only — PR metadata was not available."
|
|
86
|
+
|
|
87
|
+
If no PR/MR number provided and no current branch PR/MR exists and git fallback also fails, ask the user for a PR number or a base branch to diff against.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-scan
|
|
3
|
+
description: "Scan for known CRITICAL security issues and OWASP top 10 vulnerabilities specific to this project. Reports status of each known issue."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Run security scan for: $ARGUMENTS
|
|
7
|
+
|
|
8
|
+
If $ARGUMENTS is empty, scan the full codebase.
|
|
9
|
+
If $ARGUMENTS is a path or module name, scope the scan to that area.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
Use before merging changes that touch auth, tenant isolation, input handling, external integrations,
|
|
16
|
+
or any area that directly processes user-supplied data. Not a replacement for automated SAST —
|
|
17
|
+
a targeted, context-aware review using project conventions.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Steps
|
|
22
|
+
|
|
23
|
+
### 1. Load project context
|
|
24
|
+
|
|
25
|
+
Read `.ai/memory/conventions.md` and `.ai/memory/architecture.md`.
|
|
26
|
+
|
|
27
|
+
Extract:
|
|
28
|
+
- Security rules declared in conventions (e.g., TenantId must come from JWT, not body)
|
|
29
|
+
- Auth mechanism (JWT, sessions, API keys)
|
|
30
|
+
- Data flow: where external input enters the system
|
|
31
|
+
- Stack-specific concerns (e.g., SQL via ORM, HTML rendering, file uploads)
|
|
32
|
+
|
|
33
|
+
### 2. Map attack surface
|
|
34
|
+
|
|
35
|
+
Identify entry points within the scan scope:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Find API endpoint definitions
|
|
39
|
+
# (adapt pattern to the project's stack — controllers, routes, handlers, etc.)
|
|
40
|
+
|
|
41
|
+
# Find places that read from request body, query string, or headers
|
|
42
|
+
# Find places that write to DB or execute queries
|
|
43
|
+
# Find places that render HTML or return user-supplied content
|
|
44
|
+
# Find places that call external services
|
|
45
|
+
# Find files that handle auth or session state
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Run searches appropriate to the detected stack. Do not run all commands if the stack is clear
|
|
49
|
+
from `.ai/memory/architecture.md`.
|
|
50
|
+
|
|
51
|
+
### 3. Check OWASP Top 10
|
|
52
|
+
|
|
53
|
+
For each category, determine status based on code inspection:
|
|
54
|
+
|
|
55
|
+
| # | Category | Status | Evidence |
|
|
56
|
+
|---|----------|--------|----------|
|
|
57
|
+
| A01 | Broken Access Control | PASS / FAIL / PARTIAL / SKIP | [file:line or reason for skip] |
|
|
58
|
+
| A02 | Cryptographic Failures | PASS / FAIL / PARTIAL / SKIP | |
|
|
59
|
+
| A03 | Injection (SQL, NoSQL, cmd) | PASS / FAIL / PARTIAL / SKIP | |
|
|
60
|
+
| A04 | Insecure Design | PASS / FAIL / PARTIAL / SKIP | |
|
|
61
|
+
| A05 | Security Misconfiguration | PASS / FAIL / PARTIAL / SKIP | |
|
|
62
|
+
| A06 | Vulnerable Components | PASS / FAIL / PARTIAL / SKIP | |
|
|
63
|
+
| A07 | Auth & Session Management | PASS / FAIL / PARTIAL / SKIP | |
|
|
64
|
+
| A08 | Software & Data Integrity | PASS / FAIL / PARTIAL / SKIP | |
|
|
65
|
+
| A09 | Security Logging & Monitoring | PASS / FAIL / PARTIAL / SKIP | |
|
|
66
|
+
| A10 | Server-Side Request Forgery | PASS / FAIL / PARTIAL / SKIP | |
|
|
67
|
+
|
|
68
|
+
**Status definitions:**
|
|
69
|
+
- `PASS` — checked, no issue found
|
|
70
|
+
- `FAIL` — issue found, report exact location
|
|
71
|
+
- `PARTIAL` — partially mitigated, describe gap
|
|
72
|
+
- `SKIP` — not applicable to this scope (explain why)
|
|
73
|
+
|
|
74
|
+
### 4. Check project-specific security rules
|
|
75
|
+
|
|
76
|
+
From the rules extracted in Step 1, verify each one explicitly.
|
|
77
|
+
|
|
78
|
+
Common examples (adapt to what conventions.md actually says):
|
|
79
|
+
|
|
80
|
+
| Rule | Status | Evidence |
|
|
81
|
+
|------|--------|----------|
|
|
82
|
+
| TenantId sourced from JWT only (never from body/query) | PASS / FAIL | |
|
|
83
|
+
| No hardcoded secrets or API keys in source files | PASS / FAIL | |
|
|
84
|
+
| Auth enforced on all non-public endpoints | PASS / FAIL | |
|
|
85
|
+
| User-supplied data never passed to raw SQL or shell | PASS / FAIL | |
|
|
86
|
+
| File uploads validated for type and size | PASS / FAIL / N/A | |
|
|
87
|
+
| External service calls use timeout and error handling | PASS / FAIL / N/A | |
|
|
88
|
+
|
|
89
|
+
### 5. Check for secrets in code
|
|
90
|
+
|
|
91
|
+
Search for common secret patterns:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Patterns to search: password=, secret=, apikey=, token=, connectionstring=
|
|
95
|
+
# in non-test, non-example source files
|
|
96
|
+
# Flag any hardcoded value that is not an environment variable reference
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Report any findings with file path and line number. Flag `FAIL` in A02 if found.
|
|
100
|
+
|
|
101
|
+
### 6. Classify findings
|
|
102
|
+
|
|
103
|
+
| Severity | Criteria |
|
|
104
|
+
|----------|----------|
|
|
105
|
+
| CRITICAL | Exploitable without authentication, or exposes tenant data across boundaries |
|
|
106
|
+
| HIGH | Exploitable by authenticated users, privilege escalation, or data exposure |
|
|
107
|
+
| MEDIUM | Requires specific conditions, indirect exposure, or defense-in-depth gap |
|
|
108
|
+
| LOW | Best practice violation, minor information leakage, or hardening opportunity |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Return Format
|
|
113
|
+
|
|
114
|
+
```markdown
|
|
115
|
+
---
|
|
116
|
+
**Security Scan Report**
|
|
117
|
+
**Scope:** [full codebase or specific module]
|
|
118
|
+
**Stack:** [detected from architecture.md]
|
|
119
|
+
|
|
120
|
+
## OWASP Top 10 Status
|
|
121
|
+
[table from Step 3]
|
|
122
|
+
|
|
123
|
+
## Project-Specific Rules
|
|
124
|
+
[table from Step 4]
|
|
125
|
+
|
|
126
|
+
## Findings
|
|
127
|
+
|
|
128
|
+
### CRITICAL
|
|
129
|
+
- [none | list with file:line, description, remediation]
|
|
130
|
+
|
|
131
|
+
### HIGH
|
|
132
|
+
- [none | list]
|
|
133
|
+
|
|
134
|
+
### MEDIUM
|
|
135
|
+
- [none | list]
|
|
136
|
+
|
|
137
|
+
### LOW
|
|
138
|
+
- [none | list]
|
|
139
|
+
|
|
140
|
+
## Summary
|
|
141
|
+
| Total findings | CRITICAL | HIGH | MEDIUM | LOW |
|
|
142
|
+
|---------------|----------|------|--------|-----|
|
|
143
|
+
| N | N | N | N | N |
|
|
144
|
+
|
|
145
|
+
**Overall status:** CLEAN / NEEDS_ATTENTION / CRITICAL_ACTION_REQUIRED
|
|
146
|
+
|
|
147
|
+
## Recommended next steps
|
|
148
|
+
[numbered list, prioritized by severity]
|
|
149
|
+
---
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**CLEAN** = zero CRITICAL or HIGH findings.
|
|
153
|
+
**NEEDS_ATTENTION** = one or more MEDIUM findings, zero CRITICAL/HIGH.
|
|
154
|
+
**CRITICAL_ACTION_REQUIRED** = any CRITICAL or HIGH finding present.
|
|
155
|
+
|
|
156
|
+
Do not suggest generic remediation. Every recommendation must reference the specific file,
|
|
157
|
+
function, or rule from conventions.md.
|
package/src/add.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { cpSync, mkdirSync, existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
|
|
5
|
+
const OPTIONAL_SKILLS = ['retro', 'dev-metrics', 'security-scan', 'impact'];
|
|
6
|
+
|
|
7
|
+
export function add(skillName) {
|
|
8
|
+
if (!skillName) {
|
|
9
|
+
console.error('Error: skill name is required.');
|
|
10
|
+
console.log(`\n Available optional skills:\n${OPTIONAL_SKILLS.map(s => ` - ${s}`).join('\n')}\n`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!OPTIONAL_SKILLS.includes(skillName)) {
|
|
15
|
+
console.error(`Error: "${skillName}" is not a known optional skill.`);
|
|
16
|
+
console.log(`\n Available optional skills:\n${OPTIONAL_SKILLS.map(s => ` - ${s}`).join('\n')}\n`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const source = join(homedir(), '.claude', 'skills', 'crewkit-setup', 'templates', 'skills', skillName, 'SKILL.md');
|
|
21
|
+
|
|
22
|
+
if (!existsSync(source)) {
|
|
23
|
+
console.error(`Error: source not found at ${source}`);
|
|
24
|
+
console.log(' Make sure crewkit is installed first: npx crewkit install');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const targetDir = join(process.cwd(), '.claude', 'skills', skillName);
|
|
29
|
+
const target = join(targetDir, 'SKILL.md');
|
|
30
|
+
|
|
31
|
+
if (existsSync(target)) {
|
|
32
|
+
console.log(` Warning: ${target} already exists. Overwriting.`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
mkdirSync(targetDir, { recursive: true });
|
|
36
|
+
cpSync(source, target);
|
|
37
|
+
|
|
38
|
+
console.log(`
|
|
39
|
+
✓ Skill "${skillName}" installed
|
|
40
|
+
|
|
41
|
+
Copied to: ${target}
|
|
42
|
+
|
|
43
|
+
Use /${skillName} in Claude Code to run it.
|
|
44
|
+
`);
|
|
45
|
+
}
|