@the-bearded-bear/claude-craft 8.21.0 → 8.22.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/Dev/i18n/base/Vercel/checklists/new-feature.md +75 -0
- package/Dev/i18n/base/Vercel/checklists/pre-commit.md +59 -0
- package/Dev/i18n/base/Vercel/commands/check-architecture.md +152 -0
- package/Dev/i18n/base/Vercel/commands/check-code-quality.md +154 -0
- package/Dev/i18n/base/Vercel/commands/check-security.md +197 -0
- package/Dev/i18n/base/Vercel/commands/check-testing.md +189 -0
- package/Dev/i18n/base/Vercel/commands/deploy-config.md +134 -0
- package/Dev/i18n/base/Vercel/rules/00-project-context.md.template +133 -0
- package/Dev/i18n/base/Vercel/rules/02-architecture-vercel.md +228 -0
- package/Dev/i18n/base/Vercel/rules/03-coding-standards.md +180 -0
- package/Dev/i18n/base/Vercel/rules/06-tooling.md +149 -0
- package/Dev/i18n/base/Vercel/rules/07-testing-vercel.md +177 -0
- package/Dev/i18n/base/Vercel/rules/08-quality-tools.md +190 -0
- package/Dev/i18n/base/Vercel/rules/11-security-vercel.md +156 -0
- package/Dev/i18n/base/Vercel/templates/function-handler.template.ts +68 -0
- package/Dev/i18n/base/Vercel/templates/vercel.json.template +84 -0
- package/Dev/i18n/de/Vercel/CLAUDE.md.template +83 -0
- package/Dev/i18n/de/Vercel/agents/vercel-reviewer.md +841 -0
- package/Dev/i18n/de/Vercel/commands/check-compliance.md +281 -0
- package/Dev/i18n/en/Vercel/CLAUDE.md.template +83 -0
- package/Dev/i18n/en/Vercel/agents/vercel-reviewer.md +821 -0
- package/Dev/i18n/en/Vercel/commands/check-compliance.md +281 -0
- package/Dev/i18n/es/Vercel/CLAUDE.md.template +83 -0
- package/Dev/i18n/es/Vercel/agents/vercel-reviewer.md +832 -0
- package/Dev/i18n/es/Vercel/commands/check-compliance.md +280 -0
- package/Dev/i18n/fr/Vercel/CLAUDE.md.template +83 -0
- package/Dev/i18n/fr/Vercel/agents/vercel-reviewer.md +861 -0
- package/Dev/i18n/fr/Vercel/commands/check-compliance.md +280 -0
- package/Dev/i18n/pt/Vercel/CLAUDE.md.template +83 -0
- package/Dev/i18n/pt/Vercel/agents/vercel-reviewer.md +827 -0
- package/Dev/i18n/pt/Vercel/commands/check-compliance.md +281 -0
- package/Dev/scripts/install-vercel-rules.sh +185 -0
- package/README.md +4 -3
- package/bundles/cursor/.cursorrules +6 -2
- package/bundles/windsurf/.windsurfrules +6 -2
- package/cli/lib/tech-registry.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Vercel New Feature Checklist
|
|
2
|
+
|
|
3
|
+
> Covers adding a new Serverless Function, Cron Job, or platform-level config change. For the framework running on top of Vercel (Next.js, etc.), see that stack's own new-feature checklist — this covers **only** the Vercel-platform surface.
|
|
4
|
+
|
|
5
|
+
## Before Starting
|
|
6
|
+
|
|
7
|
+
- [ ] **Requirements clear** - expected behavior and acceptance criteria defined
|
|
8
|
+
- [ ] **Project shape identified** - static+rewrites / Serverless Functions / ISR-enabled / Cron+Scheduled (see `02-architecture-vercel.md`)
|
|
9
|
+
- [ ] **Ownership checked** - if a claude-craft framework stack already owns routing/caching for this concern, defer to it rather than adding a competing `vercel.json` entry (see the decision tree in `02-architecture-vercel.md`)
|
|
10
|
+
|
|
11
|
+
## Runtime Decision
|
|
12
|
+
|
|
13
|
+
- [ ] **Node.js runtime (Fluid Compute) chosen by default** - no explicit `runtime` export needed
|
|
14
|
+
- [ ] **Edge Runtime only chosen for an explicit, justified reason** - documented in a code comment at the top of the handler (e.g. genuine sub-Node-cold-start geo-routing need); never chosen by default or "for consistency" with older code
|
|
15
|
+
- [ ] **If migrating a legacy Edge handler**, treated as a migration-audit task with its own verification pass, not copied as a template for new code
|
|
16
|
+
|
|
17
|
+
## Caching Decision
|
|
18
|
+
|
|
19
|
+
- [ ] **ISR/cache-header need identified** - does this route need periodic regeneration, or is a static response sufficient?
|
|
20
|
+
- [ ] **If ISR is needed and a framework stack owns the route** - configured via that framework's own primitive, not hand-rolled `Cache-Control` headers in `vercel.json`
|
|
21
|
+
- [ ] **If no framework owns the route** - any manual revalidation is implemented as plain HTTP caching via `vercel.json` `headers`, and documented as such (not called "ISR" — that term is reserved for the framework-level primitive)
|
|
22
|
+
|
|
23
|
+
## Storage Decision
|
|
24
|
+
|
|
25
|
+
- [ ] **Provider chosen deliberately**: Vercel Blob (native, for file/object storage) vs. a Marketplace integration (Neon for Postgres, Upstash for KV/Redis) - never `@vercel/kv` or `@vercel/postgres` (deprecated native packages)
|
|
26
|
+
- [ ] **Connection/credentials sourced from the Marketplace integration's env vars**, not hardcoded or copied from a personal account
|
|
27
|
+
|
|
28
|
+
## Cron Feature (if applicable)
|
|
29
|
+
|
|
30
|
+
- [ ] **`crons` entry added to `vercel.json`** with a valid 5-field UTC schedule
|
|
31
|
+
- [ ] **Plan's minimum interval and cron cap checked** before committing to a sub-hourly schedule
|
|
32
|
+
- [ ] **Secret-guard implemented** in the handler (`Authorization: Bearer ${CRON_SECRET}`), see `templates/function-handler.template.ts`
|
|
33
|
+
|
|
34
|
+
## Implementation
|
|
35
|
+
|
|
36
|
+
- [ ] **Handler created** under `api/` (or the project's existing convention), one default export per file
|
|
37
|
+
- [ ] **Env var validation guard added** at the top of the handler for any newly required variable
|
|
38
|
+
- [ ] **`vercel.json` updated** with only the sections the new feature actually needs (`functions`, `crons`, `headers`) - no invented `regions`/`maxDuration`/`memory` values (YAGNI, rule 05)
|
|
39
|
+
- [ ] **No secret hardcoded** - read from `process.env` only
|
|
40
|
+
|
|
41
|
+
## Testing
|
|
42
|
+
|
|
43
|
+
### Unit Tests
|
|
44
|
+
|
|
45
|
+
- [ ] **Handler tested directly** by constructing a `Request` and asserting on the `Response` (or mocking the minimal `VercelRequest`/`VercelResponse` subset for legacy handlers)
|
|
46
|
+
- [ ] **Method-not-allowed and malformed-input branches covered**
|
|
47
|
+
- [ ] **Handler logic coverage >= 85%**
|
|
48
|
+
|
|
49
|
+
### Cron Tests (if applicable)
|
|
50
|
+
|
|
51
|
+
- [ ] **Secret-guard tested at 100%**: missing header, wrong secret, and correct secret — all three branches
|
|
52
|
+
|
|
53
|
+
### Integration
|
|
54
|
+
|
|
55
|
+
- [ ] **`vercel dev` smoke test** exercises the new route's `vercel.json` behavior (headers/rewrites/redirects), where applicable
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
- [ ] **`.env.example` updated** if a new env var was introduced
|
|
60
|
+
- [ ] **`vercel.json` changes reviewed like code** - diffed and explained in the PR description, not silently regenerated
|
|
61
|
+
|
|
62
|
+
## Final Checks
|
|
63
|
+
|
|
64
|
+
- [ ] **Lint passes** - `npx eslint .`
|
|
65
|
+
- [ ] **Types pass** - `tsc --noEmit`
|
|
66
|
+
- [ ] **Tests pass** - `npx vitest run`
|
|
67
|
+
- [ ] **`vercel.json` validated** - `npm run lint:vercel-config`
|
|
68
|
+
- [ ] **`vercel build`** succeeds locally before pushing
|
|
69
|
+
|
|
70
|
+
## Pull Request
|
|
71
|
+
|
|
72
|
+
- [ ] **Descriptive title**
|
|
73
|
+
- [ ] **Linked to issue/ticket**
|
|
74
|
+
- [ ] **Any new deprecated-package or Edge Runtime usage explicitly justified** in the description
|
|
75
|
+
- [ ] **Reviewers assigned**
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Vercel Pre-Commit Checklist
|
|
2
|
+
|
|
3
|
+
> Covers the platform-specific surface only (`vercel.json`, `api/**`, `middleware.ts`). For the framework running on top of Vercel (Next.js, etc.), see that stack's own pre-commit checklist.
|
|
4
|
+
|
|
5
|
+
## Quick Checks
|
|
6
|
+
|
|
7
|
+
Run before every commit:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx eslint . && tsc --noEmit && npx vitest run && npm run lint:vercel-config
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Checklist
|
|
14
|
+
|
|
15
|
+
### `vercel.json`
|
|
16
|
+
|
|
17
|
+
- [ ] **Validated against the platform schema** - `npx ajv validate -s schemas/vercel.schema.json -d vercel.json --strict=false`
|
|
18
|
+
- [ ] **No key duplicated from a framework's own config** - check the decision tree in `02-architecture-vercel.md` before adding `headers`/`regions`/`functions`
|
|
19
|
+
- [ ] **No invented `regions` or `functions.maxDuration`/`memory` value** - every non-default value has a concrete, documented reason (YAGNI, rule 05)
|
|
20
|
+
- [ ] **Existing `vercel.json` never silently overwritten** - a regenerated file was diffed and confirmed against the previous version, not blindly replaced
|
|
21
|
+
|
|
22
|
+
### Handler Code
|
|
23
|
+
|
|
24
|
+
- [ ] **No secrets in handler code** - all secrets read from `process.env`, none hardcoded
|
|
25
|
+
- [ ] **Env vars documented in `.env.example`** - every `process.env.X` referenced by a handler has a matching (empty/placeholder) entry
|
|
26
|
+
- [ ] **Env var validation guard present** for any handler with a required var (see `templates/function-handler.template.ts`)
|
|
27
|
+
- [ ] **No `console.log`** left in (warn/error only)
|
|
28
|
+
|
|
29
|
+
### Cron Endpoints
|
|
30
|
+
|
|
31
|
+
- [ ] **Secret-guard present** on every handler registered under `vercel.json`'s `crons` section - rejects requests missing or mismatching `Authorization: Bearer ${CRON_SECRET}`
|
|
32
|
+
- [ ] **Guard is not the only line of defense** - path is not assumed to be secret/obscure
|
|
33
|
+
|
|
34
|
+
### Deprecated Patterns
|
|
35
|
+
|
|
36
|
+
- [ ] **No new `@vercel/kv` or `@vercel/postgres` import** - these native storage packages are deprecated; use Vercel Blob (native) or the Marketplace integrations (Neon for Postgres, Upstash for KV/Redis) instead
|
|
37
|
+
- [ ] **No new `runtime: 'edge'` declaration** without an explicit migration comment - Edge Runtime is deprecated in favor of Fluid Compute; a legacy handler being touched must carry a comment explaining why it still targets Edge (see the migration note in `templates/function-handler.template.ts`)
|
|
38
|
+
|
|
39
|
+
### Testing
|
|
40
|
+
|
|
41
|
+
- [ ] **Tests pass** - `npx vitest run`
|
|
42
|
+
- [ ] **New handler has tests**
|
|
43
|
+
- [ ] **Coverage maintained** (>= 85% handler logic, 100% secret-guard branches)
|
|
44
|
+
|
|
45
|
+
## Commands
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Full pre-commit check
|
|
49
|
+
npx eslint . && tsc --noEmit && npx vitest run
|
|
50
|
+
|
|
51
|
+
# Validate vercel.json against the platform schema
|
|
52
|
+
npx ajv validate -s schemas/vercel.schema.json -d vercel.json --strict=false
|
|
53
|
+
|
|
54
|
+
# Check for deprecated storage packages
|
|
55
|
+
grep -rn "@vercel/kv\|@vercel/postgres" api/ package.json
|
|
56
|
+
|
|
57
|
+
# Check for un-annotated Edge Runtime declarations
|
|
58
|
+
grep -rn "runtime.*=.*['\"]edge['\"]" api/ middleware.ts 2>/dev/null
|
|
59
|
+
```
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Audit Vercel deployment configuration structure and project shape classification
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Vercel Architecture Audit
|
|
6
|
+
|
|
7
|
+
You are an expert Vercel platform architect. Analyze the project's `vercel.json` and deployment configuration for correctness and maintainability, strictly within the deployment-platform scope of this stack.
|
|
8
|
+
|
|
9
|
+
> Vercel is a **deployment platform**, not a framework. This command covers **only** `vercel.json`, Serverless Functions, ISR, Cron Jobs, Storage, and env/Preview Deployment config. For the framework's own routing/rendering/data-fetching conventions (e.g. Next.js App Router), use that framework's own `check-architecture` command instead.
|
|
10
|
+
|
|
11
|
+
## MISSION
|
|
12
|
+
|
|
13
|
+
Validate `vercel.json` schema correctness, classify the project's deployment shape, and flag configuration that duplicates or conflicts with a framework's native Vercel adapter.
|
|
14
|
+
|
|
15
|
+
## Plan Mode
|
|
16
|
+
|
|
17
|
+
> Plan mode is activated automatically when the scope spans multiple modules or requires cross-cutting investigation.
|
|
18
|
+
|
|
19
|
+
## AUDIT AREAS
|
|
20
|
+
|
|
21
|
+
### 1. Project Shape Detection
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
[ ] Identify shape: static+rewrites | Functions-backed | ISR-enabled | Cron+scheduled (or a combination)
|
|
25
|
+
[ ] api/ directory present and mapped to Serverless Functions — Functions-backed shape
|
|
26
|
+
[ ] revalidate / `Cache-Control: s-maxage` used on responses — ISR-enabled shape
|
|
27
|
+
[ ] crons[] declared in vercel.json — Cron+scheduled shape
|
|
28
|
+
[ ] Purely static output with rewrites/redirects only — static+rewrites shape
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. vercel.json Schema Validity
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
[ ] Valid JSON, conforms to the documented vercel.json schema (no unknown top-level keys)
|
|
35
|
+
[ ] "$schema" reference present (editor validation) — optional but recommended
|
|
36
|
+
[ ] No deprecated keys (e.g. legacy `routes` mixed with modern `rewrites`/`redirects`/`headers`)
|
|
37
|
+
[ ] version field absent or set to 2 (legacy v1 config not used)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3. rewrites / redirects / headers Correctness
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
[ ] rewrites[] source patterns do not shadow static files unintentionally
|
|
44
|
+
[ ] redirects[] use explicit `permanent: true|false` (never left implicit)
|
|
45
|
+
[ ] headers[] scoped with precise `source` globs, not a blanket "/(.*)" for sensitive headers
|
|
46
|
+
[ ] No conflicting rules where two rewrites/redirects match the same source with different destinations
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 4. regions / functions Configuration
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
[ ] functions{} block scopes memory/duration per-function-glob, not globally overbroad
|
|
53
|
+
[ ] regions[] declared explicitly if data locality matters (default is auto/global)
|
|
54
|
+
[ ] maxDuration set deliberately per function tier (not left at platform default for long-running jobs)
|
|
55
|
+
[ ] Node.js runtime used by default; Edge Runtime only present with an explicit migration flag/comment
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 5. crons[] Configuration
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
[ ] Each cron entry has a valid path and schedule (standard cron syntax)
|
|
62
|
+
[ ] Cron target endpoint exists under api/ and is not also publicly routable without auth (cross-check with check-security)
|
|
63
|
+
[ ] No duplicate schedules pointing at the same path
|
|
64
|
+
[ ] Cron frequency respects plan limits (documented, not assumed)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 6. Framework Adapter Conflict Detection
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
[ ] No vercel.json rewrites duplicating a Next.js/Nuxt/SvelteKit adapter's own routing output
|
|
71
|
+
[ ] No manual functions{} overrides fighting the framework's auto-detected build output
|
|
72
|
+
[ ] next.config.js / nuxt.config.ts (or equivalent) is the source of truth for framework routing; vercel.json only for platform-level concerns
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## OUTPUT FORMAT
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
══════════════════════════════════════════════════════════════
|
|
79
|
+
VERCEL ARCHITECTURE AUDIT
|
|
80
|
+
══════════════════════════════════════════════════════════════
|
|
81
|
+
|
|
82
|
+
📊 ARCHITECTURE SCORE: XX/100
|
|
83
|
+
|
|
84
|
+
🧭 PROJECT SHAPE
|
|
85
|
+
──────────────────────────────────────────────────────────────
|
|
86
|
+
Detected Shape: [static+rewrites | Functions-backed | ISR-enabled | Cron+scheduled | combination]
|
|
87
|
+
Status: ✅ Consistent with conventions | ⚠️ Partial drift | ❌ Non-conforming
|
|
88
|
+
|
|
89
|
+
Issues:
|
|
90
|
+
- api/ directory present but no corresponding functions{} scoping in vercel.json
|
|
91
|
+
→ Add explicit memory/duration bounds per function glob
|
|
92
|
+
|
|
93
|
+
⚙️ VERCEL.JSON SCHEMA
|
|
94
|
+
──────────────────────────────────────────────────────────────
|
|
95
|
+
Status: ✅ Valid | ⚠️ Needs cleanup | ❌ Invalid
|
|
96
|
+
|
|
97
|
+
Issues:
|
|
98
|
+
- legacy `routes` array present alongside `rewrites`
|
|
99
|
+
→ Migrate fully to `rewrites`/`redirects`/`headers`, remove `routes`
|
|
100
|
+
|
|
101
|
+
🔀 REWRITES / REDIRECTS / HEADERS
|
|
102
|
+
──────────────────────────────────────────────────────────────
|
|
103
|
+
Rules found: X
|
|
104
|
+
Conflicting rules: X
|
|
105
|
+
|
|
106
|
+
Issues:
|
|
107
|
+
- two redirects match "/blog/:slug" with different destinations
|
|
108
|
+
→ Consolidate into a single unambiguous rule
|
|
109
|
+
|
|
110
|
+
🌎 REGIONS / FUNCTIONS
|
|
111
|
+
──────────────────────────────────────────────────────────────
|
|
112
|
+
Status: ✅ Scoped deliberately | ⚠️ Overbroad | ❌ Missing
|
|
113
|
+
|
|
114
|
+
Issues:
|
|
115
|
+
- functions{} block sets maxDuration: 60 globally via "api/**"
|
|
116
|
+
→ Scope duration per function tier; most handlers need far less
|
|
117
|
+
|
|
118
|
+
⏰ CRON JOBS
|
|
119
|
+
──────────────────────────────────────────────────────────────
|
|
120
|
+
Crons declared: X
|
|
121
|
+
Auth-guarded targets: X/X
|
|
122
|
+
|
|
123
|
+
Issues:
|
|
124
|
+
- crons[] target api/cleanup.ts also reachable as a public route
|
|
125
|
+
→ See check-security for the CRITICAL auth-guard finding
|
|
126
|
+
|
|
127
|
+
🧩 FRAMEWORK ADAPTER CONFLICTS
|
|
128
|
+
──────────────────────────────────────────────────────────────
|
|
129
|
+
Status: ✅ No conflicts | ⚠️ Overlap detected
|
|
130
|
+
|
|
131
|
+
Issues:
|
|
132
|
+
- vercel.json rewrites duplicate Next.js's own output routing
|
|
133
|
+
→ Remove; let the framework's adapter own this concern
|
|
134
|
+
|
|
135
|
+
📋 RECOMMENDATIONS
|
|
136
|
+
──────────────────────────────────────────────────────────────
|
|
137
|
+
Priority 1: [Resolve conflicting rewrite/redirect rules]
|
|
138
|
+
Priority 2: [Scope functions{} bounds per handler]
|
|
139
|
+
Priority 3: [Guard cron endpoints with a secret-header check]
|
|
140
|
+
|
|
141
|
+
══════════════════════════════════════════════════════════════
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## PROCESS
|
|
145
|
+
|
|
146
|
+
1. Parse `vercel.json` and validate against the documented schema
|
|
147
|
+
2. Detect project shape from directory layout (`api/`, cron declarations, revalidate usage)
|
|
148
|
+
3. Validate rewrites/redirects/headers for conflicts and overbroad globs
|
|
149
|
+
4. Review `regions`/`functions` scoping and runtime choice (Node.js default vs legacy Edge Runtime)
|
|
150
|
+
5. Validate `crons[]` entries and cross-check target auth (flag for `check-security`)
|
|
151
|
+
6. Detect configuration that duplicates or conflicts with a framework's native Vercel adapter
|
|
152
|
+
7. Generate architecture report with a score out of 100
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze Vercel Serverless Functions code quality with ESLint, TypeScript, and bundle-size checks
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Vercel Code Quality Audit
|
|
6
|
+
|
|
7
|
+
You are an expert Vercel Functions code quality analyst. Perform comprehensive quality checks on `api/**` handlers and `middleware.ts`, strictly within the deployment-platform scope of this stack.
|
|
8
|
+
|
|
9
|
+
> Vercel is a **deployment platform**, not a framework. This command covers **only** Serverless Function handlers and middleware code quality. For the framework's own component/route code quality (e.g. Next.js pages/components), use that framework's own `check-code-quality` command instead.
|
|
10
|
+
|
|
11
|
+
## MISSION
|
|
12
|
+
|
|
13
|
+
Analyze code quality across `api/` and `middleware.ts` with focus on ESLint rules, TypeScript strictness, handler signature conventions, and bundle-size awareness for Functions.
|
|
14
|
+
|
|
15
|
+
## Plan Mode
|
|
16
|
+
|
|
17
|
+
> Plan mode is activated automatically when the scope spans multiple modules or requires cross-cutting investigation.
|
|
18
|
+
|
|
19
|
+
## QUALITY CHECKS
|
|
20
|
+
|
|
21
|
+
### 1. ESLint Analysis
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx eslint api/ middleware.ts
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Key rules to verify:
|
|
28
|
+
- `@typescript-eslint/no-explicit-any`
|
|
29
|
+
- `@typescript-eslint/no-unused-vars`
|
|
30
|
+
- `no-console` (allow warn/error only — handler logs are visible in platform log drains)
|
|
31
|
+
- `no-restricted-imports` (guards against importing deprecated `@vercel/kv`/`@vercel/postgres`)
|
|
32
|
+
|
|
33
|
+
### 2. TypeScript Analysis
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
tsc --noEmit --strict
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Verify:
|
|
40
|
+
- No implicit `any` in handler signatures
|
|
41
|
+
- `@vercel/node` types (`VercelRequest`, `VercelResponse`) or Web-standard `Request`/`Response` used consistently, not mixed
|
|
42
|
+
- `strict: true` set in `tsconfig.json`
|
|
43
|
+
|
|
44
|
+
### 3. Handler Signature Conventions
|
|
45
|
+
|
|
46
|
+
Check every file under `api/`:
|
|
47
|
+
```
|
|
48
|
+
[ ] Request and response are explicitly typed (VercelRequest/VercelResponse or Request/Response)
|
|
49
|
+
[ ] Required env vars validated at the TOP of the handler, before any business logic runs
|
|
50
|
+
[ ] Handler returns early (guard clauses) on invalid method/missing env/invalid payload
|
|
51
|
+
[ ] No env var read deep inside nested logic — read once at the top, pass down
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 4. Bundle-Size Awareness (Functions)
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx @vercel/ncc build api/heavy-handler.ts --out /tmp-bundle-check 2>&1 | tail -20
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Flag:
|
|
61
|
+
- Heavy dependencies imported at the top of a handler file when only used in one rare branch (prefer dynamic `import()` inside the branch)
|
|
62
|
+
- Full SDK imports (`import * as aws from 'aws-sdk'`) instead of scoped submodule imports
|
|
63
|
+
- Node built-ins bundled unnecessarily (check `externals` config for `@vercel/ncc`/build output)
|
|
64
|
+
|
|
65
|
+
### 5. Middleware Quality
|
|
66
|
+
|
|
67
|
+
Check `middleware.ts`:
|
|
68
|
+
```
|
|
69
|
+
[ ] matcher config scoped precisely (not a blanket "/(.*)" unless deliberate)
|
|
70
|
+
[ ] No heavy synchronous work in middleware (runs on every matched request)
|
|
71
|
+
[ ] No dynamic imports of Node-only packages incompatible with the middleware runtime
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## OUTPUT FORMAT
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
══════════════════════════════════════════════════════════════
|
|
78
|
+
VERCEL CODE QUALITY REPORT
|
|
79
|
+
══════════════════════════════════════════════════════════════
|
|
80
|
+
|
|
81
|
+
📊 QUALITY SCORE: XX/100
|
|
82
|
+
|
|
83
|
+
🔍 ESLINT ANALYSIS
|
|
84
|
+
──────────────────────────────────────────────────────────────
|
|
85
|
+
Errors: X
|
|
86
|
+
Warnings: X
|
|
87
|
+
Files with issues: X
|
|
88
|
+
|
|
89
|
+
Top Issues:
|
|
90
|
+
1. @typescript-eslint/no-explicit-any (3 occurrences)
|
|
91
|
+
- api/webhook.ts:14
|
|
92
|
+
|
|
93
|
+
2. no-restricted-imports (1 occurrence)
|
|
94
|
+
- api/cache.ts:2 — `import { kv } from '@vercel/kv'`
|
|
95
|
+
→ Deprecated; migrate to Marketplace Upstash/Neon integration
|
|
96
|
+
|
|
97
|
+
📝 TYPESCRIPT CHECK
|
|
98
|
+
──────────────────────────────────────────────────────────────
|
|
99
|
+
Status: ✅ PASS | ❌ FAIL
|
|
100
|
+
Type Errors: X
|
|
101
|
+
|
|
102
|
+
Issues:
|
|
103
|
+
- api/webhook.ts:8
|
|
104
|
+
Parameter 'req' implicitly has an 'any' type
|
|
105
|
+
|
|
106
|
+
🎯 HANDLER SIGNATURE CONVENTIONS
|
|
107
|
+
──────────────────────────────────────────────────────────────
|
|
108
|
+
Handlers reviewed: X
|
|
109
|
+
Env validated at top: X/X
|
|
110
|
+
Explicitly typed: X/X
|
|
111
|
+
|
|
112
|
+
Issues:
|
|
113
|
+
- api/orders.ts: process.env.DATABASE_URL read inside a nested try block on line 40
|
|
114
|
+
→ Validate and read once at the top of the handler; fail fast if missing
|
|
115
|
+
|
|
116
|
+
📦 BUNDLE-SIZE AWARENESS
|
|
117
|
+
──────────────────────────────────────────────────────────────
|
|
118
|
+
Handlers checked: X
|
|
119
|
+
Heavy imports flagged: X
|
|
120
|
+
|
|
121
|
+
Issues:
|
|
122
|
+
- api/report.ts imports the full 'aws-sdk' package for one S3 call
|
|
123
|
+
→ Use '@aws-sdk/client-s3' scoped submodule import instead
|
|
124
|
+
|
|
125
|
+
⚙️ MIDDLEWARE QUALITY
|
|
126
|
+
──────────────────────────────────────────────────────────────
|
|
127
|
+
Status: ✅ Scoped | ⚠️ Overbroad matcher | ❌ Blocking work found
|
|
128
|
+
|
|
129
|
+
Issues:
|
|
130
|
+
- middleware.ts matcher is "/(.*)" — runs on every single request
|
|
131
|
+
→ Scope matcher to the specific paths that need it
|
|
132
|
+
|
|
133
|
+
📋 ACTION ITEMS
|
|
134
|
+
──────────────────────────────────────────────────────────────
|
|
135
|
+
1. [CRITICAL] Migrate off deprecated @vercel/kv / @vercel/postgres imports
|
|
136
|
+
2. [HIGH] Fix TypeScript errors in handler signatures
|
|
137
|
+
3. [MEDIUM] Validate env vars at handler top, not nested
|
|
138
|
+
4. [LOW] Trim heavy imports flagged for bundle size
|
|
139
|
+
|
|
140
|
+
══════════════════════════════════════════════════════════════
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## COMMANDS TO RUN
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Full quality check
|
|
147
|
+
npx eslint api/ middleware.ts && tsc --noEmit --strict
|
|
148
|
+
|
|
149
|
+
# With auto-fix
|
|
150
|
+
npx eslint api/ middleware.ts --fix
|
|
151
|
+
|
|
152
|
+
# Deprecated storage package scan
|
|
153
|
+
grep -rn "@vercel/kv\|@vercel/postgres" api/
|
|
154
|
+
```
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Security audit for Vercel deployment configuration (env vars, Cron auth, headers, Marketplace credentials)
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Vercel Security Audit
|
|
6
|
+
|
|
7
|
+
You are an expert Vercel platform security auditor. Perform a comprehensive security analysis of the deployment configuration, strictly within the deployment-platform scope of this stack.
|
|
8
|
+
|
|
9
|
+
> Vercel is a **deployment platform**, not a framework. This command covers **only** env var handling, Cron endpoint auth, `vercel.json` headers, Storage/Marketplace credentials, and Function runtime choice. For framework-level auth/session/input-validation concerns, use that framework's own `check-security` command instead.
|
|
10
|
+
|
|
11
|
+
## MISSION
|
|
12
|
+
|
|
13
|
+
Identify security vulnerabilities specific to Vercel's deployment model, mapped to the relevant OWASP Top 10:2025 categories (see `@.claude/rules/11-security.md`).
|
|
14
|
+
|
|
15
|
+
## Plan Mode
|
|
16
|
+
|
|
17
|
+
> Plan mode is activated automatically when the scope spans multiple modules or requires cross-cutting investigation.
|
|
18
|
+
|
|
19
|
+
## SECURITY CHECKS
|
|
20
|
+
|
|
21
|
+
### 1. Env Var Handling (OWASP #2 Cryptographic Failures, #5 Security Misconfiguration)
|
|
22
|
+
|
|
23
|
+
Scan for:
|
|
24
|
+
- Secrets logged via `console.log(process.env...)` in any `api/` handler
|
|
25
|
+
- `.env.local` present in `.gitignore`
|
|
26
|
+
- Preview vs Production env var scoping — production secrets not exposed to Preview Deployments unless deliberate
|
|
27
|
+
- Client-bundled vars (`NEXT_PUBLIC_*` or equivalent) that actually hold a secret
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
grep -rn "console.log(process.env" api/
|
|
31
|
+
grep -n "^\.env" .gitignore || echo "MISSING: .env.local not gitignored"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. Cron Endpoint Auth (OWASP #1 Broken Access Control)
|
|
35
|
+
|
|
36
|
+
Check every path referenced in `vercel.json` `crons[]`:
|
|
37
|
+
- The endpoint validates a shared secret (e.g. `Authorization: Bearer $CRON_SECRET` or Vercel's `x-vercel-cron` signature) before executing
|
|
38
|
+
- The endpoint is not otherwise reachable as a normal public route without that same guard
|
|
39
|
+
- CRITICAL if a cron target performs a privileged/destructive action with **no** auth check at all
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
grep -A3 '"crons"' vercel.json
|
|
43
|
+
grep -n "CRON_SECRET\|x-vercel-cron" api/**/*.ts
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 3. CORS / CSP Headers in vercel.json (OWASP #1, #5)
|
|
47
|
+
|
|
48
|
+
Check `headers[]` in `vercel.json`:
|
|
49
|
+
- `Access-Control-Allow-Origin` is not a bare `*` on any route handling authenticated requests
|
|
50
|
+
- CSP (`Content-Security-Policy`) present and restrictive (`script-src`, `frame-ancestors`, `base-uri`)
|
|
51
|
+
- `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`, HSTS present
|
|
52
|
+
|
|
53
|
+
### 4. Marketplace Credential Handling (OWASP #6 Supply Chain, #2 Cryptographic Failures)
|
|
54
|
+
|
|
55
|
+
For Storage via Marketplace (Neon/Upstash, etc.):
|
|
56
|
+
- Connection strings/API keys stored only as env vars, never committed
|
|
57
|
+
- Marketplace integration scoped to least-privilege role (read-only where writes aren't needed)
|
|
58
|
+
- Rotate-on-compromise process documented for Marketplace-issued credentials
|
|
59
|
+
|
|
60
|
+
### 5. Deprecated Storage Package Migration Flags
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
grep -rn "@vercel/kv\|@vercel/postgres" package.json api/
|
|
64
|
+
```
|
|
65
|
+
Flag as a **migration item** (not a live vulnerability, but unsupported surface):
|
|
66
|
+
- `@vercel/kv` → migrate to Upstash via Marketplace
|
|
67
|
+
- `@vercel/postgres` → migrate to Neon (or another Marketplace Postgres) via Marketplace
|
|
68
|
+
|
|
69
|
+
### 6. Legacy Edge Runtime Usage
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
grep -rn "runtime.*=.*['\"]edge['\"]\|export const runtime = 'edge'" api/ middleware.ts
|
|
73
|
+
```
|
|
74
|
+
Flag as a **migration item**: Edge Runtime is deprecated. Recommend migrating to the Node.js runtime default (Fluid Compute) — never recommend adopting Edge Runtime in new code.
|
|
75
|
+
|
|
76
|
+
### 7. Dependency Security
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm audit --omit=dev --audit-level=moderate
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## OUTPUT FORMAT
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
══════════════════════════════════════════════════════════════
|
|
86
|
+
VERCEL SECURITY AUDIT
|
|
87
|
+
══════════════════════════════════════════════════════════════
|
|
88
|
+
|
|
89
|
+
📊 SECURITY SCORE: XX/100
|
|
90
|
+
Risk Level: 🟢 LOW | 🟡 MEDIUM | 🔴 HIGH | ⚫ CRITICAL
|
|
91
|
+
|
|
92
|
+
🔑 ENV VAR HANDLING (OWASP #2/#5)
|
|
93
|
+
──────────────────────────────────────────────────────────────
|
|
94
|
+
Status: ✅ SECURE | ⚠️ RISKS FOUND | ❌ VULNERABLE
|
|
95
|
+
|
|
96
|
+
Findings:
|
|
97
|
+
[🔴 HIGH] Secret value logged to stdout
|
|
98
|
+
File: api/webhook.ts:22
|
|
99
|
+
Code: console.log(process.env.STRIPE_SECRET_KEY)
|
|
100
|
+
Fix: Remove; never log secret env vars, even at debug level
|
|
101
|
+
|
|
102
|
+
⏰ CRON ENDPOINT AUTH (OWASP #1)
|
|
103
|
+
──────────────────────────────────────────────────────────────
|
|
104
|
+
Status: ✅ GUARDED | ❌ UNGUARDED
|
|
105
|
+
|
|
106
|
+
Findings:
|
|
107
|
+
[⚫ CRITICAL] Cron target has no auth guard
|
|
108
|
+
File: api/cron/purge-db.ts
|
|
109
|
+
Fix: Validate `Authorization: Bearer ${CRON_SECRET}` (or Vercel's cron signature header) before executing; return 401 otherwise
|
|
110
|
+
|
|
111
|
+
🌐 CORS / CSP HEADERS
|
|
112
|
+
──────────────────────────────────────────────────────────────
|
|
113
|
+
Status: ✅ CONSISTENT | ⚠️ PARTIAL | ❌ MISSING
|
|
114
|
+
|
|
115
|
+
Findings:
|
|
116
|
+
[🟡 MEDIUM] Access-Control-Allow-Origin: * on an authenticated API route
|
|
117
|
+
File: vercel.json
|
|
118
|
+
Fix: Restrict to explicit allowed origins
|
|
119
|
+
|
|
120
|
+
🔐 MARKETPLACE CREDENTIALS (OWASP #6/#2)
|
|
121
|
+
──────────────────────────────────────────────────────────────
|
|
122
|
+
Status: ✅ LEAST PRIVILEGE | ⚠️ OVERSCOPED
|
|
123
|
+
|
|
124
|
+
Findings:
|
|
125
|
+
[🟡 MEDIUM] Neon connection string uses an admin-role credential for read-only queries
|
|
126
|
+
Fix: Issue a scoped read-only role via the Marketplace integration
|
|
127
|
+
|
|
128
|
+
📦 DEPRECATED STORAGE PACKAGES (migration items)
|
|
129
|
+
──────────────────────────────────────────────────────────────
|
|
130
|
+
[ℹ️ MIGRATION] @vercel/kv imported in api/cache.ts
|
|
131
|
+
Fix: Migrate to Upstash via Vercel Marketplace
|
|
132
|
+
|
|
133
|
+
⚙️ LEGACY EDGE RUNTIME (migration items)
|
|
134
|
+
──────────────────────────────────────────────────────────────
|
|
135
|
+
[ℹ️ MIGRATION] export const runtime = 'edge' in middleware.ts
|
|
136
|
+
Fix: Migrate to the Node.js runtime default (Fluid Compute); Edge Runtime is deprecated
|
|
137
|
+
|
|
138
|
+
📦 DEPENDENCY AUDIT
|
|
139
|
+
──────────────────────────────────────────────────────────────
|
|
140
|
+
Total Dependencies: XX
|
|
141
|
+
Vulnerabilities Found: X
|
|
142
|
+
|
|
143
|
+
[🔴 HIGH] some-package < X.Y.Z
|
|
144
|
+
Fix: npm update some-package
|
|
145
|
+
|
|
146
|
+
📋 ACTION ITEMS
|
|
147
|
+
──────────────────────────────────────────────────────────────
|
|
148
|
+
Priority 1 (CRITICAL):
|
|
149
|
+
- Add auth guard to every unguarded Cron endpoint
|
|
150
|
+
|
|
151
|
+
Priority 2 (HIGH):
|
|
152
|
+
- Remove secret logging from handlers
|
|
153
|
+
- Update vulnerable dependencies
|
|
154
|
+
|
|
155
|
+
Priority 3 (MEDIUM):
|
|
156
|
+
- Restrict CORS/CSP headers
|
|
157
|
+
- Scope Marketplace credentials to least privilege
|
|
158
|
+
|
|
159
|
+
Priority 4 (MIGRATION, non-blocking):
|
|
160
|
+
- Migrate off @vercel/kv / @vercel/postgres to Marketplace equivalents
|
|
161
|
+
- Migrate off legacy Edge Runtime to Node.js/Fluid Compute
|
|
162
|
+
|
|
163
|
+
══════════════════════════════════════════════════════════════
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## COMMANDS
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Audit dependencies
|
|
170
|
+
npm audit --omit=dev --audit-level=moderate
|
|
171
|
+
|
|
172
|
+
# Check for secret logging
|
|
173
|
+
grep -rn "console.log(process.env" api/
|
|
174
|
+
|
|
175
|
+
# Check Cron auth guards
|
|
176
|
+
grep -A3 '"crons"' vercel.json
|
|
177
|
+
grep -n "CRON_SECRET\|x-vercel-cron" api/**/*.ts
|
|
178
|
+
|
|
179
|
+
# Scan for deprecated storage packages and legacy Edge Runtime
|
|
180
|
+
grep -rn "@vercel/kv\|@vercel/postgres" package.json api/
|
|
181
|
+
grep -rn "runtime.*=.*['\"]edge['\"]" api/ middleware.ts
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## SECURITY CHECKLIST
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
[ ] No secret env var ever logged (OWASP #2)
|
|
188
|
+
[ ] .env.local gitignored, Preview/Production scoping deliberate (OWASP #5)
|
|
189
|
+
[ ] Every crons[] target validates a shared secret before executing (OWASP #1)
|
|
190
|
+
[ ] No cron target reachable unauthenticated as a public route (OWASP #1)
|
|
191
|
+
[ ] CORS restricted to explicit origins on authenticated routes (OWASP #1)
|
|
192
|
+
[ ] CSP/HSTS/nosniff/frame-ancestors present in vercel.json headers[] (OWASP #5)
|
|
193
|
+
[ ] Marketplace credentials scoped to least privilege (OWASP #6)
|
|
194
|
+
[ ] @vercel/kv / @vercel/postgres usage flagged for Marketplace migration
|
|
195
|
+
[ ] No new code uses Edge Runtime; existing usage flagged for Fluid Compute migration
|
|
196
|
+
[ ] Dependencies audited, no moderate+ vulnerabilities (OWASP #10)
|
|
197
|
+
```
|