commit
Generate a concise commit message for staged changes and commit
-
First verify there are staged changes with
git diff --cached --stat -
If no staged changes, give the option to stage all changes. If I chose to stage all the git modified files, run
git add -Aand continue. If not, stop. -
Run linters on staged files before committing:
- Detect which linters are available and relevant to the project:
- If
Cargo.tomlexists: runcargo clippy --all-targets -- -D warningsandcargo fmt --check - If
package.jsonexists and has alintscript: runyarn lintornpm run lint - If
pyproject.tomlorsetup.pyexists: runruff check .if ruff is installed, otherwise tryflake8 - If
.clang-formatexists: runclang-format --dry-run --Werroron staged C/C++ files - If a
Makefilehas alinttarget: runmake lint - If
.pre-commit-config.yamlexists: runpre-commit run --fileson staged files
- If
- Only run linters that are installed on the system (check with
which) - If any linter reports errors, show them and ask whether to fix them before continuing or proceed anyway
- Detect which linters are available and relevant to the project:
-
Check if new branch is needed:
- Get current branch:
git branch --show-current - If already on a feature/bug branch (not main/master/dev/develop), skip to step 5
- If on main/master/dev/develop, ask: "Would you like to create a new branch for this work?"
- Use AskUserQuestion with options:
- "Yes, create a feature branch"
- "Yes, create a bug fix branch"
- "No, commit to current branch"
- Use AskUserQuestion with options:
- Get current branch:
-
Create new branch (if requested):
- Use the
branch-nameskill to create a branch with proper naming conventions
- Use the
-
Analyze changes and create commit:
- Use the
commit-msgskill to generate commit message options and create the commit
- Use the
-
Run CodeRabbit review (if available):
- Check if
cris installed:which cr - If installed, check auth status:
cr auth status 2>&1 - If authenticated, run
crto review the commit - Show the review output to the user
- If
cris not installed or not authenticated, skip silently
- Check if
-
Ask the user if they want to push the commit
-
Show the result of the commit and push
-
Create GitHub PR:
- Use the
gh-prcommand to create a PR with labels and reviewer assignment