claude-git-hooks 2.1.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +240 -0
- package/README.md +280 -78
- package/bin/claude-hooks +295 -119
- package/lib/config.js +164 -0
- package/lib/hooks/pre-commit.js +180 -67
- package/lib/hooks/prepare-commit-msg.js +47 -41
- package/lib/utils/claude-client.js +107 -16
- package/lib/utils/claude-diagnostics.js +266 -0
- package/lib/utils/file-operations.js +1 -65
- package/lib/utils/file-utils.js +65 -0
- package/lib/utils/installation-diagnostics.js +145 -0
- package/lib/utils/package-info.js +75 -0
- package/lib/utils/preset-loader.js +214 -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/CUSTOMIZATION_GUIDE.md +656 -0
- package/templates/SUBAGENT_INSTRUCTION.md +1 -0
- package/templates/config.example.json +41 -0
- package/templates/pre-commit +40 -2
- package/templates/prepare-commit-msg +40 -2
- 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,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
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Full-Stack Consistency Checks
|
|
2
|
+
|
|
3
|
+
This template provides specific checks for cross-layer consistency in full-stack applications.
|
|
4
|
+
|
|
5
|
+
## API Contract Consistency
|
|
6
|
+
|
|
7
|
+
### DTO ↔ TypeScript Interface Matching
|
|
8
|
+
|
|
9
|
+
**Backend DTO Example:**
|
|
10
|
+
```java
|
|
11
|
+
public class UserDTO {
|
|
12
|
+
private Long id;
|
|
13
|
+
private String email;
|
|
14
|
+
private String firstName;
|
|
15
|
+
private String lastName;
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Frontend Interface Should Match:**
|
|
20
|
+
```typescript
|
|
21
|
+
interface User {
|
|
22
|
+
id: number;
|
|
23
|
+
email: string;
|
|
24
|
+
firstName: string;
|
|
25
|
+
lastName: string;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Check for:**
|
|
30
|
+
- ✅ All fields present in both
|
|
31
|
+
- ✅ Same field names (exact match, including casing)
|
|
32
|
+
- ✅ Compatible types (Long↔number, String↔string, etc.)
|
|
33
|
+
- ✅ Optional fields marked consistently
|
|
34
|
+
|
|
35
|
+
## Error Response Consistency
|
|
36
|
+
|
|
37
|
+
**Backend Error Response:**
|
|
38
|
+
```java
|
|
39
|
+
{
|
|
40
|
+
"timestamp": "2024-01-01T12:00:00",
|
|
41
|
+
"status": 400,
|
|
42
|
+
"error": "Bad Request",
|
|
43
|
+
"message": "Validation failed",
|
|
44
|
+
"path": "/api/users"
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Frontend Should Handle:**
|
|
49
|
+
```javascript
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error.response.status === 400) {
|
|
52
|
+
// Handle validation error
|
|
53
|
+
} else if (error.response.status === 401) {
|
|
54
|
+
// Handle unauthorized
|
|
55
|
+
}
|
|
56
|
+
// etc.
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Check for:**
|
|
61
|
+
- ✅ Frontend handles all status codes backend returns
|
|
62
|
+
- ✅ Error messages displayed to user are user-friendly
|
|
63
|
+
- ✅ No sensitive info exposed in errors
|
|
64
|
+
|
|
65
|
+
## Authentication Flow Consistency
|
|
66
|
+
|
|
67
|
+
**Check for:**
|
|
68
|
+
- ✅ Token format matches between backend generation and frontend consumption
|
|
69
|
+
- ✅ Token expiration handled on both sides
|
|
70
|
+
- ✅ Refresh token logic works end-to-end
|
|
71
|
+
- ✅ Secure token storage (httpOnly cookies > localStorage)
|
|
72
|
+
- ✅ Authorization headers formatted correctly
|
|
73
|
+
|
|
74
|
+
## Validation Consistency
|
|
75
|
+
|
|
76
|
+
**Backend:**
|
|
77
|
+
```java
|
|
78
|
+
@NotNull
|
|
79
|
+
@Email
|
|
80
|
+
private String email;
|
|
81
|
+
|
|
82
|
+
@Size(min = 8, max = 100)
|
|
83
|
+
private String password;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Frontend Should Match:**
|
|
87
|
+
```javascript
|
|
88
|
+
const validationSchema = {
|
|
89
|
+
email: yup.string().email().required(),
|
|
90
|
+
password: yup.string().min(8).max(100).required()
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Check for:**
|
|
95
|
+
- ✅ Same validation rules on both sides
|
|
96
|
+
- ✅ Clear error messages match
|
|
97
|
+
- ✅ Required fields consistent
|
|
98
|
+
- ✅ Length/format constraints match
|
|
99
|
+
|
|
100
|
+
## Data Flow Checks
|
|
101
|
+
|
|
102
|
+
**When Backend Changes:**
|
|
103
|
+
- ✅ Check if frontend needs updates
|
|
104
|
+
- ✅ Verify API contract compatibility
|
|
105
|
+
- ✅ Check for breaking changes
|
|
106
|
+
|
|
107
|
+
**When Frontend Changes:**
|
|
108
|
+
- ✅ Verify API calls still match backend
|
|
109
|
+
- ✅ Check error handling is complete
|
|
110
|
+
- ✅ Ensure all backend responses handled
|
|
111
|
+
|
|
112
|
+
## Common Consistency Issues
|
|
113
|
+
|
|
114
|
+
### Type Mismatches
|
|
115
|
+
❌ Backend: `Long`, Frontend: `string` (should be `number`)
|
|
116
|
+
❌ Backend: `LocalDateTime`, Frontend: not parsing as Date
|
|
117
|
+
❌ Backend: enum values, Frontend: magic strings
|
|
118
|
+
|
|
119
|
+
### Naming Mismatches
|
|
120
|
+
❌ Backend: `user_id`, Frontend: `userId`
|
|
121
|
+
❌ Backend: `firstName`, Frontend: `first_name`
|
|
122
|
+
❌ Inconsistent pluralization
|
|
123
|
+
|
|
124
|
+
### Missing Fields
|
|
125
|
+
❌ Backend returns field frontend doesn't expect
|
|
126
|
+
❌ Frontend expects field backend doesn't send
|
|
127
|
+
❌ Optional fields treated as required
|
|
128
|
+
|
|
129
|
+
### Status Code Issues
|
|
130
|
+
❌ Backend returns 500, frontend only handles 4xx
|
|
131
|
+
❌ Backend returns 204, frontend expects JSON
|
|
132
|
+
❌ Backend changes status code, frontend not updated
|
|
133
|
+
|
|
134
|
+
## Verification Checklist
|
|
135
|
+
|
|
136
|
+
When analyzing commits that touch both backend and frontend:
|
|
137
|
+
|
|
138
|
+
- [ ] API endpoint paths match
|
|
139
|
+
- [ ] HTTP methods correct
|
|
140
|
+
- [ ] Request/response DTOs match TypeScript types
|
|
141
|
+
- [ ] All status codes handled
|
|
142
|
+
- [ ] Error responses properly handled
|
|
143
|
+
- [ ] Authentication/authorization consistent
|
|
144
|
+
- [ ] Validation rules match
|
|
145
|
+
- [ ] Data transformations are inverse operations
|
|
146
|
+
- [ ] Breaking changes documented
|
|
147
|
+
- [ ] Tests cover the integration
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Fullstack Code Quality Guidelines
|
|
2
|
+
|
|
3
|
+
## Cross-Layer Consistency (PRIORITY)
|
|
4
|
+
|
|
5
|
+
### API Contracts
|
|
6
|
+
✅ DTOs (backend) match TypeScript interfaces (frontend)
|
|
7
|
+
✅ Field names use same casing (camelCase recommended)
|
|
8
|
+
✅ Required/optional fields consistent
|
|
9
|
+
✅ Data types match (String↔string, Integer↔number, etc.)
|
|
10
|
+
|
|
11
|
+
### Error Handling
|
|
12
|
+
✅ Backend returns consistent error format
|
|
13
|
+
✅ Frontend handles all backend error codes
|
|
14
|
+
✅ User-friendly error messages in frontend
|
|
15
|
+
✅ No sensitive info in error messages
|
|
16
|
+
|
|
17
|
+
### Authentication Flow
|
|
18
|
+
✅ JWT token format consistent
|
|
19
|
+
✅ Token storage secure (httpOnly cookies preferred)
|
|
20
|
+
✅ Token expiration handled properly
|
|
21
|
+
✅ Refresh token logic works end-to-end
|
|
22
|
+
|
|
23
|
+
### Validation
|
|
24
|
+
✅ Server-side validation always present
|
|
25
|
+
✅ Client-side validation matches server rules
|
|
26
|
+
✅ Clear validation error messages
|
|
27
|
+
✅ Never trust client validation alone
|
|
28
|
+
|
|
29
|
+
## Backend Standards (Spring Boot)
|
|
30
|
+
|
|
31
|
+
### Controllers
|
|
32
|
+
- Proper HTTP methods and status codes
|
|
33
|
+
- Input validation with `@Valid`
|
|
34
|
+
- Exception handling with `@ExceptionHandler`
|
|
35
|
+
- Use DTOs, never expose entities
|
|
36
|
+
- Return consistent response format
|
|
37
|
+
|
|
38
|
+
### Services
|
|
39
|
+
- Use `@Transactional` appropriately
|
|
40
|
+
- Handle exceptions properly
|
|
41
|
+
- Keep business logic here (not in controllers)
|
|
42
|
+
- Avoid N+1 queries
|
|
43
|
+
|
|
44
|
+
### Security
|
|
45
|
+
- Never hardcode credentials
|
|
46
|
+
- Use parameterized queries
|
|
47
|
+
- Validate all input
|
|
48
|
+
- Implement proper authorization checks
|
|
49
|
+
|
|
50
|
+
## Frontend Standards (React)
|
|
51
|
+
|
|
52
|
+
### Components
|
|
53
|
+
- Keep components small and focused
|
|
54
|
+
- Use proper hooks (useState, useEffect, etc.)
|
|
55
|
+
- Implement error boundaries
|
|
56
|
+
- Handle loading and error states
|
|
57
|
+
- Ensure accessibility
|
|
58
|
+
|
|
59
|
+
### API Integration
|
|
60
|
+
- Validate API responses
|
|
61
|
+
- Handle all error scenarios
|
|
62
|
+
- Show appropriate loading states
|
|
63
|
+
- Implement proper error recovery
|
|
64
|
+
|
|
65
|
+
### Security
|
|
66
|
+
- Never use `dangerouslySetInnerHTML` without sanitization
|
|
67
|
+
- Store tokens securely
|
|
68
|
+
- Validate user input
|
|
69
|
+
- Don't expose API keys
|
|
70
|
+
|
|
71
|
+
## Common Full-Stack Issues
|
|
72
|
+
|
|
73
|
+
### Backend-Frontend Mismatches
|
|
74
|
+
❌ DTOs don't match frontend types
|
|
75
|
+
❌ Different field names or casing
|
|
76
|
+
❌ Frontend expects fields backend doesn't send
|
|
77
|
+
❌ Error responses not handled in frontend
|
|
78
|
+
|
|
79
|
+
### Security Issues
|
|
80
|
+
❌ SQL injection vulnerabilities (backend)
|
|
81
|
+
❌ XSS vulnerabilities (frontend)
|
|
82
|
+
❌ Exposed secrets or credentials
|
|
83
|
+
❌ Missing authentication/authorization
|
|
84
|
+
❌ Insecure token storage
|
|
85
|
+
|
|
86
|
+
### Data Flow Problems
|
|
87
|
+
❌ Missing validation on either layer
|
|
88
|
+
❌ Inconsistent error handling
|
|
89
|
+
❌ Breaking API changes without frontend update
|
|
90
|
+
❌ Frontend not handling all backend states
|
|
91
|
+
|
|
92
|
+
### Performance Issues
|
|
93
|
+
❌ N+1 queries (backend)
|
|
94
|
+
❌ Unnecessary re-renders (frontend)
|
|
95
|
+
❌ Large API payloads
|
|
96
|
+
❌ Missing pagination
|
|
97
|
+
❌ Unoptimized database queries
|
|
98
|
+
|
|
99
|
+
## Testing
|
|
100
|
+
|
|
101
|
+
### Backend
|
|
102
|
+
- Unit tests for services
|
|
103
|
+
- Integration tests for repositories
|
|
104
|
+
- API endpoint tests
|
|
105
|
+
- Security tests
|
|
106
|
+
|
|
107
|
+
### Frontend
|
|
108
|
+
- Component unit tests
|
|
109
|
+
- Integration tests for API calls
|
|
110
|
+
- User interaction tests
|
|
111
|
+
- Error scenario tests
|
|
112
|
+
|
|
113
|
+
### End-to-End
|
|
114
|
+
- Critical user flows
|
|
115
|
+
- Authentication flows
|
|
116
|
+
- Error handling
|
|
117
|
+
- Edge cases
|
|
118
|
+
|
|
119
|
+
## Commit Best Practices
|
|
120
|
+
|
|
121
|
+
When modifying both backend and frontend:
|
|
122
|
+
1. Ensure API contract changes are compatible
|
|
123
|
+
2. Update both layers together if breaking change
|
|
124
|
+
3. Test the complete flow locally
|
|
125
|
+
4. Document any API changes in commit message
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fullstack",
|
|
3
|
+
"displayName": "Fullstack (Spring Boot + React)",
|
|
4
|
+
"description": "Full-stack application with Spring Boot backend and React frontend",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
|
|
7
|
+
"techStack": [
|
|
8
|
+
"Spring Boot 2.6+",
|
|
9
|
+
"JPA",
|
|
10
|
+
"SQL Server",
|
|
11
|
+
"Spring Security",
|
|
12
|
+
"JWT",
|
|
13
|
+
"React 18+",
|
|
14
|
+
"Material-UI v5",
|
|
15
|
+
"Redux",
|
|
16
|
+
"Maven",
|
|
17
|
+
"Jest",
|
|
18
|
+
"JUnit"
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
"fileExtensions": [
|
|
22
|
+
".java",
|
|
23
|
+
".xml",
|
|
24
|
+
".yml",
|
|
25
|
+
".yaml",
|
|
26
|
+
".js",
|
|
27
|
+
".jsx",
|
|
28
|
+
".ts",
|
|
29
|
+
".tsx",
|
|
30
|
+
".css",
|
|
31
|
+
".scss",
|
|
32
|
+
".html",
|
|
33
|
+
".sql"
|
|
34
|
+
],
|
|
35
|
+
|
|
36
|
+
"focusAreas": [
|
|
37
|
+
"API contract consistency between backend and frontend",
|
|
38
|
+
"Data flow from database through API to UI",
|
|
39
|
+
"Authentication and authorization across layers",
|
|
40
|
+
"Error handling consistency",
|
|
41
|
+
"Security vulnerabilities (OWASP, XSS)",
|
|
42
|
+
"Performance optimization (backend queries, frontend rendering)",
|
|
43
|
+
"Type safety (DTOs match API contracts)",
|
|
44
|
+
"Cross-layer testing"
|
|
45
|
+
],
|
|
46
|
+
|
|
47
|
+
"templates": {
|
|
48
|
+
"analysis": "ANALYSIS_PROMPT.md",
|
|
49
|
+
"guidelines": "PRE_COMMIT_GUIDELINES.md",
|
|
50
|
+
"consistency": "CONSISTENCY_CHECKS.md",
|
|
51
|
+
"commitMessage": "../shared/COMMIT_MESSAGE.md",
|
|
52
|
+
"analyzeDiff": "../shared/ANALYZE_DIFF.md",
|
|
53
|
+
"resolution": "../shared/RESOLUTION_PROMPT.md"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
Evaluate the code changes across these dimensions:
|
|
16
|
+
|
|
17
|
+
### 1. **Security**
|
|
18
|
+
- Check for common vulnerabilities (injection, XSS, authentication issues)
|
|
19
|
+
- Look for exposed credentials or sensitive data
|
|
20
|
+
- Verify input validation
|
|
21
|
+
- Check for insecure configurations
|
|
22
|
+
|
|
23
|
+
### 2. **Reliability**
|
|
24
|
+
- Identify potential bugs or runtime errors
|
|
25
|
+
- Check error handling completeness
|
|
26
|
+
- Look for null pointer risks
|
|
27
|
+
- Verify exception handling
|
|
28
|
+
|
|
29
|
+
### 3. **Maintainability**
|
|
30
|
+
- Assess code clarity and organization
|
|
31
|
+
- Check for code duplication
|
|
32
|
+
- Evaluate naming conventions
|
|
33
|
+
- Review documentation quality
|
|
34
|
+
|
|
35
|
+
### 4. **Performance**
|
|
36
|
+
- Identify potential performance bottlenecks
|
|
37
|
+
- Check for inefficient algorithms
|
|
38
|
+
- Look for resource leaks
|
|
39
|
+
- Verify proper cleanup
|
|
40
|
+
|
|
41
|
+
### 5. **Best Practices**
|
|
42
|
+
- Language-specific idioms and patterns
|
|
43
|
+
- Framework best practices
|
|
44
|
+
- Design patterns usage
|
|
45
|
+
- Code organization
|
|
46
|
+
|
|
47
|
+
## Output Format
|
|
48
|
+
|
|
49
|
+
Respond with a valid JSON following the SonarQube format:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"QUALITY_GATE": "PASSED|FAILED",
|
|
54
|
+
"approved": true|false,
|
|
55
|
+
"metrics": {
|
|
56
|
+
"reliability": "A|B|C|D|E",
|
|
57
|
+
"security": "A|B|C|D|E",
|
|
58
|
+
"maintainability": "A|B|C|D|E",
|
|
59
|
+
"coverage": 0-100,
|
|
60
|
+
"duplications": 0-100,
|
|
61
|
+
"complexity": "number"
|
|
62
|
+
},
|
|
63
|
+
"issues": {
|
|
64
|
+
"blocker": 0,
|
|
65
|
+
"critical": 0,
|
|
66
|
+
"major": 0,
|
|
67
|
+
"minor": 0,
|
|
68
|
+
"info": 0
|
|
69
|
+
},
|
|
70
|
+
"details": [
|
|
71
|
+
{
|
|
72
|
+
"severity": "BLOCKER|CRITICAL|MAJOR|MINOR|INFO",
|
|
73
|
+
"type": "BUG|VULNERABILITY|CODE_SMELL",
|
|
74
|
+
"file": "path/to/file",
|
|
75
|
+
"line": 123,
|
|
76
|
+
"message": "Clear description of the issue"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"securityHotspots": 0,
|
|
80
|
+
"blockingIssues": ["List of critical issues that must be fixed"]
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Severity Guidelines
|
|
85
|
+
|
|
86
|
+
- **BLOCKER**: Critical security vulnerabilities, data loss risks, critical bugs
|
|
87
|
+
- **CRITICAL**: Major security issues, significant bugs, critical performance problems
|
|
88
|
+
- **MAJOR**: Important issues that should be fixed soon
|
|
89
|
+
- **MINOR**: Minor issues, suggestions for improvement
|
|
90
|
+
- **INFO**: Informational notes, optional improvements
|
|
91
|
+
|
|
92
|
+
## Quality Gate Rules
|
|
93
|
+
|
|
94
|
+
- **FAILED**: If blocker >= 1 OR critical > 1 OR security hotspots > 0
|
|
95
|
+
- **PASSED**: Otherwise
|
|
96
|
+
|
|
97
|
+
## Analysis Rules
|
|
98
|
+
|
|
99
|
+
- Be strict but fair - focus on real problems, not style preferences
|
|
100
|
+
- Provide actionable, specific feedback with line numbers
|
|
101
|
+
- Consider the context and purpose of the code
|
|
102
|
+
- Prioritize security and reliability over style
|
|
103
|
+
- Be constructive in your feedback
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Analyze the following changes. CONTEXT: {{CONTEXT_DESCRIPTION}}
|
|
2
|
+
{{SUBAGENT_INSTRUCTION}}
|
|
3
|
+
Please generate:
|
|
4
|
+
1. A concise and descriptive PR title (maximum 72 characters)
|
|
5
|
+
2. A detailed PR description that includes:
|
|
6
|
+
- Summary of changes
|
|
7
|
+
- Motivation/context
|
|
8
|
+
- Type of change (feature/fix/refactor/docs/etc)
|
|
9
|
+
- Recommended testing
|
|
10
|
+
3. A suggested branch name following the format: type/short-description (example: feature/add-user-auth, fix/memory-leak)
|
|
11
|
+
|
|
12
|
+
IMPORTANT: If these are local changes without push, the suggested branch name should be for creating a new branch from the current one.
|
|
13
|
+
|
|
14
|
+
Respond EXCLUSIVELY with a valid JSON with this structure:
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"prTitle": "Interesting PR title",
|
|
18
|
+
"prDescription": "detailed PR description with markdown",
|
|
19
|
+
"suggestedBranchName": "type/suggested-branch-name",
|
|
20
|
+
"changeType": "feature|fix|refactor|docs|test|chore",
|
|
21
|
+
"breakingChanges": false,
|
|
22
|
+
"testingNotes": "notes on necessary testing or 'None'"
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## COMMITS
|
|
27
|
+
{{COMMITS}}
|
|
28
|
+
|
|
29
|
+
## CHANGED FILES
|
|
30
|
+
{{DIFF_FILES}}
|
|
31
|
+
|
|
32
|
+
## FULL DIFF
|
|
33
|
+
{{FULL_DIFF}}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Analyze the following changes and generate a commit message following the Conventional Commits format.
|
|
2
|
+
|
|
3
|
+
Respond ONLY with a valid JSON:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"type": "feat|fix|docs|style|refactor|test|chore|ci|perf",
|
|
8
|
+
"scope": "optional scope (e.g.: api, frontend, db)",
|
|
9
|
+
"title": "short description in present tense (max 50 chars)",
|
|
10
|
+
"body": "optional detailed description"
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## CHANGES TO ANALYZE
|
|
15
|
+
|
|
16
|
+
### Modified files:
|
|
17
|
+
{{FILE_LIST}}
|
|
18
|
+
|
|
19
|
+
### Summary of changes:
|
|
20
|
+
Files changed: {{FILE_COUNT}}
|
|
21
|
+
Insertions: {{INSERTIONS}}, Deletions: {{DELETIONS}}
|
|
22
|
+
|
|
23
|
+
### Detailed diffs:
|
|
24
|
+
{{FILE_DIFFS}}
|