@husnudarici/claude-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # claude-kit
2
+
3
+ Scaffold a complete `.claude/` folder structure for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) projects with one command.
4
+
5
+ Sets up agents, commands, hooks, rules, skills, and settings so Claude Code works exactly the way you want.
6
+
7
+ ## Quick Start
8
+
9
+ ```bash
10
+ npx claude-kit init
11
+ ```
12
+
13
+ That's it. Your `.claude/` folder is ready.
14
+
15
+ ## What it creates
16
+
17
+ ```
18
+ .claude/
19
+ ├── agents/ # Custom AI agents
20
+ │ ├── code-reviewer.md # Reviews PRs for bugs, security, performance
21
+ │ ├── debugger.md # Systematic bug diagnosis
22
+ │ ├── test-writer.md # Generates comprehensive test suites
23
+ │ ├── refactorer.md # Improves code structure safely
24
+ │ ├── doc-writer.md # Generates documentation from code
25
+ │ └── security-auditor.md # OWASP-based security audits
26
+ ├── commands/ # One-word automations (/deploy, /fix-issue)
27
+ │ ├── fix-issue.md # Diagnose and fix GitHub issues
28
+ │ ├── deploy.md # Deploy to production with all checks
29
+ │ └── pr-review.md # Thorough PR review workflow
30
+ ├── hooks/ # Auto-run scripts
31
+ │ ├── pre-commit.sh # Type check + lint + test before commit
32
+ │ └── lint-on-save.sh # Auto-lint after every file edit
33
+ ├── rules/ # Guardrails scoped to file patterns
34
+ │ ├── frontend.md # React/Next.js component standards
35
+ │ ├── database.md # Query safety and migration rules
36
+ │ └── api.md # API route validation and error handling
37
+ ├── skills/ # Reusable capability bundles
38
+ │ └── frontend-design/
39
+ │ └── SKILL.md # Design system enforcement
40
+ └── settings.json # Permissions, model, hooks config
41
+ CLAUDE.md # Project brain -- root context file
42
+ ```
43
+
44
+ ## Features
45
+
46
+ ### Agents
47
+ Custom AI teammates that handle specific tasks autonomously:
48
+ - **code-reviewer** -- Reviews code for bugs, security issues, and performance
49
+ - **debugger** -- Traces bugs systematically using evidence
50
+ - **test-writer** -- Generates unit, integration, and edge case tests
51
+ - **refactorer** -- Improves code structure without changing behavior
52
+ - **doc-writer** -- Creates clear documentation from code analysis
53
+ - **security-auditor** -- Audits code following OWASP top 10
54
+
55
+ ### Commands
56
+ Slash commands that trigger multi-step workflows:
57
+ - `/deploy` -- Full deployment with pre-flight checks and verification
58
+ - `/fix-issue` -- End-to-end GitHub issue resolution
59
+ - `/pr-review` -- Thorough pull request review
60
+
61
+ ### Hooks
62
+ Shell scripts that auto-run before or after Claude's actions:
63
+ - **pre-commit.sh** -- Blocks commits if types, lint, or tests fail
64
+ - **lint-on-save.sh** -- Auto-lints files after every Edit/Write
65
+
66
+ ### Rules
67
+ Guardrails scoped to specific file patterns:
68
+ - **frontend.md** -- Component patterns, styling, performance, a11y
69
+ - **database.md** -- Query safety, migrations, RLS, performance
70
+ - **api.md** -- Input validation, auth, error handling, rate limiting
71
+
72
+ ### Skills
73
+ Reusable capability bundles with prompts and triggers:
74
+ - **frontend-design** -- Enforces design system (colors, typography, spacing)
75
+
76
+ ### Settings
77
+ Pre-configured `settings.json` with:
78
+ - Safe permission allow/deny lists
79
+ - Pre-commit and lint-on-save hooks
80
+ - Model selection
81
+ - Memory and git instruction toggles
82
+
83
+ ## Options
84
+
85
+ ```bash
86
+ # Scaffold with defaults (skips existing files)
87
+ npx claude-kit init
88
+
89
+ # Overwrite existing files
90
+ npx claude-kit init --force
91
+ ```
92
+
93
+ ## Customization
94
+
95
+ After scaffolding, customize everything for your project:
96
+
97
+ 1. **CLAUDE.md** -- Update tech stack, folder structure, and conventions
98
+ 2. **Agents** -- Modify review criteria, add project-specific checks
99
+ 3. **Rules** -- Adjust file path patterns to match your project structure
100
+ 4. **Commands** -- Update deploy steps for your CI/CD pipeline
101
+ 5. **Settings** -- Configure permissions for your specific tools
102
+ 6. **Skills** -- Update design tokens to match your brand
103
+
104
+ ## License
105
+
106
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
6
+ const RESET = "\x1b[0m";
7
+ const BOLD = "\x1b[1m";
8
+ const GREEN = "\x1b[32m";
9
+ const CYAN = "\x1b[36m";
10
+ const YELLOW = "\x1b[33m";
11
+ const RED = "\x1b[31m";
12
+ const DIM = "\x1b[2m";
13
+
14
+ const LOGO = `
15
+ ${CYAN}${BOLD} ╔═══════════════════════════════════╗
16
+ ║ claude-kit ║
17
+ ║ .claude/ folder scaffolding ║
18
+ ╚═══════════════════════════════════╝${RESET}
19
+ `;
20
+
21
+ function printHelp() {
22
+ console.log(LOGO);
23
+ console.log(`${BOLD}Usage:${RESET}`);
24
+ console.log(` claude-kit init Scaffold .claude/ folder in current directory`);
25
+ console.log(` claude-kit init --force Overwrite existing files`);
26
+ console.log(` claude-kit --help Show this help message`);
27
+ console.log(` claude-kit --version Show version`);
28
+ console.log();
29
+ console.log(`${BOLD}What it creates:${RESET}`);
30
+ console.log(` ${DIM}.claude/${RESET}`);
31
+ console.log(` ${DIM}├── agents/ ${RESET}${CYAN}Custom AI agents${RESET}`);
32
+ console.log(` ${DIM}├── commands/ ${RESET}${CYAN}Slash command automations${RESET}`);
33
+ console.log(` ${DIM}├── hooks/ ${RESET}${CYAN}Pre/post tool-use scripts${RESET}`);
34
+ console.log(` ${DIM}├── rules/ ${RESET}${CYAN}Guardrails for file patterns${RESET}`);
35
+ console.log(` ${DIM}├── skills/ ${RESET}${CYAN}Reusable capability bundles${RESET}`);
36
+ console.log(` ${DIM}├── settings.json ${RESET}${CYAN}Permissions, model, hooks config${RESET}`);
37
+ console.log(` ${DIM}CLAUDE.md ${RESET}${CYAN}Project brain${RESET}`);
38
+ console.log();
39
+ }
40
+
41
+ function copyDirRecursive(src, dest, force) {
42
+ const entries = fs.readdirSync(src, { withFileTypes: true });
43
+ fs.mkdirSync(dest, { recursive: true });
44
+
45
+ const results = { created: [], skipped: [] };
46
+
47
+ for (const entry of entries) {
48
+ const srcPath = path.join(src, entry.name);
49
+ const destPath = path.join(dest, entry.name);
50
+
51
+ if (entry.isDirectory()) {
52
+ const sub = copyDirRecursive(srcPath, destPath, force);
53
+ results.created.push(...sub.created);
54
+ results.skipped.push(...sub.skipped);
55
+ } else {
56
+ if (fs.existsSync(destPath) && !force) {
57
+ results.skipped.push(destPath);
58
+ } else {
59
+ fs.copyFileSync(srcPath, destPath);
60
+ // Make .sh files executable
61
+ if (entry.name.endsWith(".sh")) {
62
+ try {
63
+ fs.chmodSync(destPath, 0o755);
64
+ } catch (_) {
65
+ // chmod may not work on Windows
66
+ }
67
+ }
68
+ results.created.push(destPath);
69
+ }
70
+ }
71
+ }
72
+
73
+ return results;
74
+ }
75
+
76
+ function init(force) {
77
+ const cwd = process.cwd();
78
+ const templatesDir = path.join(__dirname, "..", "templates");
79
+
80
+ // Copy .claude/ folder
81
+ const claudeTemplateDir = path.join(templatesDir, ".claude");
82
+ const claudeDestDir = path.join(cwd, ".claude");
83
+
84
+ console.log(LOGO);
85
+ console.log(`${BOLD}Scaffolding .claude/ folder...${RESET}\n`);
86
+
87
+ const results = copyDirRecursive(claudeTemplateDir, claudeDestDir, force);
88
+
89
+ // Copy CLAUDE.md
90
+ const claudeMdSrc = path.join(templatesDir, "CLAUDE.md");
91
+ const claudeMdDest = path.join(cwd, "CLAUDE.md");
92
+
93
+ if (fs.existsSync(claudeMdDest) && !force) {
94
+ results.skipped.push(claudeMdDest);
95
+ } else {
96
+ fs.copyFileSync(claudeMdSrc, claudeMdDest);
97
+ results.created.push(claudeMdDest);
98
+ }
99
+
100
+ // Print results
101
+ if (results.created.length > 0) {
102
+ console.log(`${GREEN}${BOLD}Created:${RESET}`);
103
+ for (const f of results.created) {
104
+ const rel = path.relative(cwd, f);
105
+ console.log(` ${GREEN}+${RESET} ${rel}`);
106
+ }
107
+ console.log();
108
+ }
109
+
110
+ if (results.skipped.length > 0) {
111
+ console.log(`${YELLOW}${BOLD}Skipped (already exists):${RESET}`);
112
+ for (const f of results.skipped) {
113
+ const rel = path.relative(cwd, f);
114
+ console.log(` ${YELLOW}-${RESET} ${rel}`);
115
+ }
116
+ console.log(` ${DIM}Use --force to overwrite${RESET}`);
117
+ console.log();
118
+ }
119
+
120
+ console.log(`${GREEN}${BOLD}Done!${RESET} Your .claude/ folder is ready.\n`);
121
+ console.log(`${BOLD}Next steps:${RESET}`);
122
+ console.log(` 1. Edit ${CYAN}CLAUDE.md${RESET} with your project details`);
123
+ console.log(` 2. Customize agents, rules, and commands for your workflow`);
124
+ console.log(` 3. Update ${CYAN}.claude/settings.json${RESET} permissions`);
125
+ console.log();
126
+ }
127
+
128
+ // Parse args
129
+ const args = process.argv.slice(2);
130
+ const command = args[0];
131
+ const force = args.includes("--force") || args.includes("-f");
132
+
133
+ if (args.includes("--version") || args.includes("-v")) {
134
+ const pkg = require("../package.json");
135
+ console.log(pkg.version);
136
+ process.exit(0);
137
+ }
138
+
139
+ if (args.includes("--help") || args.includes("-h") || !command) {
140
+ printHelp();
141
+ process.exit(0);
142
+ }
143
+
144
+ if (command === "init") {
145
+ init(force);
146
+ } else {
147
+ console.log(`${RED}Unknown command: ${command}${RESET}`);
148
+ console.log(`Run ${CYAN}claude-kit --help${RESET} for usage.`);
149
+ process.exit(1);
150
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@husnudarici/claude-kit",
3
+ "version": "1.0.0",
4
+ "description": "Scaffold a .claude/ folder with agents, commands, hooks, rules, skills, and settings for Claude Code projects",
5
+ "main": "bin/cli.js",
6
+ "bin": {
7
+ "claude-kit": "bin/cli.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "templates/"
12
+ ],
13
+ "scripts": {
14
+ "test": "node bin/cli.js --help"
15
+ },
16
+ "keywords": [
17
+ "claude",
18
+ "claude-code",
19
+ "ai",
20
+ "agents",
21
+ "scaffolding",
22
+ "cli",
23
+ "developer-tools",
24
+ "anthropic"
25
+ ],
26
+ "author": "husnudarici",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/husnu/claude-kit"
31
+ },
32
+ "engines": {
33
+ "node": ">=16.0.0"
34
+ }
35
+ }
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: code-reviewer
3
+ description: Reviews code for bugs, security issues,
4
+ and performance problems before merge.
5
+ tools: Read, Glob, Grep, Bash
6
+ model: sonnet
7
+ memory: project
8
+ ---
9
+
10
+ You are the senior code reviewer.
11
+ You review every PR as if it ships to
12
+ thousands of users on day one.
13
+
14
+ ## Step 1: Understand the diff
15
+ Run `git diff HEAD~1` to see all changes.
16
+ Read every modified file top to bottom.
17
+ Map which components/APIs were touched.
18
+
19
+ ## Step 2: Security scan
20
+ - Grep for hardcoded API keys, tokens
21
+ - Check .env files are in .gitignore
22
+ - Verify Zod validation on all API inputs
23
+ - Check for SQL injection in raw queries
24
+ - Ensure no `dangerouslySetInnerHTML`
25
+ - Verify Stripe webhook signature checks
26
+
27
+ ## Step 3: Performance check
28
+ - No unnecessary re-renders (memo, useCallback)
29
+ - Images use next/image with proper sizes
30
+ - No blocking calls in Server Components
31
+ - Canvas operations use requestAnimationFrame
32
+ - Check bundle size impact of new deps
33
+
34
+ ## Step 4: Code quality
35
+ - TypeScript strict: no `any`, no `as` casts
36
+ - Functions under 50 lines
37
+ - No duplicated logic (DRY)
38
+ - Descriptive variable names
39
+ - Error boundaries around async operations
40
+
41
+ ## Step 5: Report
42
+ Format: CRITICAL / WARNING / SUGGESTION
43
+ Always run `npm run build` before approving.
44
+ Block the commit if any CRITICAL found.
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: debugger
3
+ description: Diagnoses and fixes bugs by analyzing error traces,
4
+ logs, and code flow systematically.
5
+ tools: Read, Glob, Grep, Bash
6
+ model: sonnet
7
+ ---
8
+
9
+ You are an expert debugger.
10
+ You systematically track down bugs using evidence, not guesswork.
11
+
12
+ ## Step 1: Reproduce
13
+ - Read the error message/stack trace carefully
14
+ - Identify the exact file and line number
15
+ - Understand the expected vs actual behavior
16
+
17
+ ## Step 2: Trace the data flow
18
+ - Start from the error location and work backwards
19
+ - Check function inputs, state values, API responses
20
+ - Look for null/undefined, type mismatches, race conditions
21
+
22
+ ## Step 3: Identify root cause
23
+ - Don't fix symptoms, find the actual cause
24
+ - Check recent git changes that may have introduced the bug
25
+ - Verify assumptions about data shape and types
26
+
27
+ ## Step 4: Fix
28
+ - Make the minimal change that fixes the root cause
29
+ - Don't refactor unrelated code
30
+ - Add error handling only where it prevents the specific bug
31
+
32
+ ## Step 5: Verify
33
+ - Run the relevant test suite
34
+ - Manually trace the fix to confirm it resolves the issue
35
+ - Check for side effects in related code paths
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: doc-writer
3
+ description: Generates clear documentation, JSDoc comments,
4
+ and README content from code analysis.
5
+ tools: Read, Glob, Grep, Bash
6
+ model: sonnet
7
+ ---
8
+
9
+ You write clear, useful documentation.
10
+ Documentation should help developers understand WHY, not just WHAT.
11
+
12
+ ## Step 1: Understand the code
13
+ - Read the source files thoroughly
14
+ - Identify the public API and key concepts
15
+ - Understand the architecture and data flow
16
+
17
+ ## Step 2: Write documentation
18
+ - Start with a one-line summary
19
+ - Explain the purpose and use cases
20
+ - Document parameters, return values, and side effects
21
+ - Include code examples for complex APIs
22
+ - Note any gotchas or important caveats
23
+
24
+ ## Style guidelines
25
+ - Use simple, direct language
26
+ - Prefer examples over lengthy explanations
27
+ - Keep JSDoc comments concise but complete
28
+ - Link to related functions/components
29
+ - Update existing docs rather than duplicating
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: refactorer
3
+ description: Improves code structure, readability, and
4
+ maintainability without changing behavior.
5
+ tools: Read, Glob, Grep, Bash
6
+ model: sonnet
7
+ ---
8
+
9
+ You refactor code to be cleaner and more maintainable.
10
+ Never change behavior -- only improve structure.
11
+
12
+ ## Principles
13
+ - Small, focused changes over big rewrites
14
+ - Preserve all existing tests
15
+ - If no tests exist, write them BEFORE refactoring
16
+ - Each refactoring step should be independently verifiable
17
+
18
+ ## Common refactoring patterns
19
+ - Extract long functions into smaller, named functions
20
+ - Replace magic numbers/strings with named constants
21
+ - Simplify complex conditionals
22
+ - Remove dead code and unused imports
23
+ - Consolidate duplicated logic
24
+ - Improve variable and function naming
25
+
26
+ ## Process
27
+ 1. Read the target code thoroughly
28
+ 2. Run existing tests to establish baseline
29
+ 3. Plan specific refactoring steps
30
+ 4. Apply changes incrementally
31
+ 5. Run tests after each change
32
+ 6. Verify no behavioral changes
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: security-auditor
3
+ description: Audits code for security vulnerabilities
4
+ following OWASP top 10 guidelines.
5
+ tools: Read, Glob, Grep, Bash
6
+ model: sonnet
7
+ ---
8
+
9
+ You are a security auditor.
10
+ You find vulnerabilities before attackers do.
11
+
12
+ ## Step 1: Scan for common vulnerabilities
13
+ - SQL injection in raw queries
14
+ - XSS via unsanitized user input
15
+ - CSRF token validation
16
+ - Hardcoded secrets, API keys, tokens
17
+ - Insecure direct object references
18
+
19
+ ## Step 2: Authentication & Authorization
20
+ - Verify auth checks on all protected routes
21
+ - Check session management and token expiry
22
+ - Ensure password hashing (bcrypt/argon2)
23
+ - Validate role-based access controls
24
+
25
+ ## Step 3: Data exposure
26
+ - Check API responses don't leak sensitive data
27
+ - Verify .env files are gitignored
28
+ - Ensure error messages don't expose internals
29
+ - Check logging doesn't include PII
30
+
31
+ ## Step 4: Dependencies
32
+ - Check for known vulnerabilities (npm audit)
33
+ - Review third-party package permissions
34
+ - Verify dependency versions are maintained
35
+
36
+ ## Step 5: Report
37
+ Format each finding as:
38
+ - SEVERITY: CRITICAL / HIGH / MEDIUM / LOW
39
+ - LOCATION: file:line
40
+ - DESCRIPTION: What the vulnerability is
41
+ - REMEDIATION: How to fix it
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: test-writer
3
+ description: Generates comprehensive test suites with unit,
4
+ integration, and edge case coverage.
5
+ tools: Read, Glob, Grep, Bash
6
+ model: sonnet
7
+ ---
8
+
9
+ You write thorough, maintainable tests.
10
+ Every test should fail for exactly one reason.
11
+
12
+ ## Step 1: Analyze the code
13
+ - Read the file to be tested completely
14
+ - Identify public API, edge cases, error paths
15
+ - Check existing test patterns in the project
16
+
17
+ ## Step 2: Plan test cases
18
+ - Happy path: normal expected usage
19
+ - Edge cases: empty inputs, boundaries, large data
20
+ - Error cases: invalid inputs, network failures
21
+ - Integration: component interactions
22
+
23
+ ## Step 3: Write tests
24
+ - Use the project's existing test framework
25
+ - Follow existing naming conventions
26
+ - One assertion per test when possible
27
+ - Use descriptive test names that explain the scenario
28
+
29
+ ## Step 4: Verify
30
+ - Run the test suite to confirm all tests pass
31
+ - Check coverage for the target file
32
+ - Ensure no tests are flaky or order-dependent
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: deploy
3
+ description: Deploy to production with all checks
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ Deploy the app to production:
8
+
9
+ ## Pre-flight checks
10
+ 1. `git status` -- no uncommitted changes
11
+ 2. `npm run lint` -- zero warnings
12
+ 3. `npm run build` -- clean production build
13
+ 4. `npm test` -- all tests green
14
+ 5. `npx playwright test` -- e2e passing
15
+
16
+ ## Deploy
17
+ 6. `git push origin main`
18
+ 7. Wait for CI/CD build to complete
19
+ 8. Verify deployment status
20
+
21
+ ## Post-deploy verification
22
+ 9. Hit production URL, check homepage loads
23
+ 10. Test one critical user flow
24
+ 11. Check webhook integrations are receiving events
25
+ 12. Verify /api/health returns 200
26
+
27
+ ## If anything fails
28
+ - Do NOT force push or skip checks
29
+ - Fix the issue, re-run all checks
30
+ - Only authorized team members can approve rollbacks
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: fix-issue
3
+ description: Diagnose and fix a GitHub issue end-to-end
4
+ ---
5
+
6
+ Fix the given GitHub issue:
7
+
8
+ ## Step 1: Understand the issue
9
+ 1. Read the issue description and comments
10
+ 2. Reproduce the problem locally if possible
11
+ 3. Identify the root cause
12
+
13
+ ## Step 2: Implement the fix
14
+ 1. Make the minimal change that fixes the issue
15
+ 2. Follow existing code patterns and conventions
16
+ 3. Add or update tests to cover the fix
17
+
18
+ ## Step 3: Verify
19
+ 1. Run the full test suite
20
+ 2. Run the linter
21
+ 3. Run the build to ensure no regressions
22
+ 4. Verify the fix resolves the original issue
23
+
24
+ ## Step 4: Prepare for review
25
+ 1. Create a clear commit message referencing the issue
26
+ 2. Summarize the changes and reasoning
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: pr-review
3
+ description: Review a pull request thoroughly before merge
4
+ ---
5
+
6
+ Review the given pull request:
7
+
8
+ ## Step 1: Understand the changes
9
+ 1. Read the PR description and linked issues
10
+ 2. Run `git diff` to see all changes
11
+ 3. Read every modified file top to bottom
12
+ 4. Map which components/APIs were touched
13
+
14
+ ## Step 2: Code quality checks
15
+ - TypeScript strict: no `any`, no `as` casts
16
+ - Functions under 50 lines
17
+ - No duplicated logic (DRY)
18
+ - Descriptive variable names
19
+ - Proper error handling
20
+
21
+ ## Step 3: Security review
22
+ - No hardcoded secrets or API keys
23
+ - Input validation on all endpoints
24
+ - No SQL injection vulnerabilities
25
+ - No XSS vectors
26
+
27
+ ## Step 4: Testing
28
+ - Verify test coverage for new code
29
+ - Run the test suite
30
+ - Check for edge cases
31
+
32
+ ## Step 5: Provide feedback
33
+ - Format: CRITICAL / WARNING / SUGGESTION
34
+ - Be constructive and specific
35
+ - Suggest improvements with code examples
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+ # --------------------------------------------
3
+ # Lint-on-save hook
4
+ # Runs after every Edit/Write tool use.
5
+ # Auto-formats and checks for lint errors.
6
+ # --------------------------------------------
7
+
8
+ RED="\033[0;31m"
9
+ GREEN="\033[0;32m"
10
+ NC="\033[0m"
11
+
12
+ # Get the file that was just modified
13
+ FILE="$1"
14
+
15
+ if [ -z "$FILE" ]; then
16
+ echo "No file specified"
17
+ exit 0
18
+ fi
19
+
20
+ # Only lint TypeScript/JavaScript files
21
+ if [[ "$FILE" =~ \.(ts|tsx|js|jsx)$ ]]; then
22
+ echo "Linting $FILE..."
23
+ npx eslint "$FILE" --fix --quiet
24
+ if [ $? -ne 0 ]; then
25
+ echo -e "${RED}Lint errors in $FILE${NC}"
26
+ exit 1
27
+ fi
28
+ echo -e "${GREEN}Lint passed: $FILE${NC}"
29
+ fi
30
+
31
+ exit 0
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+ # --------------------------------------------
3
+ # Pre-commit hook
4
+ # Runs tests + lint before EVERY commit.
5
+ # If anything fails, the commit is blocked.
6
+ # --------------------------------------------
7
+
8
+ RED="\033[0;31m"
9
+ GREEN="\033[0;32m"
10
+ NC="\033[0m"
11
+
12
+ # Step 1: Run TypeScript type check
13
+ echo "Checking types..."
14
+ npx tsc --noEmit
15
+ if [ $? -ne 0 ]; then
16
+ echo -e "${RED}Type errors found. Fix before committing.${NC}"
17
+ exit 2
18
+ fi
19
+
20
+ # Step 2: Run ESLint on staged files
21
+ echo "Linting staged files..."
22
+ STAGED=$(git diff --cached --name-only --diff-filter=d | grep -E "\.(ts|tsx)$")
23
+ if [ -n "$STAGED" ]; then
24
+ npx eslint $STAGED --quiet
25
+ if [ $? -ne 0 ]; then
26
+ echo -e "${RED}Lint errors. Run npm run lint to see details.${NC}"
27
+ exit 2
28
+ fi
29
+ fi
30
+
31
+ # Step 3: Run test suite
32
+ echo "Running tests..."
33
+ npm test -- --silent
34
+ if [ $? -ne 0 ]; then
35
+ echo -e "${RED}Tests failed. Commit blocked.${NC}"
36
+ exit 2
37
+ fi
38
+
39
+ echo -e "${GREEN}All checks passed!${NC}"
40
+ exit 0
@@ -0,0 +1,36 @@
1
+ ---
2
+ paths:
3
+ - "app/api/**"
4
+ - "src/app/api/**"
5
+ ---
6
+
7
+ # API Route Rules
8
+
9
+ ## Input validation
10
+ - Validate ALL inputs with Zod schemas
11
+ - Parse request body: schema.parse(await req.json())
12
+ - Validate URL params: z.string().uuid()
13
+ - Return 400 with { error: "..." } on validation failure
14
+
15
+ ## Authentication
16
+ - All protected routes: const user = await requireAuth()
17
+ - requireAuth() throws 401 if no session
18
+ - Never trust client-sent user IDs -- use auth.uid()
19
+
20
+ ## Error handling
21
+ - Consistent format: { error: string, code?: string }
22
+ - Never expose stack traces or internal errors
23
+ - Log errors with context (route, user_id, input)
24
+ - Return appropriate HTTP codes:
25
+ 400 = bad input, 401 = no auth, 403 = forbidden
26
+ 404 = not found, 429 = rate limited, 500 = server error
27
+
28
+ ## Rate limiting
29
+ - All public endpoints: rateLimit(req, { max: 10 })
30
+ - Payment endpoints: rateLimit(req, { max: 3 })
31
+ - Export endpoints: rateLimit(req, { max: 5 })
32
+
33
+ ## Response
34
+ - Always return NextResponse.json()
35
+ - Set Cache-Control headers where appropriate
36
+ - Webhooks: return 200 quickly, process async
@@ -0,0 +1,33 @@
1
+ ---
2
+ paths:
3
+ - "supabase/**"
4
+ - "src/lib/db/**"
5
+ - "prisma/**"
6
+ - "drizzle/**"
7
+ ---
8
+
9
+ # Database Rules
10
+
11
+ ## Query patterns
12
+ - Always use parameterized queries, never string concatenation
13
+ - Use transactions for multi-step operations
14
+ - Add proper indexes for frequently queried columns
15
+ - Limit result sets with pagination
16
+
17
+ ## Schema changes
18
+ - Always create migrations, never modify the database directly
19
+ - Include both up and down migrations
20
+ - Test migrations on a copy before applying to production
21
+ - Document breaking schema changes
22
+
23
+ ## Security
24
+ - Never trust client-sent user IDs -- use auth.uid()
25
+ - Row Level Security (RLS) on all user-facing tables
26
+ - Sanitize all inputs before database operations
27
+ - Never expose internal IDs in API responses
28
+
29
+ ## Performance
30
+ - Use connection pooling
31
+ - Cache frequently accessed, rarely changed data
32
+ - Avoid N+1 queries -- use joins or batch loading
33
+ - Monitor query performance and add indexes as needed
@@ -0,0 +1,34 @@
1
+ ---
2
+ paths:
3
+ - "app/**"
4
+ - "src/app/**"
5
+ - "components/**"
6
+ - "src/components/**"
7
+ ---
8
+
9
+ # Frontend Rules
10
+
11
+ ## Component patterns
12
+ - Functional components + hooks only
13
+ - No class components
14
+ - Use TypeScript strict mode, no `any` types
15
+ - No prop drilling past 2 levels -- use store or context
16
+
17
+ ## Styling
18
+ - Use Tailwind CSS for all styling
19
+ - Dark mode FIRST, light mode via overrides
20
+ - Responsive design: mobile-first approach
21
+ - Use CSS variables for theme values
22
+
23
+ ## Performance
24
+ - Memoize expensive computations (useMemo)
25
+ - Stabilize callback references (useCallback)
26
+ - Use next/image with proper width/height
27
+ - Lazy load components below the fold
28
+ - No blocking operations in render path
29
+
30
+ ## Accessibility
31
+ - All interactive elements must be keyboard accessible
32
+ - Use semantic HTML elements
33
+ - Include aria-labels where needed
34
+ - Maintain proper heading hierarchy
@@ -0,0 +1,47 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm run lint)",
5
+ "Bash(npm run test *)",
6
+ "Bash(npm run build)",
7
+ "Bash(npx playwright test *)",
8
+ "Bash(git diff *)",
9
+ "Bash(git log *)",
10
+ "Bash(git status)",
11
+ "Bash(gh issue *)",
12
+ "Bash(gh pr *)"
13
+ ],
14
+ "deny": [
15
+ "Read(.env)",
16
+ "Read(.env.*)",
17
+ "Read(secrets/**)",
18
+ "Bash(rm -rf *)",
19
+ "Bash(git push --force *)",
20
+ "Bash(curl *)"
21
+ ]
22
+ },
23
+ "hooks": {
24
+ "PreToolUse": [
25
+ {
26
+ "matcher": "Bash",
27
+ "hooks": [{
28
+ "type": "command",
29
+ "command": ".claude/hooks/pre-commit.sh"
30
+ }]
31
+ }
32
+ ],
33
+ "PostToolUse": [
34
+ {
35
+ "matcher": "Edit|Write",
36
+ "hooks": [{
37
+ "type": "command",
38
+ "command": ".claude/hooks/lint-on-save.sh"
39
+ }]
40
+ }
41
+ ]
42
+ },
43
+ "model": "claude-sonnet-4-6",
44
+ "autoMemoryEnabled": true,
45
+ "includeGitInstructions": true,
46
+ "respectGitignore": true
47
+ }
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: frontend-design
3
+ description: Enforces exact design standards
4
+ for all UI: colors, spacing, typography, layout.
5
+ user-invocable: true
6
+ ---
7
+
8
+ When building ANY UI for this product:
9
+
10
+ ## Brand colors
11
+ - Primary: #FF6B35 (Electric Coral)
12
+ - Primary Light: #FF8F6B (gradients)
13
+ - Primary Soft: #FFB088 (gradient endpoints)
14
+ - Teal accent: #00d4aa (cool complement)
15
+ - Background: #0A0A0F (rich black, NOT flat #000)
16
+ - Surface: rgba(255,255,255,0.04) (cards)
17
+ - Surface hover: rgba(255,255,255,0.07)
18
+ - Border: rgba(255,255,255,0.10)
19
+ - Text primary: #FFFFFF
20
+ - Text secondary: rgba(255,255,255,0.6)
21
+ - Text muted: rgba(255,255,255,0.4)
22
+
23
+ ## Typography
24
+ - Font: Inter (system fallback: -apple-system)
25
+ - Headings: -0.02em letter-spacing, font-weight 700
26
+ - Hero: 48-64px, gradient text optional
27
+ - Section heading: 32-36px
28
+ - Body: 15-16px, line-height 1.6
29
+ - Code: Menlo 14px
30
+ - Labels/badges: 11-12px uppercase, 0.08em tracking
31
+
32
+ ## Spacing & layout
33
+ - Section gap: 64px (py-16)
34
+ - Card padding: 24px
35
+ - Inner content gap: 12-16px
36
+ - Max content width: 1200px
37
+ - Border radius: 16px cards, 12px modals, 8px buttons
38
+
39
+ ## Dark mode aesthetic
40
+ - NEVER flat black. Use depth through:
41
+ - Subtle gradients (bg-gradient-to-b)
42
+ - Glow effects on hover (box-shadow coral)
43
+ - Border separators (rgba white 0.10)
44
+ - Surface elevation (slightly lighter bg)
@@ -0,0 +1,39 @@
1
+ # CLAUDE.md -- Project Brain
2
+
3
+ ## Tech Stack
4
+ - Next.js 14 (App Router, TypeScript)
5
+ - Tailwind CSS + shadcn/ui
6
+ - Supabase (Auth & Database)
7
+ - Stripe (Payments)
8
+ - Vercel (Hosting)
9
+
10
+ ## Folder Structure
11
+ - app/ -- pages and API routes
12
+ - components/ -- React components
13
+ - lib/ -- utilities, helpers
14
+ - stores/ -- state management
15
+ - types/ -- shared TypeScript types
16
+ - supabase/ -- migrations and SQL
17
+
18
+ ## Commands
19
+ - npm run dev -- start dev server
20
+ - npm run build -- production build
21
+ - npm test -- run test suite
22
+ - npm run lint -- ESLint check
23
+
24
+ ## Coding Conventions
25
+ - TypeScript strict mode, no `any` types
26
+ - Functional components + hooks only
27
+ - Dark mode FIRST, light mode via overrides
28
+ - No prop drilling past 2 levels -- use store
29
+
30
+ ## Git Rules
31
+ - Commit format: TYPE: [description]
32
+ - Never push unless explicitly told to
33
+ - Feature branches for 8+ file changes
34
+
35
+ ## Security
36
+ - Never hardcode API keys or secrets
37
+ - Always validate inputs with Zod
38
+ - Use environment variables for all configs
39
+ - .env files must be in .gitignore