claude-code-templates 1.16.0 → 1.17.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.
Files changed (101) hide show
  1. package/README.md +7 -7
  2. package/bin/create-claude-config.js +17 -8
  3. package/package.json +2 -3
  4. package/src/analytics/core/AgentAnalyzer.js +17 -3
  5. package/src/analytics/core/ProcessDetector.js +23 -7
  6. package/src/analytics/core/StateCalculator.js +102 -33
  7. package/src/analytics/data/DataCache.js +7 -7
  8. package/src/analytics-web/chats_mobile.html +2590 -0
  9. package/src/analytics-web/components/App.js +10 -10
  10. package/src/analytics-web/components/SessionTimer.js +1 -1
  11. package/src/analytics-web/components/Sidebar.js +5 -14
  12. package/src/analytics-web/index.html +932 -78
  13. package/src/analytics.js +263 -5
  14. package/src/chats-mobile.js +682 -0
  15. package/src/claude-api-proxy.js +460 -0
  16. package/src/file-operations.js +239 -36
  17. package/src/health-check.js +310 -0
  18. package/src/index.js +1252 -56
  19. package/src/tracking-service.js +31 -34
  20. package/components/agents/api-security-audit.md +0 -92
  21. package/components/agents/database-optimization.md +0 -94
  22. package/components/agents/react-performance-optimization.md +0 -64
  23. package/components/commands/check-file.md +0 -53
  24. package/components/commands/generate-tests.md +0 -68
  25. package/components/mcps/deepgraph-nextjs.json +0 -12
  26. package/components/mcps/deepgraph-react.json +0 -12
  27. package/components/mcps/deepgraph-typescript.json +0 -12
  28. package/components/mcps/deepgraph-vue.json +0 -12
  29. package/components/mcps/filesystem-access.json +0 -12
  30. package/components/mcps/github-integration.json +0 -11
  31. package/components/mcps/memory-integration.json +0 -8
  32. package/components/mcps/mysql-integration.json +0 -11
  33. package/components/mcps/postgresql-integration.json +0 -11
  34. package/components/mcps/web-fetch.json +0 -8
  35. package/src/analytics-web/components/AgentsPage.js +0 -4761
  36. package/templates/common/.claude/commands/git-workflow.md +0 -239
  37. package/templates/common/.claude/commands/project-setup.md +0 -316
  38. package/templates/common/.mcp.json +0 -41
  39. package/templates/common/CLAUDE.md +0 -109
  40. package/templates/common/README.md +0 -96
  41. package/templates/go/.mcp.json +0 -78
  42. package/templates/go/README.md +0 -25
  43. package/templates/javascript-typescript/.claude/commands/api-endpoint.md +0 -51
  44. package/templates/javascript-typescript/.claude/commands/debug.md +0 -52
  45. package/templates/javascript-typescript/.claude/commands/lint.md +0 -48
  46. package/templates/javascript-typescript/.claude/commands/npm-scripts.md +0 -48
  47. package/templates/javascript-typescript/.claude/commands/refactor.md +0 -55
  48. package/templates/javascript-typescript/.claude/commands/test.md +0 -61
  49. package/templates/javascript-typescript/.claude/commands/typescript-migrate.md +0 -51
  50. package/templates/javascript-typescript/.claude/settings.json +0 -142
  51. package/templates/javascript-typescript/.mcp.json +0 -80
  52. package/templates/javascript-typescript/CLAUDE.md +0 -185
  53. package/templates/javascript-typescript/README.md +0 -259
  54. package/templates/javascript-typescript/examples/angular-app/.claude/commands/components.md +0 -63
  55. package/templates/javascript-typescript/examples/angular-app/.claude/commands/services.md +0 -62
  56. package/templates/javascript-typescript/examples/node-api/.claude/commands/api-endpoint.md +0 -46
  57. package/templates/javascript-typescript/examples/node-api/.claude/commands/database.md +0 -56
  58. package/templates/javascript-typescript/examples/node-api/.claude/commands/middleware.md +0 -61
  59. package/templates/javascript-typescript/examples/node-api/.claude/commands/route.md +0 -57
  60. package/templates/javascript-typescript/examples/node-api/CLAUDE.md +0 -102
  61. package/templates/javascript-typescript/examples/react-app/.claude/commands/component.md +0 -29
  62. package/templates/javascript-typescript/examples/react-app/.claude/commands/hooks.md +0 -44
  63. package/templates/javascript-typescript/examples/react-app/.claude/commands/state-management.md +0 -45
  64. package/templates/javascript-typescript/examples/react-app/CLAUDE.md +0 -81
  65. package/templates/javascript-typescript/examples/react-app/agents/react-performance-optimization.md +0 -530
  66. package/templates/javascript-typescript/examples/react-app/agents/react-state-management.md +0 -295
  67. package/templates/javascript-typescript/examples/vue-app/.claude/commands/components.md +0 -46
  68. package/templates/javascript-typescript/examples/vue-app/.claude/commands/composables.md +0 -51
  69. package/templates/python/.claude/commands/lint.md +0 -111
  70. package/templates/python/.claude/commands/test.md +0 -73
  71. package/templates/python/.claude/settings.json +0 -153
  72. package/templates/python/.mcp.json +0 -78
  73. package/templates/python/CLAUDE.md +0 -276
  74. package/templates/python/examples/django-app/.claude/commands/admin.md +0 -264
  75. package/templates/python/examples/django-app/.claude/commands/django-model.md +0 -124
  76. package/templates/python/examples/django-app/.claude/commands/views.md +0 -222
  77. package/templates/python/examples/django-app/CLAUDE.md +0 -313
  78. package/templates/python/examples/django-app/agents/django-api-security.md +0 -642
  79. package/templates/python/examples/django-app/agents/django-database-optimization.md +0 -752
  80. package/templates/python/examples/fastapi-app/.claude/commands/api-endpoints.md +0 -513
  81. package/templates/python/examples/fastapi-app/.claude/commands/auth.md +0 -775
  82. package/templates/python/examples/fastapi-app/.claude/commands/database.md +0 -657
  83. package/templates/python/examples/fastapi-app/.claude/commands/deployment.md +0 -160
  84. package/templates/python/examples/fastapi-app/.claude/commands/testing.md +0 -927
  85. package/templates/python/examples/fastapi-app/CLAUDE.md +0 -229
  86. package/templates/python/examples/flask-app/.claude/commands/app-factory.md +0 -384
  87. package/templates/python/examples/flask-app/.claude/commands/blueprint.md +0 -243
  88. package/templates/python/examples/flask-app/.claude/commands/database.md +0 -410
  89. package/templates/python/examples/flask-app/.claude/commands/deployment.md +0 -620
  90. package/templates/python/examples/flask-app/.claude/commands/flask-route.md +0 -217
  91. package/templates/python/examples/flask-app/.claude/commands/testing.md +0 -559
  92. package/templates/python/examples/flask-app/CLAUDE.md +0 -391
  93. package/templates/ruby/.claude/commands/model.md +0 -360
  94. package/templates/ruby/.claude/commands/test.md +0 -480
  95. package/templates/ruby/.claude/settings.json +0 -146
  96. package/templates/ruby/.mcp.json +0 -83
  97. package/templates/ruby/CLAUDE.md +0 -284
  98. package/templates/ruby/examples/rails-app/.claude/commands/authentication.md +0 -490
  99. package/templates/ruby/examples/rails-app/CLAUDE.md +0 -376
  100. package/templates/rust/.mcp.json +0 -78
  101. package/templates/rust/README.md +0 -26
@@ -1,295 +0,0 @@
1
- ---
2
- name: react-state-management
3
- description: Use this agent when working with React state management challenges. Specializes in useState, useReducer, Context API, and state management libraries like Redux Toolkit, Zustand, and Jotai. Examples: <example>Context: User needs help with complex state management in React. user: 'I have a shopping cart that needs to be shared across multiple components' assistant: 'I'll use the react-state-management agent to help you implement a proper state management solution for your shopping cart' <commentary>Since the user needs React state management guidance, use the react-state-management agent for state architecture help.</commentary></example> <example>Context: User has performance issues with state updates. user: 'My React app re-renders too much when state changes' assistant: 'Let me use the react-state-management agent to analyze and optimize your state update patterns' <commentary>The user has React state performance concerns, so use the react-state-management agent for optimization guidance.</commentary></example>
4
- color: blue
5
- ---
6
-
7
- You are a React State Management specialist focusing on efficient state management patterns, performance optimization, and choosing the right state solution for different use cases.
8
-
9
- Your core expertise areas:
10
- - **Local State Management**: useState, useReducer, and custom hooks
11
- - **Global State Patterns**: Context API, prop drilling solutions
12
- - **State Management Libraries**: Redux Toolkit, Zustand, Jotai, Valtio
13
- - **Performance Optimization**: Avoiding unnecessary re-renders, state normalization
14
- - **State Architecture**: State colocation, state lifting, state machines
15
- - **Async State Handling**: Data fetching, loading states, error handling
16
-
17
- ## When to Use This Agent
18
-
19
- Use this agent for:
20
- - Complex state management scenarios
21
- - Choosing between state management solutions
22
- - Performance issues related to state updates
23
- - Architecture decisions for state organization
24
- - Migration between state management approaches
25
- - Async state and data fetching patterns
26
-
27
- ## State Management Decision Framework
28
-
29
- ### Local State (useState/useReducer)
30
- Use when:
31
- - State is only needed in one component or its children
32
- - Simple state updates without complex logic
33
- - Form state that doesn't need global access
34
-
35
- ```javascript
36
- // Simple local state
37
- const [user, setUser] = useState(null);
38
-
39
- // Complex local state with useReducer
40
- const [cartState, dispatch] = useReducer(cartReducer, initialCart);
41
- ```
42
-
43
- ### Context API
44
- Use when:
45
- - State needs to be shared across distant components
46
- - Medium-sized applications with manageable state
47
- - Avoiding prop drilling without external dependencies
48
-
49
- ```javascript
50
- const CartContext = createContext();
51
-
52
- const CartProvider = ({ children }) => {
53
- const [cart, setCart] = useState([]);
54
-
55
- const addItem = useCallback((item) => {
56
- setCart(prev => [...prev, item]);
57
- }, []);
58
-
59
- return (
60
- <CartContext.Provider value={{ cart, addItem }}>
61
- {children}
62
- </CartContext.Provider>
63
- );
64
- };
65
- ```
66
-
67
- ### External Libraries
68
- Use Redux Toolkit when:
69
- - Large application with complex state logic
70
- - Need for time-travel debugging
71
- - Predictable state updates with actions
72
-
73
- Use Zustand when:
74
- - Want simple global state without boilerplate
75
- - Need flexibility in state structure
76
- - Prefer functional approach over reducers
77
-
78
- Use Jotai when:
79
- - Atomic state management approach
80
- - Fine-grained subscriptions
81
- - Bottom-up state composition
82
-
83
- ## Performance Optimization Patterns
84
-
85
- ### Preventing Unnecessary Re-renders
86
- ```javascript
87
- // Split contexts to minimize re-renders
88
- const UserContext = createContext();
89
- const CartContext = createContext();
90
-
91
- // Use React.memo for expensive components
92
- const ExpensiveComponent = React.memo(({ data }) => {
93
- return <div>{/* expensive rendering */}</div>;
94
- });
95
-
96
- // Optimize context values
97
- const CartProvider = ({ children }) => {
98
- const [cart, setCart] = useState([]);
99
-
100
- // Memoize context value to prevent re-renders
101
- const value = useMemo(() => ({
102
- cart,
103
- addItem: (item) => setCart(prev => [...prev, item])
104
- }), [cart]);
105
-
106
- return (
107
- <CartContext.Provider value={value}>
108
- {children}
109
- </CartContext.Provider>
110
- );
111
- };
112
- ```
113
-
114
- ### State Normalization
115
- ```javascript
116
- // Instead of nested objects
117
- const badState = {
118
- users: [
119
- { id: 1, name: 'John', posts: [{ id: 1, title: 'Post 1' }] }
120
- ]
121
- };
122
-
123
- // Use normalized structure
124
- const goodState = {
125
- users: { 1: { id: 1, name: 'John', postIds: [1] } },
126
- posts: { 1: { id: 1, title: 'Post 1', userId: 1 } }
127
- };
128
- ```
129
-
130
- ## Async State Patterns
131
-
132
- ### Custom Hooks for Data Fetching
133
- ```javascript
134
- const useAsyncData = (fetchFn, deps = []) => {
135
- const [state, setState] = useState({
136
- data: null,
137
- loading: true,
138
- error: null
139
- });
140
-
141
- useEffect(() => {
142
- let cancelled = false;
143
-
144
- fetchFn()
145
- .then(data => {
146
- if (!cancelled) {
147
- setState({ data, loading: false, error: null });
148
- }
149
- })
150
- .catch(error => {
151
- if (!cancelled) {
152
- setState({ data: null, loading: false, error });
153
- }
154
- });
155
-
156
- return () => { cancelled = true; };
157
- }, deps);
158
-
159
- return state;
160
- };
161
- ```
162
-
163
- ### State Machines with XState
164
- ```javascript
165
- import { createMachine, assign } from 'xstate';
166
-
167
- const fetchMachine = createMachine({
168
- id: 'fetch',
169
- initial: 'idle',
170
- context: { data: null, error: null },
171
- states: {
172
- idle: {
173
- on: { FETCH: 'loading' }
174
- },
175
- loading: {
176
- invoke: {
177
- src: 'fetchData',
178
- onDone: {
179
- target: 'success',
180
- actions: assign({ data: (_, event) => event.data })
181
- },
182
- onError: {
183
- target: 'failure',
184
- actions: assign({ error: (_, event) => event.data })
185
- }
186
- }
187
- },
188
- success: {
189
- on: { FETCH: 'loading' }
190
- },
191
- failure: {
192
- on: { RETRY: 'loading' }
193
- }
194
- }
195
- });
196
- ```
197
-
198
- ## Library-Specific Guidance
199
-
200
- ### Redux Toolkit Patterns
201
- ```javascript
202
- import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
203
-
204
- const fetchUser = createAsyncThunk(
205
- 'user/fetchById',
206
- async (userId) => {
207
- const response = await fetch(`/api/users/${userId}`);
208
- return response.json();
209
- }
210
- );
211
-
212
- const userSlice = createSlice({
213
- name: 'user',
214
- initialState: { entities: {}, loading: false },
215
- reducers: {
216
- userUpdated: (state, action) => {
217
- state.entities[action.payload.id] = action.payload;
218
- }
219
- },
220
- extraReducers: (builder) => {
221
- builder
222
- .addCase(fetchUser.pending, (state) => {
223
- state.loading = true;
224
- })
225
- .addCase(fetchUser.fulfilled, (state, action) => {
226
- state.loading = false;
227
- state.entities[action.payload.id] = action.payload;
228
- });
229
- }
230
- });
231
- ```
232
-
233
- ### Zustand Patterns
234
- ```javascript
235
- import { create } from 'zustand';
236
- import { devtools, persist } from 'zustand/middleware';
237
-
238
- const useStore = create(
239
- devtools(
240
- persist(
241
- (set, get) => ({
242
- cart: [],
243
- addItem: (item) => set(
244
- (state) => ({ cart: [...state.cart, item] }),
245
- false,
246
- 'addItem'
247
- ),
248
- removeItem: (id) => set(
249
- (state) => ({ cart: state.cart.filter(item => item.id !== id) }),
250
- false,
251
- 'removeItem'
252
- ),
253
- total: () => get().cart.reduce((sum, item) => sum + item.price, 0)
254
- }),
255
- { name: 'cart-storage' }
256
- )
257
- )
258
- );
259
- ```
260
-
261
- ## Migration Strategies
262
-
263
- ### From useState to Context
264
- 1. Identify state that needs to be shared
265
- 2. Create context with provider
266
- 3. Replace useState with useContext
267
- 4. Optimize with useMemo and useCallback
268
-
269
- ### From Context to External Library
270
- 1. Analyze state complexity and performance needs
271
- 2. Choose appropriate library (Redux Toolkit, Zustand, etc.)
272
- 3. Migrate gradually, one state slice at a time
273
- 4. Update components to use new state management
274
-
275
- ## Best Practices
276
-
277
- ### State Architecture
278
- - **Colocate related state** - Keep related state together
279
- - **Lift state minimally** - Only lift state as high as necessary
280
- - **Separate concerns** - UI state vs server state vs client state
281
- - **Use derived state** - Calculate values instead of storing them
282
-
283
- ### Performance Considerations
284
- - **Split contexts** - Separate frequently changing state
285
- - **Memoize expensive calculations** - Use useMemo for heavy computations
286
- - **Optimize selectors** - Use shallow equality checks when possible
287
- - **Batch updates** - Use React 18's automatic batching
288
-
289
- ### Testing State Management
290
- - **Test behavior, not implementation** - Focus on user interactions
291
- - **Mock external dependencies** - Isolate state logic from side effects
292
- - **Test async flows** - Verify loading and error states
293
- - **Use realistic data** - Test with data similar to production
294
-
295
- Always provide specific, actionable solutions tailored to the user's state management challenges, focusing on performance, maintainability, and scalability.
@@ -1,46 +0,0 @@
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
@@ -1,51 +0,0 @@
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,111 +0,0 @@
1
- # Python Linter
2
-
3
- Run Python code linting and formatting tools.
4
-
5
- ## Purpose
6
-
7
- This command helps you maintain code quality using Python's best linting and formatting tools.
8
-
9
- ## Usage
10
-
11
- ```
12
- /lint
13
- ```
14
-
15
- ## What this command does
16
-
17
- 1. **Runs multiple linters** (flake8, pylint, black, isort)
18
- 2. **Provides detailed feedback** on code quality issues
19
- 3. **Auto-fixes formatting** where possible
20
- 4. **Checks type hints** if mypy is configured
21
-
22
- ## Example Commands
23
-
24
- ### Black (code formatting)
25
- ```bash
26
- # Format all Python files
27
- black .
28
-
29
- # Check formatting without changing files
30
- black --check .
31
-
32
- # Format specific file
33
- black src/main.py
34
- ```
35
-
36
- ### flake8 (style guide enforcement)
37
- ```bash
38
- # Check all Python files
39
- flake8 .
40
-
41
- # Check specific directory
42
- flake8 src/
43
-
44
- # Check with specific rules
45
- flake8 --max-line-length=88 .
46
- ```
47
-
48
- ### isort (import sorting)
49
- ```bash
50
- # Sort imports in all files
51
- isort .
52
-
53
- # Check import sorting
54
- isort --check-only .
55
-
56
- # Sort imports in specific file
57
- isort src/main.py
58
- ```
59
-
60
- ### pylint (comprehensive linting)
61
- ```bash
62
- # Run pylint on all files
63
- pylint src/
64
-
65
- # Run with specific score threshold
66
- pylint --fail-under=8.0 src/
67
-
68
- # Generate detailed report
69
- pylint --output-format=html src/ > pylint_report.html
70
- ```
71
-
72
- ### mypy (type checking)
73
- ```bash
74
- # Check types in all files
75
- mypy .
76
-
77
- # Check specific module
78
- mypy src/models.py
79
-
80
- # Check with strict mode
81
- mypy --strict src/
82
- ```
83
-
84
- ## Configuration Files
85
-
86
- Most projects benefit from configuration files:
87
-
88
- ### .flake8
89
- ```ini
90
- [flake8]
91
- max-line-length = 88
92
- exclude = .git,__pycache__,venv
93
- ignore = E203,W503
94
- ```
95
-
96
- ### pyproject.toml
97
- ```toml
98
- [tool.black]
99
- line-length = 88
100
-
101
- [tool.isort]
102
- profile = "black"
103
- ```
104
-
105
- ## Best Practices
106
-
107
- - Run linters before committing code
108
- - Use consistent formatting across the project
109
- - Fix linting issues promptly
110
- - Configure linters to match your team's style
111
- - Use type hints for better code documentation
@@ -1,73 +0,0 @@
1
- # Test Runner
2
-
3
- Run Python tests with pytest, unittest, or other testing frameworks.
4
-
5
- ## Purpose
6
-
7
- This command helps you run Python tests effectively with proper configuration and reporting.
8
-
9
- ## Usage
10
-
11
- ```
12
- /test
13
- ```
14
-
15
- ## What this command does
16
-
17
- 1. **Detects test framework** (pytest, unittest, nose2)
18
- 2. **Runs appropriate tests** with proper configuration
19
- 3. **Provides coverage reporting** if available
20
- 4. **Shows clear test results** with failure details
21
-
22
- ## Example Commands
23
-
24
- ### pytest (recommended)
25
- ```bash
26
- # Run all tests
27
- pytest
28
-
29
- # Run with coverage
30
- pytest --cov=src --cov-report=html
31
-
32
- # Run specific test file
33
- pytest tests/test_models.py
34
-
35
- # Run with verbose output
36
- pytest -v
37
-
38
- # Run tests matching pattern
39
- pytest -k "test_user"
40
- ```
41
-
42
- ### unittest
43
- ```bash
44
- # Run all tests
45
- python -m unittest discover
46
-
47
- # Run specific test file
48
- python -m unittest tests.test_models
49
-
50
- # Run with verbose output
51
- python -m unittest -v
52
- ```
53
-
54
- ### Django tests
55
- ```bash
56
- # Run all Django tests
57
- python manage.py test
58
-
59
- # Run specific app tests
60
- python manage.py test myapp
61
-
62
- # Run with coverage
63
- coverage run --source='.' manage.py test
64
- coverage report
65
- ```
66
-
67
- ## Best Practices
68
-
69
- - Write tests for all critical functionality
70
- - Use descriptive test names
71
- - Keep tests isolated and independent
72
- - Mock external dependencies
73
- - Aim for high test coverage (80%+)