claude-git-hooks 2.4.0 → 2.5.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.
@@ -1,41 +1,41 @@
1
- {
2
- "preset": "ai",
3
- "analysis": {
4
- "maxFileSize": 1000000,
5
- "maxFiles": 30,
6
- "timeout": 180000,
7
- "contextLines": 3,
8
- "ignoreExtensions": []
9
- },
10
- "commitMessage": {
11
- "autoKeyword": "auto",
12
- "timeout": 180000
13
- },
14
- "subagents": {
15
- "enabled": false,
16
- "model": "haiku",
17
- "batchSize": 1
18
- },
19
- "templates": {
20
- "baseDir": ".claude",
21
- "analysis": "CLAUDE_ANALYSIS_PROMPT_SONAR.md",
22
- "guidelines": "CLAUDE_PRE_COMMIT_SONAR.md",
23
- "commitMessage": "COMMIT_MESSAGE.md",
24
- "analyzeDiff": "ANALYZE_DIFF.md",
25
- "resolution": "CLAUDE_RESOLUTION_PROMPT.md",
26
- "subagentInstruction": "SUBAGENT_INSTRUCTION.md"
27
- },
28
- "output": {
29
- "outputDir": ".claude/out",
30
- "debugFile": ".claude/out/debug-claude-response.json",
31
- "resolutionFile": ".claude/out/claude_resolution_prompt.md",
32
- "prAnalysisFile": ".claude/out/pr-analysis.json"
33
- },
34
- "system": {
35
- "debug": false,
36
- "wslCheckTimeout": 3000
37
- },
38
- "git": {
39
- "diffFilter": "ACM"
40
- }
41
- }
1
+ {
2
+ "preset": "ai",
3
+ "analysis": {
4
+ "maxFileSize": 1000000,
5
+ "maxFiles": 30,
6
+ "timeout": 180000,
7
+ "contextLines": 3,
8
+ "ignoreExtensions": []
9
+ },
10
+ "commitMessage": {
11
+ "autoKeyword": "auto",
12
+ "timeout": 180000
13
+ },
14
+ "subagents": {
15
+ "enabled": false,
16
+ "model": "haiku",
17
+ "batchSize": 1
18
+ },
19
+ "templates": {
20
+ "baseDir": ".claude",
21
+ "analysis": "CLAUDE_ANALYSIS_PROMPT_SONAR.md",
22
+ "guidelines": "CLAUDE_PRE_COMMIT_SONAR.md",
23
+ "commitMessage": "COMMIT_MESSAGE.md",
24
+ "analyzeDiff": "ANALYZE_DIFF.md",
25
+ "resolution": "CLAUDE_RESOLUTION_PROMPT.md",
26
+ "subagentInstruction": "SUBAGENT_INSTRUCTION.md"
27
+ },
28
+ "output": {
29
+ "outputDir": ".claude/out",
30
+ "debugFile": ".claude/out/debug-claude-response.json",
31
+ "resolutionFile": ".claude/out/claude_resolution_prompt.md",
32
+ "prAnalysisFile": ".claude/out/pr-analysis.json"
33
+ },
34
+ "system": {
35
+ "debug": false,
36
+ "wslCheckTimeout": 3000
37
+ },
38
+ "git": {
39
+ "diffFilter": "ACM"
40
+ }
41
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "$schema": "Configuration example for GitHub integration (v2.5.0+)",
3
+ "_comment": "GitHub PR creation via Octokit - Claude generates metadata, Octokit creates PR deterministically",
4
+ "github": {
5
+ "enabled": true,
6
+ "pr": {
7
+ "defaultBase": "develop",
8
+
9
+ "_comment_reviewers": "Reviewers to add to PRs. Use GitHub usernames (without @). Also auto-detected from CODEOWNERS if exists.",
10
+ "reviewers": ["teammate1-username", "teammate2-username"],
11
+
12
+ "_comment_reviewers_advanced": "For preset-based or conditional reviewers, use arrays keyed by preset name",
13
+ "reviewers_by_preset": {
14
+ "backend": ["backend-dev", "tech-lead"],
15
+ "frontend": ["frontend-dev", "ux-designer"],
16
+ "fullstack": ["fullstack-dev"]
17
+ },
18
+
19
+ "_comment_reviewerRules": "Pattern-based reviewer assignment. Matches file paths in the PR diff.",
20
+ "reviewerRules": [
21
+ {
22
+ "pattern": ".*\\.java$",
23
+ "reviewers": ["backend-dev"]
24
+ },
25
+ {
26
+ "pattern": ".*\\.sql$",
27
+ "reviewers": ["dba-team"]
28
+ },
29
+ {
30
+ "pattern": ".*\\.(tsx|jsx)$",
31
+ "reviewers": ["frontend-dev"]
32
+ }
33
+ ],
34
+
35
+ "_comment_labelRules": "Labels added automatically based on active preset. Also detects breaking-change automatically.",
36
+ "labelRules": {
37
+ "backend": ["backend", "java", "spring-boot"],
38
+ "frontend": ["frontend", "react", "typescript"],
39
+ "fullstack": ["fullstack"],
40
+ "database": ["database", "sql"],
41
+ "ai": ["ai", "nodejs", "tooling"],
42
+ "default": []
43
+ }
44
+ }
45
+ },
46
+
47
+ "_usage": "Copy relevant sections to .claude/config.json in your project",
48
+ "_token_setup": "Run 'claude-hooks setup-github' to configure GitHub token",
49
+ "_token_location": "Token stored in .claude/settings.local.json (gitignored) or env var GITHUB_TOKEN",
50
+ "_codeowners": "CODEOWNERS file auto-detected from: CODEOWNERS, .github/CODEOWNERS, docs/CODEOWNERS"
51
+ }
@@ -3,12 +3,14 @@
3
3
  ## Claude API Best Practices
4
4
 
5
5
  ### Model Selection
6
+
6
7
  ✅ **Haiku**: Simple tasks, fast responses, cost-effective
7
8
  ✅ **Sonnet**: Balanced performance, most use cases
8
9
  ✅ **Opus**: Complex reasoning, highest quality
9
10
  ❌ Don't use Opus when Haiku would suffice
10
11
 
11
12
  ### API Usage
13
+
12
14
  ✅ Implement proper timeout handling
13
15
  ✅ Handle rate limiting gracefully
14
16
  ✅ Retry with exponential backoff on failures
@@ -17,6 +19,7 @@
17
19
  ✅ Calculate and monitor token usage
18
20
 
19
21
  ### Error Handling
22
+
20
23
  ```javascript
21
24
  // ✅ Good
22
25
  try {
@@ -39,6 +42,7 @@ try {
39
42
  ## Prompt Engineering
40
43
 
41
44
  ### Structure
45
+
42
46
  ✅ Clear role/context at the beginning
43
47
  ✅ Specific task instructions
44
48
  ✅ Well-defined output format (usually JSON)
@@ -46,6 +50,7 @@ try {
46
50
  ✅ Appropriate length (token-efficient)
47
51
 
48
52
  ### Quality Checklist
53
+
49
54
  ✅ Instructions are unambiguous
50
55
  ✅ Output format is machine-parseable
51
56
  ✅ Context is sufficient but not excessive
@@ -53,6 +58,7 @@ try {
53
58
  ✅ Placeholders are replaced correctly
54
59
 
55
60
  ### Common Prompt Issues
61
+
56
62
  ❌ Vague instructions
57
63
  ❌ No output format specification
58
64
  ❌ Too much unnecessary context
@@ -62,6 +68,7 @@ try {
62
68
  ## CLI User Experience
63
69
 
64
70
  ### Error Messages
71
+
65
72
  ✅ Clear, actionable error messages
66
73
  ✅ Suggest solutions when possible
67
74
  ✅ Use appropriate log levels
@@ -69,6 +76,7 @@ try {
69
76
  ✅ Include context (what was being attempted)
70
77
 
71
78
  ### User Feedback
79
+
72
80
  ✅ Show progress for long operations
73
81
  ✅ Confirm destructive operations
74
82
  ✅ Provide helpful usage information
@@ -78,6 +86,7 @@ try {
78
86
  ## Git Operations Safety
79
87
 
80
88
  ### Safe Practices
89
+
81
90
  ✅ Validate repository state before operations
82
91
  ✅ Use `--cached` for staged changes
83
92
  ✅ Handle special characters in filenames
@@ -85,6 +94,7 @@ try {
85
94
  ✅ Graceful handling of git errors
86
95
 
87
96
  ### Dangerous Operations
97
+
88
98
  ❌ Never run git commands that modify history without explicit user confirmation
89
99
  ❌ Avoid hard resets
90
100
  ❌ Be careful with force pushes
@@ -93,6 +103,7 @@ try {
93
103
  ## Security
94
104
 
95
105
  ### API Keys
106
+
96
107
  ✅ Load from environment variables
97
108
  ✅ Never log or display API keys
98
109
  ✅ Never commit API keys to repository
@@ -100,6 +111,7 @@ try {
100
111
  ✅ Clear keys from memory when done
101
112
 
102
113
  ### Command Injection
114
+
103
115
  ✅ Validate all user input
104
116
  ✅ Use parameterized commands when possible
105
117
  ✅ Escape special characters
@@ -107,14 +119,15 @@ try {
107
119
  ✅ Sanitize file paths
108
120
 
109
121
  ### Sensitive Data
122
+
110
123
  ✅ Don't send secrets to Claude API
111
124
  ✅ Filter sensitive data from diffs
112
125
  ✅ Be careful with error messages (don't expose internals)
113
- ✅ Implement SKIP_ANALYSIS for sensitive code
114
126
 
115
127
  ## Code Organization
116
128
 
117
129
  ### File Structure
130
+
118
131
  ```
119
132
  lib/
120
133
  hooks/ # Git hook implementations
@@ -129,6 +142,7 @@ bin/ # CLI entry points
129
142
  ```
130
143
 
131
144
  ### Module Design
145
+
132
146
  ✅ Single responsibility principle
133
147
  ✅ Clear, descriptive function names
134
148
  ✅ Comprehensive error handling
@@ -138,12 +152,14 @@ bin/ # CLI entry points
138
152
  ## Common Issues to Avoid
139
153
 
140
154
  ### Critical Issues
155
+
141
156
  ❌ Exposed API keys or secrets
142
157
  ❌ Command injection vulnerabilities
143
158
  ❌ Destructive git operations without confirmation
144
159
  ❌ Unhandled promise rejections
145
160
 
146
161
  ### Major Issues
162
+
147
163
  ❌ Missing error handling
148
164
  ❌ Poor user experience (unclear errors)
149
165
  ❌ Cross-platform incompatibility
@@ -151,6 +167,7 @@ bin/ # CLI entry points
151
167
  ❌ Missing input validation
152
168
 
153
169
  ### Minor Issues
170
+
154
171
  ❌ Insufficient logging
155
172
  ❌ Unclear variable names
156
173
  ❌ Missing documentation
@@ -1,12 +1,12 @@
1
- {
2
- "analysis": {
3
- "maxFileSize": 1000000,
4
- "maxFiles": 10,
5
- "timeout": 300000
6
- },
7
- "subagents": {
8
- "enabled": true,
9
- "model": "haiku",
10
- "batchSize": 3
11
- }
12
- }
1
+ {
2
+ "analysis": {
3
+ "maxFileSize": 1000000,
4
+ "maxFiles": 10,
5
+ "timeout": 300000
6
+ },
7
+ "subagents": {
8
+ "enabled": true,
9
+ "model": "haiku",
10
+ "batchSize": 3
11
+ }
12
+ }
@@ -1,42 +1,37 @@
1
- {
2
- "name": "ai",
3
- "displayName": "AI/CLI (Node.js + Claude)",
4
- "description": "Node.js CLI tools with Claude API integration",
5
- "version": "1.0.0",
6
-
7
- "techStack": [
8
- "Node.js",
9
- "ES Modules",
10
- "Claude API",
11
- "CLI tools",
12
- "Git hooks",
13
- "Bash scripting",
14
- "Markdown templates"
15
- ],
16
-
17
- "fileExtensions": [
18
- ".js",
19
- ".json",
20
- ".md",
21
- ".sh"
22
- ],
23
-
24
- "focusAreas": [
25
- "Claude API usage and best practices",
26
- "Prompt engineering quality",
27
- "CLI user experience",
28
- "Error handling and logging",
29
- "Git operations safety",
30
- "Cross-platform compatibility",
31
- "Token usage optimization",
32
- "Security (API keys, secrets)"
33
- ],
34
-
35
- "templates": {
36
- "analysis": "ANALYSIS_PROMPT.md",
37
- "guidelines": "PRE_COMMIT_GUIDELINES.md",
38
- "commitMessage": "../shared/COMMIT_MESSAGE.md",
39
- "analyzeDiff": "../shared/ANALYZE_DIFF.md",
40
- "resolution": "../shared/RESOLUTION_PROMPT.md"
41
- }
42
- }
1
+ {
2
+ "name": "ai",
3
+ "displayName": "AI/CLI (Node.js + Claude)",
4
+ "description": "Node.js CLI tools with Claude API integration",
5
+ "version": "1.0.0",
6
+
7
+ "techStack": [
8
+ "Node.js",
9
+ "ES Modules",
10
+ "Claude API",
11
+ "CLI tools",
12
+ "Git hooks",
13
+ "Bash scripting",
14
+ "Markdown templates"
15
+ ],
16
+
17
+ "fileExtensions": [".js", ".json", ".md", ".sh"],
18
+
19
+ "focusAreas": [
20
+ "Claude API usage and best practices",
21
+ "Prompt engineering quality",
22
+ "CLI user experience",
23
+ "Error handling and logging",
24
+ "Git operations safety",
25
+ "Cross-platform compatibility",
26
+ "Token usage optimization",
27
+ "Security (API keys, secrets)"
28
+ ],
29
+
30
+ "templates": {
31
+ "analysis": "ANALYSIS_PROMPT.md",
32
+ "guidelines": "PRE_COMMIT_GUIDELINES.md",
33
+ "commitMessage": "../shared/COMMIT_MESSAGE.md",
34
+ "analyzeDiff": "../shared/ANALYZE_DIFF.md",
35
+ "resolution": "../shared/RESOLUTION_PROMPT.md"
36
+ }
37
+ }
@@ -13,32 +13,35 @@ Perform a comprehensive code quality analysis focusing on these areas:
13
13
  ## Analysis Guidelines
14
14
 
15
15
  1. **Security First**: Check for OWASP Top 10 vulnerabilities, especially:
16
- - SQL injection risks
17
- - Authentication/authorization flaws
18
- - Sensitive data exposure
19
- - XML external entities (XXE)
20
- - Insecure deserialization
16
+ - SQL injection risks
17
+ - Authentication/authorization flaws
18
+ - Sensitive data exposure
19
+ - XML external entities (XXE)
20
+ - Insecure deserialization
21
21
 
22
22
  2. **Spring Boot Best Practices**:
23
- - Proper use of `@Transactional`
24
- - Correct exception handling
25
- - Appropriate use of DTOs vs Entities
26
- - Proper dependency injection
27
- - Configuration management
23
+ - Proper use of `@Transactional`
24
+ - Correct exception handling
25
+ - Appropriate use of DTOs vs Entities
26
+ - Proper dependency injection // Si intelligence -> recomendar @RequiredArgsConstructor || Si Automation -> recomendar @Autowired
27
+ - Configuration management
28
28
 
29
29
  3. **JPA/Hibernate**:
30
- - N+1 query problems
31
- - Lazy loading issues
32
- - Proper use of relationships
33
- - Query optimization
34
- - Transaction boundaries
30
+ - N+1 query problems
31
+ - Lazy loading issues
32
+ - Proper use of relationships
33
+ - Query optimization
34
+ - Transaction boundaries
35
35
 
36
36
  4. **Code Quality**:
37
- - SOLID principles
38
- - DRY violations
39
- - Proper error handling
40
- - Logging best practices
41
- - Test coverage
37
+ - SOLID principles
38
+ - DRY violations
39
+ - Proper error handling
40
+ - Logging should be like so
41
+ - debug: regular flow, operations details
42
+ - info: important business events
43
+ - warn: anomalies and manageable errors
44
+ - error: exceptions and errors
42
45
 
43
46
  ## Output Format
44
47
 
@@ -48,14 +51,6 @@ Respond with a valid JSON following the SonarQube format:
48
51
  {
49
52
  "QUALITY_GATE": "PASSED|FAILED",
50
53
  "approved": true|false,
51
- "metrics": {
52
- "reliability": "A|B|C|D|E",
53
- "security": "A|B|C|D|E",
54
- "maintainability": "A|B|C|D|E",
55
- "coverage": 0-100,
56
- "duplications": 0-100,
57
- "complexity": "number"
58
- },
59
54
  "issues": {
60
55
  "blocker": 0,
61
56
  "critical": 0,
@@ -3,45 +3,63 @@
3
3
  ## Spring Boot Standards
4
4
 
5
5
  ### Controllers
6
- - Use proper HTTP methods and status codes
6
+
7
+ - Use proper HTTP methods
8
+ - Endpoints should handle entities as substantives
9
+ - Make sure Response Codes include: [200, 201, 204, 400, 401, 403, 404, 409, 422, 500, 503] (if non-compliant classify as BLOCKER)
7
10
  - Validate input with `@Valid`
8
11
  - Handle exceptions with `@ExceptionHandler`
9
12
  - Keep controllers thin - business logic in services
10
13
  - Use DTOs for API contracts
11
14
 
12
15
  ### Services
16
+
13
17
  - Use `@Transactional` appropriately
14
18
  - Handle exceptions properly
15
19
  - Keep methods focused and small
16
20
  - Avoid business logic in controllers or repositories
17
21
 
18
22
  ### Repositories
23
+
19
24
  - Extend appropriate Spring Data interfaces
20
25
  - Use method naming conventions for queries
21
26
  - Optimize queries with `@Query` when needed
22
27
  - Avoid N+1 problems with `@EntityGraph`
23
28
 
24
29
  ### Entities
30
+
25
31
  - Use Lombok annotations appropriately
26
32
  - Define proper relationships (`@OneToMany`, `@ManyToOne`, etc.)
27
33
  - Use `@Version` for optimistic locking
28
34
  - Never expose entities in API - use DTOs
29
35
 
36
+ ### Mappers
37
+
38
+ - Use Mapstruct for all mapping (If non-compliant, classify as MINOR)
39
+ - Mappers should not have logic (If non-compliant, classify as MAJOR)
40
+
41
+ ### Logging
42
+
43
+ - Recommend @Slf4j annotation in Lombok (If non-compliant, classify as MINOR)
44
+
30
45
  ## Security Requirements
31
46
 
32
47
  ### Authentication & Authorization
48
+
33
49
  - Never hardcode credentials
34
50
  - Use Spring Security properly
35
51
  - Validate JWT tokens correctly
36
52
  - Check permissions before operations
37
53
 
38
54
  ### Data Validation
55
+
39
56
  - Validate all user input
40
57
  - Use parameterized queries (JPA does this by default)
41
58
  - Sanitize data before logging
42
59
  - Never trust client-side validation alone
43
60
 
44
61
  ### SQL Injection Prevention
62
+
45
63
  - Always use JPA/JPQL or prepared statements
46
64
  - Never concatenate SQL strings
47
65
  - Be careful with native queries
@@ -50,35 +68,55 @@
50
68
  ## Performance
51
69
 
52
70
  ### Database
71
+
53
72
  - Use pagination for large result sets
54
73
  - Optimize queries with proper indexes
55
74
  - Avoid loading unnecessary data
56
75
  - Use projections when you don't need full entities
57
76
 
58
77
  ### Threading
78
+
59
79
  - Be careful with `@Async` methods
60
80
  - Use proper thread pool configuration
61
81
  - Avoid blocking operations in async methods
62
82
  - Handle exceptions in async methods
63
83
 
64
84
  ### Caching
85
+
65
86
  - Use `@Cacheable` appropriately
66
87
  - Clear caches when data changes
67
88
  - Don't cache sensitive data without encryption
68
89
 
69
90
  ## Testing
70
91
 
71
- - Write unit tests for business logic
92
+ ### Unit Tests
93
+
94
+ - Unit tests should use exclusively JUnit 5, and specific annotations @SpringBootTest, @MockBean, @Test
72
95
  - Use `@DataJpaTest` for repository tests
73
96
  - Use `@WebMvcTest` for controller tests
74
97
  - Mock external dependencies
75
98
  - Aim for 80%+ coverage on new code
76
99
 
100
+ ### Integration Tests
101
+
102
+ - Use `@SpringBootTest` with real application context
103
+ - Test complete request-response flows
104
+ - Verify database transactions and rollbacks
105
+ - Test API endpoint integration with all layers
106
+ - Use `@Transactional` with `@Rollback` for test data cleanup
107
+
108
+ ### Security Tests
109
+
110
+ - Test authentication and authorization scenarios
111
+ - Verify access control for protected endpoints
112
+ - Test with invalid/expired tokens
113
+ - Validate input sanitization and XSS prevention
114
+ - Test SQL injection prevention with malicious input
115
+
77
116
  ## Common Issues to Avoid
78
117
 
79
118
  ❌ Returning entities from controllers
80
119
  ❌ Missing `@Transactional` on write operations
81
- ❌ N+1 query problems
82
120
  ❌ Hardcoded secrets or credentials
83
121
  ❌ Catching and ignoring exceptions
84
122
  ❌ Missing input validation
@@ -1,12 +1,12 @@
1
- {
2
- "analysis": {
3
- "maxFileSize": 1000000,
4
- "maxFiles": 10,
5
- "timeout": 300000
6
- },
7
- "subagents": {
8
- "enabled": true,
9
- "model": "haiku",
10
- "batchSize": 3
11
- }
12
- }
1
+ {
2
+ "analysis": {
3
+ "maxFileSize": 1000000,
4
+ "maxFiles": 10,
5
+ "timeout": 300000
6
+ },
7
+ "subagents": {
8
+ "enabled": true,
9
+ "model": "haiku",
10
+ "batchSize": 3
11
+ }
12
+ }
@@ -1,12 +1,12 @@
1
- {
2
- "analysis": {
3
- "maxFileSize": 1000000,
4
- "maxFiles": 8,
5
- "timeout": 300000
6
- },
7
- "subagents": {
8
- "enabled": true,
9
- "model": "haiku",
10
- "batchSize": 2
11
- }
12
- }
1
+ {
2
+ "analysis": {
3
+ "maxFileSize": 1000000,
4
+ "maxFiles": 8,
5
+ "timeout": 300000
6
+ },
7
+ "subagents": {
8
+ "enabled": true,
9
+ "model": "haiku",
10
+ "batchSize": 2
11
+ }
12
+ }
@@ -1,12 +1,12 @@
1
- {
2
- "analysis": {
3
- "maxFileSize": 1000000,
4
- "maxFiles": 10,
5
- "timeout": 300000
6
- },
7
- "subagents": {
8
- "enabled": true,
9
- "model": "haiku",
10
- "batchSize": 3
11
- }
12
- }
1
+ {
2
+ "analysis": {
3
+ "maxFileSize": 1000000,
4
+ "maxFiles": 10,
5
+ "timeout": 300000
6
+ },
7
+ "subagents": {
8
+ "enabled": true,
9
+ "model": "haiku",
10
+ "batchSize": 3
11
+ }
12
+ }
@@ -1,12 +1,12 @@
1
- {
2
- "analysis": {
3
- "maxFileSize": 1000000,
4
- "maxFiles": 10,
5
- "timeout": 300000
6
- },
7
- "subagents": {
8
- "enabled": true,
9
- "model": "haiku",
10
- "batchSize": 3
11
- }
12
- }
1
+ {
2
+ "analysis": {
3
+ "maxFileSize": 1000000,
4
+ "maxFiles": 10,
5
+ "timeout": 300000
6
+ },
7
+ "subagents": {
8
+ "enabled": true,
9
+ "model": "haiku",
10
+ "batchSize": 3
11
+ }
12
+ }