claude-git-hooks 2.1.0 → 2.3.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/CHANGELOG.md +178 -0
- package/README.md +203 -79
- package/bin/claude-hooks +295 -119
- package/lib/config.js +163 -0
- package/lib/hooks/pre-commit.js +179 -67
- package/lib/hooks/prepare-commit-msg.js +47 -41
- package/lib/utils/claude-client.js +93 -11
- package/lib/utils/file-operations.js +1 -65
- package/lib/utils/file-utils.js +65 -0
- package/lib/utils/package-info.js +75 -0
- package/lib/utils/preset-loader.js +209 -0
- package/lib/utils/prompt-builder.js +83 -67
- package/lib/utils/resolution-prompt.js +12 -2
- package/package.json +49 -50
- package/templates/ANALYZE_DIFF.md +33 -0
- package/templates/COMMIT_MESSAGE.md +24 -0
- package/templates/SUBAGENT_INSTRUCTION.md +1 -0
- package/templates/config.example.json +41 -0
- package/templates/presets/ai/ANALYSIS_PROMPT.md +133 -0
- package/templates/presets/ai/PRE_COMMIT_GUIDELINES.md +176 -0
- package/templates/presets/ai/config.json +12 -0
- package/templates/presets/ai/preset.json +42 -0
- package/templates/presets/backend/ANALYSIS_PROMPT.md +85 -0
- package/templates/presets/backend/PRE_COMMIT_GUIDELINES.md +87 -0
- package/templates/presets/backend/config.json +12 -0
- package/templates/presets/backend/preset.json +49 -0
- package/templates/presets/database/ANALYSIS_PROMPT.md +114 -0
- package/templates/presets/database/PRE_COMMIT_GUIDELINES.md +143 -0
- package/templates/presets/database/config.json +12 -0
- package/templates/presets/database/preset.json +38 -0
- package/templates/presets/default/config.json +12 -0
- package/templates/presets/default/preset.json +53 -0
- package/templates/presets/frontend/ANALYSIS_PROMPT.md +99 -0
- package/templates/presets/frontend/PRE_COMMIT_GUIDELINES.md +95 -0
- package/templates/presets/frontend/config.json +12 -0
- package/templates/presets/frontend/preset.json +50 -0
- package/templates/presets/fullstack/ANALYSIS_PROMPT.md +107 -0
- package/templates/presets/fullstack/CONSISTENCY_CHECKS.md +147 -0
- package/templates/presets/fullstack/PRE_COMMIT_GUIDELINES.md +125 -0
- package/templates/presets/fullstack/config.json +12 -0
- package/templates/presets/fullstack/preset.json +55 -0
- package/templates/shared/ANALYSIS_PROMPT.md +103 -0
- package/templates/shared/ANALYZE_DIFF.md +33 -0
- package/templates/shared/COMMIT_MESSAGE.md +24 -0
- package/templates/shared/PRE_COMMIT_GUIDELINES.md +145 -0
- package/templates/shared/RESOLUTION_PROMPT.md +32 -0
- package/templates/check-version.sh +0 -266
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Database Code Quality Guidelines
|
|
2
|
+
|
|
3
|
+
## SQL Server Best Practices
|
|
4
|
+
|
|
5
|
+
### Schema Design
|
|
6
|
+
✅ Use appropriate data types (avoid VARCHAR(MAX) unless needed)
|
|
7
|
+
✅ Define primary keys on all tables
|
|
8
|
+
✅ Define foreign keys for relationships
|
|
9
|
+
✅ Add CHECK constraints for data validation
|
|
10
|
+
✅ Use NOT NULL where appropriate
|
|
11
|
+
✅ Add default values where sensible
|
|
12
|
+
|
|
13
|
+
### Indexes
|
|
14
|
+
✅ Index all foreign key columns
|
|
15
|
+
✅ Index columns used in WHERE, JOIN, ORDER BY
|
|
16
|
+
✅ Consider covering indexes for frequent queries
|
|
17
|
+
✅ Don't over-index (impacts INSERT/UPDATE performance)
|
|
18
|
+
✅ Use include columns for covering indexes
|
|
19
|
+
✅ Monitor index fragmentation
|
|
20
|
+
|
|
21
|
+
### Query Performance
|
|
22
|
+
✅ Avoid SELECT * (specify columns)
|
|
23
|
+
✅ Use proper JOIN types (INNER, LEFT, etc.)
|
|
24
|
+
✅ Include WHERE clauses to limit results
|
|
25
|
+
✅ Use appropriate indexes
|
|
26
|
+
✅ Avoid functions on indexed columns in WHERE
|
|
27
|
+
✅ Use EXISTS instead of IN for subqueries
|
|
28
|
+
✅ Implement pagination for large result sets
|
|
29
|
+
|
|
30
|
+
### Stored Procedures
|
|
31
|
+
✅ Start with SET NOCOUNT ON
|
|
32
|
+
✅ Use TRY...CATCH for error handling
|
|
33
|
+
✅ Use parameters (prevent SQL injection)
|
|
34
|
+
✅ Return meaningful error codes/messages
|
|
35
|
+
✅ Use transactions for multi-step operations
|
|
36
|
+
✅ Comment complex logic
|
|
37
|
+
|
|
38
|
+
### Transactions
|
|
39
|
+
✅ Keep transactions short
|
|
40
|
+
✅ Handle errors properly (ROLLBACK on error)
|
|
41
|
+
✅ Use appropriate isolation level
|
|
42
|
+
✅ Don't hold locks longer than needed
|
|
43
|
+
✅ Commit or rollback all transactions
|
|
44
|
+
|
|
45
|
+
### Security
|
|
46
|
+
✅ Use parameterized queries (no string concatenation)
|
|
47
|
+
✅ Grant minimum necessary permissions
|
|
48
|
+
✅ Encrypt sensitive data at rest
|
|
49
|
+
✅ Use schemas to organize objects
|
|
50
|
+
✅ Avoid dynamic SQL when possible
|
|
51
|
+
✅ If using dynamic SQL, use sp_executesql with parameters
|
|
52
|
+
|
|
53
|
+
## Common Issues to Avoid
|
|
54
|
+
|
|
55
|
+
### Critical Issues (BLOCKER)
|
|
56
|
+
❌ UPDATE/DELETE without WHERE clause
|
|
57
|
+
❌ SQL injection vulnerabilities
|
|
58
|
+
❌ Granting excessive permissions (db_owner, sysadmin)
|
|
59
|
+
❌ No transaction handling for multi-step operations
|
|
60
|
+
|
|
61
|
+
### Performance Issues (MAJOR)
|
|
62
|
+
❌ SELECT * in production code
|
|
63
|
+
❌ Missing indexes on foreign keys
|
|
64
|
+
❌ Functions on indexed columns in WHERE
|
|
65
|
+
❌ Implicit conversions
|
|
66
|
+
❌ Cursors for set-based operations
|
|
67
|
+
❌ Missing WHERE clause causing full table scan
|
|
68
|
+
|
|
69
|
+
### Data Integrity Issues (CRITICAL)
|
|
70
|
+
❌ Missing foreign key constraints
|
|
71
|
+
❌ Missing primary keys
|
|
72
|
+
❌ No CHECK constraints for validation
|
|
73
|
+
❌ Nullable columns that shouldn't be
|
|
74
|
+
❌ No default values where needed
|
|
75
|
+
|
|
76
|
+
### Code Quality Issues (MINOR)
|
|
77
|
+
❌ No error handling
|
|
78
|
+
❌ Unclear variable names
|
|
79
|
+
❌ Missing comments on complex logic
|
|
80
|
+
❌ Inconsistent formatting
|
|
81
|
+
❌ Magic numbers without explanation
|
|
82
|
+
|
|
83
|
+
## T-SQL Specific
|
|
84
|
+
|
|
85
|
+
### Error Handling
|
|
86
|
+
```sql
|
|
87
|
+
BEGIN TRY
|
|
88
|
+
BEGIN TRANSACTION;
|
|
89
|
+
|
|
90
|
+
-- Your operations here
|
|
91
|
+
|
|
92
|
+
COMMIT TRANSACTION;
|
|
93
|
+
END TRY
|
|
94
|
+
BEGIN CATCH
|
|
95
|
+
IF @@TRANCOUNT > 0
|
|
96
|
+
ROLLBACK TRANSACTION;
|
|
97
|
+
|
|
98
|
+
-- Log error or re-throw
|
|
99
|
+
THROW;
|
|
100
|
+
END CATCH;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Parameterization
|
|
104
|
+
```sql
|
|
105
|
+
-- ✅ Good (parameterized)
|
|
106
|
+
EXEC sp_executesql
|
|
107
|
+
N'SELECT * FROM Users WHERE UserId = @UserId',
|
|
108
|
+
N'@UserId INT',
|
|
109
|
+
@UserId = @InputUserId;
|
|
110
|
+
|
|
111
|
+
-- ❌ Bad (SQL injection risk)
|
|
112
|
+
EXEC('SELECT * FROM Users WHERE UserId = ' + @InputUserId);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Index Usage
|
|
116
|
+
```sql
|
|
117
|
+
-- ❌ Bad (function prevents index usage)
|
|
118
|
+
SELECT * FROM Users WHERE YEAR(CreatedDate) = 2024;
|
|
119
|
+
|
|
120
|
+
-- ✅ Good (can use index)
|
|
121
|
+
SELECT * FROM Users
|
|
122
|
+
WHERE CreatedDate >= '2024-01-01'
|
|
123
|
+
AND CreatedDate < '2025-01-01';
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Migration Scripts
|
|
127
|
+
|
|
128
|
+
✅ Include rollback script
|
|
129
|
+
✅ Make scripts idempotent when possible
|
|
130
|
+
✅ Check for existence before CREATE/ALTER
|
|
131
|
+
✅ Use transactions
|
|
132
|
+
✅ Test on non-production first
|
|
133
|
+
✅ Document breaking changes
|
|
134
|
+
✅ Version your scripts
|
|
135
|
+
|
|
136
|
+
## Testing
|
|
137
|
+
|
|
138
|
+
- Test with realistic data volumes
|
|
139
|
+
- Test edge cases (NULL, empty strings, etc.)
|
|
140
|
+
- Test concurrent access
|
|
141
|
+
- Verify indexes are being used (execution plan)
|
|
142
|
+
- Test rollback scenarios
|
|
143
|
+
- Verify constraints work as expected
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "database",
|
|
3
|
+
"displayName": "Database (SQL Server)",
|
|
4
|
+
"description": "SQL Server database scripts and migrations",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
|
|
7
|
+
"techStack": [
|
|
8
|
+
"SQL Server",
|
|
9
|
+
"T-SQL",
|
|
10
|
+
"Stored Procedures",
|
|
11
|
+
"Views",
|
|
12
|
+
"Triggers",
|
|
13
|
+
"Indexes"
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
"fileExtensions": [
|
|
17
|
+
".sql"
|
|
18
|
+
],
|
|
19
|
+
|
|
20
|
+
"focusAreas": [
|
|
21
|
+
"SQL injection prevention",
|
|
22
|
+
"Query performance and optimization",
|
|
23
|
+
"Index usage and design",
|
|
24
|
+
"Transaction management",
|
|
25
|
+
"Proper use of constraints",
|
|
26
|
+
"Data integrity",
|
|
27
|
+
"Security and permissions",
|
|
28
|
+
"Avoiding common anti-patterns"
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
"templates": {
|
|
32
|
+
"analysis": "ANALYSIS_PROMPT.md",
|
|
33
|
+
"guidelines": "PRE_COMMIT_GUIDELINES.md",
|
|
34
|
+
"commitMessage": "../shared/COMMIT_MESSAGE.md",
|
|
35
|
+
"analyzeDiff": "../shared/ANALYZE_DIFF.md",
|
|
36
|
+
"resolution": "../shared/RESOLUTION_PROMPT.md"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "default",
|
|
3
|
+
"displayName": "Default (General-purpose)",
|
|
4
|
+
"description": "General scripting and development",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
|
|
7
|
+
"techStack": [
|
|
8
|
+
"General scripting",
|
|
9
|
+
"JavaScript",
|
|
10
|
+
"Python",
|
|
11
|
+
"Bash",
|
|
12
|
+
"Ruby",
|
|
13
|
+
"Perl",
|
|
14
|
+
"PowerShell",
|
|
15
|
+
"SQL",
|
|
16
|
+
"YAML",
|
|
17
|
+
"JSON",
|
|
18
|
+
"XML"
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
"fileExtensions": [
|
|
22
|
+
".js",
|
|
23
|
+
".sh",
|
|
24
|
+
".bash",
|
|
25
|
+
".py",
|
|
26
|
+
".rb",
|
|
27
|
+
".pl",
|
|
28
|
+
".ps1",
|
|
29
|
+
".sql",
|
|
30
|
+
".yaml",
|
|
31
|
+
".yml",
|
|
32
|
+
".json",
|
|
33
|
+
".xml",
|
|
34
|
+
".md"
|
|
35
|
+
],
|
|
36
|
+
|
|
37
|
+
"focusAreas": [
|
|
38
|
+
"Code quality basics",
|
|
39
|
+
"Security fundamentals (input validation, escaping)",
|
|
40
|
+
"Performance best practices",
|
|
41
|
+
"Maintainability",
|
|
42
|
+
"Error handling",
|
|
43
|
+
"Documentation"
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
"templates": {
|
|
47
|
+
"analysis": "../shared/ANALYSIS_PROMPT.md",
|
|
48
|
+
"guidelines": "../shared/PRE_COMMIT_GUIDELINES.md",
|
|
49
|
+
"commitMessage": "../shared/COMMIT_MESSAGE.md",
|
|
50
|
+
"analyzeDiff": "../shared/ANALYZE_DIFF.md",
|
|
51
|
+
"resolution": "../shared/RESOLUTION_PROMPT.md"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
You are analyzing a **{{PRESET_NAME}}** project with the following technology stack:
|
|
2
|
+
|
|
3
|
+
**Tech Stack:** {{TECH_STACK}}
|
|
4
|
+
|
|
5
|
+
**Analyzing files matching:** {{FILE_EXTENSIONS}}
|
|
6
|
+
|
|
7
|
+
## Your Task
|
|
8
|
+
|
|
9
|
+
Perform a comprehensive code quality analysis focusing on these areas:
|
|
10
|
+
|
|
11
|
+
{{FOCUS_AREAS}}
|
|
12
|
+
|
|
13
|
+
## Analysis Guidelines
|
|
14
|
+
|
|
15
|
+
1. **Security First**: Check for frontend security issues:
|
|
16
|
+
- XSS vulnerabilities (dangerouslySetInnerHTML)
|
|
17
|
+
- Exposed API keys or secrets
|
|
18
|
+
- Insecure authentication token handling
|
|
19
|
+
- CSRF vulnerabilities
|
|
20
|
+
- Unvalidated redirects
|
|
21
|
+
|
|
22
|
+
2. **React Best Practices**:
|
|
23
|
+
- Proper use of hooks (useState, useEffect, useCallback, useMemo)
|
|
24
|
+
- Avoiding unnecessary re-renders
|
|
25
|
+
- Proper dependency arrays in useEffect
|
|
26
|
+
- Component composition over inheritance
|
|
27
|
+
- Proper prop types or TypeScript types
|
|
28
|
+
|
|
29
|
+
3. **State Management**:
|
|
30
|
+
- Redux patterns and anti-patterns
|
|
31
|
+
- Proper use of Redux Saga
|
|
32
|
+
- Immutable state updates
|
|
33
|
+
- Avoid prop drilling
|
|
34
|
+
- Local vs global state decisions
|
|
35
|
+
|
|
36
|
+
4. **Performance**:
|
|
37
|
+
- Unnecessary re-renders
|
|
38
|
+
- Missing React.memo or useMemo
|
|
39
|
+
- Large bundle sizes
|
|
40
|
+
- Unoptimized images
|
|
41
|
+
- Memory leaks (cleanup in useEffect)
|
|
42
|
+
|
|
43
|
+
5. **Accessibility**:
|
|
44
|
+
- Semantic HTML
|
|
45
|
+
- ARIA labels where needed
|
|
46
|
+
- Keyboard navigation
|
|
47
|
+
- Screen reader support
|
|
48
|
+
- Color contrast
|
|
49
|
+
|
|
50
|
+
6. **Code Quality**:
|
|
51
|
+
- Component reusability
|
|
52
|
+
- DRY violations
|
|
53
|
+
- Proper error handling
|
|
54
|
+
- Console errors/warnings
|
|
55
|
+
- Test coverage
|
|
56
|
+
|
|
57
|
+
## Output Format
|
|
58
|
+
|
|
59
|
+
Respond with a valid JSON following the SonarQube format:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"QUALITY_GATE": "PASSED|FAILED",
|
|
64
|
+
"approved": true|false,
|
|
65
|
+
"metrics": {
|
|
66
|
+
"reliability": "A|B|C|D|E",
|
|
67
|
+
"security": "A|B|C|D|E",
|
|
68
|
+
"maintainability": "A|B|C|D|E",
|
|
69
|
+
"coverage": 0-100,
|
|
70
|
+
"duplications": 0-100,
|
|
71
|
+
"complexity": "number"
|
|
72
|
+
},
|
|
73
|
+
"issues": {
|
|
74
|
+
"blocker": 0,
|
|
75
|
+
"critical": 0,
|
|
76
|
+
"major": 0,
|
|
77
|
+
"minor": 0,
|
|
78
|
+
"info": 0
|
|
79
|
+
},
|
|
80
|
+
"details": [
|
|
81
|
+
{
|
|
82
|
+
"severity": "BLOCKER|CRITICAL|MAJOR|MINOR|INFO",
|
|
83
|
+
"type": "BUG|VULNERABILITY|CODE_SMELL",
|
|
84
|
+
"file": "path/to/file.jsx",
|
|
85
|
+
"line": 123,
|
|
86
|
+
"message": "Clear description of the issue"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"securityHotspots": 0,
|
|
90
|
+
"blockingIssues": ["List of critical issues that must be fixed"]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Analysis Rules
|
|
95
|
+
|
|
96
|
+
- **Block commit** if: Security vulnerabilities (XSS, exposed secrets), critical bugs, or accessibility blockers
|
|
97
|
+
- **Pass** if: Only minor issues, info messages, or no issues
|
|
98
|
+
- Be strict but fair - focus on real problems, not style preferences
|
|
99
|
+
- Provide actionable, specific feedback with line numbers
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Frontend Code Quality Guidelines
|
|
2
|
+
|
|
3
|
+
## React Standards
|
|
4
|
+
|
|
5
|
+
### Components
|
|
6
|
+
- Use functional components with hooks
|
|
7
|
+
- Keep components small and focused (< 200 lines)
|
|
8
|
+
- Extract reusable logic into custom hooks
|
|
9
|
+
- Use proper prop types or TypeScript
|
|
10
|
+
- Avoid deep nesting (max 3-4 levels)
|
|
11
|
+
|
|
12
|
+
### Hooks
|
|
13
|
+
- Follow Rules of Hooks (top level, not in loops/conditions)
|
|
14
|
+
- Provide complete dependency arrays in useEffect
|
|
15
|
+
- Use useCallback for functions passed to child components
|
|
16
|
+
- Use useMemo for expensive calculations
|
|
17
|
+
- Clean up effects (return cleanup function)
|
|
18
|
+
|
|
19
|
+
### State Management
|
|
20
|
+
- Keep state as local as possible
|
|
21
|
+
- Use Redux only for truly global state
|
|
22
|
+
- Follow Redux best practices (immutable updates)
|
|
23
|
+
- Use Redux Saga for side effects
|
|
24
|
+
- Normalize state shape
|
|
25
|
+
|
|
26
|
+
### Performance
|
|
27
|
+
- Use React.memo for expensive components
|
|
28
|
+
- Lazy load routes and heavy components
|
|
29
|
+
- Optimize images and assets
|
|
30
|
+
- Avoid inline function definitions in JSX
|
|
31
|
+
- Use virtualization for long lists
|
|
32
|
+
|
|
33
|
+
## Security Requirements
|
|
34
|
+
|
|
35
|
+
### XSS Prevention
|
|
36
|
+
- Never use `dangerouslySetInnerHTML` without sanitization
|
|
37
|
+
- Validate and sanitize user input
|
|
38
|
+
- Be careful with URL parameters
|
|
39
|
+
- Escape user-generated content
|
|
40
|
+
|
|
41
|
+
### Authentication
|
|
42
|
+
- Store tokens securely (httpOnly cookies preferred)
|
|
43
|
+
- Never log sensitive data
|
|
44
|
+
- Implement proper session timeout
|
|
45
|
+
- Clear sensitive data on logout
|
|
46
|
+
|
|
47
|
+
### API Security
|
|
48
|
+
- Never expose API keys in client code
|
|
49
|
+
- Use environment variables for configuration
|
|
50
|
+
- Validate API responses
|
|
51
|
+
- Handle errors without exposing internals
|
|
52
|
+
|
|
53
|
+
## Accessibility (a11y)
|
|
54
|
+
|
|
55
|
+
### Must Have
|
|
56
|
+
- Semantic HTML elements
|
|
57
|
+
- Alt text for images
|
|
58
|
+
- ARIA labels for icons and buttons
|
|
59
|
+
- Keyboard navigation support
|
|
60
|
+
- Focus management
|
|
61
|
+
|
|
62
|
+
### Forms
|
|
63
|
+
- Label all inputs properly
|
|
64
|
+
- Show validation errors clearly
|
|
65
|
+
- Support keyboard navigation
|
|
66
|
+
- Provide helpful error messages
|
|
67
|
+
|
|
68
|
+
## Common Issues to Avoid
|
|
69
|
+
|
|
70
|
+
❌ Missing dependency arrays in useEffect
|
|
71
|
+
❌ Using dangerouslySetInnerHTML
|
|
72
|
+
❌ Exposed API keys or secrets
|
|
73
|
+
❌ Missing error boundaries
|
|
74
|
+
❌ Unnecessary re-renders
|
|
75
|
+
❌ Memory leaks (missing cleanup)
|
|
76
|
+
❌ Ignoring console warnings
|
|
77
|
+
❌ Poor accessibility
|
|
78
|
+
❌ Missing loading/error states
|
|
79
|
+
❌ Not handling async errors
|
|
80
|
+
|
|
81
|
+
## Testing
|
|
82
|
+
|
|
83
|
+
- Write tests for complex components
|
|
84
|
+
- Test user interactions
|
|
85
|
+
- Test error scenarios
|
|
86
|
+
- Mock API calls
|
|
87
|
+
- Aim for 70%+ coverage on new code
|
|
88
|
+
|
|
89
|
+
## Styling
|
|
90
|
+
|
|
91
|
+
- Use consistent naming (BEM, CSS modules, or styled-components)
|
|
92
|
+
- Avoid inline styles except for dynamic values
|
|
93
|
+
- Ensure responsive design
|
|
94
|
+
- Check color contrast ratios
|
|
95
|
+
- Use CSS variables for theming
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "frontend",
|
|
3
|
+
"displayName": "Frontend (React + Material-UI)",
|
|
4
|
+
"description": "React frontend with Material-UI, Redux, React Hook Form",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
|
|
7
|
+
"techStack": [
|
|
8
|
+
"React 18+",
|
|
9
|
+
"React Router 6+",
|
|
10
|
+
"Material-UI v5",
|
|
11
|
+
"Semantic UI",
|
|
12
|
+
"Redux",
|
|
13
|
+
"Redux Saga",
|
|
14
|
+
"React Hook Form",
|
|
15
|
+
"Highcharts",
|
|
16
|
+
"Axios",
|
|
17
|
+
"Jest",
|
|
18
|
+
"Testing Library"
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
"fileExtensions": [
|
|
22
|
+
".js",
|
|
23
|
+
".jsx",
|
|
24
|
+
".ts",
|
|
25
|
+
".tsx",
|
|
26
|
+
".css",
|
|
27
|
+
".scss",
|
|
28
|
+
".html"
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
"focusAreas": [
|
|
32
|
+
"Component design and reusability",
|
|
33
|
+
"React hooks best practices",
|
|
34
|
+
"State management patterns",
|
|
35
|
+
"Performance optimization (memoization, lazy loading)",
|
|
36
|
+
"XSS prevention and input sanitization",
|
|
37
|
+
"Accessibility (a11y)",
|
|
38
|
+
"Responsive design",
|
|
39
|
+
"Error boundaries and error handling",
|
|
40
|
+
"Test coverage"
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
"templates": {
|
|
44
|
+
"analysis": "ANALYSIS_PROMPT.md",
|
|
45
|
+
"guidelines": "PRE_COMMIT_GUIDELINES.md",
|
|
46
|
+
"commitMessage": "../shared/COMMIT_MESSAGE.md",
|
|
47
|
+
"analyzeDiff": "../shared/ANALYZE_DIFF.md",
|
|
48
|
+
"resolution": "../shared/RESOLUTION_PROMPT.md"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
You are analyzing a **{{PRESET_NAME}}** project with the following technology stack:
|
|
2
|
+
|
|
3
|
+
**Tech Stack:** {{TECH_STACK}}
|
|
4
|
+
|
|
5
|
+
**Analyzing files matching:** {{FILE_EXTENSIONS}}
|
|
6
|
+
|
|
7
|
+
## Your Task
|
|
8
|
+
|
|
9
|
+
Perform a comprehensive full-stack code quality analysis. **PRIORITY: Check consistency between layers first**, then apply layer-specific guidelines.
|
|
10
|
+
|
|
11
|
+
**Focus Areas:**
|
|
12
|
+
{{FOCUS_AREAS}}
|
|
13
|
+
|
|
14
|
+
## Full-Stack Analysis Guidelines
|
|
15
|
+
|
|
16
|
+
### 1. **Cross-Layer Consistency** (HIGHEST PRIORITY)
|
|
17
|
+
|
|
18
|
+
Check these consistency issues first:
|
|
19
|
+
|
|
20
|
+
- **API Contracts**: Do DTOs match frontend types/interfaces?
|
|
21
|
+
- **Error Handling**: Are backend error responses handled properly in frontend?
|
|
22
|
+
- **Authentication**: Is JWT/token handling consistent?
|
|
23
|
+
- **Data Validation**: Is validation present on both client and server?
|
|
24
|
+
- **Status Codes**: Are HTTP status codes used correctly and handled properly?
|
|
25
|
+
|
|
26
|
+
### 2. **Backend Layer** (Spring Boot)
|
|
27
|
+
|
|
28
|
+
- REST API design and best practices
|
|
29
|
+
- JPA entities and repositories
|
|
30
|
+
- Security vulnerabilities (OWASP)
|
|
31
|
+
- SQL injection prevention
|
|
32
|
+
- Transaction management
|
|
33
|
+
- DTO mappings
|
|
34
|
+
- Service layer patterns
|
|
35
|
+
|
|
36
|
+
### 3. **Frontend Layer** (React)
|
|
37
|
+
|
|
38
|
+
- Component design and reusability
|
|
39
|
+
- React hooks best practices
|
|
40
|
+
- State management patterns
|
|
41
|
+
- XSS prevention
|
|
42
|
+
- Performance optimization
|
|
43
|
+
- Accessibility (a11y)
|
|
44
|
+
- Error boundaries
|
|
45
|
+
|
|
46
|
+
### 4. **Security Across Layers**
|
|
47
|
+
|
|
48
|
+
- Backend: SQL injection, authentication, authorization
|
|
49
|
+
- Frontend: XSS, exposed secrets, token storage
|
|
50
|
+
- Both: Input validation, error message exposure, CORS
|
|
51
|
+
|
|
52
|
+
### 5. **Performance Across Layers**
|
|
53
|
+
|
|
54
|
+
- Backend: Database queries, N+1 problems, caching
|
|
55
|
+
- Frontend: Re-renders, bundle size, lazy loading
|
|
56
|
+
- Both: API payload size, pagination
|
|
57
|
+
|
|
58
|
+
## Output Format
|
|
59
|
+
|
|
60
|
+
Respond with a valid JSON following the SonarQube format:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"QUALITY_GATE": "PASSED|FAILED",
|
|
65
|
+
"approved": true|false,
|
|
66
|
+
"metrics": {
|
|
67
|
+
"reliability": "A|B|C|D|E",
|
|
68
|
+
"security": "A|B|C|D|E",
|
|
69
|
+
"maintainability": "A|B|C|D|E",
|
|
70
|
+
"coverage": 0-100,
|
|
71
|
+
"duplications": 0-100,
|
|
72
|
+
"complexity": "number"
|
|
73
|
+
},
|
|
74
|
+
"issues": {
|
|
75
|
+
"blocker": 0,
|
|
76
|
+
"critical": 0,
|
|
77
|
+
"major": 0,
|
|
78
|
+
"minor": 0,
|
|
79
|
+
"info": 0
|
|
80
|
+
},
|
|
81
|
+
"details": [
|
|
82
|
+
{
|
|
83
|
+
"severity": "BLOCKER|CRITICAL|MAJOR|MINOR|INFO",
|
|
84
|
+
"type": "BUG|VULNERABILITY|CODE_SMELL|CONSISTENCY",
|
|
85
|
+
"file": "path/to/file",
|
|
86
|
+
"line": 123,
|
|
87
|
+
"message": "Clear description - mention if it's a cross-layer issue"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"securityHotspots": 0,
|
|
91
|
+
"blockingIssues": ["List of critical issues that must be fixed"],
|
|
92
|
+
"consistencyIssues": ["Cross-layer inconsistencies found"]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Analysis Rules
|
|
97
|
+
|
|
98
|
+
- **Block commit** if:
|
|
99
|
+
- Critical cross-layer inconsistencies (mismatched contracts, broken data flow)
|
|
100
|
+
- Security vulnerabilities in any layer
|
|
101
|
+
- Critical bugs in backend or frontend
|
|
102
|
+
|
|
103
|
+
- **Pass** if: Only minor issues or no issues
|
|
104
|
+
|
|
105
|
+
- **Special attention**: When both backend and frontend files are modified together, carefully verify they work together correctly
|
|
106
|
+
|
|
107
|
+
- Provide actionable, specific feedback with line numbers and layer context
|