claude-code-templates 1.1.1 → 1.1.3
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/bin/create-claude-config.js +3 -4
- package/package.json +3 -3
- package/scripts/sync-templates.js +28 -28
- package/src/command-scanner.js +103 -3
- package/src/file-operations.js +56 -13
- package/src/index.js +3 -6
- package/src/prompts.js +164 -30
- package/src/templates.js +12 -20
- package/templates/javascript-typescript/examples/angular-app/.claude/commands/components.md +63 -0
- package/templates/javascript-typescript/examples/angular-app/.claude/commands/services.md +62 -0
- package/templates/javascript-typescript/examples/node-api/.claude/commands/api-endpoint.md +46 -0
- package/templates/javascript-typescript/examples/node-api/.claude/commands/database.md +56 -0
- package/templates/javascript-typescript/examples/node-api/.claude/commands/middleware.md +61 -0
- package/templates/javascript-typescript/examples/node-api/.claude/commands/route.md +57 -0
- package/templates/javascript-typescript/examples/node-api/CLAUDE.md +102 -0
- package/templates/javascript-typescript/examples/react-app/.claude/commands/component.md +29 -0
- package/templates/javascript-typescript/examples/react-app/.claude/commands/hooks.md +44 -0
- package/templates/javascript-typescript/examples/react-app/.claude/commands/state-management.md +45 -0
- package/templates/javascript-typescript/examples/react-app/CLAUDE.md +81 -0
- package/templates/javascript-typescript/examples/vue-app/.claude/commands/components.md +46 -0
- package/templates/javascript-typescript/examples/vue-app/.claude/commands/composables.md +51 -0
- package/templates/javascript-typescript/.claude/commands/react-component.md +0 -54
- package/templates/javascript-typescript/.claude/commands/route.md +0 -193
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# CLAUDE.md - React Application
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code when working with React applications using TypeScript.
|
|
4
|
+
|
|
5
|
+
## Project Type
|
|
6
|
+
|
|
7
|
+
This is a React application with TypeScript support.
|
|
8
|
+
|
|
9
|
+
## Development Commands
|
|
10
|
+
|
|
11
|
+
### Component Development
|
|
12
|
+
- **`/component`** - Create React components with TypeScript
|
|
13
|
+
- **`/hooks`** - Create and manage React hooks
|
|
14
|
+
- **`/state-management`** - Implement state management solutions
|
|
15
|
+
|
|
16
|
+
### Testing and Quality
|
|
17
|
+
- **`/test`** - Run tests and create test files
|
|
18
|
+
- **`/lint`** - Run linting and fix code style issues
|
|
19
|
+
- **`/typescript-migrate`** - Migrate JavaScript files to TypeScript
|
|
20
|
+
|
|
21
|
+
### Development Workflow
|
|
22
|
+
- **`/npm-scripts`** - Run npm scripts and package management
|
|
23
|
+
- **`/debug`** - Debug React applications
|
|
24
|
+
- **`/refactor`** - Refactor and optimize code
|
|
25
|
+
|
|
26
|
+
## Framework-Specific Guidelines
|
|
27
|
+
|
|
28
|
+
### React Best Practices
|
|
29
|
+
- Use functional components with hooks
|
|
30
|
+
- Implement proper TypeScript typing for props and state
|
|
31
|
+
- Follow React performance optimization patterns
|
|
32
|
+
- Use proper component composition patterns
|
|
33
|
+
|
|
34
|
+
### State Management
|
|
35
|
+
- Use useState for local component state
|
|
36
|
+
- Consider useContext for shared state
|
|
37
|
+
- Implement Redux Toolkit for complex state management
|
|
38
|
+
- Use Zustand for lightweight state management
|
|
39
|
+
|
|
40
|
+
### Component Architecture
|
|
41
|
+
- Keep components small and focused
|
|
42
|
+
- Use custom hooks for reusable logic
|
|
43
|
+
- Implement proper prop drilling prevention
|
|
44
|
+
- Follow component testing best practices
|
|
45
|
+
|
|
46
|
+
### Performance Optimization
|
|
47
|
+
- Use React.memo for expensive components
|
|
48
|
+
- Implement proper dependency arrays in useEffect
|
|
49
|
+
- Use useMemo and useCallback judiciously
|
|
50
|
+
- Optimize bundle size with code splitting
|
|
51
|
+
|
|
52
|
+
## TypeScript Configuration
|
|
53
|
+
|
|
54
|
+
The project uses strict TypeScript configuration:
|
|
55
|
+
- Strict type checking enabled
|
|
56
|
+
- Proper interface definitions for props
|
|
57
|
+
- Generic type support for reusable components
|
|
58
|
+
- Integration with React's built-in types
|
|
59
|
+
|
|
60
|
+
## Testing Strategy
|
|
61
|
+
|
|
62
|
+
- Unit tests with Jest and React Testing Library
|
|
63
|
+
- Component testing with proper mocking
|
|
64
|
+
- Integration tests for complex workflows
|
|
65
|
+
- E2E tests for critical user journeys
|
|
66
|
+
|
|
67
|
+
## File Naming Conventions
|
|
68
|
+
|
|
69
|
+
- Components: `PascalCase.tsx` (e.g., `UserCard.tsx`)
|
|
70
|
+
- Hooks: `use` prefix in `camelCase` (e.g., `useApiData.ts`)
|
|
71
|
+
- Types: `types.ts` or inline interfaces
|
|
72
|
+
- Tests: `ComponentName.test.tsx`
|
|
73
|
+
|
|
74
|
+
## Recommended Libraries
|
|
75
|
+
|
|
76
|
+
- **State Management**: Redux Toolkit, Zustand, Context API
|
|
77
|
+
- **Styling**: Styled-components, Emotion, Tailwind CSS
|
|
78
|
+
- **Forms**: React Hook Form, Formik
|
|
79
|
+
- **Routing**: React Router v6
|
|
80
|
+
- **HTTP Client**: Axios, SWR, React Query
|
|
81
|
+
- **Testing**: Jest, React Testing Library, Cypress
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Vue Components
|
|
2
|
+
|
|
3
|
+
Create Vue Single File Components for $ARGUMENTS following project conventions.
|
|
4
|
+
|
|
5
|
+
## Task
|
|
6
|
+
|
|
7
|
+
Create or optimize Vue components based on the requirements:
|
|
8
|
+
|
|
9
|
+
1. **Analyze project structure**: Check existing Vue components to understand patterns, conventions, and file organization
|
|
10
|
+
2. **Examine Vue setup**: Identify Vue version (2/3), TypeScript usage, and Composition/Options API preference
|
|
11
|
+
3. **Check styling approach**: Determine if using CSS modules, SCSS, styled-components, or other styling methods
|
|
12
|
+
4. **Review testing patterns**: Check existing component tests to understand testing framework and conventions
|
|
13
|
+
5. **Create component structure**: Generate SFC with template, script, and style sections
|
|
14
|
+
6. **Implement component**: Write TypeScript interfaces, props, emits, and component logic
|
|
15
|
+
7. **Add accessibility**: Include proper ARIA attributes and semantic HTML
|
|
16
|
+
8. **Create tests**: Write comprehensive component tests following project patterns
|
|
17
|
+
9. **Add documentation**: Include JSDoc comments and usage examples
|
|
18
|
+
|
|
19
|
+
## Component Requirements
|
|
20
|
+
|
|
21
|
+
- Follow project's TypeScript conventions and interfaces
|
|
22
|
+
- Use existing component patterns and naming conventions
|
|
23
|
+
- Implement proper props validation and typing
|
|
24
|
+
- Add appropriate event emissions with TypeScript signatures
|
|
25
|
+
- Include scoped styles following project's styling approach
|
|
26
|
+
- Add proper accessibility attributes (ARIA, semantic HTML)
|
|
27
|
+
- Consider responsive design if applicable
|
|
28
|
+
|
|
29
|
+
## Vue Patterns to Consider
|
|
30
|
+
|
|
31
|
+
Based on the component type:
|
|
32
|
+
- **Composition API**: For Vue 3 projects with `<script setup>`
|
|
33
|
+
- **Options API**: For Vue 2 or legacy Vue 3 projects
|
|
34
|
+
- **Composables**: Extract reusable logic into composables
|
|
35
|
+
- **Provide/Inject**: For deep component communication
|
|
36
|
+
- **Slots**: For flexible component content
|
|
37
|
+
- **Teleport**: For portal-like functionality (Vue 3)
|
|
38
|
+
|
|
39
|
+
## Important Notes
|
|
40
|
+
|
|
41
|
+
- ALWAYS examine existing components first to understand project patterns
|
|
42
|
+
- Use the same Vue API style (Composition vs Options) as the project
|
|
43
|
+
- Follow project's folder structure for components
|
|
44
|
+
- Don't install new dependencies without asking
|
|
45
|
+
- Consider component performance (v-memo, computed properties)
|
|
46
|
+
- Add proper TypeScript types for all props and emits
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Vue Composables
|
|
2
|
+
|
|
3
|
+
Create Vue composables for $ARGUMENTS following project conventions.
|
|
4
|
+
|
|
5
|
+
## Task
|
|
6
|
+
|
|
7
|
+
Create or optimize Vue composables based on the requirements:
|
|
8
|
+
|
|
9
|
+
1. **Analyze existing composables**: Check project for existing composable patterns, naming conventions, and file organization
|
|
10
|
+
2. **Examine Vue setup**: Verify Vue 3 Composition API usage and TypeScript configuration
|
|
11
|
+
3. **Identify composable type**: Determine the composable category:
|
|
12
|
+
- State management (reactive data, computed properties)
|
|
13
|
+
- API/HTTP operations (data fetching, mutations)
|
|
14
|
+
- DOM interactions (event listeners, element refs)
|
|
15
|
+
- Utility functions (validation, formatting, storage)
|
|
16
|
+
- Lifecycle management (cleanup, watchers)
|
|
17
|
+
4. **Check dependencies**: Review existing composables to avoid duplication
|
|
18
|
+
5. **Implement composable**: Create composable with proper TypeScript types and reactivity
|
|
19
|
+
6. **Add lifecycle management**: Include proper cleanup with onUnmounted when needed
|
|
20
|
+
7. **Create tests**: Write comprehensive unit tests for composable logic
|
|
21
|
+
8. **Add documentation**: Include JSDoc comments and usage examples
|
|
22
|
+
|
|
23
|
+
## Implementation Requirements
|
|
24
|
+
|
|
25
|
+
- Follow project's TypeScript conventions and interfaces
|
|
26
|
+
- Use appropriate Vue reactivity APIs (ref, reactive, computed, watch)
|
|
27
|
+
- Include proper error handling and loading states
|
|
28
|
+
- Add cleanup for side effects (event listeners, timers, subscriptions)
|
|
29
|
+
- Make composables reusable and focused on single responsibility
|
|
30
|
+
- Consider performance implications (shallow vs deep reactivity)
|
|
31
|
+
|
|
32
|
+
## Common Composable Patterns
|
|
33
|
+
|
|
34
|
+
Based on the request:
|
|
35
|
+
- **Data fetching**: API calls with loading/error states
|
|
36
|
+
- **Form handling**: Input management, validation, submission
|
|
37
|
+
- **State management**: Local state, persistence, computed values
|
|
38
|
+
- **DOM utilities**: Element refs, event handling, intersection observer
|
|
39
|
+
- **Storage**: localStorage, sessionStorage, IndexedDB
|
|
40
|
+
- **Authentication**: User state, token management, permissions
|
|
41
|
+
- **UI utilities**: Dark mode, responsive breakpoints, modals
|
|
42
|
+
|
|
43
|
+
## Important Notes
|
|
44
|
+
|
|
45
|
+
- ALWAYS examine existing composables first to understand project patterns
|
|
46
|
+
- Use proper Vue 3 Composition API patterns
|
|
47
|
+
- Follow project's folder structure for composables (usually /composables)
|
|
48
|
+
- Don't install new dependencies without asking
|
|
49
|
+
- Consider composable composition (using other composables within composables)
|
|
50
|
+
- Add proper TypeScript return types and generic constraints
|
|
51
|
+
- Include proper reactivity patterns (avoid losing reactivity)
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# React Component Generator
|
|
2
|
-
|
|
3
|
-
Create a React component for $ARGUMENTS following project conventions.
|
|
4
|
-
|
|
5
|
-
## Task
|
|
6
|
-
|
|
7
|
-
I'll help you create a complete React component by:
|
|
8
|
-
|
|
9
|
-
1. Analyzing your project structure and conventions
|
|
10
|
-
2. Creating component files with appropriate organization
|
|
11
|
-
3. Implementing the component with proper TypeScript types
|
|
12
|
-
4. Adding styles according to your project's styling approach
|
|
13
|
-
5. Creating tests for the component
|
|
14
|
-
6. Adding documentation and usage examples
|
|
15
|
-
|
|
16
|
-
## Process
|
|
17
|
-
|
|
18
|
-
I'll follow these steps:
|
|
19
|
-
|
|
20
|
-
1. Examine your project to understand component patterns and conventions
|
|
21
|
-
2. Identify the styling approach (CSS/SCSS modules, styled-components, Tailwind, etc.)
|
|
22
|
-
3. Determine testing frameworks and patterns
|
|
23
|
-
4. Create the component with appropriate file structure
|
|
24
|
-
5. Implement component logic, props interface, and styling
|
|
25
|
-
6. Add comprehensive tests
|
|
26
|
-
7. Document the component's usage and props
|
|
27
|
-
|
|
28
|
-
## Component Features
|
|
29
|
-
|
|
30
|
-
I can implement various component types and features:
|
|
31
|
-
|
|
32
|
-
- Functional components with hooks
|
|
33
|
-
- TypeScript interfaces for props and state
|
|
34
|
-
- Proper prop validation and defaults
|
|
35
|
-
- Responsive design considerations
|
|
36
|
-
- Accessibility (a11y) best practices
|
|
37
|
-
- Performance optimizations (memoization, etc.)
|
|
38
|
-
- Error boundaries when appropriate
|
|
39
|
-
- Loading and error states
|
|
40
|
-
- Animation and transition effects
|
|
41
|
-
|
|
42
|
-
## Component Architecture Patterns
|
|
43
|
-
|
|
44
|
-
I'll adapt to your project's component architecture:
|
|
45
|
-
|
|
46
|
-
- Atomic Design methodology (atoms, molecules, organisms)
|
|
47
|
-
- Feature-based organization
|
|
48
|
-
- Container/Presentational pattern
|
|
49
|
-
- Compound components
|
|
50
|
-
- Render props pattern
|
|
51
|
-
- Higher-Order Components (HOCs)
|
|
52
|
-
- Custom hooks for logic extraction
|
|
53
|
-
|
|
54
|
-
I'll analyze your existing components to match your project's specific patterns and conventions.
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# Route Creator
|
|
2
|
-
|
|
3
|
-
Create API routes and endpoints for Node.js applications with proper structure and best practices.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
This command helps you quickly create new API routes with:
|
|
8
|
-
- RESTful endpoint structure
|
|
9
|
-
- Proper HTTP method handling
|
|
10
|
-
- Input validation
|
|
11
|
-
- Error handling
|
|
12
|
-
- Documentation comments
|
|
13
|
-
- TypeScript support
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
Use this command to create API routes for your Node.js application:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
/route
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## What this command does
|
|
24
|
-
|
|
25
|
-
1. **Analyzes your project structure** to understand your routing setup
|
|
26
|
-
2. **Asks for route details** (endpoint path, HTTP methods, parameters)
|
|
27
|
-
3. **Creates route files** with proper structure and validation
|
|
28
|
-
4. **Generates TypeScript types** for request/response (if TypeScript project)
|
|
29
|
-
5. **Adds proper error handling** and status codes
|
|
30
|
-
6. **Includes documentation** and examples
|
|
31
|
-
|
|
32
|
-
## Example Output
|
|
33
|
-
|
|
34
|
-
For a `/users` route, this might create:
|
|
35
|
-
|
|
36
|
-
### Express.js Route
|
|
37
|
-
```javascript
|
|
38
|
-
// routes/users.js
|
|
39
|
-
const express = require('express');
|
|
40
|
-
const router = express.Router();
|
|
41
|
-
|
|
42
|
-
// GET /users - Get all users
|
|
43
|
-
router.get('/', async (req, res) => {
|
|
44
|
-
try {
|
|
45
|
-
// TODO: Implement user fetching logic
|
|
46
|
-
const users = [];
|
|
47
|
-
res.json(users);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
res.status(500).json({ error: 'Failed to fetch users' });
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// GET /users/:id - Get user by ID
|
|
54
|
-
router.get('/:id', async (req, res) => {
|
|
55
|
-
try {
|
|
56
|
-
const { id } = req.params;
|
|
57
|
-
// TODO: Implement user fetching by ID
|
|
58
|
-
const user = {};
|
|
59
|
-
|
|
60
|
-
if (!user) {
|
|
61
|
-
return res.status(404).json({ error: 'User not found' });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
res.json(user);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
res.status(500).json({ error: 'Failed to fetch user' });
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// POST /users - Create new user
|
|
71
|
-
router.post('/', async (req, res) => {
|
|
72
|
-
try {
|
|
73
|
-
const { name, email } = req.body;
|
|
74
|
-
|
|
75
|
-
// Input validation
|
|
76
|
-
if (!name || !email) {
|
|
77
|
-
return res.status(400).json({
|
|
78
|
-
error: 'Name and email are required'
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// TODO: Implement user creation logic
|
|
83
|
-
const newUser = { id: Date.now(), name, email };
|
|
84
|
-
|
|
85
|
-
res.status(201).json(newUser);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
res.status(500).json({ error: 'Failed to create user' });
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
module.exports = router;
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### TypeScript Route (if TS project)
|
|
95
|
-
```typescript
|
|
96
|
-
// routes/users.ts
|
|
97
|
-
import { Router, Request, Response } from 'express';
|
|
98
|
-
|
|
99
|
-
interface User {
|
|
100
|
-
id: number;
|
|
101
|
-
name: string;
|
|
102
|
-
email: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
interface CreateUserRequest {
|
|
106
|
-
name: string;
|
|
107
|
-
email: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const router = Router();
|
|
111
|
-
|
|
112
|
-
// GET /users - Get all users
|
|
113
|
-
router.get('/', async (req: Request, res: Response<User[]>) => {
|
|
114
|
-
try {
|
|
115
|
-
// TODO: Implement user fetching logic
|
|
116
|
-
const users: User[] = [];
|
|
117
|
-
res.json(users);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
res.status(500).json({ error: 'Failed to fetch users' } as any);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// POST /users - Create new user
|
|
124
|
-
router.post('/', async (req: Request<{}, User, CreateUserRequest>, res: Response<User>) => {
|
|
125
|
-
try {
|
|
126
|
-
const { name, email } = req.body;
|
|
127
|
-
|
|
128
|
-
if (!name || !email) {
|
|
129
|
-
return res.status(400).json({
|
|
130
|
-
error: 'Name and email are required'
|
|
131
|
-
} as any);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// TODO: Implement user creation logic
|
|
135
|
-
const newUser: User = { id: Date.now(), name, email };
|
|
136
|
-
|
|
137
|
-
res.status(201).json(newUser);
|
|
138
|
-
} catch (error) {
|
|
139
|
-
res.status(500).json({ error: 'Failed to create user' } as any);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
export default router;
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## When to use this command
|
|
147
|
-
|
|
148
|
-
- **Creating new API endpoints** for your application
|
|
149
|
-
- **Adding CRUD operations** for data models
|
|
150
|
-
- **Building RESTful APIs** with proper structure
|
|
151
|
-
- **Setting up route handlers** with validation and error handling
|
|
152
|
-
- **Generating boilerplate** for API development
|
|
153
|
-
|
|
154
|
-
## Framework Support
|
|
155
|
-
|
|
156
|
-
This command adapts to your specific Node.js framework:
|
|
157
|
-
|
|
158
|
-
### Express.js
|
|
159
|
-
- Creates `routes/` directory structure
|
|
160
|
-
- Uses Express Router
|
|
161
|
-
- Includes middleware support
|
|
162
|
-
- Adds common HTTP methods (GET, POST, PUT, DELETE)
|
|
163
|
-
|
|
164
|
-
### Fastify
|
|
165
|
-
- Creates Fastify route plugins
|
|
166
|
-
- Includes schema validation
|
|
167
|
-
- Uses Fastify's built-in serialization
|
|
168
|
-
- Adds proper error handling
|
|
169
|
-
|
|
170
|
-
### NestJS
|
|
171
|
-
- Creates controller classes
|
|
172
|
-
- Includes decorators (@Get, @Post, etc.)
|
|
173
|
-
- Generates DTOs for validation
|
|
174
|
-
- Uses dependency injection
|
|
175
|
-
|
|
176
|
-
## Best Practices Included
|
|
177
|
-
|
|
178
|
-
- **Input Validation** - Validates request parameters and body
|
|
179
|
-
- **Error Handling** - Proper try/catch blocks and error responses
|
|
180
|
-
- **Status Codes** - Appropriate HTTP status codes for different scenarios
|
|
181
|
-
- **TypeScript Types** - Strong typing for requests and responses
|
|
182
|
-
- **Documentation** - JSDoc comments explaining each endpoint
|
|
183
|
-
- **Security** - Basic input sanitization and validation
|
|
184
|
-
- **Testing Setup** - Suggests test cases for the new routes
|
|
185
|
-
|
|
186
|
-
## Tips
|
|
187
|
-
|
|
188
|
-
1. **Plan your API structure** before creating routes
|
|
189
|
-
2. **Use consistent naming** for endpoints (plural nouns for collections)
|
|
190
|
-
3. **Include proper validation** for all input data
|
|
191
|
-
4. **Add authentication/authorization** where needed
|
|
192
|
-
5. **Test your routes** after creation
|
|
193
|
-
6. **Document your API** for other developers
|