quicknotes/.cursor/rules/conventional_commits.mdc

70 lines
No EOL
2.1 KiB
Text

---
description: Automatically commit changes made by CursorAI using conventional commits format
globs: **/*
---
<rule>
filters:
- type: event
pattern: "build_success"
- type: file_change
pattern: "*"
actions:
- type: execute
command: |
# Extract the change type and scope from the changes
CHANGE_TYPE=""
case "$CHANGE_DESCRIPTION" in
*"add"*|*"create"*|*"implement"*) CHANGE_TYPE="feat";;
*"fix"*|*"correct"*|*"resolve"*) CHANGE_TYPE="fix";;
*"refactor"*|*"restructure"*) CHANGE_TYPE="refactor";;
*"test"*) CHANGE_TYPE="test";;
*"doc"*|*"comment"*) CHANGE_TYPE="docs";;
*"style"*|*"format"*) CHANGE_TYPE="style";;
*"perf"*|*"optimize"*) CHANGE_TYPE="perf";;
*) CHANGE_TYPE="chore";;
esac
# Extract scope from file path
SCOPE=$(dirname "$FILE" | tr '/' '-')
# Commit the changes
git add "$FILE"
git commit -m "$CHANGE_TYPE($SCOPE): $CHANGE_DESCRIPTION"
- type: suggest
message: |
Changes should be committed using conventional commits format:
Format: <type>(<scope>): <description>
Types:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests or correcting existing tests
- chore: Changes to the build process or auxiliary tools
The scope should be derived from the file path or affected component.
The description should be clear and concise, written in imperative mood.
examples:
- input: |
# After adding a new function
CHANGE_DESCRIPTION="add user authentication function"
FILE="src/auth/login.ts"
output: "feat(src-auth): add user authentication function"
- input: |
# After fixing a bug
CHANGE_DESCRIPTION="fix incorrect date parsing"
FILE="lib/utils/date.js"
output: "fix(lib-utils): fix incorrect date parsing"
metadata:
priority: high
version: 1.0
</rule>