Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:21:45 +08:00
commit f7e8a33d24
14 changed files with 665 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
{
"name": "ai-commit-gen",
"description": "AI-powered commit message generator - analyzes your git diff and creates conventional commit messages instantly",
"version": "1.0.0",
"author": {
"name": "Jeremy Longshore",
"email": "[email protected]"
},
"skills": [
"./skills"
],
"commands": [
"./commands"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# ai-commit-gen
AI-powered commit message generator - analyzes your git diff and creates conventional commit messages instantly

242
commands/commit.md Normal file
View File

@@ -0,0 +1,242 @@
---
name: commit
description: Generate an AI-powered conventional commit message from your git diff and commit changes
model: claude-sonnet-4-5-20250929
---
You are an expert at analyzing code changes and writing clear, conventional commit messages.
# Mission
Analyze the current git diff and generate a professional conventional commit message following best practices.
# Process
## 1. Check Git Status
```bash
git status
```
If there are no changes staged or unstaged, inform the user:
```
No changes to commit. Stage your changes with:
git add <files>
```
## 2. Analyze Changes
Get both staged and unstaged changes:
```bash
git diff HEAD
```
If there are only staged changes:
```bash
git diff --cached
```
## 3. Analyze the Diff
Look for:
- **Type of change**: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- **Scope**: Which part of the codebase (optional but recommended)
- **Breaking changes**: API changes, removed features
- **Impact**: How significant are the changes
### Type Guidelines
- `feat`: New feature or functionality
- `fix`: Bug fix
- `docs`: Documentation only
- `style`: Code style/formatting (no logic change)
- `refactor`: Code restructuring (no behavior change)
- `perf`: Performance improvement
- `test`: Adding/updating tests
- `build`: Build system changes
- `ci`: CI/CD changes
- `chore`: Maintenance tasks
## 4. Generate Commit Message
Format:
```
<type>(<scope>): <subject>
<body>
<footer>
```
**Subject** (required):
- Imperative mood: "add feature" not "added feature"
- No period at end
- 50 characters or less
- Lowercase after type
**Body** (optional but recommended):
- Explain what and why, not how
- Wrap at 72 characters
- Separate from subject with blank line
**Footer** (if applicable):
- Breaking changes: `BREAKING CHANGE: description`
- Issue references: `Closes #123`, `Fixes #456`
## 5. Present Options
Show the user 3 commit message options:
**Option 1: Concise** (subject only)
```
feat(api): add user authentication endpoint
```
**Option 2: Detailed** (with body)
```
feat(api): add user authentication endpoint
Implement JWT-based authentication with email/password login.
Includes password hashing with bcrypt and token refresh logic.
```
**Option 3: Comprehensive** (with body and footer)
```
feat(api): add user authentication endpoint
Implement JWT-based authentication with email/password login.
Includes password hashing with bcrypt and token refresh logic.
Closes #42
```
## 6. Confirm and Commit
Ask the user which option they prefer (1, 2, or 3), or if they want to customize.
Once confirmed, commit with:
```bash
git commit -m "<commit message>"
```
If the commit includes multiple files across different areas, consider suggesting to split into multiple commits.
# Examples
## Example 1: Bug Fix
**Diff**: Fix null pointer in user service
```
fix(auth): handle null user in validation
Previously crashed when user was null. Now returns proper
error message and 401 status code.
Fixes #89
```
## Example 2: New Feature
**Diff**: Added dashboard charts
```
feat(dashboard): add analytics charts
Implement revenue and user growth charts using Chart.js.
Includes real-time updates via WebSocket connection.
```
## Example 3: Documentation
**Diff**: Updated README
```
docs(readme): add installation instructions
Include step-by-step setup guide with prerequisites
and troubleshooting section.
```
## Example 4: Breaking Change
**Diff**: Changed API response format
```
feat(api): standardize response format
Wrap all responses in {data, error, metadata} structure
for consistency across endpoints.
BREAKING CHANGE: All API responses now use new format.
Update clients to access data via response.data field.
```
# Best Practices
1. **Be specific**: "add user auth" not just "add feature"
2. **Use imperative mood**: "fix bug" not "fixed bug"
3. **Keep subject short**: Under 50 chars
4. **Explain why**: In the body, explain reasoning
5. **Reference issues**: Link to issue tracker
6. **Note breaking changes**: Always document in footer
# Quick Mode
If user provides custom message with the command:
`/commit "fix: resolve login bug"`
Skip analysis and commit directly with their message.
# Advanced Features
**Amend last commit** (if requested):
```bash
git commit --amend -m "<new message>"
```
**Sign commit** (if GPG configured):
```bash
git commit -S -m "<message>"
```
**Empty commit** (for CI triggers):
```bash
git commit --allow-empty -m "<message>"
```
# Error Handling
If commit fails:
- Check for pre-commit hooks blocking commit
- Verify files are staged
- Check for merge conflicts
- Ensure commit message format is valid
# Output Format
```
🔍 Analyzing changes...
Found changes in:
- src/auth/user.service.ts
- tests/auth.test.ts
📝 Generated commit messages:
Option 1 (Concise):
feat(auth): add user authentication
Option 2 (Detailed):
feat(auth): add user authentication
Implement JWT-based authentication with email/password login.
Includes password hashing and token refresh logic.
Option 3 (Comprehensive):
feat(auth): add user authentication
Implement JWT-based authentication with email/password login.
Includes password hashing and token refresh logic.
Closes #42
Which option? (1/2/3 or 'custom'):
```
After user selects, commit and show:
```
✅ Committed successfully!
Commit: abc1234
Message: feat(auth): add user authentication
```

85
plugin.lock.json Normal file
View File

@@ -0,0 +1,85 @@
{
"$schema": "internal://schemas/plugin.lock.v1.json",
"pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/productivity/ai-commit-gen",
"normalized": {
"repo": null,
"ref": "refs/tags/v20251128.0",
"commit": "353fe713b2300c79ac9f6cbbf2444356f65f449e",
"treeHash": "ab4d55e8430824149b905a6af3f255d3b1023d808513beddcc3f9cedb02575ce",
"generatedAt": "2025-11-28T10:18:03.130434Z",
"toolVersion": "publish_plugins.py@0.2.0"
},
"origin": {
"remote": "git@github.com:zhongweili/42plugin-data.git",
"branch": "master",
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
},
"manifest": {
"name": "ai-commit-gen",
"description": "AI-powered commit message generator - analyzes your git diff and creates conventional commit messages instantly",
"version": "1.0.0"
},
"content": {
"files": [
{
"path": "README.md",
"sha256": "5174859111cd077df9dbce01e32f5d97b162cd4efa5779d8455a09193c437bd5"
},
{
"path": ".claude-plugin/plugin.json",
"sha256": "5d722af4a35795f5c44d7e170f63de76b6561915ecaeae311d58cb1f7801d660"
},
{
"path": "commands/commit.md",
"sha256": "a3966520b4471c06c7dfa460dee4df104cc08050e6a165df02c24dc907b1bfa9"
},
{
"path": "skills/skill-adapter/references/examples.md",
"sha256": "922bbc3c4ebf38b76f515b5c1998ebde6bf902233e00e2c5a0e9176f975a7572"
},
{
"path": "skills/skill-adapter/references/best-practices.md",
"sha256": "c8f32b3566252f50daacd346d7045a1060c718ef5cfb07c55a0f2dec5f1fb39e"
},
{
"path": "skills/skill-adapter/references/README.md",
"sha256": "f744505cdc04ad6211a434a730fe4a224dbacf489ba165933d0a817cec788bf1"
},
{
"path": "skills/skill-adapter/scripts/helper-template.sh",
"sha256": "0881d5660a8a7045550d09ae0acc15642c24b70de6f08808120f47f86ccdf077"
},
{
"path": "skills/skill-adapter/scripts/validation.sh",
"sha256": "92551a29a7f512d2036e4f1fb46c2a3dc6bff0f7dde4a9f699533e446db48502"
},
{
"path": "skills/skill-adapter/scripts/README.md",
"sha256": "af3fe277aaf0a4edce7c6845664d9ce27614d38599db002e3b39de31c14ade3e"
},
{
"path": "skills/skill-adapter/assets/test-data.json",
"sha256": "ac17dca3d6e253a5f39f2a2f1b388e5146043756b05d9ce7ac53a0042eee139d"
},
{
"path": "skills/skill-adapter/assets/README.md",
"sha256": "6e919c3f4674a5bd7d36ae0c27dda0f0beb417cbbd8aba6930b52575eeef1104"
},
{
"path": "skills/skill-adapter/assets/skill-schema.json",
"sha256": "f5639ba823a24c9ac4fb21444c0717b7aefde1a4993682897f5bf544f863c2cd"
},
{
"path": "skills/skill-adapter/assets/config-template.json",
"sha256": "0c2ba33d2d3c5ccb266c0848fc43caa68a2aa6a80ff315d4b378352711f83e1c"
}
],
"dirSha256": "ab4d55e8430824149b905a6af3f255d3b1023d808513beddcc3f9cedb02575ce"
},
"security": {
"scannedAt": null,
"scannerVersion": null,
"flags": []
}
}

View File

@@ -0,0 +1,6 @@
# Assets
Bundled resources for ai-commit-gen skill
- [ ] commit_message_template.txt: A template for generating commit messages.
- [ ] example_diff.txt: An example git diff file for testing and demonstration purposes.

View File

@@ -0,0 +1,32 @@
{
"skill": {
"name": "skill-name",
"version": "1.0.0",
"enabled": true,
"settings": {
"verbose": false,
"autoActivate": true,
"toolRestrictions": true
}
},
"triggers": {
"keywords": [
"example-trigger-1",
"example-trigger-2"
],
"patterns": []
},
"tools": {
"allowed": [
"Read",
"Grep",
"Bash"
],
"restricted": []
},
"metadata": {
"author": "Plugin Author",
"category": "general",
"tags": []
}
}

View File

@@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Claude Skill Configuration",
"type": "object",
"required": ["name", "description"],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z0-9-]+$",
"maxLength": 64,
"description": "Skill identifier (lowercase, hyphens only)"
},
"description": {
"type": "string",
"maxLength": 1024,
"description": "What the skill does and when to use it"
},
"allowed-tools": {
"type": "string",
"description": "Comma-separated list of allowed tools"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+$",
"description": "Semantic version (x.y.z)"
}
}
}

View File

@@ -0,0 +1,27 @@
{
"testCases": [
{
"name": "Basic activation test",
"input": "trigger phrase example",
"expected": {
"activated": true,
"toolsUsed": ["Read", "Grep"],
"success": true
}
},
{
"name": "Complex workflow test",
"input": "multi-step trigger example",
"expected": {
"activated": true,
"steps": 3,
"toolsUsed": ["Read", "Write", "Bash"],
"success": true
}
}
],
"fixtures": {
"sampleInput": "example data",
"expectedOutput": "processed result"
}
}

View File

@@ -0,0 +1,7 @@
# References
Bundled resources for ai-commit-gen skill
- [ ] conventional_commits_standard.md: A markdown file containing the full Conventional Commits standard.
- [ ] git_diff_analysis_guide.md: A guide on how to effectively analyze git diffs for commit message generation.
- [ ] commit_message_examples.md: A collection of example commit messages following the Conventional Commits standard.

View File

@@ -0,0 +1,69 @@
# Skill Best Practices
Guidelines for optimal skill usage and development.
## For Users
### Activation Best Practices
1. **Use Clear Trigger Phrases**
- Match phrases from skill description
- Be specific about intent
- Provide necessary context
2. **Provide Sufficient Context**
- Include relevant file paths
- Specify scope of analysis
- Mention any constraints
3. **Understand Tool Permissions**
- Check allowed-tools in frontmatter
- Know what the skill can/cannot do
- Request appropriate actions
### Workflow Optimization
- Start with simple requests
- Build up to complex workflows
- Verify each step before proceeding
- Use skill consistently for related tasks
## For Developers
### Skill Development Guidelines
1. **Clear Descriptions**
- Include explicit trigger phrases
- Document all capabilities
- Specify limitations
2. **Proper Tool Permissions**
- Use minimal necessary tools
- Document security implications
- Test with restricted tools
3. **Comprehensive Documentation**
- Provide usage examples
- Document common pitfalls
- Include troubleshooting guide
### Maintenance
- Keep version updated
- Test after tool updates
- Monitor user feedback
- Iterate on descriptions
## Performance Tips
- Scope skills to specific domains
- Avoid overlapping trigger phrases
- Keep descriptions under 1024 chars
- Test activation reliability
## Security Considerations
- Never include secrets in skill files
- Validate all inputs
- Use read-only tools when possible
- Document security requirements

View File

@@ -0,0 +1,70 @@
# Skill Usage Examples
This document provides practical examples of how to use this skill effectively.
## Basic Usage
### Example 1: Simple Activation
**User Request:**
```
[Describe trigger phrase here]
```
**Skill Response:**
1. Analyzes the request
2. Performs the required action
3. Returns results
### Example 2: Complex Workflow
**User Request:**
```
[Describe complex scenario]
```
**Workflow:**
1. Step 1: Initial analysis
2. Step 2: Data processing
3. Step 3: Result generation
4. Step 4: Validation
## Advanced Patterns
### Pattern 1: Chaining Operations
Combine this skill with other tools:
```
Step 1: Use this skill for [purpose]
Step 2: Chain with [other tool]
Step 3: Finalize with [action]
```
### Pattern 2: Error Handling
If issues occur:
- Check trigger phrase matches
- Verify context is available
- Review allowed-tools permissions
## Tips & Best Practices
- ✅ Be specific with trigger phrases
- ✅ Provide necessary context
- ✅ Check tool permissions match needs
- ❌ Avoid vague requests
- ❌ Don't mix unrelated tasks
## Common Issues
**Issue:** Skill doesn't activate
**Solution:** Use exact trigger phrases from description
**Issue:** Unexpected results
**Solution:** Check input format and context
## See Also
- Main SKILL.md for full documentation
- scripts/ for automation helpers
- assets/ for configuration examples

View File

@@ -0,0 +1,7 @@
# Scripts
Bundled resources for ai-commit-gen skill
- [ ] analyze_diff.py: Analyzes the git diff and extracts relevant information for commit message generation.
- [ ] commit_message_generator.py: Generates commit message options based on the analyzed diff.
- [ ] validate_commit_message.py: Validates the generated commit message against the Conventional Commits standard.

View File

@@ -0,0 +1,42 @@
#!/bin/bash
# Helper script template for skill automation
# Customize this for your skill's specific needs
set -e
function show_usage() {
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " -h, --help Show this help message"
echo " -v, --verbose Enable verbose output"
echo ""
}
# Parse arguments
VERBOSE=false
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_usage
exit 0
;;
-v|--verbose)
VERBOSE=true
shift
;;
*)
echo "Unknown option: $1"
show_usage
exit 1
;;
esac
done
# Your skill logic here
if [ "$VERBOSE" = true ]; then
echo "Running skill automation..."
fi
echo "✅ Complete"

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# Skill validation helper
# Validates skill activation and functionality
set -e
echo "🔍 Validating skill..."
# Check if SKILL.md exists
if [ ! -f "../SKILL.md" ]; then
echo "❌ Error: SKILL.md not found"
exit 1
fi
# Validate frontmatter
if ! grep -q "^---$" "../SKILL.md"; then
echo "❌ Error: No frontmatter found"
exit 1
fi
# Check required fields
if ! grep -q "^name:" "../SKILL.md"; then
echo "❌ Error: Missing 'name' field"
exit 1
fi
if ! grep -q "^description:" "../SKILL.md"; then
echo "❌ Error: Missing 'description' field"
exit 1
fi
echo "✅ Skill validation passed"