claude-git-hooks 2.0.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 +212 -0
- package/README.md +217 -92
- package/bin/claude-hooks +311 -149
- package/lib/config.js +163 -0
- package/lib/hooks/pre-commit.js +180 -68
- package/lib/hooks/prepare-commit-msg.js +47 -41
- package/lib/utils/claude-client.js +93 -11
- package/lib/utils/file-operations.js +23 -74
- 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,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}}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# General Code Quality Guidelines
|
|
2
|
+
|
|
3
|
+
## Security Fundamentals
|
|
4
|
+
|
|
5
|
+
### Input Validation
|
|
6
|
+
✅ Validate all user input
|
|
7
|
+
✅ Sanitize data before use
|
|
8
|
+
✅ Use parameterized queries
|
|
9
|
+
✅ Escape output properly
|
|
10
|
+
✅ Validate file paths
|
|
11
|
+
|
|
12
|
+
### Credentials and Secrets
|
|
13
|
+
✅ Never hardcode credentials
|
|
14
|
+
✅ Use environment variables or secure vaults
|
|
15
|
+
✅ Don't log sensitive data
|
|
16
|
+
✅ Rotate keys regularly
|
|
17
|
+
✅ Use secure random generators
|
|
18
|
+
|
|
19
|
+
### Authentication & Authorization
|
|
20
|
+
✅ Implement proper authentication
|
|
21
|
+
✅ Check permissions before operations
|
|
22
|
+
✅ Use secure session management
|
|
23
|
+
✅ Implement rate limiting
|
|
24
|
+
✅ Log security events
|
|
25
|
+
|
|
26
|
+
## Reliability
|
|
27
|
+
|
|
28
|
+
### Error Handling
|
|
29
|
+
✅ Handle all error cases
|
|
30
|
+
✅ Provide meaningful error messages
|
|
31
|
+
✅ Clean up resources in finally blocks
|
|
32
|
+
✅ Don't swallow exceptions silently
|
|
33
|
+
✅ Log errors appropriately
|
|
34
|
+
|
|
35
|
+
### Null Safety
|
|
36
|
+
✅ Check for null/undefined values
|
|
37
|
+
✅ Use optional chaining where supported
|
|
38
|
+
✅ Provide default values
|
|
39
|
+
✅ Document when null is valid
|
|
40
|
+
✅ Avoid null pointer exceptions
|
|
41
|
+
|
|
42
|
+
### Resource Management
|
|
43
|
+
✅ Close files and connections
|
|
44
|
+
✅ Free allocated memory
|
|
45
|
+
✅ Use try-with-resources patterns
|
|
46
|
+
✅ Implement proper cleanup
|
|
47
|
+
✅ Avoid resource leaks
|
|
48
|
+
|
|
49
|
+
## Maintainability
|
|
50
|
+
|
|
51
|
+
### Code Organization
|
|
52
|
+
✅ Keep functions small and focused
|
|
53
|
+
✅ Use descriptive names
|
|
54
|
+
✅ Follow consistent naming conventions
|
|
55
|
+
✅ Organize code logically
|
|
56
|
+
✅ Limit nesting depth
|
|
57
|
+
|
|
58
|
+
### Documentation
|
|
59
|
+
✅ Document complex logic
|
|
60
|
+
✅ Explain non-obvious decisions
|
|
61
|
+
✅ Keep comments up to date
|
|
62
|
+
✅ Use inline documentation
|
|
63
|
+
✅ Document public APIs
|
|
64
|
+
|
|
65
|
+
### Code Duplication
|
|
66
|
+
✅ Extract common code into functions
|
|
67
|
+
✅ Use appropriate design patterns
|
|
68
|
+
✅ Don't copy-paste code
|
|
69
|
+
✅ Refactor when you see duplication
|
|
70
|
+
✅ Keep DRY (Don't Repeat Yourself)
|
|
71
|
+
|
|
72
|
+
## Performance
|
|
73
|
+
|
|
74
|
+
### General Guidelines
|
|
75
|
+
✅ Choose appropriate data structures
|
|
76
|
+
✅ Avoid unnecessary loops
|
|
77
|
+
✅ Cache expensive computations
|
|
78
|
+
✅ Use lazy loading when appropriate
|
|
79
|
+
✅ Profile before optimizing
|
|
80
|
+
|
|
81
|
+
### Resource Usage
|
|
82
|
+
✅ Limit memory allocations
|
|
83
|
+
✅ Use streaming for large data
|
|
84
|
+
✅ Implement pagination
|
|
85
|
+
✅ Clean up resources promptly
|
|
86
|
+
✅ Avoid memory leaks
|
|
87
|
+
|
|
88
|
+
## Common Issues to Avoid
|
|
89
|
+
|
|
90
|
+
### Critical Issues (BLOCKER)
|
|
91
|
+
❌ Security vulnerabilities (SQL injection, XSS, etc.)
|
|
92
|
+
❌ Exposed credentials or secrets
|
|
93
|
+
❌ Data loss risks
|
|
94
|
+
❌ Critical bugs that crash the application
|
|
95
|
+
|
|
96
|
+
### Major Issues (CRITICAL/MAJOR)
|
|
97
|
+
❌ Unhandled exceptions
|
|
98
|
+
❌ Resource leaks
|
|
99
|
+
❌ Missing input validation
|
|
100
|
+
❌ Poor error handling
|
|
101
|
+
❌ Performance bottlenecks
|
|
102
|
+
|
|
103
|
+
### Minor Issues (MINOR/INFO)
|
|
104
|
+
❌ Code duplication
|
|
105
|
+
❌ Poor naming
|
|
106
|
+
❌ Missing documentation
|
|
107
|
+
❌ Style inconsistencies
|
|
108
|
+
❌ Unused code
|
|
109
|
+
|
|
110
|
+
## Testing
|
|
111
|
+
|
|
112
|
+
✅ Write tests for new functionality
|
|
113
|
+
✅ Test error scenarios
|
|
114
|
+
✅ Test edge cases
|
|
115
|
+
✅ Mock external dependencies
|
|
116
|
+
✅ Aim for reasonable coverage
|
|
117
|
+
|
|
118
|
+
## Version Control
|
|
119
|
+
|
|
120
|
+
✅ Write clear commit messages
|
|
121
|
+
✅ Keep commits focused and atomic
|
|
122
|
+
✅ Don't commit sensitive data
|
|
123
|
+
✅ Review your own changes first
|
|
124
|
+
✅ Rebase/clean up before pushing
|
|
125
|
+
|
|
126
|
+
## Language-Specific
|
|
127
|
+
|
|
128
|
+
Different languages have specific best practices:
|
|
129
|
+
|
|
130
|
+
- **JavaScript/Node.js**: Use strict mode, handle promises, avoid callback hell
|
|
131
|
+
- **Python**: Follow PEP 8, use virtual environments, handle exceptions
|
|
132
|
+
- **Java**: Follow naming conventions, use proper access modifiers, handle checked exceptions
|
|
133
|
+
- **SQL**: Use parameterized queries, optimize for performance, maintain data integrity
|
|
134
|
+
- **Shell scripts**: Quote variables, check exit codes, handle errors
|
|
135
|
+
|
|
136
|
+
## Quality Standards
|
|
137
|
+
|
|
138
|
+
Strive for:
|
|
139
|
+
- **Reliability**: A or B
|
|
140
|
+
- **Security**: A or B
|
|
141
|
+
- **Maintainability**: A or B
|
|
142
|
+
- **Coverage**: 70%+ for new code
|
|
143
|
+
- **Complexity**: Keep cyclomatic complexity low
|
|
144
|
+
|
|
145
|
+
Remember: The goal is to write code that is secure, reliable, maintainable, and performs well.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# FIX_CRITICAL_ISSUES
|
|
2
|
+
|
|
3
|
+
CONTEXT:
|
|
4
|
+
repo:{{REPO_NAME}}
|
|
5
|
+
branch:{{BRANCH_NAME}}
|
|
6
|
+
commit:{{COMMIT_SHA}}
|
|
7
|
+
files:{{FILE_COUNT}}
|
|
8
|
+
|
|
9
|
+
CRITICAL_ISSUES:
|
|
10
|
+
{{BLOCKING_ISSUES}}
|
|
11
|
+
|
|
12
|
+
AFFECTED_FILES:
|
|
13
|
+
{{FILE_CONTENTS}}
|
|
14
|
+
|
|
15
|
+
INSTRUCTIONS:
|
|
16
|
+
1.Navigate→exact_file:line
|
|
17
|
+
2.Apply_minimal_fix
|
|
18
|
+
3.Maintain_style/conventions
|
|
19
|
+
4.No_unrelated_refactoring
|
|
20
|
+
|
|
21
|
+
OUTPUT:
|
|
22
|
+
- diff_format
|
|
23
|
+
- one_line_explanation_max
|
|
24
|
+
|
|
25
|
+
PRIORITY:
|
|
26
|
+
1.security_vulns
|
|
27
|
+
2.null_ptr/runtime
|
|
28
|
+
3.logic_errors
|
|
29
|
+
4.performance
|
|
30
|
+
5.code_quality
|
|
31
|
+
|
|
32
|
+
START_FIXING:
|