create-claude-webapp 1.0.0 → 1.0.1
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/.claude/agents/acceptance-test-generator.md +256 -0
- package/.claude/agents/auth-flow-designer.md +93 -0
- package/.claude/agents/code-reviewer.md +193 -0
- package/.claude/agents/code-verifier.md +194 -0
- package/.claude/agents/deployment-executor.md +90 -0
- package/.claude/agents/design-sync.md +226 -0
- package/.claude/agents/document-reviewer.md +304 -0
- package/.claude/agents/environment-validator.md +100 -0
- package/.claude/agents/integration-test-reviewer.md +196 -0
- package/.claude/agents/investigator.md +162 -0
- package/.claude/agents/prd-creator.md +220 -0
- package/.claude/agents/quality-fixer-frontend.md +323 -0
- package/.claude/agents/quality-fixer.md +280 -0
- package/.claude/agents/requirement-analyzer.md +149 -0
- package/.claude/agents/rls-policy-designer.md +86 -0
- package/.claude/agents/rule-advisor.md +123 -0
- package/.claude/agents/scope-discoverer.md +231 -0
- package/.claude/agents/solver.md +173 -0
- package/.claude/agents/supabase-migration-generator.md +85 -0
- package/.claude/agents/task-decomposer.md +246 -0
- package/.claude/agents/task-executor-frontend.md +264 -0
- package/.claude/agents/task-executor.md +261 -0
- package/.claude/agents/technical-designer-frontend.md +444 -0
- package/.claude/agents/technical-designer.md +370 -0
- package/.claude/agents/verifier.md +193 -0
- package/.claude/agents/work-planner.md +211 -0
- package/.claude/commands/add-integration-tests.md +116 -0
- package/.claude/commands/build.md +77 -0
- package/.claude/commands/db-migrate.md +96 -0
- package/.claude/commands/deploy.md +95 -0
- package/.claude/commands/design.md +75 -0
- package/.claude/commands/diagnose.md +202 -0
- package/.claude/commands/front-build.md +116 -0
- package/.claude/commands/front-design.md +61 -0
- package/.claude/commands/front-plan.md +53 -0
- package/.claude/commands/front-reverse-design.md +183 -0
- package/.claude/commands/front-review.md +89 -0
- package/.claude/commands/implement.md +80 -0
- package/.claude/commands/local-dev.md +94 -0
- package/.claude/commands/plan.md +61 -0
- package/.claude/commands/project-inject.md +76 -0
- package/.claude/commands/refine-skill.md +207 -0
- package/.claude/commands/reverse-engineer.md +301 -0
- package/.claude/commands/review.md +88 -0
- package/.claude/commands/setup-auth.md +68 -0
- package/.claude/commands/setup-supabase.md +66 -0
- package/.claude/commands/setup-vercel.md +71 -0
- package/.claude/commands/sync-skills.md +116 -0
- package/.claude/commands/task.md +13 -0
- package/.claude/skills/coding-standards/SKILL.md +246 -0
- package/.claude/skills/documentation-criteria/SKILL.md +184 -0
- package/.claude/skills/documentation-criteria/references/adr-template.md +64 -0
- package/.claude/skills/documentation-criteria/references/design-template.md +263 -0
- package/.claude/skills/documentation-criteria/references/plan-template.md +130 -0
- package/.claude/skills/documentation-criteria/references/prd-template.md +109 -0
- package/.claude/skills/documentation-criteria/references/task-template.md +38 -0
- package/.claude/skills/frontend/technical-spec/SKILL.md +147 -0
- package/.claude/skills/frontend/typescript-rules/SKILL.md +136 -0
- package/.claude/skills/frontend/typescript-testing/SKILL.md +129 -0
- package/.claude/skills/fullstack-integration/SKILL.md +466 -0
- package/.claude/skills/implementation-approach/SKILL.md +141 -0
- package/.claude/skills/integration-e2e-testing/SKILL.md +146 -0
- package/.claude/skills/interview/SKILL.md +345 -0
- package/.claude/skills/project-context/SKILL.md +53 -0
- package/.claude/skills/stack-auth/SKILL.md +519 -0
- package/.claude/skills/subagents-orchestration-guide/SKILL.md +218 -0
- package/.claude/skills/supabase/SKILL.md +289 -0
- package/.claude/skills/supabase-edge-functions/SKILL.md +386 -0
- package/.claude/skills/supabase-local/SKILL.md +328 -0
- package/.claude/skills/supabase-testing/SKILL.md +513 -0
- package/.claude/skills/task-analyzer/SKILL.md +131 -0
- package/.claude/skills/task-analyzer/references/skills-index.yaml +375 -0
- package/.claude/skills/technical-spec/SKILL.md +86 -0
- package/.claude/skills/typescript-rules/SKILL.md +121 -0
- package/.claude/skills/typescript-testing/SKILL.md +155 -0
- package/.claude/skills/vercel-deployment/SKILL.md +355 -0
- package/.claude/skills/vercel-edge/SKILL.md +407 -0
- package/README.md +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontend/typescript-rules
|
|
3
|
+
description: Applies React/TypeScript type safety, component design, and state management rules. Use when implementing React components.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TypeScript Development Rules (Frontend)
|
|
7
|
+
|
|
8
|
+
## Frontend-Specific Anti-patterns
|
|
9
|
+
|
|
10
|
+
In addition to universal anti-patterns in coding-standards skill, watch for these Frontend-specific issues:
|
|
11
|
+
|
|
12
|
+
- **Prop drilling through 3+ levels** - Should use Context API or state management
|
|
13
|
+
- **Massive components (300+ lines)** - Split into smaller components
|
|
14
|
+
|
|
15
|
+
## Type Safety in Frontend Implementation
|
|
16
|
+
|
|
17
|
+
**Type Safety in Data Flow**
|
|
18
|
+
- **Frontend -> Backend**: Props/State (Type Guaranteed) -> API Request (Serialization)
|
|
19
|
+
- **Backend -> Frontend**: API Response (`unknown`) -> Type Guard -> State (Type Guaranteed)
|
|
20
|
+
|
|
21
|
+
**Frontend-Specific Type Scenarios**:
|
|
22
|
+
- **React Props/State**: TypeScript manages types, unknown unnecessary
|
|
23
|
+
- **External API Responses**: Always receive as `unknown`, validate with type guards
|
|
24
|
+
- **localStorage/sessionStorage**: Treat as `unknown`, validate
|
|
25
|
+
- **URL Parameters**: Treat as `unknown`, validate
|
|
26
|
+
- **Form Input (Controlled Components)**: Type-safe with React synthetic events
|
|
27
|
+
|
|
28
|
+
**Type Complexity Management (Frontend)**
|
|
29
|
+
- **Props Design**:
|
|
30
|
+
- Props count: 3-7 props ideal (consider component splitting if exceeds 10)
|
|
31
|
+
- Optional Props: 50% or less (consider default values or Context if excessive)
|
|
32
|
+
- Nesting: Up to 2 levels (flatten deeper structures)
|
|
33
|
+
- Type Assertions: Review design if used 3+ times
|
|
34
|
+
- **External API Types**: Relax constraints and define according to reality (convert appropriately internally)
|
|
35
|
+
|
|
36
|
+
## Coding Conventions
|
|
37
|
+
|
|
38
|
+
**Component Design Criteria**
|
|
39
|
+
- **Function Components (Mandatory)**: Official React recommendation, optimizable by modern tooling
|
|
40
|
+
- **Classes Prohibited**: Class components completely deprecated (Exception: Error Boundary)
|
|
41
|
+
- **Custom Hooks**: Standard pattern for logic reuse
|
|
42
|
+
|
|
43
|
+
**Function Design**
|
|
44
|
+
- **0-2 parameters maximum**: Use object for 3+ parameters
|
|
45
|
+
```typescript
|
|
46
|
+
// Object parameter
|
|
47
|
+
function createUser({ name, email, role }: CreateUserParams) {}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Props Design (Props-driven Approach)**
|
|
51
|
+
- Props are the interface: Define all necessary information as props
|
|
52
|
+
- Avoid implicit dependencies: Do not depend on global state or context without necessity
|
|
53
|
+
- Type-safe: Always define Props type explicitly
|
|
54
|
+
|
|
55
|
+
**Environment Variables**
|
|
56
|
+
- **Use build tool's environment variable system**: `process.env` does not work in browsers
|
|
57
|
+
- **No secrets on client-side**: All frontend code is public, manage secrets in backend
|
|
58
|
+
|
|
59
|
+
**Dependency Injection**
|
|
60
|
+
- **Custom Hooks for dependency injection**: Ensure testability and modularity
|
|
61
|
+
|
|
62
|
+
**Asynchronous Processing**
|
|
63
|
+
- Promise Handling: Always use `async/await`
|
|
64
|
+
- Error Handling: Always handle with `try-catch` or Error Boundary
|
|
65
|
+
- Type Definition: Explicitly define return value types (e.g., `Promise<Result>`)
|
|
66
|
+
|
|
67
|
+
**Format Rules**
|
|
68
|
+
- Semicolon omission (follow Biome settings)
|
|
69
|
+
- Types in `PascalCase`, variables/functions in `camelCase`
|
|
70
|
+
- Imports use absolute paths (`src/`)
|
|
71
|
+
|
|
72
|
+
**Clean Code Principles**
|
|
73
|
+
- Delete unused code immediately
|
|
74
|
+
- Delete debug `console.log()`
|
|
75
|
+
- No commented-out code (manage history with version control)
|
|
76
|
+
- Comments explain "why" (not "what")
|
|
77
|
+
|
|
78
|
+
## Error Handling
|
|
79
|
+
|
|
80
|
+
**Absolute Rule**: Error suppression prohibited. All errors must have log output and appropriate handling.
|
|
81
|
+
|
|
82
|
+
**Fail-Fast Principle**: Fail quickly on errors to prevent continued processing in invalid states
|
|
83
|
+
```typescript
|
|
84
|
+
// Prohibited: Unconditional fallback
|
|
85
|
+
catch (error) {
|
|
86
|
+
return defaultValue // Hides error
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Required: Explicit failure
|
|
90
|
+
catch (error) {
|
|
91
|
+
logger.error('Processing failed', error)
|
|
92
|
+
throw error // Handle with Error Boundary or higher layer
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Result Type Pattern**: Express errors with types for explicit handling
|
|
97
|
+
```typescript
|
|
98
|
+
type Result<T, E> = { ok: true; value: T } | { ok: false; error: E }
|
|
99
|
+
|
|
100
|
+
// Example: Express error possibility with types
|
|
101
|
+
function parseUser(data: unknown): Result<User, ValidationError> {
|
|
102
|
+
if (!isValid(data)) return { ok: false, error: new ValidationError() }
|
|
103
|
+
return { ok: true, value: data as User }
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Custom Error Classes**
|
|
108
|
+
```typescript
|
|
109
|
+
export class AppError extends Error {
|
|
110
|
+
constructor(message: string, public readonly code: string, public readonly statusCode = 500) {
|
|
111
|
+
super(message)
|
|
112
|
+
this.name = this.constructor.name
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Purpose-specific: ValidationError(400), ApiError(502), NotFoundError(404)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Layer-Specific Error Handling (React)**
|
|
119
|
+
- Error Boundary: Catch React component errors, display fallback UI
|
|
120
|
+
- Custom Hook: Detect business rule violations, propagate AppError as-is
|
|
121
|
+
- API Layer: Convert fetch errors to domain errors
|
|
122
|
+
|
|
123
|
+
**Structured Logging and Sensitive Information Protection**
|
|
124
|
+
Never include sensitive information (password, token, apiKey, secret, creditCard) in logs
|
|
125
|
+
|
|
126
|
+
**Asynchronous Error Handling in React**
|
|
127
|
+
- Error Boundary setup mandatory: Catch rendering errors
|
|
128
|
+
- Use try-catch with all async/await in event handlers
|
|
129
|
+
- Always log and re-throw errors or display error state
|
|
130
|
+
|
|
131
|
+
## Performance Optimization
|
|
132
|
+
|
|
133
|
+
- Component Memoization: Use React.memo for expensive components
|
|
134
|
+
- State Optimization: Minimize re-renders with proper state structure
|
|
135
|
+
- Lazy Loading: Use React.lazy and Suspense for code splitting
|
|
136
|
+
- Bundle Size: Monitor with the `build` script and keep under 500KB
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontend/typescript-testing
|
|
3
|
+
description: Designs tests with React Testing Library and MSW. Applies component testing patterns.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TypeScript Testing Rules (Frontend)
|
|
7
|
+
|
|
8
|
+
## Test Framework
|
|
9
|
+
- **Vitest**: This project uses Vitest
|
|
10
|
+
- **React Testing Library**: For component testing
|
|
11
|
+
- **MSW (Mock Service Worker)**: For API mocking
|
|
12
|
+
- Test imports: `import { describe, it, expect, beforeEach, vi } from 'vitest'`
|
|
13
|
+
- Component test imports: `import { render, screen, fireEvent } from '@testing-library/react'`
|
|
14
|
+
- Mock creation: Use `vi.mock()`
|
|
15
|
+
|
|
16
|
+
## Basic Testing Policy
|
|
17
|
+
|
|
18
|
+
### Quality Requirements
|
|
19
|
+
- **Coverage**: Unit test coverage must be 60% or higher (Frontend standard 2025)
|
|
20
|
+
- **Independence**: Each test can run independently without depending on other tests
|
|
21
|
+
- **Reproducibility**: Tests are environment-independent and always return the same results
|
|
22
|
+
- **Readability**: Test code maintains the same quality as production code
|
|
23
|
+
|
|
24
|
+
### Coverage Requirements (ADR-0002 Compliant)
|
|
25
|
+
**Mandatory**: Unit test coverage must be 60% or higher
|
|
26
|
+
**Component-specific targets**:
|
|
27
|
+
- Atoms (Button, Text, etc.): 70% or higher
|
|
28
|
+
- Molecules (FormField, etc.): 65% or higher
|
|
29
|
+
- Organisms (Header, Footer, etc.): 60% or higher
|
|
30
|
+
- Custom Hooks: 65% or higher
|
|
31
|
+
- Utils: 70% or higher
|
|
32
|
+
|
|
33
|
+
**Metrics**: Statements, Branches, Functions, Lines
|
|
34
|
+
|
|
35
|
+
### Test Types and Scope
|
|
36
|
+
1. **Unit Tests (React Testing Library)**
|
|
37
|
+
- Verify behavior of individual components or functions
|
|
38
|
+
- Mock all external dependencies
|
|
39
|
+
- Most numerous, implemented with fine granularity
|
|
40
|
+
- Focus on user-observable behavior
|
|
41
|
+
|
|
42
|
+
2. **Integration Tests (React Testing Library + MSW)**
|
|
43
|
+
- Verify coordination between multiple components
|
|
44
|
+
- Mock APIs with MSW (Mock Service Worker)
|
|
45
|
+
- No actual DB connections (backend manages DB)
|
|
46
|
+
- Verify major functional flows
|
|
47
|
+
|
|
48
|
+
3. **Cross-functional Verification in E2E Tests**
|
|
49
|
+
- Mandatory verification of impact on existing features when adding new features
|
|
50
|
+
- Cover integration points with "High" and "Medium" impact levels from Design Doc's "Integration Point Map"
|
|
51
|
+
- Verification pattern: Existing feature operation -> Enable new feature -> Verify continuity of existing features
|
|
52
|
+
- Success criteria: No change in displayed content, rendering time within 5 seconds
|
|
53
|
+
- Designed for automatic execution in CI/CD pipelines
|
|
54
|
+
|
|
55
|
+
## Test Implementation Conventions
|
|
56
|
+
|
|
57
|
+
### Directory Structure (Co-location Principle)
|
|
58
|
+
```
|
|
59
|
+
src/
|
|
60
|
+
└── components/
|
|
61
|
+
└── Button/
|
|
62
|
+
├── Button.tsx
|
|
63
|
+
├── Button.test.tsx # Co-located with component
|
|
64
|
+
└── index.ts
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Rationale**:
|
|
68
|
+
- React Testing Library best practice
|
|
69
|
+
- ADR-0002 Co-location principle
|
|
70
|
+
- Easy to find and maintain tests alongside implementation
|
|
71
|
+
|
|
72
|
+
### Naming Conventions
|
|
73
|
+
- Test files: `{ComponentName}.test.tsx`
|
|
74
|
+
- Integration test files: `{FeatureName}.integration.test.tsx`
|
|
75
|
+
- Test suites: Names describing target components or features
|
|
76
|
+
- Test cases: Names describing expected behavior from user perspective
|
|
77
|
+
|
|
78
|
+
### Test Code Quality Rules
|
|
79
|
+
|
|
80
|
+
**Recommended: Keep all tests always active**
|
|
81
|
+
- Merit: Guarantees test suite completeness
|
|
82
|
+
- Practice: Fix problematic tests and activate them
|
|
83
|
+
|
|
84
|
+
**Avoid: test.skip() or commenting out**
|
|
85
|
+
- Reason: Creates test gaps and incomplete quality checks
|
|
86
|
+
- Solution: Completely delete unnecessary tests
|
|
87
|
+
|
|
88
|
+
## Mock Type Safety Enforcement
|
|
89
|
+
|
|
90
|
+
### MSW (Mock Service Worker) Setup
|
|
91
|
+
```typescript
|
|
92
|
+
// Type-safe MSW handler
|
|
93
|
+
import { rest } from 'msw'
|
|
94
|
+
|
|
95
|
+
const handlers = [
|
|
96
|
+
rest.get('/api/users/:id', (req, res, ctx) => {
|
|
97
|
+
return res(ctx.json({ id: '1', name: 'John' } satisfies User))
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Component Mock Type Safety
|
|
103
|
+
```typescript
|
|
104
|
+
// Only required parts
|
|
105
|
+
type TestProps = Pick<ButtonProps, 'label' | 'onClick'>
|
|
106
|
+
const mockProps: TestProps = { label: 'Click', onClick: vi.fn() }
|
|
107
|
+
|
|
108
|
+
// Only when absolutely necessary, with clear justification
|
|
109
|
+
const mockRouter = {
|
|
110
|
+
push: vi.fn()
|
|
111
|
+
} as unknown as Router // Complex router type structure
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Basic React Testing Library Example
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
118
|
+
import { render, screen, fireEvent } from '@testing-library/react'
|
|
119
|
+
import { Button } from './Button'
|
|
120
|
+
|
|
121
|
+
describe('Button', () => {
|
|
122
|
+
it('should call onClick when clicked', () => {
|
|
123
|
+
const onClick = vi.fn()
|
|
124
|
+
render(<Button label="Click me" onClick={onClick} />)
|
|
125
|
+
fireEvent.click(screen.getByRole('button', { name: 'Click me' }))
|
|
126
|
+
expect(onClick).toHaveBeenCalledOnce()
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
```
|