claude-code-standards 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,53 @@
1
+ # claude-code-standards
2
+
3
+ Reusable Claude Code agents, rules, and conventions for any project. Auto-detects your tech stack and generates a tailored `CLAUDE.md` + specialized agents.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -D claude-code-standards
9
+ ```
10
+
11
+ ## Initialize
12
+
13
+ ```bash
14
+ npx claude-code-standards init
15
+ ```
16
+
17
+ This will:
18
+ 1. Read your `package.json` to detect your tech stack
19
+ 2. Generate a `CLAUDE.md` with relevant rules for your stack
20
+ 3. Install agents to `.claude/agents/` (code-guardian, figma-builder, figma-validator)
21
+ 4. Install docs to `.claude/docs/`
22
+
23
+ ## What gets detected
24
+
25
+ | Dependency | Rules Applied |
26
+ |---|---|
27
+ | `next` | App Router conventions, layout patterns, route organization |
28
+ | `@reduxjs/toolkit` | RTK Query service patterns, tag constants, Object.values |
29
+ | `@radix-ui/react-slot` | Shadcn/UI read-only rule, wrapper pattern |
30
+ | `@nestjs/core` | Module structure, DTO validation, guard patterns |
31
+ | `zod` | Centralized validation schemas |
32
+ | `@ebay/nice-modal-react` | ModalConstant pattern, barrel registration |
33
+ | `tailwindcss` | Tailwind conventions |
34
+ | And more... | Stripe, LiveKit, TypeORM, Prisma, etc. |
35
+
36
+ ## Agents
37
+
38
+ ### code-guardian
39
+ Run **first** before any task. Audits the codebase against CLAUDE.md rules and discovers undocumented patterns.
40
+
41
+ ### figma-builder (frontend only)
42
+ Builds pixel-perfect components from Figma frames. Extracts all assets, preserves exact styling.
43
+
44
+ ### figma-validator (frontend only)
45
+ Validates built components against Figma screenshots. Catches missing assets, wrong colors, spacing issues.
46
+
47
+ ## Customization
48
+
49
+ After `init`, edit `CLAUDE.md` to add project-specific rules. The generated file is a starting point — customize it for your project's unique conventions.
50
+
51
+ ## License
52
+
53
+ MIT
package/bin/init.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path');
4
+ const { detectStack } = require('../lib/detect');
5
+ const { generateClaudeMd, installAgents, installDocs } = require('../lib/install');
6
+
7
+ const projectDir = process.cwd();
8
+
9
+ console.log('\nšŸ” Claude Code Standards — Initializing...\n');
10
+ console.log(`Project: ${projectDir}\n`);
11
+
12
+ // Step 1: Detect stack
13
+ console.log('Detecting tech stack...');
14
+ const stack = detectStack(projectDir);
15
+
16
+ const detected = [];
17
+ if (stack.nextjs) detected.push('Next.js');
18
+ if (stack.react && !stack.nextjs) detected.push('React');
19
+ if (stack.nestjs) detected.push('NestJS');
20
+ if (stack.express) detected.push('Express');
21
+ if (stack.rtkQuery) detected.push('RTK Query');
22
+ if (stack.tailwind) detected.push('Tailwind CSS');
23
+ if (stack.shadcn) detected.push('Shadcn/UI');
24
+ if (stack.niceModal) detected.push('nice-modal-react');
25
+ if (stack.zod) detected.push('Zod');
26
+ if (stack.typeorm) detected.push('TypeORM');
27
+ if (stack.prisma) detected.push('Prisma');
28
+ if (stack.stripe) detected.push('Stripe');
29
+
30
+ console.log(` Detected: ${detected.join(', ') || 'No specific stack detected'}`);
31
+ console.log(` Type: ${stack.isFrontend ? 'Frontend' : ''}${stack.isFrontend && stack.isBackend ? ' + ' : ''}${stack.isBackend ? 'Backend' : ''}`);
32
+ console.log('');
33
+
34
+ // Step 2: Generate CLAUDE.md
35
+ console.log('Generating CLAUDE.md...');
36
+ generateClaudeMd(projectDir, stack);
37
+ console.log(' Created CLAUDE.md');
38
+
39
+ // Step 3: Install agents
40
+ console.log('\nInstalling agents...');
41
+ installAgents(projectDir, stack);
42
+
43
+ // Step 4: Install docs
44
+ console.log('\nInstalling docs...');
45
+ installDocs(projectDir, stack);
46
+
47
+ console.log('\nāœ… Done! Claude Code Standards initialized.');
48
+ console.log('\nNext steps:');
49
+ console.log(' 1. Review CLAUDE.md and customize project-specific sections');
50
+ console.log(' 2. Run the code-guardian agent to audit your codebase');
51
+ console.log(' 3. Commit .claude/ directory to your repo\n');
package/lib/detect.js ADDED
@@ -0,0 +1,81 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * Detect the tech stack of a project by reading its package.json
6
+ * Returns an object with boolean flags for each detected technology
7
+ */
8
+ function detectStack(projectDir) {
9
+ const pkgPath = path.join(projectDir, 'package.json');
10
+
11
+ if (!fs.existsSync(pkgPath)) {
12
+ console.error('No package.json found in', projectDir);
13
+ process.exit(1);
14
+ }
15
+
16
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
17
+ const allDeps = {
18
+ ...pkg.dependencies,
19
+ ...pkg.devDependencies,
20
+ };
21
+
22
+ const has = (dep) => !!allDeps[dep];
23
+
24
+ return {
25
+ // Frameworks
26
+ nextjs: has('next'),
27
+ react: has('react'),
28
+ nestjs: has('@nestjs/core'),
29
+ express: has('express'),
30
+
31
+ // State management
32
+ rtkQuery: has('@reduxjs/toolkit'),
33
+ redux: has('react-redux') || has('@reduxjs/toolkit'),
34
+ zustand: has('zustand'),
35
+ tanstackQuery: has('@tanstack/react-query'),
36
+
37
+ // UI
38
+ tailwind: has('tailwindcss'),
39
+ shadcn: has('@radix-ui/react-slot') || has('class-variance-authority'),
40
+ niceModal: has('@ebay/nice-modal-react'),
41
+
42
+ // Validation
43
+ zod: has('zod'),
44
+ yup: has('yup'),
45
+ classValidator: has('class-validator'),
46
+
47
+ // ORM / Database
48
+ typeorm: has('typeorm'),
49
+ prisma: has('@prisma/client'),
50
+ drizzle: has('drizzle-orm'),
51
+
52
+ // Auth
53
+ passport: has('passport'),
54
+ nextAuth: has('next-auth'),
55
+
56
+ // Payments
57
+ stripe: has('stripe') || has('@stripe/react-stripe-js'),
58
+
59
+ // Real-time
60
+ livekit: has('@livekit/components-react') || has('livekit-server-sdk'),
61
+ socketio: has('socket.io') || has('socket.io-client'),
62
+
63
+ // Testing
64
+ jest: has('jest'),
65
+ vitest: has('vitest'),
66
+ playwright: has('@playwright/test'),
67
+
68
+ // Meta
69
+ isMonorepo: fs.existsSync(path.join(projectDir, 'packages')) ||
70
+ fs.existsSync(path.join(projectDir, 'apps')) ||
71
+ has('turborepo') || has('lerna'),
72
+ isFrontend: has('react') || has('vue') || has('svelte') || has('next') || has('nuxt'),
73
+ isBackend: has('@nestjs/core') || has('express') || has('fastify') || has('hono'),
74
+
75
+ // Package info
76
+ name: pkg.name || 'unknown',
77
+ description: pkg.description || '',
78
+ };
79
+ }
80
+
81
+ module.exports = { detectStack };
package/lib/install.js ADDED
@@ -0,0 +1,130 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const TEMPLATES_DIR = path.join(__dirname, '..', 'templates');
5
+
6
+ /**
7
+ * Copy a file from templates to project, creating directories as needed
8
+ */
9
+ function copyTemplate(templatePath, destPath) {
10
+ const dir = path.dirname(destPath);
11
+ if (!fs.existsSync(dir)) {
12
+ fs.mkdirSync(dir, { recursive: true });
13
+ }
14
+ fs.copyFileSync(
15
+ path.join(TEMPLATES_DIR, templatePath),
16
+ destPath
17
+ );
18
+ }
19
+
20
+ /**
21
+ * Generate CLAUDE.md from template with stack-aware sections
22
+ */
23
+ function generateClaudeMd(projectDir, stack) {
24
+ const template = fs.readFileSync(
25
+ path.join(TEMPLATES_DIR, 'CLAUDE.md.template'),
26
+ 'utf-8'
27
+ );
28
+
29
+ let output = template;
30
+
31
+ // Replace placeholders
32
+ output = output.replace(/\{\{PROJECT_NAME\}\}/g, stack.name);
33
+ output = output.replace(/\{\{PROJECT_DESCRIPTION\}\}/g, stack.description);
34
+
35
+ // Build tech stack table
36
+ const techStack = [];
37
+ if (stack.nextjs) techStack.push('| Framework | Next.js (App Router) |');
38
+ else if (stack.react) techStack.push('| Framework | React |');
39
+ else if (stack.nestjs) techStack.push('| Framework | NestJS |');
40
+ else if (stack.express) techStack.push('| Framework | Express |');
41
+
42
+ if (stack.tailwind) techStack.push('| Styling | Tailwind CSS |');
43
+ if (stack.shadcn) techStack.push('| UI Components | Shadcn/UI |');
44
+ if (stack.rtkQuery) techStack.push('| State | Redux Toolkit + RTK Query |');
45
+ else if (stack.zustand) techStack.push('| State | Zustand |');
46
+ else if (stack.tanstackQuery) techStack.push('| Data Fetching | TanStack Query |');
47
+ if (stack.zod) techStack.push('| Validation | Zod |');
48
+ else if (stack.classValidator) techStack.push('| Validation | class-validator |');
49
+ if (stack.typeorm) techStack.push('| ORM | TypeORM |');
50
+ else if (stack.prisma) techStack.push('| ORM | Prisma |');
51
+ if (stack.stripe) techStack.push('| Payments | Stripe |');
52
+
53
+ output = output.replace('{{TECH_STACK_TABLE}}', techStack.join('\n'));
54
+
55
+ // Conditional sections
56
+ const conditionalSections = {
57
+ '{{#IF_RTK_QUERY}}': stack.rtkQuery,
58
+ '{{#IF_NEXTJS}}': stack.nextjs,
59
+ '{{#IF_SHADCN}}': stack.shadcn,
60
+ '{{#IF_ZOD}}': stack.zod,
61
+ '{{#IF_NICE_MODAL}}': stack.niceModal,
62
+ '{{#IF_NESTJS}}': stack.nestjs,
63
+ '{{#IF_FRONTEND}}': stack.isFrontend,
64
+ '{{#IF_BACKEND}}': stack.isBackend,
65
+ };
66
+
67
+ for (const [tag, condition] of Object.entries(conditionalSections)) {
68
+ const endTag = tag.replace('#IF_', '/IF_');
69
+ const regex = new RegExp(`${escapeRegex(tag)}([\\s\\S]*?)${escapeRegex(endTag)}`, 'g');
70
+
71
+ if (condition) {
72
+ // Keep the content, remove the tags
73
+ output = output.replace(regex, '$1');
74
+ } else {
75
+ // Remove the entire section including content
76
+ output = output.replace(regex, '');
77
+ }
78
+ }
79
+
80
+ // Clean up empty lines
81
+ output = output.replace(/\n{3,}/g, '\n\n');
82
+
83
+ const destPath = path.join(projectDir, 'CLAUDE.md');
84
+ if (fs.existsSync(destPath)) {
85
+ // Backup existing
86
+ fs.copyFileSync(destPath, destPath + '.backup');
87
+ console.log(' Backed up existing CLAUDE.md → CLAUDE.md.backup');
88
+ }
89
+ fs.writeFileSync(destPath, output);
90
+ }
91
+
92
+ /**
93
+ * Install agents based on detected stack
94
+ */
95
+ function installAgents(projectDir, stack) {
96
+ const agentsDir = path.join(projectDir, '.claude', 'agents');
97
+
98
+ // Always install code-guardian
99
+ copyTemplate('agents/code-guardian.md', path.join(agentsDir, 'code-guardian.md'));
100
+ console.log(' Installed agent: code-guardian');
101
+
102
+ // Frontend-only agents
103
+ if (stack.isFrontend) {
104
+ copyTemplate('agents/figma-builder.md', path.join(agentsDir, 'figma-builder.md'));
105
+ copyTemplate('agents/figma-validator.md', path.join(agentsDir, 'figma-validator.md'));
106
+ console.log(' Installed agent: figma-builder');
107
+ console.log(' Installed agent: figma-validator');
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Install docs based on detected stack
113
+ */
114
+ function installDocs(projectDir, stack) {
115
+ const docsDir = path.join(projectDir, '.claude', 'docs');
116
+
117
+ copyTemplate('docs/architectural_patterns.md', path.join(docsDir, 'architectural_patterns.md'));
118
+ console.log(' Installed doc: architectural_patterns');
119
+
120
+ if (stack.isFrontend && stack.shadcn) {
121
+ copyTemplate('docs/dashboard_redesign.md', path.join(docsDir, 'dashboard_redesign.md'));
122
+ console.log(' Installed doc: dashboard_redesign');
123
+ }
124
+ }
125
+
126
+ function escapeRegex(str) {
127
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
128
+ }
129
+
130
+ module.exports = { generateClaudeMd, installAgents, installDocs, copyTemplate };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "claude-code-standards",
3
+ "version": "1.0.0",
4
+ "description": "Reusable Claude Code agents, rules, and conventions for any project. Auto-detects your tech stack and generates CLAUDE.md + agents.",
5
+ "bin": {
6
+ "claude-code-standards": "./bin/init.js"
7
+ },
8
+ "files": [
9
+ "bin/",
10
+ "lib/",
11
+ "templates/"
12
+ ],
13
+ "keywords": [
14
+ "claude",
15
+ "claude-code",
16
+ "code-quality",
17
+ "agents",
18
+ "standards",
19
+ "conventions"
20
+ ],
21
+ "author": "CoTrain",
22
+ "license": "MIT"
23
+ }
@@ -0,0 +1,96 @@
1
+ # CLAUDE.md
2
+
3
+ ## Project Overview
4
+
5
+ {{PROJECT_NAME}} — {{PROJECT_DESCRIPTION}}
6
+
7
+ ## Commands
8
+
9
+ ```bash
10
+ npm run dev # Dev server
11
+ npm run build # Production build (ALWAYS run after changes to verify)
12
+ npm run lint # Linting
13
+ ```
14
+
15
+ ## Tech Stack
16
+
17
+ | Layer | Technology |
18
+ |-------|-----------|
19
+ {{TECH_STACK_TABLE}}
20
+
21
+ ## Key Conventions
22
+
23
+ - **Import alias**: Use `@/*` or configured path alias for imports. Avoid deep relative paths.
24
+ - **Component organization** — organize by what the component IS:
25
+ - `ui/` — UI library primitives (READ-ONLY if using shadcn/ui)
26
+ - `sidebar/` — shell navigation (sidebar, header)
27
+ - `cards/` — reusable card components
28
+ - `banners/` — hero/banner sections
29
+ - `widgets/` — floating/interactive widgets
30
+ - `sections/` — page sections that compose cards/banners
31
+ - `pages/` — full page-level content views
32
+ - `modal/` — modal dialogs
33
+ - Think about what the component IS, not what page it appears on.
34
+ {{#IF_SHADCN}}
35
+ - **`src/components/ui/` is READ-ONLY** — never modify UI library primitives directly. Create wrappers in feature directories that import and extend them.
36
+ {{/IF_SHADCN}}
37
+ {{#IF_ZOD}}
38
+ - **Form validation**: All Zod schemas go in a dedicated validation directory. Never define validation inline in components.
39
+ {{/IF_ZOD}}
40
+ {{#IF_NICE_MODAL}}
41
+ - **Modals**: Use `@ebay/nice-modal-react` with centralized `ModalConstant` for IDs. Each modal uses `NiceModal.create()` + UI Dialog. Register in barrel file.
42
+ {{/IF_NICE_MODAL}}
43
+ {{#IF_NEXTJS}}
44
+ - **Routing**: Each major section should be a page route. Layouts provide persistent shells. Use `usePathname()` + `<Link>` for navigation.
45
+ {{/IF_NEXTJS}}
46
+
47
+ {{#IF_RTK_QUERY}}
48
+ ## Service Layer
49
+
50
+ - **`src/services/api/`** — RTK Query services ONLY. Each file extends the base API factory. One service per domain.
51
+ - **Base service** — Network setup only (JWT injection, error handling). Do NOT add business logic.
52
+ - **Service registry** — When adding a new service, register in 3 places: reducers, middleware, and re-export.
53
+ - **Tag constants** — All RTK cache tags in a centralized constant file. Never define tags inline. Use `Object.values()` for tag arrays.
54
+ - **Request/Response types** — All DTOs in dedicated model directories. Never define types inline in service files.
55
+ - **Service wrappers** — Optional convenience hooks wrapping RTK mutations. Only create when the same logic is reused across components.
56
+ {{/IF_RTK_QUERY}}
57
+
58
+ {{#IF_NESTJS}}
59
+ ## Backend Conventions
60
+
61
+ - **Module structure**: One module per domain. Each module has controller, service, and DTOs.
62
+ - **DTOs**: All in dedicated DTO files with class-validator decorators. Never accept raw objects.
63
+ - **Guards**: Use guards for auth. Mark public endpoints explicitly.
64
+ - **Pipes**: Use ValidationPipe globally. DTOs handle validation.
65
+ - **Interceptors**: Use for response transformation and logging.
66
+ {{/IF_NESTJS}}
67
+
68
+ ## Bug Fixing
69
+
70
+ Identify the EXACT file and component before patching. After fixing, grep the codebase for similar patterns that may need the same fix.
71
+
72
+ {{#IF_FRONTEND}}
73
+ ## Figma-to-Code Rules
74
+
75
+ When building from Figma designs:
76
+ - **Never neglect backgrounds** — apply every gradient, color, shadow
77
+ - **Always read UI library source** — check for default styles that override yours
78
+ - **Exact spacing** — match gap, padding, margin from the design exactly
79
+ - **Check every surface** — background, box-shadow, border, border-radius must all match
80
+ - **Use figma-builder and figma-validator agents** for pixel-perfect implementation
81
+ - **Visual compare** — always compare rendered output against the design
82
+ {{/IF_FRONTEND}}
83
+
84
+ ## Agents
85
+
86
+ Run **code-guardian** FIRST before starting any task.
87
+
88
+ - `.claude/agents/code-guardian.md` — Audits rule compliance, finds violations, discovers undocumented patterns
89
+ {{#IF_FRONTEND}}
90
+ - `.claude/agents/figma-builder.md` — Builds pixel-perfect components from Figma
91
+ - `.claude/agents/figma-validator.md` — Validates components against Figma designs
92
+ {{/IF_FRONTEND}}
93
+
94
+ ## Additional Documentation
95
+
96
+ - `.claude/docs/architectural_patterns.md` — Recurring patterns and conventions
@@ -0,0 +1,138 @@
1
+ ---
2
+ name: code-guardian
3
+ description: Audits the codebase against CLAUDE.md rules and discovers undocumented patterns. Run this FIRST before starting any task. This agent is curious — it enforces rules AND actively looks for new patterns worth documenting.
4
+ ---
5
+
6
+ You are the Code Guardian — an auditor and curious observer of this codebase.
7
+
8
+ ## Your Mission
9
+ 1. **Enforce** — check that all CLAUDE.md rules are being followed
10
+ 2. **Discover** — find patterns, conventions, and issues not yet documented
11
+ 3. **Report** — produce a clear, actionable report
12
+
13
+ ## Setup
14
+ 1. Read `CLAUDE.md` at the project root — this is your source of truth
15
+ 2. Read `package.json` to understand the tech stack
16
+ 3. Check `.claude/docs/` for additional documented patterns
17
+
18
+ ## Universal Checks (All Projects)
19
+
20
+ ### Types & Interfaces
21
+ ```bash
22
+ # Inline types in service/API files (should be in a models/types directory)
23
+ grep -rn "^export interface\|^export type\|^interface \|^type " src/services/ --include="*.ts" 2>/dev/null | grep -v "export type {"
24
+ ```
25
+
26
+ ### Constants
27
+ ```bash
28
+ # Hardcoded string constants that should be centralized
29
+ grep -rn "const.*=\s*['\"]" src/services/ --include="*.ts" 2>/dev/null | grep -v "import\|require\|from\|//" | head -20
30
+ ```
31
+
32
+ ### Dead Code
33
+ ```bash
34
+ # Console.log left in code
35
+ grep -rn "console\.log\|console\.warn" src/ --include="*.ts" --include="*.tsx" 2>/dev/null | grep -v "node_modules\|_archive" | head -20
36
+
37
+ # TODO/FIXME comments
38
+ grep -rn "TODO\|FIXME\|HACK\|XXX" src/ app/ --include="*.ts" --include="*.tsx" 2>/dev/null | grep -v "node_modules\|_archive" | head -20
39
+
40
+ # Large files (>300 lines)
41
+ find src/ -name "*.tsx" -o -name "*.ts" 2>/dev/null | xargs wc -l 2>/dev/null | sort -rn | head -20
42
+ ```
43
+
44
+ ### Import Hygiene
45
+ ```bash
46
+ # Relative imports deeper than 2 levels (should use alias)
47
+ grep -rn "from '\.\./\.\.\.\." src/ --include="*.tsx" --include="*.ts" 2>/dev/null | head -10
48
+ ```
49
+
50
+ ## Stack-Specific Checks
51
+
52
+ Read `package.json` and run only the relevant checks:
53
+
54
+ ### If RTK Query (`@reduxjs/toolkit` in dependencies)
55
+ ```bash
56
+ # Inline tag constants in service files
57
+ grep -rn "^const.*TAGS\s*=" src/services/api/ --include="*.ts" 2>/dev/null
58
+
59
+ # Tag arrays not using Object.values()
60
+ grep -rn "RTKTagsConstant\.\w*\.\w*," src/services/api/ --include="*.ts" 2>/dev/null | head -10
61
+
62
+ # TanStack Query usage (forbidden if RTK Query is primary)
63
+ grep -rn "@tanstack/react-query" src/ --include="*.ts" --include="*.tsx" 2>/dev/null
64
+ ```
65
+
66
+ ### If Next.js (`next` in dependencies)
67
+ ```bash
68
+ # Pages missing 'use client' or 'use server' directive
69
+ find app/ -name "page.tsx" 2>/dev/null | head -20
70
+
71
+ # Layout files
72
+ find app/ -name "layout.tsx" 2>/dev/null
73
+ ```
74
+
75
+ ### If Shadcn/UI (`@radix-ui/react-slot` in dependencies)
76
+ ```bash
77
+ # Modified shadcn files (ui/ should be read-only)
78
+ grep -rn "// custom\|// modified\|// added" src/components/ui/ --include="*.tsx" 2>/dev/null
79
+ ```
80
+
81
+ ### If Zod (`zod` in dependencies)
82
+ ```bash
83
+ # Inline Zod schemas (should be in validation directory)
84
+ grep -rn "z\.object\|z\.string().min" src/components/ app/ --include="*.tsx" 2>/dev/null | grep -v "import" | head -10
85
+ ```
86
+
87
+ ### If NestJS (`@nestjs/core` in dependencies)
88
+ ```bash
89
+ # Controllers without guards
90
+ grep -rL "@UseGuards\|@Public" src/**/*.controller.ts 2>/dev/null
91
+
92
+ # Services without proper injection
93
+ grep -rn "new.*Service()" src/ --include="*.ts" 2>/dev/null | head -10
94
+
95
+ # DTOs without class-validator decorators
96
+ find src/ -name "*.dto.ts" 2>/dev/null | head -20
97
+ ```
98
+
99
+ ## Discovery Mode
100
+
101
+ After running checks, observe:
102
+
103
+ ```bash
104
+ # Component directory structure
105
+ ls src/components/ 2>/dev/null
106
+
107
+ # Naming convention consistency
108
+ find src/components -name "*.tsx" 2>/dev/null | head -30
109
+
110
+ # Export patterns (named vs default)
111
+ grep -rn "^export default\|^export function\|^export const" src/components/ --include="*.tsx" 2>/dev/null | head -20
112
+
113
+ # Barrel exports
114
+ find src/ -name "index.ts" -o -name "index.tsx" 2>/dev/null | head -20
115
+
116
+ # Hardcoded colors (potential design tokens)
117
+ grep -rn "#[0-9a-fA-F]\{6\}" src/components/ --include="*.tsx" 2>/dev/null | wc -l
118
+ ```
119
+
120
+ ## Report Format
121
+
122
+ ### VIOLATIONS (Must Fix)
123
+ Issues that break documented rules.
124
+ - Rule violated
125
+ - File:line
126
+ - What's wrong → How to fix
127
+
128
+ ### SUGGESTIONS (Should Consider)
129
+ Code that works but could be better.
130
+ - What was found → Why it matters → Suggested improvement
131
+
132
+ ### DISCOVERIES (Document This)
133
+ New patterns not yet in CLAUDE.md.
134
+ - Pattern description → Where it appears → Add to CLAUDE.md?
135
+
136
+ ---
137
+
138
+ **You are READ-ONLY. Never modify files. Only observe and report.**
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: figma-builder
3
+ description: Builds pixel-perfect React components from Figma frames. Extracts all assets, downloads them locally, and produces components that exactly match the design.
4
+ ---
5
+
6
+ You are a pixel-perfect Figma-to-code builder.
7
+
8
+ ## Your Task
9
+ You will be given a **Figma node ID** and an **output file path**.
10
+
11
+ ### 1. Extract the design
12
+ Call `get_design_context` with the Figma file key and node ID. This returns:
13
+ - Reference React+Tailwind code
14
+ - Asset URLs as constants
15
+ - A screenshot of the design
16
+
17
+ ### 2. Download ALL assets
18
+ For **every** asset URL in the response:
19
+ - Download using `curl -sL "{url}" -o public/assets/{name}.{ext}`
20
+ - Check file type with `file` command, use correct extension
21
+ - Name descriptively: `icon-home.svg`, `illustration-discover.png`, etc.
22
+ - **Do NOT skip any asset**
23
+
24
+ ### 3. Build the component
25
+ Using the Figma-generated code as reference:
26
+ - Use the project's UI component library as base
27
+ - Replace ALL Figma temporary URLs with local `/assets/` paths
28
+ - Preserve **EXACT** values: colors, spacing, fonts, border-radius, dimensions
29
+ - **NEVER substitute icons** — use the actual extracted assets
30
+ - **NEVER approximate** — if the design says `text-[14px] tracking-[-0.15px]`, use exactly that
31
+
32
+ ### 4. Component library awareness
33
+ Before using any UI library component:
34
+ - **Read the source file** to check for default styles
35
+ - Identify defaults that conflict with the design
36
+ - Override them explicitly
37
+
38
+ ### 5. Background & surface styles
39
+ - **NEVER neglect backgrounds** — apply every gradient, color, shadow from the design
40
+ - Check every container's background, box-shadow, border, border-radius
41
+
42
+ ### 6. Spacing in grids
43
+ - Match `gap`, `padding`, `margin` exactly from the design
44
+ - Don't use framework defaults when the design specifies exact pixel values
45
+
46
+ ### 7. Component placement
47
+ Place each component in the directory that matches its role:
48
+ - `sidebar/` — navigation components
49
+ - `cards/` — reusable card components
50
+ - `banners/` — hero/banner sections
51
+ - `widgets/` — floating/interactive widgets
52
+ - `sections/` — page sections composing cards/banners
53
+ - `pages/` — full page-level content views
54
+ - `modal/` — modal dialogs
55
+
56
+ ### 8. Critical rules
57
+ - **NEVER substitute library icons** for extracted assets
58
+ - **NEVER invent data** — use exactly the text from the design
59
+ - **NEVER skip assets** — download every single one
60
+ - **NEVER ignore backgrounds** — every container's surface must match
61
+ - **NEVER modify UI library source files** — create wrappers instead
62
+ - After building, verify all imports resolve and no temporary URLs remain
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: figma-validator
3
+ description: Validates built components against Figma designs. Finds missing assets, wrong colors, spacing issues, and fixes them. Run after figma-builder.
4
+ ---
5
+
6
+ You are a pixel-perfect design validator.
7
+
8
+ ## Your Task
9
+ You will be given a **Figma node ID** and a **component file path**.
10
+
11
+ ### 1. Get the reference
12
+ - Call `get_screenshot` to see the actual design
13
+ - Call `get_design_context` to get the reference code and asset URLs
14
+
15
+ ### 2. Read the component
16
+ Read the built component file.
17
+
18
+ ### 3. Audit checklist
19
+
20
+ **a. Missing assets** — hardcoded text/emoji where images should be?
21
+
22
+ **b. Wrong colors** — compare hex values against the design reference
23
+
24
+ **c. Wrong spacing** — padding, margin, gap must match exact pixel values
25
+
26
+ **d. Missing elements** — is everything from the design present?
27
+
28
+ **e. Substituted icons** — library icons used instead of extracted assets?
29
+
30
+ **f. Wrong typography** — font family, size, weight, letter-spacing, line-height
31
+
32
+ **g. Wrong layout** — flex direction, alignment, grid columns
33
+
34
+ **h. Missing interactivity** — hover states, click handlers, cursors
35
+
36
+ **i. Missing backgrounds** — cards/sections plain white when design shows color?
37
+
38
+ **j. UI library conflicts** — check source files for default styles overriding custom ones
39
+
40
+ **k. Section spacing** — vertical spacing between sections, grid gaps
41
+
42
+ ### 4. Fix every issue
43
+ Edit the component file to fix each discrepancy. Download missing assets.
44
+
45
+ ### 5. Report
46
+ - Total issues found
47
+ - Issues fixed (list each)
48
+ - Final status: PASS or NEEDS ATTENTION
@@ -0,0 +1,51 @@
1
+ # Architectural Patterns
2
+
3
+ Recurring patterns across this codebase. Auto-generated by `claude-code-standards` — customize for your project.
4
+
5
+ ---
6
+
7
+ ## 1. Component Organization
8
+
9
+ Components are organized by **type**, not by feature:
10
+ - `ui/` — UI library primitives (read-only)
11
+ - `sidebar/` — navigation shell
12
+ - `cards/` — reusable card components
13
+ - `banners/` — hero/banner sections
14
+ - `widgets/` — floating/interactive widgets
15
+ - `sections/` — page sections composing smaller components
16
+ - `pages/` — full page content views
17
+ - `modal/` — modal dialogs
18
+
19
+ ---
20
+
21
+ ## 2. Service Layer
22
+
23
+ API services follow a factory pattern:
24
+ - One service per domain (auth, user, project, etc.)
25
+ - Base service handles network config (token injection, error handling)
26
+ - Services define only endpoints — no business logic
27
+ - Types/interfaces live in model directories, not in service files
28
+ - Cache tags are centralized in a constants file
29
+
30
+ ---
31
+
32
+ ## 3. Constants
33
+
34
+ All constants are centralized:
35
+ - API cache tags → dedicated constant file
36
+ - Modal IDs → `ModalConstant`
37
+ - Route paths → if applicable
38
+ - Never define string constants inline in service or component files
39
+
40
+ ---
41
+
42
+ ## 4. Validation
43
+
44
+ Form validation schemas are centralized:
45
+ - All schemas in a dedicated validation directory
46
+ - Never define validation inline in components
47
+ - Import and reference schemas by name
48
+
49
+ ---
50
+
51
+ *Add project-specific patterns below as they emerge.*
@@ -0,0 +1,29 @@
1
+ # Dashboard Design Specification
2
+
3
+ ## Architecture
4
+ - Single unified layout: sidebar + header + content area
5
+ - Shell stays mounted, content area swaps based on route
6
+ - Both user types share the same shell — differences are content-level only
7
+
8
+ ## Component Library
9
+ - Use UI library primitives as base, customize to match design
10
+ - UI library source files are READ-ONLY — create wrappers instead
11
+ - Every component must be reusable and accept props for variation
12
+
13
+ ## Auth Flow
14
+ - Auth is modal-based — no standalone auth pages
15
+ - Header shows Login/Signup buttons when no session
16
+ - After auth, modals close and session state updates
17
+
18
+ ## Unauthenticated State
19
+ - Dashboard renders immediately without a session
20
+ - Home tab is auto-selected by default
21
+ - Other tabs are visible but disabled/locked
22
+ - Content uses hardcoded design data
23
+
24
+ ## Design Source of Truth
25
+ - Connect to design tool (Figma MCP) before building
26
+ - Use hardcoded data directly from the design
27
+ - Match spacing, color, typography exactly
28
+
29
+ *Customize this for your project's specific design requirements.*