ccsetup 1.1.1 → 1.2.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/README.md +144 -342
- package/bin/create-project.js +1246 -90
- package/bin/lib/claudeInterface.js +209 -0
- package/lib/aiAgentSelector.js +155 -0
- package/lib/templates/README.md +176 -0
- package/lib/templates/catalog.js +230 -0
- package/lib/templates/filter.js +257 -0
- package/lib/templates/index.js +45 -0
- package/lib/templates/metadata/agents.json +413 -0
- package/lib/templates/metadata-extractor.js +329 -0
- package/lib/templates/search.js +356 -0
- package/package.json +13 -5
- package/template/{agents → .claude/agents}/checker.md +29 -0
- package/template/.claude/settings.json +32 -0
- package/template/.claude/skills/codex-review/SKILL.md +139 -0
- package/template/.claude/skills/prd/SKILL.md +343 -0
- package/template/.claude/skills/ralph/SKILL.md +339 -0
- package/template/.claude/skills/secops/SKILL.md +259 -0
- package/template/.codex/skills/codex-review/SKILL.md +139 -0
- package/template/.codex/skills/prd/SKILL.md +343 -0
- package/template/.codex/skills/ralph/SKILL.md +339 -0
- package/template/AGENTS.md +43 -0
- package/template/CLAUDE.md +141 -21
- package/template/CONTRIBUTING.md +37 -0
- package/template/agents/README.md +15 -171
- package/template/docs/ROADMAP.md +0 -36
- package/template/docs/agent-orchestration.md +24 -141
- package/template/docs/codex-setup.md +32 -0
- package/template/hooks/codex-review/index.js +105 -0
- package/template/hooks/workflow-selector/index.js +398 -0
- package/template/scripts/codex-review/codex-review.sh +266 -0
- package/template/scripts/ralph/CLAUDE.md +174 -0
- package/template/scripts/ralph/CODEX.md +76 -0
- package/template/scripts/ralph/ralph.sh +150 -0
- package/template/tickets/ticket-list.md +17 -68
- package/template/agents/ai-engineer.md +0 -31
- package/template/agents/api-documenter.md +0 -31
- package/template/agents/architect-review.md +0 -42
- package/template/agents/backend-architect.md +0 -29
- package/template/agents/business-analyst.md +0 -34
- package/template/agents/c-pro.md +0 -34
- package/template/agents/cloud-architect.md +0 -31
- package/template/agents/code-reviewer.md +0 -28
- package/template/agents/content-marketer.md +0 -34
- package/template/agents/context-manager.md +0 -63
- package/template/agents/cpp-pro.md +0 -37
- package/template/agents/customer-support.md +0 -34
- package/template/agents/data-engineer.md +0 -31
- package/template/agents/data-scientist.md +0 -28
- package/template/agents/database-admin.md +0 -31
- package/template/agents/database-optimizer.md +0 -31
- package/template/agents/debugger.md +0 -29
- package/template/agents/deployment-engineer.md +0 -31
- package/template/agents/devops-troubleshooter.md +0 -31
- package/template/agents/dx-optimizer.md +0 -62
- package/template/agents/error-detective.md +0 -31
- package/template/agents/frontend-developer.md +0 -30
- package/template/agents/golang-pro.md +0 -31
- package/template/agents/graphql-architect.md +0 -31
- package/template/agents/incident-responder.md +0 -73
- package/template/agents/javascript-pro.md +0 -34
- package/template/agents/legacy-modernizer.md +0 -31
- package/template/agents/ml-engineer.md +0 -31
- package/template/agents/mlops-engineer.md +0 -56
- package/template/agents/mobile-developer.md +0 -31
- package/template/agents/network-engineer.md +0 -31
- package/template/agents/payment-integration.md +0 -31
- package/template/agents/performance-engineer.md +0 -31
- package/template/agents/prompt-engineer.md +0 -58
- package/template/agents/python-pro.md +0 -31
- package/template/agents/quant-analyst.md +0 -31
- package/template/agents/risk-manager.md +0 -40
- package/template/agents/rust-pro.md +0 -34
- package/template/agents/sales-automator.md +0 -34
- package/template/agents/search-specialist.md +0 -58
- package/template/agents/security-auditor.md +0 -31
- package/template/agents/sql-pro.md +0 -34
- package/template/agents/terraform-specialist.md +0 -34
- package/template/agents/test-automator.md +0 -31
- /package/template/{agents → .claude/agents}/backend.md +0 -0
- /package/template/{agents → .claude/agents}/blockchain.md +0 -0
- /package/template/{agents → .claude/agents}/coder.md +0 -0
- /package/template/{agents → .claude/agents}/frontend.md +0 -0
- /package/template/{agents → .claude/agents}/planner.md +0 -0
- /package/template/{agents → .claude/agents}/researcher.md +0 -0
- /package/template/{agents → .claude/agents}/shadcn.md +0 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ralph
|
|
3
|
+
description: "Convert PRDs to prd.json format for the Ralph autonomous agent system. Use when you have an existing PRD and need to convert it to Ralph's JSON format. Triggers on: convert this prd, turn this into ralph format, create prd.json from this, ralph json."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Ralph PRD Converter
|
|
7
|
+
|
|
8
|
+
Converts existing PRDs to the prd.json format that Ralph uses for autonomous execution. Scans the codebase to populate quality checks, file hints, and story notes automatically.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## The Job
|
|
13
|
+
|
|
14
|
+
1. **Scan the codebase** to detect quality commands and relevant file paths
|
|
15
|
+
2. Read the PRD (markdown file or text) — check for a Tech Context section first
|
|
16
|
+
3. Convert to `scripts/ralph/prd.json` with codebase-informed stories
|
|
17
|
+
4. Initialize `scripts/ralph/progress.txt` if it doesn't exist
|
|
18
|
+
|
|
19
|
+
**Important:** Do NOT start implementing. Just create the prd.json.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Step 1: Codebase Reconnaissance
|
|
24
|
+
|
|
25
|
+
Before converting, silently scan the project using Claude Code tools.
|
|
26
|
+
|
|
27
|
+
### If PRD has a Tech Context section
|
|
28
|
+
The improved `/prd` skill generates a Tech Context section with stack, quality gates, and relevant file paths. If present, use it directly — no need to re-scan.
|
|
29
|
+
|
|
30
|
+
### If PRD has no Tech Context section
|
|
31
|
+
Scan manually:
|
|
32
|
+
|
|
33
|
+
**Detect quality commands** — Read `package.json` scripts, config files, Makefiles:
|
|
34
|
+
- Look for: `typecheck`, `tsc`, `check-types` → record the exact script (e.g., `npm run typecheck`)
|
|
35
|
+
- Look for: `lint`, `eslint`, `biome check` → record exact script (e.g., `npm run lint`)
|
|
36
|
+
- Look for: `test`, `vitest`, `jest`, `pytest` → record exact script (e.g., `npm test`)
|
|
37
|
+
- Look for: `build` → record exact script (e.g., `npm run build`)
|
|
38
|
+
|
|
39
|
+
**Scan relevant files** — Use Glob to find files related to each user story:
|
|
40
|
+
- Database: `**/schema.prisma`, `**/models/**`, `**/migrations/**`
|
|
41
|
+
- API: `**/api/**`, `**/routes/**`, `**/app/**/route.*`
|
|
42
|
+
- Components: `**/components/**`
|
|
43
|
+
- Utilities: `**/hooks/**`, `**/utils/**`, `**/lib/**`
|
|
44
|
+
|
|
45
|
+
These become `notes` on each story — giving Ralph file-level hints for where to work.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Step 2: Output Format
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"project": "[Project Name]",
|
|
54
|
+
"branchName": "ralph/[feature-name-kebab-case]",
|
|
55
|
+
"description": "[Feature description from PRD title/intro]",
|
|
56
|
+
"qualityChecks": {
|
|
57
|
+
"typecheck": "npm run typecheck",
|
|
58
|
+
"lint": "npm run lint",
|
|
59
|
+
"test": "npm test",
|
|
60
|
+
"build": "npm run build"
|
|
61
|
+
},
|
|
62
|
+
"userStories": [
|
|
63
|
+
{
|
|
64
|
+
"id": "US-001",
|
|
65
|
+
"title": "[Story title]",
|
|
66
|
+
"description": "As a [user], I want [feature] so that [benefit]",
|
|
67
|
+
"acceptanceCriteria": [
|
|
68
|
+
"Criterion 1",
|
|
69
|
+
"Criterion 2",
|
|
70
|
+
"Typecheck passes",
|
|
71
|
+
"Lint passes"
|
|
72
|
+
],
|
|
73
|
+
"priority": 1,
|
|
74
|
+
"passes": false,
|
|
75
|
+
"notes": "Relevant files: prisma/schema.prisma, src/app/api/tasks/route.ts"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### The `qualityChecks` field
|
|
82
|
+
|
|
83
|
+
This is **new and critical**. It tells Ralph the exact commands to run, so each iteration doesn't have to guess. Only include checks that actually exist in the project:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
"qualityChecks": {
|
|
87
|
+
"typecheck": "npm run typecheck",
|
|
88
|
+
"lint": "npm run lint"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If a project has no typecheck, don't include it. If it uses `make check`, use that. Be exact.
|
|
93
|
+
|
|
94
|
+
### The `notes` field
|
|
95
|
+
|
|
96
|
+
Pre-populate with **file hints** from your codebase scan — relevant files the story will likely touch or extend:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
"notes": "Relevant files: prisma/schema.prisma (Task model), src/components/TaskCard.tsx (extend with badge)"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This gives each Ralph iteration a head start instead of scanning the codebase from scratch.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Story Size: The Number One Rule
|
|
107
|
+
|
|
108
|
+
**Each story must be completable in ONE Ralph iteration (one context window).**
|
|
109
|
+
|
|
110
|
+
Ralph spawns a fresh instance per iteration with no memory of previous work. If a story is too big, the LLM runs out of context before finishing and produces broken code.
|
|
111
|
+
|
|
112
|
+
### Right-sized stories:
|
|
113
|
+
- Add a database column and migration
|
|
114
|
+
- Add a UI component to an existing page
|
|
115
|
+
- Update a server action with new logic
|
|
116
|
+
- Add a filter dropdown to a list
|
|
117
|
+
|
|
118
|
+
### Too big (split these):
|
|
119
|
+
- "Build the entire dashboard" — Split into: schema, queries, UI components, filters
|
|
120
|
+
- "Add authentication" — Split into: schema, middleware, login UI, session handling
|
|
121
|
+
- "Refactor the API" — Split into one story per endpoint or pattern
|
|
122
|
+
|
|
123
|
+
**Rule of thumb:** If you cannot describe the change in 2-3 sentences, it is too big.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Story Ordering: Dependencies First
|
|
128
|
+
|
|
129
|
+
Stories execute in priority order. Earlier stories must not depend on later ones.
|
|
130
|
+
|
|
131
|
+
**Correct order:**
|
|
132
|
+
1. Schema/database changes (migrations)
|
|
133
|
+
2. Server actions / backend logic
|
|
134
|
+
3. UI components that use the backend
|
|
135
|
+
4. Dashboard/summary views that aggregate data
|
|
136
|
+
|
|
137
|
+
**Wrong order:**
|
|
138
|
+
1. UI component (depends on schema that does not exist yet)
|
|
139
|
+
2. Schema change
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Acceptance Criteria: Must Be Verifiable
|
|
144
|
+
|
|
145
|
+
Each criterion must be something Ralph can CHECK, not something vague.
|
|
146
|
+
|
|
147
|
+
### Good criteria (verifiable):
|
|
148
|
+
- "Add `status` column to tasks table with default 'pending'"
|
|
149
|
+
- "Filter dropdown has options: All, Active, Completed"
|
|
150
|
+
- "Clicking delete shows confirmation dialog"
|
|
151
|
+
|
|
152
|
+
### Bad criteria (vague):
|
|
153
|
+
- "Works correctly"
|
|
154
|
+
- "User can do X easily"
|
|
155
|
+
- "Good UX"
|
|
156
|
+
- "Handles edge cases"
|
|
157
|
+
|
|
158
|
+
### Quality criteria — use what the project actually has
|
|
159
|
+
|
|
160
|
+
Append the quality checks detected in Step 1. Examples:
|
|
161
|
+
|
|
162
|
+
- Project has typecheck + lint → append `"Typecheck passes"`, `"Lint passes"`
|
|
163
|
+
- Project has only tests → append `"Tests pass"`
|
|
164
|
+
- Project has a build step → append `"Build passes"`
|
|
165
|
+
|
|
166
|
+
Do **not** hardcode "Typecheck passes" if the project has no typecheck.
|
|
167
|
+
|
|
168
|
+
### For stories that change UI, also include:
|
|
169
|
+
```
|
|
170
|
+
"Verify in browser using dev-browser skill"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Conversion Rules
|
|
176
|
+
|
|
177
|
+
1. **Each user story becomes one JSON entry**
|
|
178
|
+
2. **IDs**: Sequential (US-001, US-002, etc.)
|
|
179
|
+
3. **Priority**: Based on dependency order, then document order
|
|
180
|
+
4. **All stories**: `passes: false`
|
|
181
|
+
5. **notes**: Pre-populate with relevant file paths from codebase scan
|
|
182
|
+
6. **branchName**: Derive from feature name, kebab-case, prefixed with `ralph/`
|
|
183
|
+
7. **qualityChecks**: Populated from detected project commands (Step 1)
|
|
184
|
+
8. **Quality criteria on stories**: Match what `qualityChecks` contains
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Splitting Large PRDs
|
|
189
|
+
|
|
190
|
+
If a PRD has big features, split them:
|
|
191
|
+
|
|
192
|
+
**Original:**
|
|
193
|
+
> "Add user notification system"
|
|
194
|
+
|
|
195
|
+
**Split into:**
|
|
196
|
+
1. US-001: Add notifications table to database
|
|
197
|
+
2. US-002: Create notification service for sending notifications
|
|
198
|
+
3. US-003: Add notification bell icon to header
|
|
199
|
+
4. US-004: Create notification dropdown panel
|
|
200
|
+
5. US-005: Add mark-as-read functionality
|
|
201
|
+
6. US-006: Add notification preferences page
|
|
202
|
+
|
|
203
|
+
Each is one focused change that can be completed and verified independently.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Example
|
|
208
|
+
|
|
209
|
+
**Input PRD with Tech Context:**
|
|
210
|
+
```markdown
|
|
211
|
+
# PRD: Task Status Feature
|
|
212
|
+
|
|
213
|
+
## Tech Context
|
|
214
|
+
- **Stack:** Next.js 14 (App Router) + TypeScript + Tailwind CSS
|
|
215
|
+
- **DB:** Prisma with PostgreSQL (`prisma/schema.prisma`)
|
|
216
|
+
- **UI:** shadcn/ui in `src/components/ui/`
|
|
217
|
+
- **Quality gates:** Typecheck (`tsc --noEmit`), Lint (`eslint`), Tests (`vitest`)
|
|
218
|
+
- **Relevant code:**
|
|
219
|
+
- Task model: `prisma/schema.prisma`
|
|
220
|
+
- Task list: `src/components/TaskList.tsx`
|
|
221
|
+
- Task card: `src/components/TaskCard.tsx`
|
|
222
|
+
- Badge: `src/components/ui/Badge.tsx`
|
|
223
|
+
- API: `src/app/api/tasks/`
|
|
224
|
+
|
|
225
|
+
## User Stories
|
|
226
|
+
### US-001: Add status field to database ...
|
|
227
|
+
### US-002: Display status badge on task cards ...
|
|
228
|
+
### US-003: Add status toggle ...
|
|
229
|
+
### US-004: Filter tasks by status ...
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Output prd.json:**
|
|
233
|
+
```json
|
|
234
|
+
{
|
|
235
|
+
"project": "TaskApp",
|
|
236
|
+
"branchName": "ralph/task-status",
|
|
237
|
+
"description": "Task Status Feature - Track task progress with status indicators",
|
|
238
|
+
"qualityChecks": {
|
|
239
|
+
"typecheck": "npx tsc --noEmit",
|
|
240
|
+
"lint": "npm run lint",
|
|
241
|
+
"test": "npx vitest run"
|
|
242
|
+
},
|
|
243
|
+
"userStories": [
|
|
244
|
+
{
|
|
245
|
+
"id": "US-001",
|
|
246
|
+
"title": "Add status field to tasks table",
|
|
247
|
+
"description": "As a developer, I need to store task status in the database.",
|
|
248
|
+
"acceptanceCriteria": [
|
|
249
|
+
"Add status column: 'pending' | 'in_progress' | 'done' (default 'pending')",
|
|
250
|
+
"Generate and run migration successfully",
|
|
251
|
+
"Typecheck passes",
|
|
252
|
+
"Lint passes"
|
|
253
|
+
],
|
|
254
|
+
"priority": 1,
|
|
255
|
+
"passes": false,
|
|
256
|
+
"notes": "Relevant files: prisma/schema.prisma (Task model)"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"id": "US-002",
|
|
260
|
+
"title": "Display status badge on task cards",
|
|
261
|
+
"description": "As a user, I want to see task status at a glance.",
|
|
262
|
+
"acceptanceCriteria": [
|
|
263
|
+
"Each task card shows colored status badge",
|
|
264
|
+
"Badge colors: gray=pending, blue=in_progress, green=done",
|
|
265
|
+
"Typecheck passes",
|
|
266
|
+
"Lint passes",
|
|
267
|
+
"Verify in browser using dev-browser skill"
|
|
268
|
+
],
|
|
269
|
+
"priority": 2,
|
|
270
|
+
"passes": false,
|
|
271
|
+
"notes": "Relevant files: src/components/TaskCard.tsx (extend), src/components/ui/Badge.tsx (reuse with color variants)"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"id": "US-003",
|
|
275
|
+
"title": "Add status toggle to task list rows",
|
|
276
|
+
"description": "As a user, I want to change task status directly from the list.",
|
|
277
|
+
"acceptanceCriteria": [
|
|
278
|
+
"Each row has status dropdown or toggle",
|
|
279
|
+
"Changing status saves immediately via PATCH /api/tasks/[id]",
|
|
280
|
+
"UI updates without page refresh",
|
|
281
|
+
"Typecheck passes",
|
|
282
|
+
"Lint passes",
|
|
283
|
+
"Verify in browser using dev-browser skill"
|
|
284
|
+
],
|
|
285
|
+
"priority": 3,
|
|
286
|
+
"passes": false,
|
|
287
|
+
"notes": "Relevant files: src/components/TaskList.tsx, src/app/api/tasks/[id]/route.ts"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"id": "US-004",
|
|
291
|
+
"title": "Filter tasks by status",
|
|
292
|
+
"description": "As a user, I want to filter the list to see only certain statuses.",
|
|
293
|
+
"acceptanceCriteria": [
|
|
294
|
+
"Filter dropdown: All | Pending | In Progress | Done",
|
|
295
|
+
"Filter persists in URL params",
|
|
296
|
+
"Typecheck passes",
|
|
297
|
+
"Lint passes",
|
|
298
|
+
"Tests pass",
|
|
299
|
+
"Verify in browser using dev-browser skill"
|
|
300
|
+
],
|
|
301
|
+
"priority": 4,
|
|
302
|
+
"passes": false,
|
|
303
|
+
"notes": "Relevant files: src/components/TaskList.tsx (add filter dropdown)"
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Archiving Previous Runs
|
|
312
|
+
|
|
313
|
+
**Before writing a new prd.json, check if there is an existing one from a different feature:**
|
|
314
|
+
|
|
315
|
+
1. Read the current `prd.json` if it exists
|
|
316
|
+
2. Check if `branchName` differs from the new feature's branch name
|
|
317
|
+
3. If different AND `progress.txt` has content beyond the header:
|
|
318
|
+
- Create archive folder: `archive/YYYY-MM-DD-feature-name/`
|
|
319
|
+
- Copy current `prd.json` and `progress.txt` to archive
|
|
320
|
+
- Reset `progress.txt` with fresh header
|
|
321
|
+
|
|
322
|
+
**The ralph.sh script handles this automatically** when you run it, but if you are manually updating prd.json between runs, archive first.
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Checklist Before Saving
|
|
327
|
+
|
|
328
|
+
Before writing prd.json, verify:
|
|
329
|
+
|
|
330
|
+
- [ ] Ran codebase reconnaissance or read PRD's Tech Context (Step 1)
|
|
331
|
+
- [ ] `qualityChecks` populated with exact commands from the project
|
|
332
|
+
- [ ] **Previous run archived** (if prd.json exists with different branchName, archive it first)
|
|
333
|
+
- [ ] Each story is completable in one iteration (small enough)
|
|
334
|
+
- [ ] Stories are ordered by dependency (schema → backend → UI)
|
|
335
|
+
- [ ] Story quality criteria match what `qualityChecks` contains (not hardcoded)
|
|
336
|
+
- [ ] UI stories have "Verify in browser using dev-browser skill" as criterion
|
|
337
|
+
- [ ] Acceptance criteria are verifiable (not vague)
|
|
338
|
+
- [ ] Story `notes` pre-populated with relevant file paths
|
|
339
|
+
- [ ] No story depends on a later story
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
|
|
2
|
+
---
|
|
3
|
+
name: secops
|
|
4
|
+
description: >-
|
|
5
|
+
Scan dependencies for vulnerabilities using OSV Scanner before installing any packages.
|
|
6
|
+
Use when installing, updating, or auditing dependencies with pip, npm, cargo, go get,
|
|
7
|
+
gem, composer, nuget, or maven.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 🔒 CRITICAL SECURITY - OSV-Scanner Requirement
|
|
11
|
+
|
|
12
|
+
**MANDATORY SECOPS POLICY**: All dependency installations MUST be scanned with `osv-scanner` BEFORE installation. This is a non-negotiable security requirement.
|
|
13
|
+
|
|
14
|
+
### Security Workflow - ALWAYS Follow This Order
|
|
15
|
+
|
|
16
|
+
**BEFORE installing ANY dependencies:**
|
|
17
|
+
|
|
18
|
+
1. **Query the OSV API to check the package before installing:**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
curl -s -X POST "https://api.osv.dev/v1/query" \
|
|
22
|
+
-H "Content-Type: application/json" \
|
|
23
|
+
-d '{"package": {"name": "PACKAGE_NAME", "ecosystem": "ECOSYSTEM"}, "version": "VERSION"}'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Package Manager | Ecosystem |
|
|
27
|
+
|---|---|
|
|
28
|
+
| pip | `PyPI` |
|
|
29
|
+
| npm/yarn/pnpm | `npm` |
|
|
30
|
+
| cargo | `crates.io` |
|
|
31
|
+
| go get | `Go` |
|
|
32
|
+
| gem | `RubyGems` |
|
|
33
|
+
| composer | `Packagist` |
|
|
34
|
+
| nuget | `NuGet` |
|
|
35
|
+
| maven | `Maven` |
|
|
36
|
+
|
|
37
|
+
- Empty `{}` = no known vulnerabilities → proceed
|
|
38
|
+
- Response contains `vulns` = **STOP**. Report to user, suggest safe version.
|
|
39
|
+
|
|
40
|
+
2. **Prepare the lockfile for scanning:**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# If only pyproject.toml exists, generate requirements.txt first
|
|
44
|
+
# (osv-scanner works best with concrete dependency lists)
|
|
45
|
+
|
|
46
|
+
# Check if requirements.txt exists
|
|
47
|
+
ls requirements.txt 2>/dev/null || echo "No requirements.txt found"
|
|
48
|
+
|
|
49
|
+
# If no requirements.txt, generate from pyproject.toml
|
|
50
|
+
uv pip compile pyproject.toml -o requirements.txt
|
|
51
|
+
|
|
52
|
+
# OR use uv to generate lock file
|
|
53
|
+
uv lock
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
3. **Scan the lockfile:**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
osv-scanner scan -r .
|
|
60
|
+
|
|
61
|
+
# Or specific lockfile:
|
|
62
|
+
osv-scanner scan -L requirements.txt
|
|
63
|
+
osv-scanner scan -L package-lock.json
|
|
64
|
+
osv-scanner scan -L Cargo.lock
|
|
65
|
+
osv-scanner scan -L go.sum
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Language | Lockfiles |
|
|
69
|
+
|---|---|
|
|
70
|
+
| Python | `requirements.txt`, `Pipfile.lock`, `poetry.lock`, `uv.lock` |
|
|
71
|
+
| JavaScript | `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml` |
|
|
72
|
+
| Rust | `Cargo.lock` |
|
|
73
|
+
| Go | `go.mod`, `go.sum` |
|
|
74
|
+
| Ruby | `Gemfile.lock` |
|
|
75
|
+
| PHP | `composer.lock` |
|
|
76
|
+
| .NET | `packages.lock.json` |
|
|
77
|
+
|
|
78
|
+
4. **Review the scan results:**
|
|
79
|
+
|
|
80
|
+
- ❌ **If vulnerabilities are found:** STOP - Do NOT install. Report findings to the user and discuss mitigation options.
|
|
81
|
+
- ✅ **If scan is clean:** Proceed with installation.
|
|
82
|
+
|
|
83
|
+
5. **Only after clean scan, install dependencies:**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Python with uv (this project's standard)
|
|
87
|
+
uv sync
|
|
88
|
+
uv pip install <package>
|
|
89
|
+
|
|
90
|
+
# Node.js
|
|
91
|
+
npm install
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
6. **After installation, scan the entire project:**
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Scan all dependencies recursively
|
|
98
|
+
osv-scanner scan -r .
|
|
99
|
+
|
|
100
|
+
# Scan with specific config
|
|
101
|
+
osv-scanner scan --config osv-scanner.toml .
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Generating Requirements Files
|
|
105
|
+
|
|
106
|
+
If a project only has `pyproject.toml` and you need to scan dependencies:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Generate requirements.txt from pyproject.toml
|
|
110
|
+
uv pip compile pyproject.toml -o requirements.txt
|
|
111
|
+
|
|
112
|
+
# OR generate detailed lock file
|
|
113
|
+
uv lock
|
|
114
|
+
|
|
115
|
+
# Then scan the generated file
|
|
116
|
+
osv-scanner scan -L requirements.txt
|
|
117
|
+
# OR
|
|
118
|
+
osv-scanner scan -L uv.lock
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Why generate requirements.txt?**
|
|
122
|
+
|
|
123
|
+
- OSV-Scanner provides better results with concrete dependency lists
|
|
124
|
+
- requirements.txt includes resolved transitive dependencies
|
|
125
|
+
- Lock files (uv.lock) capture exact versions for reproducible scans
|
|
126
|
+
|
|
127
|
+
### Examples
|
|
128
|
+
|
|
129
|
+
#### ❌ WRONG - Installing without scanning:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# This is FORBIDDEN - no security scan!
|
|
133
|
+
uv pip install requests
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### ✅ CORRECT - Full security workflow:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Step 1: Query OSV API
|
|
140
|
+
curl -s -X POST "https://api.osv.dev/v1/query" \
|
|
141
|
+
-H "Content-Type: application/json" \
|
|
142
|
+
-d '{"package": {"name": "requests", "ecosystem": "PyPI"}, "version": "2.28.0"}'
|
|
143
|
+
|
|
144
|
+
# Step 2: Ensure requirements.txt exists
|
|
145
|
+
if [ ! -f requirements.txt ]; then
|
|
146
|
+
uv pip compile pyproject.toml -o requirements.txt
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
# Step 3: Scan before installation
|
|
150
|
+
osv-scanner scan -L requirements.txt
|
|
151
|
+
|
|
152
|
+
# Step 4: If clean, proceed with installation
|
|
153
|
+
uv sync
|
|
154
|
+
|
|
155
|
+
# Step 5: Scan again after installation
|
|
156
|
+
osv-scanner scan -r .
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### ✅ CORRECT - Adding a new package:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Step 1: Add to pyproject.toml manually or:
|
|
163
|
+
# uv add <package> (this also installs - use with caution)
|
|
164
|
+
|
|
165
|
+
# Step 2: Generate/update requirements.txt
|
|
166
|
+
uv pip compile pyproject.toml -o requirements.txt
|
|
167
|
+
|
|
168
|
+
# Step 3: Scan the updated dependencies
|
|
169
|
+
osv-scanner scan -L requirements.txt
|
|
170
|
+
|
|
171
|
+
# Step 4: If vulnerabilities found, STOP and report
|
|
172
|
+
# Step 5: If clean, proceed with sync
|
|
173
|
+
uv sync
|
|
174
|
+
|
|
175
|
+
# Step 6: Final scan
|
|
176
|
+
osv-scanner scan -r .
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### When to Scan
|
|
180
|
+
|
|
181
|
+
Run `osv-scanner` in these situations:
|
|
182
|
+
|
|
183
|
+
- ✅ Before installing ANY new package
|
|
184
|
+
- ✅ Before updating existing packages
|
|
185
|
+
- ✅ Before accepting dependency changes from others
|
|
186
|
+
- ✅ Periodically on the entire project (weekly recommended)
|
|
187
|
+
- ✅ Before deploying to production
|
|
188
|
+
- ✅ When investigating security concerns
|
|
189
|
+
|
|
190
|
+
### Critical Rules
|
|
191
|
+
|
|
192
|
+
1. **NEVER bypass osv-scanner** - This is a security requirement, not a suggestion
|
|
193
|
+
2. **NEVER install packages without scanning first** - No exceptions
|
|
194
|
+
3. **NEVER ignore osv-scanner warnings** - Always report vulnerabilities to the user
|
|
195
|
+
4. **ALWAYS rescan after installation** - Verify the installed state is secure
|
|
196
|
+
5. **ALWAYS generate requirements.txt if missing** - Needed for accurate vulnerability scanning
|
|
197
|
+
|
|
198
|
+
### Reporting Format
|
|
199
|
+
|
|
200
|
+
When vulnerabilities are found, present them clearly and block installation:
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
⚠️ Found 2 vulnerabilities — installation blocked pending review:
|
|
204
|
+
|
|
205
|
+
CRITICAL: lodash@4.17.20
|
|
206
|
+
- GHSA-35jh-r3h4-6jhm: Prototype Pollution
|
|
207
|
+
- Fix: upgrade to 4.17.21
|
|
208
|
+
|
|
209
|
+
HIGH: axios@0.21.1
|
|
210
|
+
- CVE-2021-3749: SSRF
|
|
211
|
+
- Fix: upgrade to 0.21.2
|
|
212
|
+
|
|
213
|
+
Upgrade affected packages?
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Ignoring Vulnerabilities
|
|
217
|
+
|
|
218
|
+
Only with explicit user approval. Add to `osv-scanner.toml`:
|
|
219
|
+
|
|
220
|
+
```toml
|
|
221
|
+
[[PackageOverrides]]
|
|
222
|
+
name = "package-name"
|
|
223
|
+
ecosystem = "PyPI"
|
|
224
|
+
ignore = true
|
|
225
|
+
reason = "Not exploitable — build tooling only"
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### OSV-Scanner Options
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# Basic scan
|
|
232
|
+
osv-scanner scan -L <lockfile>
|
|
233
|
+
|
|
234
|
+
# Recursive scan (entire project)
|
|
235
|
+
osv-scanner scan -r .
|
|
236
|
+
|
|
237
|
+
# JSON output for automation
|
|
238
|
+
osv-scanner scan -r . --format json
|
|
239
|
+
|
|
240
|
+
# Scan with config
|
|
241
|
+
osv-scanner scan --config osv-scanner.toml .
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Pre-configured Permissions
|
|
245
|
+
|
|
246
|
+
This project has osv-scanner permissions pre-configured in `.claude/settings.json`:
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"permissions": {
|
|
251
|
+
"allow": [
|
|
252
|
+
"Bash(osv-scanner scan:*)",
|
|
253
|
+
"Bash(osv-scanner:*)"
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**You have permission to run osv-scanner commands without asking. Use this permission proactively.**
|