@claude-code-mastery/starter-kit 1.0.0 → 1.1.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.
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Example query: Find a user by email
3
+ *
4
+ * Usage: npx tsx scripts/db-query.ts example-find-user <email>
5
+ *
6
+ * This is a TEST query — not production code.
7
+ */
8
+
9
+ import type { StrictDB } from 'strictdb';
10
+
11
+ export default {
12
+ name: 'example-find-user',
13
+ description: 'Look up a user by email address',
14
+
15
+ async run(db: StrictDB, args: string[]): Promise<void> {
16
+ const email = args[0];
17
+ if (!email) {
18
+ console.error(' Usage: example-find-user <email>');
19
+ process.exit(1);
20
+ }
21
+
22
+ const user = await db.queryOne('users', { email });
23
+
24
+ if (!user) {
25
+ console.log(` No user found with email: ${email}`);
26
+ return;
27
+ }
28
+
29
+ console.log(' Found user:');
30
+ console.log(JSON.stringify(user, null, 2));
31
+ },
32
+ };
@@ -0,0 +1,571 @@
1
+ #!/usr/bin/env bash
2
+ # scaffold-clean.sh — Fast batch scaffold for clean mode projects
3
+ # Replaces ~15 individual tool calls with a single script execution
4
+ #
5
+ # Usage: bash scripts/scaffold-clean.sh <project-path> <project-name> <starter-kit-root>
6
+ #
7
+ # Creates a complete clean-mode project with progress indicators.
8
+
9
+ set -euo pipefail
10
+
11
+ # ── Arguments ──────────────────────────────────────────────────────────────────
12
+ PROJECT_PATH="$1"
13
+ PROJECT_NAME="$2"
14
+ STARTER_KIT="$3"
15
+ REGISTRY="${HOME}/.claude/starter-kit-projects.json"
16
+
17
+ # ── Validation ─────────────────────────────────────────────────────────────────
18
+ if [ -d "$PROJECT_PATH" ]; then
19
+ echo "ERROR: Directory already exists: $PROJECT_PATH"
20
+ echo "Remove it first or choose a different name."
21
+ exit 1
22
+ fi
23
+
24
+ if [ ! -d "$STARTER_KIT/.claude/commands" ]; then
25
+ echo "ERROR: Starter kit not found at: $STARTER_KIT"
26
+ exit 1
27
+ fi
28
+
29
+ # ── Progress Tracking ──────────────────────────────────────────────────────────
30
+ TOTAL_STEPS=8
31
+ CURRENT=0
32
+ START_NS=$(date +%s%N)
33
+
34
+ progress() {
35
+ CURRENT=$((CURRENT + 1))
36
+ local pct=$((CURRENT * 100 / TOTAL_STEPS))
37
+ local now_ns=$(date +%s%N)
38
+ local elapsed_ms=$(( (now_ns - START_NS) / 1000000 ))
39
+
40
+ # Progress bar (20 chars)
41
+ local filled=$((pct / 5))
42
+ local empty=$((20 - filled))
43
+ local bar=""
44
+ for ((i=0; i<filled; i++)); do bar+="\xe2\x96\x88"; done
45
+ for ((i=0; i<empty; i++)); do bar+="\xe2\x96\x91"; done
46
+
47
+ # Estimated time remaining
48
+ local eta=""
49
+ if [ "$CURRENT" -eq "$TOTAL_STEPS" ]; then
50
+ eta="Done!"
51
+ elif [ "$elapsed_ms" -gt 0 ] && [ "$CURRENT" -gt 0 ]; then
52
+ local ms_per_step=$((elapsed_ms / CURRENT))
53
+ local remaining_ms=$(( (TOTAL_STEPS - CURRENT) * ms_per_step ))
54
+ if [ "$remaining_ms" -ge 1000 ]; then
55
+ local remaining_s=$((remaining_ms / 1000))
56
+ local remaining_frac=$(( (remaining_ms % 1000) / 100 ))
57
+ eta="~${remaining_s}.${remaining_frac}s remaining"
58
+ else
59
+ eta="~${remaining_ms}ms remaining"
60
+ fi
61
+ else
62
+ eta="estimating..."
63
+ fi
64
+
65
+ printf "[%d/%d] %3d%% $(echo -e "$bar") %-40s %s\n" \
66
+ "$CURRENT" "$TOTAL_STEPS" "$pct" "$1" "$eta"
67
+ }
68
+
69
+ # ── Header ─────────────────────────────────────────────────────────────────────
70
+ echo ""
71
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
72
+ echo " NEW PROJECT: $PROJECT_NAME (clean mode)"
73
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
74
+ echo ""
75
+
76
+ # ── Step 1: Create directories ─────────────────────────────────────────────────
77
+ progress "Creating directory structure..."
78
+ mkdir -p "$PROJECT_PATH"/.claude/{commands,skills,agents,hooks}
79
+ mkdir -p "$PROJECT_PATH"/project-docs
80
+ mkdir -p "$PROJECT_PATH"/tests
81
+
82
+ # ── Step 2: Copy 16 project-scoped commands ────────────────────────────────────
83
+ progress "Copying 16 project commands..."
84
+ for cmd in architecture commit create-api create-e2e diagram help \
85
+ optimize-docker progress refactor review security-check \
86
+ setup show-user-guide test-plan what-is-my-ai-doing worktree; do
87
+ cp "$STARTER_KIT/.claude/commands/${cmd}.md" "$PROJECT_PATH/.claude/commands/"
88
+ done
89
+
90
+ # ── Step 3: Copy skills, agents, hooks ─────────────────────────────────────────
91
+ progress "Copying skills, agents, hooks..."
92
+ cp -r "$STARTER_KIT/.claude/skills/code-review" "$PROJECT_PATH/.claude/skills/"
93
+ cp -r "$STARTER_KIT/.claude/skills/create-service" "$PROJECT_PATH/.claude/skills/"
94
+ cp "$STARTER_KIT/.claude/agents/code-reviewer.md" "$PROJECT_PATH/.claude/agents/"
95
+ cp "$STARTER_KIT/.claude/agents/test-writer.md" "$PROJECT_PATH/.claude/agents/"
96
+ cp "$STARTER_KIT/.claude/hooks/block-secrets.py" "$PROJECT_PATH/.claude/hooks/"
97
+ cp "$STARTER_KIT/.claude/hooks/lint-on-save.sh" "$PROJECT_PATH/.claude/hooks/"
98
+ cp "$STARTER_KIT/.claude/hooks/verify-no-secrets.sh" "$PROJECT_PATH/.claude/hooks/"
99
+
100
+ # ── Step 4: Write settings.json (clean mode — 3 hooks only) ───────────────────
101
+ progress "Writing settings.json..."
102
+ cat > "$PROJECT_PATH/.claude/settings.json" << 'SETTINGS_EOF'
103
+ {
104
+ "hooks": {
105
+ "PreToolUse": [
106
+ {
107
+ "matcher": "Read|Edit|Write",
108
+ "hooks": [
109
+ {
110
+ "type": "command",
111
+ "command": "python3 .claude/hooks/block-secrets.py"
112
+ }
113
+ ]
114
+ }
115
+ ],
116
+ "PostToolUse": [
117
+ {
118
+ "matcher": "Write",
119
+ "hooks": [
120
+ {
121
+ "type": "command",
122
+ "command": "bash .claude/hooks/lint-on-save.sh"
123
+ }
124
+ ]
125
+ }
126
+ ],
127
+ "Stop": [
128
+ {
129
+ "hooks": [
130
+ {
131
+ "type": "command",
132
+ "command": "bash .claude/hooks/verify-no-secrets.sh"
133
+ }
134
+ ]
135
+ }
136
+ ]
137
+ }
138
+ }
139
+ SETTINGS_EOF
140
+
141
+ # ── Step 4b: Create features.json (empty manifest for clean mode) ─────────────
142
+ cat > "$PROJECT_PATH/.claude/features.json" << 'FEATURES_EOF'
143
+ {
144
+ "schemaVersion": 1,
145
+ "installedBy": "claude-code-mastery-starter-kit",
146
+ "language": "none",
147
+ "features": {}
148
+ }
149
+ FEATURES_EOF
150
+
151
+ # ── Step 5: Create CLAUDE.md + CLAUDE.local.md ────────────────────────────────
152
+ progress "Creating CLAUDE.md files..."
153
+
154
+ cat > "$PROJECT_PATH/CLAUDE.md" << 'CLAUDEMD_EOF'
155
+ # CLAUDE.md — Project Instructions
156
+
157
+ ---
158
+
159
+ ## Critical Rules
160
+
161
+ ### 0. NEVER Publish Sensitive Data
162
+
163
+ - NEVER commit passwords, API keys, tokens, or secrets to git/npm/docker
164
+ - NEVER commit `.env` files — ALWAYS verify `.env` is in `.gitignore`
165
+ - Before ANY commit: verify no secrets are included
166
+ - NEVER output secrets in suggestions, logs, or responses
167
+
168
+ ### 1. NEVER Hardcode Credentials
169
+
170
+ - ALWAYS use environment variables for secrets
171
+ - NEVER put API keys, passwords, or tokens directly in code
172
+ - NEVER hardcode connection strings — use environment variables from .env
173
+
174
+ ### 2. ALWAYS Ask Before Deploying
175
+
176
+ - NEVER auto-deploy, even if the fix seems simple
177
+ - NEVER assume approval — wait for explicit "yes, deploy"
178
+ - ALWAYS ask before deploying to production
179
+
180
+ ---
181
+
182
+ ## When Something Seems Wrong
183
+
184
+ Before jumping to conclusions:
185
+
186
+ - Missing UI element? → Check feature gates BEFORE assuming bug
187
+ - Empty data? → Check if services are running BEFORE assuming broken
188
+ - 404 error? → Check service separation BEFORE adding endpoint
189
+ - Auth failing? → Check which auth system BEFORE debugging
190
+ - Test failing? → Read the error message fully BEFORE changing code
191
+
192
+ ---
193
+
194
+ ## Project Documentation
195
+
196
+ | Document | Purpose | When to Read |
197
+ |----------|---------|--------------|
198
+ | `project-docs/ARCHITECTURE.md` | System overview & data flow | Before architectural changes |
199
+ | `project-docs/INFRASTRUCTURE.md` | Deployment details | Before environment changes |
200
+ | `project-docs/DECISIONS.md` | Architectural decisions | Before proposing alternatives |
201
+
202
+ **ALWAYS read relevant docs before making cross-service changes.**
203
+
204
+ ---
205
+
206
+ ## Git Workflow — Branch FIRST, Work Second
207
+
208
+ **Auto-branch hook is ON by default.** A hook blocks commits to `main`. **ALWAYS check and branch BEFORE editing any files:**
209
+
210
+ ```bash
211
+ # MANDATORY first step — do this BEFORE writing or editing anything:
212
+ git branch --show-current
213
+ # If on main → create a feature branch IMMEDIATELY:
214
+ git checkout -b feat/<task-name>
215
+ # NOW start working.
216
+ ```
217
+
218
+ If you edit files on `main` and then try to commit, the hook will block you. Branch first — it takes 1 second and avoids wasted work.
219
+
220
+ ---
221
+
222
+ ## Workflow Preferences
223
+
224
+ - Quality over speed — if unsure, ask before executing
225
+ - One task, one chat — `/clear` between unrelated tasks
226
+ - When testing: queue observations, fix in batch (not one at a time)
227
+
228
+ ---
229
+
230
+ ## Naming — NEVER Rename Mid-Project
231
+
232
+ If you must rename packages, modules, or key variables:
233
+
234
+ 1. Create a checklist of ALL files and references first
235
+ 2. Use IDE semantic rename (not search-and-replace)
236
+ 3. Full project search for old name after renaming
237
+ 4. Check: .md files, .txt files, .env files, comments, strings, paths
238
+ 5. Start a FRESH Claude session after renaming
239
+ CLAUDEMD_EOF
240
+
241
+ cat > "$PROJECT_PATH/CLAUDE.local.md" << 'LOCALMD_EOF'
242
+ # CLAUDE.local.md — Personal Overrides
243
+
244
+ > **This file is gitignored.** It's for YOUR personal preferences — things that shouldn't be shared with the team.
245
+ >
246
+ > **When to use this vs CLAUDE.md:**
247
+ > - `CLAUDE.md` = team rules (checked into git, everyone follows them)
248
+ > - `CLAUDE.local.md` = personal preferences (gitignored, only affects you)
249
+
250
+ ---
251
+
252
+ ## My Identity
253
+
254
+ - GitHub: YourUsername
255
+ - SSH: `git@github.com:YourUsername/<repo>.git`
256
+
257
+ ## Communication Style
258
+
259
+ <!-- Uncomment the style that fits you: -->
260
+ <!-- - Respond concisely — I prefer terse explanations -->
261
+ <!-- - Be thorough — explain your reasoning in detail -->
262
+ <!-- - Show me the code first, explain after -->
263
+ <!-- - Always explain trade-offs before making a choice -->
264
+
265
+ ## Commit Preferences
266
+
267
+ - When creating commits, use conventional commit format (feat:, fix:, docs:, etc.)
268
+
269
+ ## Testing Preferences
270
+
271
+ <!-- Uncomment what matches your workflow: -->
272
+ <!-- - Run tests after every code change automatically -->
273
+ <!-- - Only run tests when I ask -->
274
+ <!-- - Always run E2E tests headed so I can watch -->
275
+ <!-- - Prefer unit tests over E2E for new features -->
276
+
277
+ ## Deployment Preferences
278
+
279
+ <!-- Uncomment what matches your workflow: -->
280
+ <!-- - Always ask before deploying (default CLAUDE.md behavior) -->
281
+ <!-- - Deploy to staging automatically, ask before production -->
282
+ <!-- - I handle deployments myself — just build and test -->
283
+
284
+ ## Code Style
285
+
286
+ <!-- Uncomment what matches your preferences: -->
287
+ <!-- - I prefer named exports over default exports -->
288
+ <!-- - Use arrow functions for React components -->
289
+ <!-- - Prefer early returns over nested if/else -->
290
+ <!-- - Use verbose variable names, never abbreviate -->
291
+
292
+ ## Local Environment
293
+
294
+ - Node version: 20.x
295
+ - Package manager: (your choice)
296
+ - OS: (your OS here)
297
+
298
+ ## Project-Specific Notes
299
+
300
+ <!-- Add anything specific to how YOU work on this project -->
301
+ LOCALMD_EOF
302
+
303
+ # ── Step 6: Create project templates ──────────────────────────────────────────
304
+ progress "Creating project templates..."
305
+
306
+ cat > "$PROJECT_PATH/project-docs/ARCHITECTURE.md" << 'ARCH_EOF'
307
+ # Architecture
308
+
309
+ > System overview and data flow for the project.
310
+
311
+ ## Overview
312
+
313
+ <!-- Describe the high-level architecture here -->
314
+
315
+ ## Components
316
+
317
+ <!-- List major components and their responsibilities -->
318
+
319
+ ## Data Flow
320
+
321
+ <!-- Describe how data moves through the system -->
322
+
323
+ ## Dependencies
324
+
325
+ <!-- List external services and dependencies -->
326
+ ARCH_EOF
327
+
328
+ cat > "$PROJECT_PATH/project-docs/INFRASTRUCTURE.md" << 'INFRA_EOF'
329
+ # Infrastructure
330
+
331
+ > Deployment and environment details.
332
+
333
+ ## Environments
334
+
335
+ <!-- List environments: development, staging, production -->
336
+
337
+ ## Deployment
338
+
339
+ <!-- Describe the deployment process -->
340
+
341
+ ## Environment Variables
342
+
343
+ <!-- List required environment variables and their purpose -->
344
+
345
+ ## Monitoring
346
+
347
+ <!-- Describe monitoring and alerting setup -->
348
+ INFRA_EOF
349
+
350
+ cat > "$PROJECT_PATH/project-docs/DECISIONS.md" << 'DEC_EOF'
351
+ # Architectural Decisions
352
+
353
+ > Record of key technical decisions and their rationale.
354
+
355
+ ## Template
356
+
357
+ ### Decision: [Title]
358
+ - **Date:** YYYY-MM-DD
359
+ - **Status:** Accepted / Superseded / Deprecated
360
+ - **Context:** What prompted the decision
361
+ - **Decision:** What was decided
362
+ - **Consequences:** What are the trade-offs
363
+ - **Alternatives considered:** What else was evaluated
364
+
365
+ ---
366
+
367
+ <!-- Add decisions below -->
368
+ DEC_EOF
369
+
370
+ cat > "$PROJECT_PATH/tests/CHECKLIST.md" << 'CHECK_EOF'
371
+ # Test Checklist
372
+
373
+ > Track what needs testing and what's been verified.
374
+
375
+ ## Test Coverage
376
+
377
+ | Area | Unit Tests | Integration Tests | E2E Tests | Status |
378
+ |------|-----------|-------------------|-----------|--------|
379
+ | <!-- feature --> | <!-- yes/no --> | <!-- yes/no --> | <!-- yes/no --> | <!-- pending/done --> |
380
+
381
+ ## Manual Test Cases
382
+
383
+ - [ ] <!-- Describe manual test case -->
384
+
385
+ ## Regression Tests
386
+
387
+ - [ ] <!-- Describe regression test case -->
388
+ CHECK_EOF
389
+
390
+ cat > "$PROJECT_PATH/tests/ISSUES_FOUND.md" << 'ISSUES_EOF'
391
+ # Issues Found During Testing
392
+
393
+ > Track bugs and issues discovered during testing sessions.
394
+
395
+ ## Template
396
+
397
+ ### Issue: [Title]
398
+ - **Found:** YYYY-MM-DD
399
+ - **Severity:** Critical / High / Medium / Low
400
+ - **Status:** Open / Fixed / Won't Fix
401
+ - **Description:** What happened
402
+ - **Steps to reproduce:** How to trigger the issue
403
+ - **Expected behavior:** What should happen
404
+ - **Actual behavior:** What actually happened
405
+ - **Fix:** How it was resolved (if fixed)
406
+
407
+ ---
408
+
409
+ <!-- Add issues below -->
410
+ ISSUES_EOF
411
+
412
+ # ── Step 7: Create config files ───────────────────────────────────────────────
413
+ progress "Creating config files (.env, .gitignore, README)..."
414
+
415
+ touch "$PROJECT_PATH/.env"
416
+
417
+ cat > "$PROJECT_PATH/.env.example" << 'ENVEX_EOF'
418
+ # Environment Variables
419
+ NODE_ENV=development
420
+ PORT=3000
421
+ ENVEX_EOF
422
+
423
+ cat > "$PROJECT_PATH/.gitignore" << 'GI_EOF'
424
+ # Environment
425
+ .env
426
+ .env.*
427
+ .env.local
428
+
429
+ # Dependencies
430
+ node_modules/
431
+ vendor/
432
+ .venv/
433
+ __pycache__/
434
+
435
+ # Build output
436
+ dist/
437
+ build/
438
+ bin/
439
+ out/
440
+
441
+ # Test artifacts
442
+ coverage/
443
+ test-results/
444
+ playwright-report/
445
+ .pytest_cache/
446
+ htmlcov/
447
+
448
+ # IDE
449
+ .idea/
450
+ .vscode/
451
+ *.swp
452
+ *.swo
453
+
454
+ # OS
455
+ .DS_Store
456
+ Thumbs.db
457
+
458
+ # Claude local overrides
459
+ CLAUDE.local.md
460
+
461
+ # Temporary AI research files
462
+ _ai_temp/
463
+ GI_EOF
464
+
465
+ cat > "$PROJECT_PATH/.dockerignore" << 'DI_EOF'
466
+ .env
467
+ .env.*
468
+ .git/
469
+ node_modules/
470
+ dist/
471
+ coverage/
472
+ test-results/
473
+ playwright-report/
474
+ .venv/
475
+ __pycache__/
476
+ *.md
477
+ !README.md
478
+ _ai_temp/
479
+ DI_EOF
480
+
481
+ cat > "$PROJECT_PATH/README.md" << README_EOF
482
+ # $PROJECT_NAME
483
+
484
+ > Scaffolded with [Claude Code Mastery Starter Kit](https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit) (clean mode)
485
+
486
+ ## Getting Started
487
+
488
+ This project was created with **clean mode** — all Claude Code infrastructure is in place with zero coding opinions. You decide your own language, framework, and structure.
489
+
490
+ ## What's Included
491
+
492
+ - \`.claude/\` — 16 slash commands, 2 skills, 2 agents, 3 hooks
493
+ - \`project-docs/\` — Architecture, Infrastructure, and Decisions templates
494
+ - \`tests/\` — Test checklist and issue tracking templates
495
+ - \`CLAUDE.md\` — Security rules only (no coding opinions)
496
+ - \`.env\` / \`.env.example\` — Environment variable pattern
497
+
498
+ ## Available Commands
499
+
500
+ Run \`/help\` in Claude Code to see all 16 available commands.
501
+
502
+ ## Project Documentation
503
+
504
+ | Document | Purpose |
505
+ |----------|---------|
506
+ | \`project-docs/ARCHITECTURE.md\` | System overview & data flow |
507
+ | \`project-docs/INFRASTRUCTURE.md\` | Deployment details |
508
+ | \`project-docs/DECISIONS.md\` | Architectural decisions |
509
+ README_EOF
510
+
511
+ # ── Step 8: Git init + register project ───────────────────────────────────────
512
+ progress "Initializing git + registering project..."
513
+
514
+ git -C "$PROJECT_PATH" init -q
515
+ git -C "$PROJECT_PATH" add -A
516
+ git -C "$PROJECT_PATH" commit -q -m "Initial clean project scaffold"
517
+
518
+ # Register in project registry
519
+ python3 << PYEOF
520
+ import json, os
521
+ from datetime import datetime, timezone
522
+
523
+ registry = "$REGISTRY"
524
+ if os.path.exists(registry):
525
+ with open(registry) as f:
526
+ data = json.load(f)
527
+ else:
528
+ os.makedirs(os.path.dirname(registry), exist_ok=True)
529
+ data = {"projects": []}
530
+
531
+ data["projects"].append({
532
+ "name": "$PROJECT_NAME",
533
+ "path": os.path.realpath("$PROJECT_PATH"),
534
+ "profile": "clean",
535
+ "language": "none",
536
+ "framework": "none",
537
+ "database": "none",
538
+ "createdAt": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
539
+ })
540
+
541
+ with open(registry, "w") as f:
542
+ json.dump(data, f, indent=2)
543
+ f.write("\n")
544
+ PYEOF
545
+
546
+ # ── Summary ────────────────────────────────────────────────────────────────────
547
+ END_NS=$(date +%s%N)
548
+ TOTAL_MS=$(( (END_NS - START_NS) / 1000000 ))
549
+ FILE_COUNT=$(find "$PROJECT_PATH" -type f -not -path '*/.git/*' | wc -l)
550
+
551
+ # Format elapsed time
552
+ if [ "$TOTAL_MS" -ge 1000 ]; then
553
+ TOTAL_S=$((TOTAL_MS / 1000))
554
+ TOTAL_FRAC=$(( (TOTAL_MS % 1000) / 100 ))
555
+ TIME_STR="${TOTAL_S}.${TOTAL_FRAC}s"
556
+ else
557
+ TIME_STR="${TOTAL_MS}ms"
558
+ fi
559
+
560
+ echo ""
561
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
562
+ echo " Completed in ${TIME_STR}"
563
+ echo " Created at: $PROJECT_PATH"
564
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
565
+ echo ""
566
+ echo " ${FILE_COUNT} files | 16 commands | 2 skills | 2 agents | 3 hooks"
567
+ echo ""
568
+ echo " Next steps:"
569
+ echo " cd $PROJECT_PATH"
570
+ echo " claude # Start Claude Code — run /help to see commands"
571
+ echo ""