UNPKG

claude-git-hooks

Version:

Git hooks with Claude CLI for code analysis and automatic commit messages

134 lines (110 loc) 3.5 kB
You are analyzing a **{{PRESET_NAME}}** project with the following technology stack: **Tech Stack:** {{TECH_STACK}} **Analyzing files matching:** {{FILE_EXTENSIONS}} ## Your Task Perform a comprehensive code quality analysis focusing on these areas: {{FOCUS_AREAS}} ## Analysis Guidelines 1. **Claude API Best Practices**: - Proper use of Claude API endpoints - Correct model selection (haiku/sonnet/opus) - Token usage optimization - Error handling for API failures - Rate limiting considerations - Timeout handling 2. **Prompt Engineering**: - Clear and specific instructions - Well-structured prompts - Appropriate context inclusion - Effective use of examples - Proper output format specifications - Token-efficient prompting 3. **CLI User Experience**: - Clear, helpful error messages - Appropriate use of colors/formatting - Progress indicators for long operations - Helpful usage instructions - Graceful error recovery - Cross-platform compatibility 4. **Git Operations**: - Safe git command execution - Proper error handling - Repository state validation - Avoiding destructive operations - Cross-platform path handling 5. **Security**: - API key protection (never log/expose) - Secure credential storage - Input validation - Avoiding command injection - Sensitive data handling in prompts 6. **Code Quality**: - Proper error handling - Comprehensive logging - Modular, reusable functions - Clear documentation - Maintainable code structure ## Specific Checks ### Claude API Usage ✅ Using appropriate model for task (haiku for simple, sonnet for complex) ✅ Implementing proper error handling (network, API, rate limit) ✅ Token usage calculated and optimized ✅ Prompts are well-structured and clear ✅ Output parsing is robust ✅ API keys never logged or exposed ### Git Operations ✅ Using proper git commands ✅ Handling errors gracefully ✅ Cross-platform path compatibility ✅ Avoiding destructive operations without confirmation ✅ Proper handling of special characters in filenames ### Template Quality ✅ Clear instructions for Claude ✅ Well-defined output format ✅ Appropriate context provided ✅ Token-efficient design ✅ Placeholders used correctly ## Output Format Respond with a valid JSON following the structured JSON format: ```json { "QUALITY_GATE": "PASSED|FAILED", "approved": true|false, "metrics": { "reliability": "A|B|C|D|E", "security": "A|B|C|D|E", "maintainability": "A|B|C|D|E", "coverage": 0-100, "duplications": 0-100, "complexity": "number" }, "issues": { "blocker": 0, "critical": 0, "major": 0, "minor": 0, "info": 0 }, "details": [ { "severity": "BLOCKER|CRITICAL|MAJOR|MINOR|INFO", "type": "BUG|VULNERABILITY|CODE_SMELL|PROMPT_QUALITY", "file": "path/to/file", "line": 123, "message": "Clear description of the issue" } ], "securityHotspots": 0, "blockingIssues": ["List of critical issues that must be fixed"] } ``` ## Analysis Rules - **Block commit** if: - Exposed API keys or secrets - Security vulnerabilities - Critical bugs in git operations - Destructive operations without safeguards - **Pass** if: Only minor issues, suggestions, or no issues - Be constructive about prompt quality - suggest improvements - Focus on safety and user experience - Provide actionable, specific feedback with line numbers