claude-code-templates 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 +291 -0
- package/bin/create-claude-config.js +59 -0
- package/package.json +51 -0
- package/src/file-operations.js +66 -0
- package/src/index.js +81 -0
- package/src/prompts.js +110 -0
- package/src/templates.js +134 -0
- package/src/utils.js +172 -0
- package/templates/common/CLAUDE.md +109 -0
- package/templates/common/README.md +96 -0
- package/templates/javascript-typescript/.claude/commands/api-endpoint.md +1 -0
- package/templates/javascript-typescript/.claude/commands/debug.md +1 -0
- package/templates/javascript-typescript/.claude/commands/lint.md +1 -0
- package/templates/javascript-typescript/.claude/commands/npm-scripts.md +1 -0
- package/templates/javascript-typescript/.claude/commands/react-component.md +1 -0
- package/templates/javascript-typescript/.claude/commands/refactor.md +1 -0
- package/templates/javascript-typescript/.claude/commands/test.md +1 -0
- package/templates/javascript-typescript/.claude/commands/typescript-migrate.md +1 -0
- package/templates/javascript-typescript/.claude/hooks/format-on-save.json +1 -0
- package/templates/javascript-typescript/.claude/hooks/lint-on-save.json +1 -0
- package/templates/javascript-typescript/.claude/hooks/typescript-check.json +1 -0
- package/templates/javascript-typescript/.claude/settings.json +103 -0
- package/templates/javascript-typescript/CLAUDE.md +185 -0
- package/templates/javascript-typescript/README.md +233 -0
- package/templates/javascript-typescript/examples/node-api/.claude/commands/middleware.md +1 -0
- package/templates/javascript-typescript/examples/node-api/.claude/commands/route.md +1 -0
- package/templates/javascript-typescript/examples/node-api/CLAUDE.md +1 -0
- package/templates/javascript-typescript/examples/react-app/.claude/commands/component.md +1 -0
- package/templates/javascript-typescript/examples/react-app/.claude/commands/hooks.md +1 -0
- package/templates/javascript-typescript/examples/react-app/CLAUDE.md +1 -0
- package/templates/python/CLAUDE.md +276 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is a JavaScript/TypeScript project optimized for modern web development. The project uses industry-standard tools and follows best practices for scalable application development.
|
|
8
|
+
|
|
9
|
+
## Development Commands
|
|
10
|
+
|
|
11
|
+
### Package Management
|
|
12
|
+
- `npm install` or `yarn install` - Install dependencies
|
|
13
|
+
- `npm ci` or `yarn install --frozen-lockfile` - Install dependencies for CI/CD
|
|
14
|
+
- `npm update` or `yarn upgrade` - Update dependencies
|
|
15
|
+
|
|
16
|
+
### Build Commands
|
|
17
|
+
- `npm run build` - Build the project for production
|
|
18
|
+
- `npm run dev` or `npm start` - Start development server
|
|
19
|
+
- `npm run preview` - Preview production build locally
|
|
20
|
+
|
|
21
|
+
### Testing Commands
|
|
22
|
+
- `npm test` or `npm run test` - Run all tests
|
|
23
|
+
- `npm run test:watch` - Run tests in watch mode
|
|
24
|
+
- `npm run test:coverage` - Run tests with coverage report
|
|
25
|
+
- `npm run test:unit` - Run unit tests only
|
|
26
|
+
- `npm run test:integration` - Run integration tests only
|
|
27
|
+
- `npm run test:e2e` - Run end-to-end tests
|
|
28
|
+
|
|
29
|
+
### Code Quality Commands
|
|
30
|
+
- `npm run lint` - Run ESLint for code linting
|
|
31
|
+
- `npm run lint:fix` - Run ESLint with auto-fix
|
|
32
|
+
- `npm run format` - Format code with Prettier
|
|
33
|
+
- `npm run format:check` - Check code formatting
|
|
34
|
+
- `npm run typecheck` - Run TypeScript type checking
|
|
35
|
+
|
|
36
|
+
### Development Tools
|
|
37
|
+
- `npm run storybook` - Start Storybook (if available)
|
|
38
|
+
- `npm run analyze` - Analyze bundle size
|
|
39
|
+
- `npm run clean` - Clean build artifacts
|
|
40
|
+
|
|
41
|
+
## Technology Stack
|
|
42
|
+
|
|
43
|
+
### Core Technologies
|
|
44
|
+
- **JavaScript/TypeScript** - Primary programming languages
|
|
45
|
+
- **Node.js** - Runtime environment
|
|
46
|
+
- **npm/yarn** - Package management
|
|
47
|
+
|
|
48
|
+
### Common Frameworks
|
|
49
|
+
- **React** - UI library with hooks and functional components
|
|
50
|
+
- **Vue.js** - Progressive framework for building user interfaces
|
|
51
|
+
- **Angular** - Full-featured framework for web applications
|
|
52
|
+
- **Express.js** - Web application framework for Node.js
|
|
53
|
+
- **Next.js** - React framework with SSR/SSG capabilities
|
|
54
|
+
|
|
55
|
+
### Build Tools
|
|
56
|
+
- **Vite** - Fast build tool and development server
|
|
57
|
+
- **Webpack** - Module bundler
|
|
58
|
+
- **Rollup** - Module bundler for libraries
|
|
59
|
+
- **esbuild** - Extremely fast JavaScript bundler
|
|
60
|
+
|
|
61
|
+
### Testing Framework
|
|
62
|
+
- **Jest** - JavaScript testing framework
|
|
63
|
+
- **Vitest** - Fast unit test framework
|
|
64
|
+
- **Testing Library** - Simple and complete testing utilities
|
|
65
|
+
- **Cypress** - End-to-end testing framework
|
|
66
|
+
- **Playwright** - Cross-browser testing
|
|
67
|
+
|
|
68
|
+
### Code Quality Tools
|
|
69
|
+
- **ESLint** - JavaScript/TypeScript linter
|
|
70
|
+
- **Prettier** - Code formatter
|
|
71
|
+
- **TypeScript** - Static type checking
|
|
72
|
+
- **Husky** - Git hooks
|
|
73
|
+
|
|
74
|
+
## Project Structure Guidelines
|
|
75
|
+
|
|
76
|
+
### File Organization
|
|
77
|
+
```
|
|
78
|
+
src/
|
|
79
|
+
├── components/ # Reusable UI components
|
|
80
|
+
├── pages/ # Page components or routes
|
|
81
|
+
├── hooks/ # Custom React hooks
|
|
82
|
+
├── utils/ # Utility functions
|
|
83
|
+
├── services/ # API calls and external services
|
|
84
|
+
├── types/ # TypeScript type definitions
|
|
85
|
+
├── constants/ # Application constants
|
|
86
|
+
├── styles/ # Global styles and themes
|
|
87
|
+
└── tests/ # Test files
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Naming Conventions
|
|
91
|
+
- **Files**: Use kebab-case for file names (`user-profile.component.ts`)
|
|
92
|
+
- **Components**: Use PascalCase for component names (`UserProfile`)
|
|
93
|
+
- **Functions**: Use camelCase for function names (`getUserData`)
|
|
94
|
+
- **Constants**: Use UPPER_SNAKE_CASE for constants (`API_BASE_URL`)
|
|
95
|
+
- **Types/Interfaces**: Use PascalCase with descriptive names (`UserData`, `ApiResponse`)
|
|
96
|
+
|
|
97
|
+
## TypeScript Guidelines
|
|
98
|
+
|
|
99
|
+
### Type Safety
|
|
100
|
+
- Enable strict mode in `tsconfig.json`
|
|
101
|
+
- Use explicit types for function parameters and return values
|
|
102
|
+
- Prefer interfaces over types for object shapes
|
|
103
|
+
- Use union types for multiple possible values
|
|
104
|
+
- Avoid `any` type - use `unknown` when type is truly unknown
|
|
105
|
+
|
|
106
|
+
### Best Practices
|
|
107
|
+
- Use type guards for runtime type checking
|
|
108
|
+
- Leverage utility types (`Partial`, `Pick`, `Omit`, etc.)
|
|
109
|
+
- Create custom types for domain-specific data
|
|
110
|
+
- Use enums for finite sets of values
|
|
111
|
+
- Document complex types with JSDoc comments
|
|
112
|
+
|
|
113
|
+
## Code Quality Standards
|
|
114
|
+
|
|
115
|
+
### ESLint Configuration
|
|
116
|
+
- Use recommended ESLint rules for JavaScript/TypeScript
|
|
117
|
+
- Enable React-specific rules if using React
|
|
118
|
+
- Configure import/export rules for consistent module usage
|
|
119
|
+
- Set up accessibility rules for inclusive development
|
|
120
|
+
|
|
121
|
+
### Prettier Configuration
|
|
122
|
+
- Use consistent indentation (2 spaces recommended)
|
|
123
|
+
- Set maximum line length (80-100 characters)
|
|
124
|
+
- Use single quotes for strings
|
|
125
|
+
- Add trailing commas for better git diffs
|
|
126
|
+
|
|
127
|
+
### Testing Standards
|
|
128
|
+
- Aim for 80%+ test coverage
|
|
129
|
+
- Write unit tests for utilities and business logic
|
|
130
|
+
- Use integration tests for component interactions
|
|
131
|
+
- Implement e2e tests for critical user flows
|
|
132
|
+
- Follow AAA pattern (Arrange, Act, Assert)
|
|
133
|
+
|
|
134
|
+
## Performance Optimization
|
|
135
|
+
|
|
136
|
+
### Bundle Optimization
|
|
137
|
+
- Use code splitting for large applications
|
|
138
|
+
- Implement lazy loading for routes and components
|
|
139
|
+
- Optimize images and assets
|
|
140
|
+
- Use tree shaking to eliminate dead code
|
|
141
|
+
- Analyze bundle size regularly
|
|
142
|
+
|
|
143
|
+
### Runtime Performance
|
|
144
|
+
- Implement proper memoization (React.memo, useMemo, useCallback)
|
|
145
|
+
- Use virtualization for large lists
|
|
146
|
+
- Optimize re-renders in React applications
|
|
147
|
+
- Implement proper error boundaries
|
|
148
|
+
- Use web workers for heavy computations
|
|
149
|
+
|
|
150
|
+
## Security Guidelines
|
|
151
|
+
|
|
152
|
+
### Dependencies
|
|
153
|
+
- Regularly audit dependencies with `npm audit`
|
|
154
|
+
- Keep dependencies updated
|
|
155
|
+
- Use lock files (`package-lock.json`, `yarn.lock`)
|
|
156
|
+
- Avoid dependencies with known vulnerabilities
|
|
157
|
+
|
|
158
|
+
### Code Security
|
|
159
|
+
- Sanitize user inputs
|
|
160
|
+
- Use HTTPS for API calls
|
|
161
|
+
- Implement proper authentication and authorization
|
|
162
|
+
- Store sensitive data securely (environment variables)
|
|
163
|
+
- Use Content Security Policy (CSP) headers
|
|
164
|
+
|
|
165
|
+
## Development Workflow
|
|
166
|
+
|
|
167
|
+
### Before Starting
|
|
168
|
+
1. Check Node.js version compatibility
|
|
169
|
+
2. Install dependencies with `npm install`
|
|
170
|
+
3. Copy environment variables from `.env.example`
|
|
171
|
+
4. Run type checking with `npm run typecheck`
|
|
172
|
+
|
|
173
|
+
### During Development
|
|
174
|
+
1. Use TypeScript for type safety
|
|
175
|
+
2. Run linter frequently to catch issues early
|
|
176
|
+
3. Write tests for new features
|
|
177
|
+
4. Use meaningful commit messages
|
|
178
|
+
5. Review code changes before committing
|
|
179
|
+
|
|
180
|
+
### Before Committing
|
|
181
|
+
1. Run full test suite: `npm test`
|
|
182
|
+
2. Check linting: `npm run lint`
|
|
183
|
+
3. Verify formatting: `npm run format:check`
|
|
184
|
+
4. Run type checking: `npm run typecheck`
|
|
185
|
+
5. Test production build: `npm run build`
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# JavaScript/TypeScript Claude Code Templates
|
|
2
|
+
|
|
3
|
+
This template provides optimized Claude Code configurations for JavaScript and TypeScript development, including modern frameworks like React, Vue, Node.js, and more.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
Copy the template files to your JavaScript/TypeScript project:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# Copy all template files
|
|
12
|
+
cp -r claude-code-templates/javascript-typescript/* your-project/
|
|
13
|
+
|
|
14
|
+
# Or copy specific files
|
|
15
|
+
cp claude-code-templates/javascript-typescript/CLAUDE.md your-project/
|
|
16
|
+
cp -r claude-code-templates/javascript-typescript/.claude/ your-project/
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Usage
|
|
20
|
+
Navigate to your project and start Claude Code:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
cd your-project
|
|
24
|
+
claude
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Use the included custom commands:
|
|
28
|
+
```bash
|
|
29
|
+
# Run tests
|
|
30
|
+
/test
|
|
31
|
+
|
|
32
|
+
# Run linting
|
|
33
|
+
/lint
|
|
34
|
+
|
|
35
|
+
# Create React component
|
|
36
|
+
/react-component
|
|
37
|
+
|
|
38
|
+
# Debug application
|
|
39
|
+
/debug
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## What's Included
|
|
43
|
+
|
|
44
|
+
### Core Configuration
|
|
45
|
+
- **`CLAUDE.md`** - Comprehensive guidance for JavaScript/TypeScript development
|
|
46
|
+
- **`.claude/settings.json`** - Optimized settings for JS/TS projects
|
|
47
|
+
- **Custom Commands** - Pre-configured commands for common development tasks
|
|
48
|
+
|
|
49
|
+
### Development Hooks
|
|
50
|
+
- **`format-on-save.json`** - Automatically format code with Prettier
|
|
51
|
+
- **`lint-on-save.json`** - Run ESLint on file changes
|
|
52
|
+
- **`typescript-check.json`** - Verify TypeScript types on save
|
|
53
|
+
|
|
54
|
+
### Custom Commands
|
|
55
|
+
- **`test.md`** - Execute tests with Jest, Vitest, or other frameworks
|
|
56
|
+
- **`lint.md`** - Run ESLint with customizable rules
|
|
57
|
+
- **`debug.md`** - Debug Node.js applications and browser code
|
|
58
|
+
- **`refactor.md`** - Refactor code with AI assistance
|
|
59
|
+
- **`typescript-migrate.md`** - Migrate JavaScript files to TypeScript
|
|
60
|
+
- **`npm-scripts.md`** - Manage and execute npm scripts
|
|
61
|
+
- **`react-component.md`** - Generate React components with best practices
|
|
62
|
+
- **`api-endpoint.md`** - Create API endpoints for Node.js applications
|
|
63
|
+
|
|
64
|
+
### Project Examples
|
|
65
|
+
- **React App** - Configuration for React applications
|
|
66
|
+
- **Node.js API** - Configuration for backend API development
|
|
67
|
+
|
|
68
|
+
## Framework-Specific Setup
|
|
69
|
+
|
|
70
|
+
### React Projects
|
|
71
|
+
```bash
|
|
72
|
+
# Copy React-specific configuration
|
|
73
|
+
cp -r claude-code-templates/javascript-typescript/examples/react-app/.claude/ your-react-app/
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Additional commands for React:
|
|
77
|
+
- `/component` - Create React components
|
|
78
|
+
- `/hooks` - Generate custom React hooks
|
|
79
|
+
|
|
80
|
+
### Node.js API Projects
|
|
81
|
+
```bash
|
|
82
|
+
# Copy Node.js-specific configuration
|
|
83
|
+
cp -r claude-code-templates/javascript-typescript/examples/node-api/.claude/ your-api-project/
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Additional commands for Node.js:
|
|
87
|
+
- `/route` - Create API routes
|
|
88
|
+
- `/middleware` - Generate middleware functions
|
|
89
|
+
|
|
90
|
+
## Supported Tools and Frameworks
|
|
91
|
+
|
|
92
|
+
### Package Managers
|
|
93
|
+
- **npm** - Node Package Manager
|
|
94
|
+
- **yarn** - Fast, reliable package manager
|
|
95
|
+
- **pnpm** - Efficient package manager
|
|
96
|
+
|
|
97
|
+
### Build Tools
|
|
98
|
+
- **Vite** - Next generation frontend tooling
|
|
99
|
+
- **Webpack** - Module bundler
|
|
100
|
+
- **Rollup** - Module bundler for libraries
|
|
101
|
+
- **esbuild** - Extremely fast JavaScript bundler
|
|
102
|
+
|
|
103
|
+
### Testing Frameworks
|
|
104
|
+
- **Jest** - JavaScript testing framework
|
|
105
|
+
- **Vitest** - Fast unit test framework
|
|
106
|
+
- **Testing Library** - Testing utilities
|
|
107
|
+
- **Cypress** - End-to-end testing
|
|
108
|
+
- **Playwright** - Cross-browser testing
|
|
109
|
+
|
|
110
|
+
### Code Quality
|
|
111
|
+
- **ESLint** - JavaScript/TypeScript linter
|
|
112
|
+
- **Prettier** - Code formatter
|
|
113
|
+
- **TypeScript** - Static type checking
|
|
114
|
+
- **Husky** - Git hooks
|
|
115
|
+
|
|
116
|
+
### Frontend Frameworks
|
|
117
|
+
- **React** - UI library
|
|
118
|
+
- **Vue.js** - Progressive framework
|
|
119
|
+
- **Angular** - Full-featured framework
|
|
120
|
+
- **Svelte** - Compile-time framework
|
|
121
|
+
|
|
122
|
+
### Backend Frameworks
|
|
123
|
+
- **Express.js** - Web framework for Node.js
|
|
124
|
+
- **Fastify** - Fast and low overhead web framework
|
|
125
|
+
- **Koa** - Lightweight web framework
|
|
126
|
+
- **NestJS** - Progressive Node.js framework
|
|
127
|
+
|
|
128
|
+
## Common Development Workflows
|
|
129
|
+
|
|
130
|
+
### Setting Up a New Project
|
|
131
|
+
1. Initialize project: `npm init` or `yarn init`
|
|
132
|
+
2. Install dependencies: `npm install` or `yarn install`
|
|
133
|
+
3. Copy Claude Code templates
|
|
134
|
+
4. Configure ESLint and Prettier
|
|
135
|
+
5. Set up testing framework
|
|
136
|
+
6. Configure build tools
|
|
137
|
+
|
|
138
|
+
### Daily Development
|
|
139
|
+
1. Start development server: `npm run dev`
|
|
140
|
+
2. Use Claude Code commands for common tasks
|
|
141
|
+
3. Run tests: `/test`
|
|
142
|
+
4. Format and lint code: `/lint`
|
|
143
|
+
5. Debug issues: `/debug`
|
|
144
|
+
|
|
145
|
+
### Code Quality Checks
|
|
146
|
+
1. Type checking: `npm run typecheck`
|
|
147
|
+
2. Linting: `npm run lint`
|
|
148
|
+
3. Testing: `npm run test`
|
|
149
|
+
4. Build verification: `npm run build`
|
|
150
|
+
|
|
151
|
+
## Customization
|
|
152
|
+
|
|
153
|
+
### Modifying Commands
|
|
154
|
+
Edit files in `.claude/commands/` to customize commands for your workflow:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Edit test command
|
|
158
|
+
vim .claude/commands/test.md
|
|
159
|
+
|
|
160
|
+
# Add new custom command
|
|
161
|
+
echo "# My Custom Command" > .claude/commands/my-command.md
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Adjusting Settings
|
|
165
|
+
Modify `.claude/settings.json` to match your project preferences:
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"language": "typescript",
|
|
170
|
+
"framework": "react",
|
|
171
|
+
"testFramework": "jest",
|
|
172
|
+
"packageManager": "npm"
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Adding Hooks
|
|
177
|
+
Create custom hooks in `.claude/hooks/` for automated tasks:
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"trigger": "on_file_save",
|
|
182
|
+
"pattern": "*.ts,*.tsx",
|
|
183
|
+
"command": "npm run typecheck"
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Best Practices
|
|
188
|
+
|
|
189
|
+
### Project Structure
|
|
190
|
+
- Use clear, descriptive folder names
|
|
191
|
+
- Separate concerns (components, utils, services)
|
|
192
|
+
- Follow framework conventions
|
|
193
|
+
- Keep configuration files in project root
|
|
194
|
+
|
|
195
|
+
### Code Quality
|
|
196
|
+
- Enable TypeScript strict mode
|
|
197
|
+
- Use ESLint with recommended rules
|
|
198
|
+
- Format code consistently with Prettier
|
|
199
|
+
- Write comprehensive tests
|
|
200
|
+
|
|
201
|
+
### Performance
|
|
202
|
+
- Implement code splitting for large applications
|
|
203
|
+
- Use lazy loading for routes and components
|
|
204
|
+
- Optimize bundle size regularly
|
|
205
|
+
- Monitor runtime performance
|
|
206
|
+
|
|
207
|
+
## Troubleshooting
|
|
208
|
+
|
|
209
|
+
### Common Issues
|
|
210
|
+
- **TypeScript errors**: Run `npm run typecheck` to identify issues
|
|
211
|
+
- **Linting failures**: Use `npm run lint:fix` to auto-fix issues
|
|
212
|
+
- **Test failures**: Run tests in watch mode with `npm run test:watch`
|
|
213
|
+
- **Build errors**: Check dependencies and configuration files
|
|
214
|
+
|
|
215
|
+
### Getting Help
|
|
216
|
+
- Check the main repository documentation
|
|
217
|
+
- Review framework-specific guides
|
|
218
|
+
- Use Claude Code's built-in help: `/help`
|
|
219
|
+
- Consult community resources and documentation
|
|
220
|
+
|
|
221
|
+
## Contributing
|
|
222
|
+
|
|
223
|
+
Found ways to improve these templates? We welcome contributions:
|
|
224
|
+
|
|
225
|
+
1. Fork the repository
|
|
226
|
+
2. Create a feature branch
|
|
227
|
+
3. Add your improvements
|
|
228
|
+
4. Test with real projects
|
|
229
|
+
5. Submit a pull request
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
This template is part of the Claude Code Templates project and is licensed under the MIT License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Middleware Command
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# API Route Command
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Node.js API CLAUDE.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# React Component Command
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# React Hooks Command
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# React App CLAUDE.md
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is a Python project optimized for modern Python development. The project uses industry-standard tools and follows best practices for scalable application development.
|
|
8
|
+
|
|
9
|
+
## Development Commands
|
|
10
|
+
|
|
11
|
+
### Environment Management
|
|
12
|
+
- `python -m venv venv` - Create virtual environment
|
|
13
|
+
- `source venv/bin/activate` (Linux/Mac) or `venv\Scripts\activate` (Windows) - Activate virtual environment
|
|
14
|
+
- `deactivate` - Deactivate virtual environment
|
|
15
|
+
- `pip install -r requirements.txt` - Install dependencies
|
|
16
|
+
- `pip install -r requirements-dev.txt` - Install development dependencies
|
|
17
|
+
|
|
18
|
+
### Package Management
|
|
19
|
+
- `pip install <package>` - Install a package
|
|
20
|
+
- `pip install -e .` - Install project in development mode
|
|
21
|
+
- `pip freeze > requirements.txt` - Generate requirements file
|
|
22
|
+
- `pip-tools compile requirements.in` - Compile requirements with pip-tools
|
|
23
|
+
|
|
24
|
+
### Testing Commands
|
|
25
|
+
- `pytest` - Run all tests
|
|
26
|
+
- `pytest -v` - Run tests with verbose output
|
|
27
|
+
- `pytest --cov` - Run tests with coverage report
|
|
28
|
+
- `pytest --cov-report=html` - Generate HTML coverage report
|
|
29
|
+
- `pytest -x` - Stop on first failure
|
|
30
|
+
- `pytest -k "test_name"` - Run specific test by name
|
|
31
|
+
- `python -m unittest` - Run tests with unittest
|
|
32
|
+
|
|
33
|
+
### Code Quality Commands
|
|
34
|
+
- `black .` - Format code with Black
|
|
35
|
+
- `black --check .` - Check code formatting without changes
|
|
36
|
+
- `isort .` - Sort imports
|
|
37
|
+
- `isort --check-only .` - Check import sorting
|
|
38
|
+
- `flake8` - Run linting with Flake8
|
|
39
|
+
- `pylint src/` - Run linting with Pylint
|
|
40
|
+
- `mypy src/` - Run type checking with MyPy
|
|
41
|
+
|
|
42
|
+
### Development Tools
|
|
43
|
+
- `python -m pip install --upgrade pip` - Upgrade pip
|
|
44
|
+
- `python -c "import sys; print(sys.version)"` - Check Python version
|
|
45
|
+
- `python -m site` - Show Python site information
|
|
46
|
+
- `python -m pdb script.py` - Debug with pdb
|
|
47
|
+
|
|
48
|
+
## Technology Stack
|
|
49
|
+
|
|
50
|
+
### Core Technologies
|
|
51
|
+
- **Python** - Primary programming language (3.8+)
|
|
52
|
+
- **pip** - Package management
|
|
53
|
+
- **venv** - Virtual environment management
|
|
54
|
+
|
|
55
|
+
### Common Frameworks
|
|
56
|
+
- **Django** - High-level web framework
|
|
57
|
+
- **Flask** - Micro web framework
|
|
58
|
+
- **FastAPI** - Modern API framework with automatic documentation
|
|
59
|
+
- **SQLAlchemy** - SQL toolkit and ORM
|
|
60
|
+
- **Pydantic** - Data validation using Python type hints
|
|
61
|
+
|
|
62
|
+
### Data Science & ML
|
|
63
|
+
- **NumPy** - Numerical computing
|
|
64
|
+
- **Pandas** - Data manipulation and analysis
|
|
65
|
+
- **Matplotlib/Seaborn** - Data visualization
|
|
66
|
+
- **Scikit-learn** - Machine learning library
|
|
67
|
+
- **TensorFlow/PyTorch** - Deep learning frameworks
|
|
68
|
+
|
|
69
|
+
### Testing Frameworks
|
|
70
|
+
- **pytest** - Testing framework
|
|
71
|
+
- **unittest** - Built-in testing framework
|
|
72
|
+
- **pytest-cov** - Coverage plugin for pytest
|
|
73
|
+
- **factory-boy** - Test fixtures
|
|
74
|
+
- **responses** - Mock HTTP requests
|
|
75
|
+
|
|
76
|
+
### Code Quality Tools
|
|
77
|
+
- **Black** - Code formatter
|
|
78
|
+
- **isort** - Import sorter
|
|
79
|
+
- **flake8** - Style guide enforcement
|
|
80
|
+
- **pylint** - Code analysis
|
|
81
|
+
- **mypy** - Static type checker
|
|
82
|
+
- **pre-commit** - Git hooks framework
|
|
83
|
+
|
|
84
|
+
## Project Structure Guidelines
|
|
85
|
+
|
|
86
|
+
### File Organization
|
|
87
|
+
```
|
|
88
|
+
src/
|
|
89
|
+
├── package_name/
|
|
90
|
+
│ ├── __init__.py
|
|
91
|
+
│ ├── main.py # Application entry point
|
|
92
|
+
│ ├── models/ # Data models
|
|
93
|
+
│ ├── views/ # Web views (Django/Flask)
|
|
94
|
+
│ ├── api/ # API endpoints
|
|
95
|
+
│ ├── services/ # Business logic
|
|
96
|
+
│ ├── utils/ # Utility functions
|
|
97
|
+
│ └── config/ # Configuration files
|
|
98
|
+
tests/
|
|
99
|
+
├── __init__.py
|
|
100
|
+
├── conftest.py # pytest configuration
|
|
101
|
+
├── test_models.py
|
|
102
|
+
├── test_views.py
|
|
103
|
+
└── test_utils.py
|
|
104
|
+
requirements/
|
|
105
|
+
├── base.txt # Base requirements
|
|
106
|
+
├── dev.txt # Development requirements
|
|
107
|
+
└── prod.txt # Production requirements
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Naming Conventions
|
|
111
|
+
- **Files/Modules**: Use snake_case (`user_profile.py`)
|
|
112
|
+
- **Classes**: Use PascalCase (`UserProfile`)
|
|
113
|
+
- **Functions/Variables**: Use snake_case (`get_user_data`)
|
|
114
|
+
- **Constants**: Use UPPER_SNAKE_CASE (`API_BASE_URL`)
|
|
115
|
+
- **Private methods**: Prefix with underscore (`_private_method`)
|
|
116
|
+
|
|
117
|
+
## Python Guidelines
|
|
118
|
+
|
|
119
|
+
### Type Hints
|
|
120
|
+
- Use type hints for function parameters and return values
|
|
121
|
+
- Import types from `typing` module when needed
|
|
122
|
+
- Use `Optional` for nullable values
|
|
123
|
+
- Use `Union` for multiple possible types
|
|
124
|
+
- Document complex types with comments
|
|
125
|
+
|
|
126
|
+
### Code Style
|
|
127
|
+
- Follow PEP 8 style guide
|
|
128
|
+
- Use meaningful variable and function names
|
|
129
|
+
- Keep functions focused and single-purpose
|
|
130
|
+
- Use docstrings for modules, classes, and functions
|
|
131
|
+
- Limit line length to 88 characters (Black default)
|
|
132
|
+
|
|
133
|
+
### Best Practices
|
|
134
|
+
- Use list comprehensions for simple transformations
|
|
135
|
+
- Prefer `pathlib` over `os.path` for file operations
|
|
136
|
+
- Use context managers (`with` statements) for resource management
|
|
137
|
+
- Handle exceptions appropriately with try/except blocks
|
|
138
|
+
- Use `logging` module instead of print statements
|
|
139
|
+
|
|
140
|
+
## Testing Standards
|
|
141
|
+
|
|
142
|
+
### Test Structure
|
|
143
|
+
- Organize tests to mirror source code structure
|
|
144
|
+
- Use descriptive test names that explain the behavior
|
|
145
|
+
- Follow AAA pattern (Arrange, Act, Assert)
|
|
146
|
+
- Use fixtures for common test data
|
|
147
|
+
- Group related tests in classes
|
|
148
|
+
|
|
149
|
+
### Coverage Goals
|
|
150
|
+
- Aim for 90%+ test coverage
|
|
151
|
+
- Write unit tests for business logic
|
|
152
|
+
- Use integration tests for external dependencies
|
|
153
|
+
- Mock external services in tests
|
|
154
|
+
- Test error conditions and edge cases
|
|
155
|
+
|
|
156
|
+
### pytest Configuration
|
|
157
|
+
```python
|
|
158
|
+
# pytest.ini or pyproject.toml
|
|
159
|
+
[tool.pytest.ini_options]
|
|
160
|
+
testpaths = ["tests"]
|
|
161
|
+
python_files = ["test_*.py", "*_test.py"]
|
|
162
|
+
python_classes = ["Test*"]
|
|
163
|
+
python_functions = ["test_*"]
|
|
164
|
+
addopts = "--cov=src --cov-report=term-missing"
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Virtual Environment Setup
|
|
168
|
+
|
|
169
|
+
### Creation and Activation
|
|
170
|
+
```bash
|
|
171
|
+
# Create virtual environment
|
|
172
|
+
python -m venv venv
|
|
173
|
+
|
|
174
|
+
# Activate (Linux/Mac)
|
|
175
|
+
source venv/bin/activate
|
|
176
|
+
|
|
177
|
+
# Activate (Windows)
|
|
178
|
+
venv\Scripts\activate
|
|
179
|
+
|
|
180
|
+
# Install dependencies
|
|
181
|
+
pip install -r requirements.txt
|
|
182
|
+
pip install -r requirements-dev.txt
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Requirements Management
|
|
186
|
+
- Use `requirements.txt` for production dependencies
|
|
187
|
+
- Use `requirements-dev.txt` for development dependencies
|
|
188
|
+
- Consider using `pip-tools` for dependency resolution
|
|
189
|
+
- Pin versions for reproducible builds
|
|
190
|
+
|
|
191
|
+
## Django-Specific Guidelines
|
|
192
|
+
|
|
193
|
+
### Project Structure
|
|
194
|
+
```
|
|
195
|
+
project_name/
|
|
196
|
+
├── manage.py
|
|
197
|
+
├── project_name/
|
|
198
|
+
│ ├── __init__.py
|
|
199
|
+
│ ├── settings/
|
|
200
|
+
│ ├── urls.py
|
|
201
|
+
│ └── wsgi.py
|
|
202
|
+
├── apps/
|
|
203
|
+
│ ├── users/
|
|
204
|
+
│ ├── products/
|
|
205
|
+
│ └── orders/
|
|
206
|
+
└── requirements/
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Common Commands
|
|
210
|
+
- `python manage.py runserver` - Start development server
|
|
211
|
+
- `python manage.py migrate` - Apply database migrations
|
|
212
|
+
- `python manage.py makemigrations` - Create new migrations
|
|
213
|
+
- `python manage.py createsuperuser` - Create admin user
|
|
214
|
+
- `python manage.py collectstatic` - Collect static files
|
|
215
|
+
- `python manage.py test` - Run Django tests
|
|
216
|
+
|
|
217
|
+
## FastAPI-Specific Guidelines
|
|
218
|
+
|
|
219
|
+
### Project Structure
|
|
220
|
+
```
|
|
221
|
+
src/
|
|
222
|
+
├── main.py # FastAPI application
|
|
223
|
+
├── api/
|
|
224
|
+
│ ├── __init__.py
|
|
225
|
+
│ ├── dependencies.py # Dependency injection
|
|
226
|
+
│ └── v1/
|
|
227
|
+
│ ├── __init__.py
|
|
228
|
+
│ └── endpoints/
|
|
229
|
+
├── core/
|
|
230
|
+
│ ├── __init__.py
|
|
231
|
+
│ ├── config.py # Settings
|
|
232
|
+
│ └── security.py # Authentication
|
|
233
|
+
├── models/
|
|
234
|
+
├── schemas/ # Pydantic models
|
|
235
|
+
└── services/
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Common Commands
|
|
239
|
+
- `uvicorn main:app --reload` - Start development server
|
|
240
|
+
- `uvicorn main:app --host 0.0.0.0 --port 8000` - Start production server
|
|
241
|
+
|
|
242
|
+
## Security Guidelines
|
|
243
|
+
|
|
244
|
+
### Dependencies
|
|
245
|
+
- Regularly update dependencies with `pip list --outdated`
|
|
246
|
+
- Use `safety` package to check for known vulnerabilities
|
|
247
|
+
- Pin dependency versions in requirements files
|
|
248
|
+
- Use virtual environments to isolate dependencies
|
|
249
|
+
|
|
250
|
+
### Code Security
|
|
251
|
+
- Validate input data with Pydantic or similar
|
|
252
|
+
- Use environment variables for sensitive configuration
|
|
253
|
+
- Implement proper authentication and authorization
|
|
254
|
+
- Sanitize data before database operations
|
|
255
|
+
- Use HTTPS for production deployments
|
|
256
|
+
|
|
257
|
+
## Development Workflow
|
|
258
|
+
|
|
259
|
+
### Before Starting
|
|
260
|
+
1. Check Python version compatibility
|
|
261
|
+
2. Create and activate virtual environment
|
|
262
|
+
3. Install dependencies from requirements files
|
|
263
|
+
4. Run type checking with `mypy`
|
|
264
|
+
|
|
265
|
+
### During Development
|
|
266
|
+
1. Use type hints for better code documentation
|
|
267
|
+
2. Run tests frequently to catch issues early
|
|
268
|
+
3. Use meaningful commit messages
|
|
269
|
+
4. Format code with Black before committing
|
|
270
|
+
|
|
271
|
+
### Before Committing
|
|
272
|
+
1. Run full test suite: `pytest`
|
|
273
|
+
2. Check code formatting: `black --check .`
|
|
274
|
+
3. Sort imports: `isort --check-only .`
|
|
275
|
+
4. Run linting: `flake8`
|
|
276
|
+
5. Run type checking: `mypy src/`
|