claude-dev-kit 2.1.1 → 2.1.2

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.
@@ -246,7 +246,54 @@ Files to update:
246
246
  - Dev commands table (extracted from `package.json` `scripts` or language conventions)
247
247
  - Validation gate commands
248
248
 
249
- ### 5c. Update .claude/settings.json
249
+ ### 5c. Generate CLAUDE.local.md.example
250
+
251
+ If `CLAUDE.local.md.example` does not already exist in the project root, copy `.claude/templates/CLAUDE.local.md.example` (or generate the standard template) so developers know they can create a personal `CLAUDE.local.md`.
252
+
253
+ Also ensure `.gitignore` (or `.git/info/exclude` for projects without a shared `.gitignore`) contains `CLAUDE.local.md`.
254
+
255
+ ### 5d. Scaffold stack-specific rules overrides
256
+
257
+ Check if `.claude/rules/` already exists. If not present, note to the user that the generic rules installed with CDK cover universal patterns. If a stack-specific rules file would add value (e.g., a `db-conventions.md` for Prisma schema practices, or a `components.md` for Next.js component hierarchy), generate it now:
258
+
259
+ **Next.js + Prisma projects** — create `.claude/rules/db-conventions.md`:
260
+ ```markdown
261
+ ---
262
+ globs: "prisma/**,app/generated/**,lib/db*"
263
+ ---
264
+
265
+ # Database Conventions (Prisma)
266
+
267
+ - Schema lives at `prisma/schema.prisma` — all model changes start here
268
+ - Run `bun prisma migrate dev` to generate migrations from schema changes
269
+ - Never edit generated migration files — re-generate if incorrect
270
+ - Use `prisma.model.findFirst` for conflict checks — not `findUnique` on non-unique fields
271
+ - Always call `db.refresh(obj)` / re-query after mutations to return updated state
272
+ - Prisma client is a singleton — import from `lib/db`, never instantiate directly
273
+ - Use `select` / `include` to fetch only the fields the caller needs
274
+ ```
275
+
276
+ **FastAPI + SQLAlchemy projects** — create `.claude/rules/db-conventions.md`:
277
+ ```markdown
278
+ ---
279
+ globs: "app/models/**,app/schemas/**,alembic/**"
280
+ ---
281
+
282
+ # Database Conventions (SQLAlchemy 2.x)
283
+
284
+ - Models at `app/models/<domain>.py` — use `mapped_column` and `Mapped[T]` for all columns
285
+ - Schemas at `app/schemas/<domain>.py` — separate `Create`, `Update`, `Out` Pydantic models
286
+ - Migrations via Alembic — never edit the DB schema directly in production
287
+ - Use `AsyncSession` throughout — never use synchronous session in async endpoints
288
+ - Always `await db.refresh(obj)` after commit to return accurate data to the caller
289
+ - Use SQLAlchemy 2.x `select()` / `insert()` — no raw SQL unless absolutely necessary
290
+ ```
291
+
292
+ **Express.js projects** — create `.claude/rules/db-conventions.md` if an ORM is detected, following the same pattern.
293
+
294
+ Skip this step if stack is `generic` or no database layer was detected.
295
+
296
+ ### 5e. Update .claude/settings.json
250
297
 
251
298
  Read existing settings.json. Preserve the `hooks` section verbatim. Replace only the `permissions.allow` array with:
252
299
 
@@ -294,12 +341,20 @@ Read existing settings.json. Preserve the `hooks` section verbatim. Replace only
294
341
  - `.claude/agents/dev-e2e.md` — Playwright patterns
295
342
  - `CLAUDE.md` — project guide created/updated
296
343
  - `.claude/settings.json` — permissions updated
344
+ - `.claude/rules/code-style.md` — universal code quality rules (all files)
345
+ - `.claude/rules/security.md` — universal security practices (all files)
346
+ - `.claude/rules/api-conventions.md` — HTTP/REST conventions (api/** files, path-scoped)
347
+ - `.claude/rules/testing.md` — test structure and coverage rules (test files, path-scoped)
348
+ - `.claude/rules/db-conventions.md` — database/ORM conventions (stack-specific, if applicable)
349
+ - `CLAUDE.local.md.example` — personal override template (copy to `CLAUDE.local.md`)
297
350
 
298
351
  ### Next Steps
299
- 1. **Review** `CLAUDE.md` and add any project-specific conventions
300
- 2. **Run** `/primer` to verify Claude understands the project
301
- 3. **Plan** your backlog: `/pm:groom` `/pm:size` `/pm:plan-epic`
302
- 4. **Build**: `/dev <issue-number>` to implement your first feature
352
+ 1. **Personal setup**: Copy `CLAUDE.local.md.example` → `CLAUDE.local.md` and fill in your preferences (it's gitignored)
353
+ 2. **Review** `CLAUDE.md` and add any project-specific notes in the Project Notes section
354
+ 3. **Customize rules**: Edit `.claude/rules/*.md` files for project-specific conventions
355
+ 4. **Run** `/primer` to verify Claude understands the project
356
+ 5. **Plan** your backlog: `/pm:groom` → `/pm:size` → `/pm:plan-epic`
357
+ 6. **Build**: `/dev <issue-number>` to implement your first feature
303
358
  ```
304
359
 
305
360
  ---
@@ -0,0 +1,39 @@
1
+ ---
2
+ globs: "src/api/**,app/api/**,src/routes/**,src/controllers/**,app/**/route.ts,app/**/route.tsx"
3
+ ---
4
+
5
+ # API Layer Conventions
6
+
7
+ Routes are thin. They validate input, delegate to services, and return responses. Business logic lives in services.
8
+
9
+ ## Structure
10
+
11
+ - Validate all input at the route boundary (Zod / Pydantic) **before** calling any service function
12
+ - Services raise domain exceptions — routes catch them and translate to HTTP responses
13
+ - Never import DB clients directly in route handlers — use service functions
14
+ - Auth middleware runs before every protected route — never check auth inside services
15
+
16
+ ## Response Shape
17
+
18
+ Always return consistent JSON:
19
+ - **Success**: the resource or `{ "data": ... }` wrapper
20
+ - **Error**: `{ "error": "human-readable message" }` or `{ "error": { "field": "message" } }` for validation
21
+
22
+ ## HTTP Status Codes
23
+
24
+ | Status | When to use |
25
+ |--------|-------------|
26
+ | `200` | Successful GET / PUT / PATCH |
27
+ | `201` | Resource created (POST) |
28
+ | `204` | Success with no body (DELETE) |
29
+ | `400` | Bad input / validation failure |
30
+ | `401` | Not authenticated |
31
+ | `403` | Authenticated but not authorized |
32
+ | `404` | Resource not found |
33
+ | `409` | Conflict (duplicate, slot already taken) |
34
+ | `422` | Valid schema but fails business rules |
35
+ | `500` | Unexpected server error — never expose details |
36
+
37
+ ## Pagination
38
+
39
+ For list endpoints returning potentially large sets: use cursor-based pagination. Return `{ data: [], nextCursor: string | null }`.
@@ -0,0 +1,14 @@
1
+ # Code Style
2
+
3
+ Keep code readable, explicit, and maintainable. These rules apply to all files in this project.
4
+
5
+ - Files stay under 500 lines — split into smaller modules when exceeded
6
+ - Functions do one thing and are named for what they do, not how they do it
7
+ - Prefer explicit over implicit — avoid magic strings, side-effect-heavy imports, or clever tricks
8
+ - No commented-out code in commits
9
+ - No `any` types in TypeScript — use `z.infer<typeof Schema>`, Prisma/Drizzle generated types, or `unknown`
10
+ - Environment variables must go through a typed config module — never use `process.env.X` inline across the codebase
11
+ - Hard-code nothing that belongs in config: URLs, timeouts, limits, feature flags
12
+ - Separate concerns: keep route/handler, service/use-case, and data-access layers distinct
13
+ - External dependencies (DB, API clients, queues) must be injectable for testability
14
+ - Handle all error paths explicitly — no silent failures or swallowed exceptions
@@ -0,0 +1,14 @@
1
+ # Security
2
+
3
+ These rules apply to all files. When in doubt, err on the side of caution.
4
+
5
+ - Never commit secrets, API keys, tokens, or credentials — use environment variables and `.gitignore`
6
+ - Validate **all** input at system boundaries (API routes, CLI args, file uploads, webhooks) before processing
7
+ - Never expose internal error messages, stack traces, or DB query details to API clients
8
+ - Use parameterized queries or an ORM — never concatenate user input into raw SQL strings
9
+ - Sanitize user-supplied content before rendering in HTML to prevent XSS
10
+ - Authentication checks must happen before any business logic — never after
11
+ - Reject unexpected fields in API payloads using strict schema validation (Zod `strict()`, Pydantic `model_config = ConfigDict(extra="forbid")`)
12
+ - Log security events (failed auth, rate-limit hits, permission denials) but never log sensitive values (passwords, tokens, PII)
13
+ - Use `httpOnly` + `Secure` + `SameSite=Strict` cookie attributes for session tokens
14
+ - Apply the principle of least privilege: request only the permissions/scopes your code actually needs
@@ -0,0 +1,16 @@
1
+ ---
2
+ globs: "**/*.test.ts,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx,**/*.test.py,**/tests/**,**/__tests__/**"
3
+ ---
4
+
5
+ # Testing Conventions
6
+
7
+ - **AAA pattern**: Arrange → Act → Assert — one clear block per concern
8
+ - Test behavior, not implementation: test what a function *does*, not how it does it internally
9
+ - Test names describe the scenario in plain language: `"returns 409 when slot is already booked"`
10
+ - Cover: happy path, each distinct error path, and boundary conditions
11
+ - **Dependency injection for mocking** — avoid module-level patching when the code supports DI
12
+ - 90%+ branch coverage on all new and modified files
13
+ - No arbitrary `sleep()` or `setTimeout()` in tests — use proper async waiting mechanisms
14
+ - Never test private methods or internal state directly — test through the public interface
15
+ - One `describe` block per unit/feature — keep test files focused
16
+ - Mock at the seam closest to the external dependency (DB, HTTP, filesystem)
@@ -0,0 +1,81 @@
1
+ {
2
+ "_comment": "Copy this file to settings.json. It is gitignored — each developer configures their own.",
3
+ "_hooks_note": "The hooks block below is the CDK default. If you have an existing settings.json, merge this hooks section into it.",
4
+ "permissions": {
5
+ "allow": [
6
+ "Read",
7
+ "Write",
8
+ "Edit",
9
+ "Bash(git:*)",
10
+ "Bash(gh:*)",
11
+ "Bash(grep:*)",
12
+ "Bash(ls:*)",
13
+ "Bash(tree:*)",
14
+ "Bash(find:*)",
15
+ "Bash(cat:*)",
16
+ "Bash(echo:*)",
17
+ "Bash(gemini:*)",
18
+ "Bash(gemini -p:*)",
19
+ "Bash(opencode:*)",
20
+ "Bash(which:*)",
21
+ "Bash(python:*)",
22
+ "Bash(python3:*)",
23
+ "Bash(mkdir:*)",
24
+ "Bash(touch:*)",
25
+ "Bash(ollama:*)"
26
+ ],
27
+ "deny": [
28
+ "Bash(rm -rf:*)",
29
+ "Bash(chmod 777:*)",
30
+ "Read(.env)",
31
+ "Read(.env.*)",
32
+ "Edit(.claude/settings.json)"
33
+ ]
34
+ },
35
+ "hooks": {
36
+ "SessionStart": [
37
+ {
38
+ "hooks": [
39
+ {
40
+ "type": "command",
41
+ "command": "echo \"For context, today's date is $(date). Please keep this in mind.\""
42
+ }
43
+ ]
44
+ }
45
+ ],
46
+ "PreToolUse": [
47
+ {
48
+ "hooks": [
49
+ {
50
+ "type": "command",
51
+ "command": "node .claude/hooks/pre-tool-use/block-dangerous-commands.js"
52
+ }
53
+ ]
54
+ }
55
+ ],
56
+ "Stop": [
57
+ {
58
+ "hooks": [
59
+ {
60
+ "type": "command",
61
+ "command": "python .claude/hooks/stop/context_monitor.py"
62
+ },
63
+ {
64
+ "type": "command",
65
+ "command": "python .claude/hooks/stop/learning_logger.py"
66
+ }
67
+ ]
68
+ }
69
+ ],
70
+ "UserPromptSubmit": [
71
+ {
72
+ "hooks": [
73
+ {
74
+ "type": "command",
75
+ "command": "cd .claude/hooks/skill-activation-prompt && node_modules/.bin/tsx skill-activation-prompt.ts"
76
+ }
77
+ ]
78
+ }
79
+ ]
80
+ }
81
+ }
@@ -35,6 +35,16 @@
35
35
  ## Key Conventions
36
36
  <!-- KEY_CONVENTIONS -->
37
37
 
38
+ > Detailed rules live in `.claude/rules/` — Claude loads them automatically:
39
+ > - `code-style.md` — code quality and structure rules (all files)
40
+ > - `security.md` — security practices (all files)
41
+ > - `api-conventions.md` — HTTP status codes, response shapes, route structure (api/** files)
42
+ > - `testing.md` — AAA pattern, coverage targets, mock strategy (test files)
43
+
44
+ ## Personal Overrides
45
+
46
+ Copy `CLAUDE.local.md.example` → `CLAUDE.local.md` to set personal preferences (gitignored).
47
+
38
48
  ## Agent System (Claude Dev Kit)
39
49
  This project uses the claude-dev-kit autonomous development pipeline:
40
50
 
@@ -0,0 +1,36 @@
1
+ # CLAUDE.local.md — Personal Overrides
2
+
3
+ > This file is personal to you. Copy it to `CLAUDE.local.md` (which is gitignored).
4
+ > It loads alongside `CLAUDE.md` but never affects your teammates.
5
+
6
+ ---
7
+
8
+ ## My Experience Level
9
+
10
+ <!-- Tell Claude how to calibrate explanations for you. -->
11
+ <!-- Examples: -->
12
+ <!-- "I'm a senior TypeScript engineer — skip basics, focus on tradeoffs." -->
13
+ <!-- "I'm new to Prisma; explain ORM concepts when they come up." -->
14
+
15
+ ## My Local Setup
16
+
17
+ <!-- Override project defaults for your machine. -->
18
+ <!-- Examples: -->
19
+ <!-- Local DB: postgresql://localhost:5432/myapp_dev -->
20
+ <!-- Dev server port: 4000 -->
21
+ <!-- I run migrations with: bun prisma migrate dev -->
22
+
23
+ ## My Workflow Preferences
24
+
25
+ <!-- Personal habits Claude should respect. -->
26
+ <!-- Examples: -->
27
+ <!-- "Always show me the full file diff before writing, so I can approve." -->
28
+ <!-- "I prefer smaller, focused PRs over large bundled ones." -->
29
+ <!-- "Skip test output summaries — I'll read the raw output myself." -->
30
+
31
+ ## Editor / Terminal
32
+
33
+ <!-- Context that helps Claude format output usefully for your environment. -->
34
+ <!-- Examples: -->
35
+ <!-- Terminal: Ghostty (supports 256 colors, Unicode) -->
36
+ <!-- "When showing multi-file changes, use unified diff format." -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-dev-kit",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Transform Claude Code into a fully autonomous development team — orchestrated sub-agents for planning, implementation, testing, and review.",
5
5
  "bin": {
6
6
  "claude-dev-kit": "./bin/claude-dev-kit.js"
@@ -10,8 +10,11 @@
10
10
  ".claude/agents/",
11
11
  ".claude/commands/",
12
12
  ".claude/hooks/",
13
+ ".claude/rules/",
14
+ ".claude/settings.json.example",
13
15
  ".claude/skills/",
14
16
  ".claude/templates/",
17
+ "CLAUDE.local.md.example",
15
18
  "scripts/install.sh"
16
19
  ],
17
20
  "keywords": [
@@ -22,7 +25,9 @@
22
25
  "developer-tools",
23
26
  "autonomous-development"
24
27
  ],
25
- "engines": { "node": ">=18" },
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
26
31
  "license": "MIT",
27
32
  "repository": {
28
33
  "type": "git",
@@ -126,34 +126,19 @@ if [[ "$MCP_ONLY" == "false" ]]; then
126
126
  ask_yn "Install .claude/ into $TARGET?" || { echo "Aborted."; exit 0; }
127
127
  fi
128
128
 
129
- # Merge CDK files into existing .claude/ (or create fresh if none)
130
- # - CDK-owned dirs (agents, commands, hooks, skills, templates) are always updated
131
- # - User-owned files (settings.json, CLAUDE.md) are never overwritten
132
- if [[ -d "$TARGET/.claude" ]]; then
133
- info "Existing .claude/ found merging CDK files (settings.json and CLAUDE.md preserved)"
134
- fi
135
- mkdir -p "$TARGET/.claude"
136
- if command -v rsync &>/dev/null; then
137
- rsync -a \
138
- --exclude='settings.json' \
139
- --exclude='CLAUDE.md' \
140
- --exclude='node_modules' \
141
- --exclude='*.jsonl' \
142
- "$KIT_ROOT/.claude/" "$TARGET/.claude/"
129
+ # ── Delegate all .claude/ file management to the migration tool ──────────────
130
+ # migrate.sh handles: categorization, conflict resolution, settings.json merge,
131
+ # CLAUDE.md merge, and manifest maintenance. It is safe to run standalone.
132
+ if bash "$SCRIPT_DIR/migrate.sh" "$KIT_ROOT" "$TARGET"; then
133
+ : # migrate.sh prints its own success messages
143
134
  else
144
- for dir in agents commands hooks skills templates; do
145
- if [[ -d "$KIT_ROOT/.claude/$dir" ]]; then
146
- mkdir -p "$TARGET/.claude/$dir"
147
- cp -r "$KIT_ROOT/.claude/$dir/." "$TARGET/.claude/$dir/"
148
- fi
149
- done
150
- rm -rf "$TARGET/.claude/hooks/skill-activation-prompt/node_modules"
135
+ error "Migration failed check output above"
136
+ exit 1
151
137
  fi
152
- success ".claude/ installed"
153
138
 
154
- # Ensure log directory exists now that .claude/ is present
139
+ # Ensure log directory + file exist now that .claude/ is present
155
140
  mkdir -p "$TARGET/.claude"
156
- : > "$LOG_FILE" # create/truncate log
141
+ : > "$LOG_FILE"
157
142
 
158
143
  # ── Inject .gitignore entries into target project ────────────────────────────
159
144
  TARGET_GITIGNORE="$TARGET/.gitignore"
@@ -161,20 +146,31 @@ if [[ "$MCP_ONLY" == "false" ]]; then
161
146
  if [[ -f "$TARGET_GITIGNORE" ]] && grep -qF "$GITIGNORE_MARKER" "$TARGET_GITIGNORE" 2>/dev/null; then
162
147
  info ".gitignore already contains CDK entries — skipping"
163
148
  else
164
- info "Adding .gitignore entries to protect secrets..."
149
+ info "Adding .gitignore entries..."
165
150
  cat >> "$TARGET_GITIGNORE" <<'EOF'
166
151
 
167
152
  # Claude Dev Kit — managed entries
168
153
  # settings.json may contain MCP API tokens written by install.sh — never commit it.
169
154
  .claude/settings.json
170
- # Audit log and install log contain local paths — no need to track.
155
+ # Audit log, install log, and migration manifest contain local paths — no need to track.
171
156
  .claude/audit.log
172
157
  .claude/install.log
158
+ .claude/.cdk-manifest
159
+ # Personal Claude overrides — machine-local, never shared with teammates.
160
+ CLAUDE.local.md
173
161
  EOF
174
- success ".gitignore updated (settings.json, audit.log, install.log excluded)"
162
+ success ".gitignore updated"
175
163
  fi
176
164
 
177
- # Install hook dependencies
165
+ # ── Copy CLAUDE.local.md.example if not present ──────────────────────────────
166
+ EXAMPLE_SRC="$KIT_ROOT/CLAUDE.local.md.example"
167
+ EXAMPLE_DEST="$TARGET/CLAUDE.local.md.example"
168
+ if [[ -f "$EXAMPLE_SRC" && ! -f "$EXAMPLE_DEST" ]]; then
169
+ cp "$EXAMPLE_SRC" "$EXAMPLE_DEST"
170
+ info "CLAUDE.local.md.example added — copy to CLAUDE.local.md for personal preferences"
171
+ fi
172
+
173
+ # ── Install hook dependencies ─────────────────────────────────────────────
178
174
  HOOK_DIR="$TARGET/.claude/hooks/skill-activation-prompt"
179
175
  if [[ -f "$HOOK_DIR/package.json" ]]; then
180
176
  info "Installing skill-activation-prompt hook dependencies..."
@@ -193,6 +189,7 @@ EOF
193
189
  popd > /dev/null
194
190
  success "Hook dependencies installed"
195
191
  fi
192
+
196
193
  fi
197
194
 
198
195
  # ─── Phase 2: MCP Wizard ──────────────────────────────────────────────────────