-
Notifications
You must be signed in to change notification settings - Fork 10
Add commit skill for quality-gated commits #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,164 @@ | ||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||
| name: commit | ||||||||||||||||||||||||
| description: Use this skill when the user wants to commit staged changes. This skill checks linting, then formatting (matching CI order), runs tests, generates a commit message, and commits the changes. Invoke when the user says things like "commit my changes", "commit this", "create a commit", or "/commit". | ||||||||||||||||||||||||
| allowed-tools: Bash, Read, Grep, Glob, Edit | ||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Commit Skill | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| You are a commit assistant that ensures code quality before committing changes. Follow these steps in order, stopping if any step fails. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Step 1: Check for Staged Changes | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| First, verify there are staged changes to commit: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| git diff --cached --stat | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| If there are no staged changes, inform the user and stop. Suggest they stage changes with `git add`. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Step 2: Check Linting | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Run the linting check first (matches CI order in .github/workflows/ci.yml): | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| uv run --frozen ruff check . | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### If linting check fails: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 1. Inform the user about the linting errors | ||||||||||||||||||||||||
| 2. Ask if they want you to auto-fix what can be auto-fixed | ||||||||||||||||||||||||
| 3. If yes, run: `uv run --frozen ruff check . --fix` | ||||||||||||||||||||||||
| 4. If there are remaining errors that cannot be auto-fixed: | ||||||||||||||||||||||||
| - Show the errors clearly to the user | ||||||||||||||||||||||||
| - STOP the commit process | ||||||||||||||||||||||||
| - Explain what needs to be manually fixed | ||||||||||||||||||||||||
| 5. If all errors were auto-fixed: | ||||||||||||||||||||||||
| - Stage the fixes by running `git add` only on the files that were fixed | ||||||||||||||||||||||||
|
Comment on lines
+33
to
+39
|
||||||||||||||||||||||||
| 3. If yes, run: `uv run --frozen ruff check . --fix` | |
| 4. If there are remaining errors that cannot be auto-fixed: | |
| - Show the errors clearly to the user | |
| - STOP the commit process | |
| - Explain what needs to be manually fixed | |
| 5. If all errors were auto-fixed: | |
| - Stage the fixes by running `git add` only on the files that were fixed | |
| 3. If yes, and you may have other modified files in the working tree, first capture the current set of changed files: | |
| ```bash | |
| git diff --name-only | sort > /tmp/before_ruff.txt |
Then run the auto-fix:
uv run --frozen ruff check . --fixAfter the fix, capture the new set of changed files and compute exactly which files were modified by Ruff:
git diff --name-only | sort > /tmp/after_ruff.txt
comm -13 /tmp/before_ruff.txt /tmp/after_ruff.txt > /tmp/ruff_fixed.txt- If there are remaining errors that cannot be auto-fixed:
- Show the errors clearly to the user
- STOP the commit process
- Explain what needs to be manually fixed
- If all errors were auto-fixed:
-
Stage only the files modified by Ruff:
git add $(cat /tmp/ruff_fixed.txt)
-
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When re-running lint after auto-fixes, the skill again omits --preview even though CI includes it. To keep the “re-verify after auto-fixes” step faithful to CI (and avoid CI-only failures), update this re-run command to match the CI invocation as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI runs
uv run --frozen ruff check . --preview(see.github/workflows/ci.yml). This skill usesruff check .without--preview, so it may report a clean lint locally but fail CI if preview-only rules are enabled/changed. Align the command here (and the--fixvariant) with CI by including--preview(or explicitly justify why it’s omitted).