claude: add slash command skill to lint commits in a PR#30162
Conversation
Add a /lint-pr slash command that checks pull request commits against project standards. It can be run with no arguments to lint the current branch against upstream/dev, or with a PR number to lint a remote PR. Checks implemented: - M1: subject line length (72 chars, 90 with long identifiers) - M2: body line wrapping (72 chars, exempt code blocks/URLs) - M3: blank line after subject - M4: subject format (area[/detail]: lowercase description) - M5: commit message adequately explains the change - M6: bug fix commits explain bug, fix, and rationale - M7: commit atomicity (one logical change per commit) - M8: commit message accuracy (message matches the diff) Signed-off-by: Noah Watkins <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds a new Claude skill (/lint-pr) that lints pull request commits against the repo’s commit message standards and (for some checks) commit diffs, supporting both local-branch and remote-PR workflows.
Changes:
- Introduces
.claude/skills/lint-pr/SKILL.mddefining the/lint-prskill and its execution steps. - Specifies commit message checks M1–M8, including formatting, adequacy, bug-fix explanation, atomicity, and message/diff consistency.
- Defines an expected output/report format for per-commit results and summary.
andrwng
left a comment
There was a problem hiding this comment.
I'm wondering if these can/should also be ported so that agents know to write commit messages according to these rules without having to lint first to catch its own mistakes
| the subject) is optional. If present, every line in the body must be at | ||
| most 72 characters, with the following exceptions: | ||
|
|
||
| **Fenced code blocks:** Lines between a pair of `` ``` `` markers |
There was a problem hiding this comment.
Maybe it falls in this category, but copy-pasted log lines too
| - Backtick-quoted area: same as above but wrapped in backticks | ||
| (e.g. `` `kafka` ``, `` `ct/l1` ``) |
There was a problem hiding this comment.
Huh, didn't realize we had commits like these?
| **PASS for new-file-only commits.** If the diffstat shows only new files | ||
| being added (no modifications to existing files), this is likely | ||
| greenfield code. The code itself (including its comments and | ||
| documentation) serves as the explanation. Pass. |
There was a problem hiding this comment.
I think this might be a bit too lenient. For instance, it might be helpful as a reviewer to understand how the greenfield code fits together, if there are several components being added
There was a problem hiding this comment.
yeah i think including context in the commit message is important. for example, even as the source code changes over time, i can still look at the file's first commit to better understand what past us was up to.
I wonder if it's worth delineating what's useful to a branch reviewer vs what's useful for commit history generally.
Yeh, this crossed my mind. In general I think that the agents do a pretty good job since they tend to follow existing patterns and are eager to explain things. I think if we start seeing an issue with this we can fine-tune CLAUDE.md, but we also want to keep CLAUDE.md lean. |
|
|
||
| Apply the following checks to each commit message: | ||
|
|
||
| #### M1: Subject line length |
There was a problem hiding this comment.
I am wondering if semgrep rules could cover this basic checks:
- line lenght
- format
- etc
This would be much faster and cheaper
There was a problem hiding this comment.
like semgrep insetad of claude?
| Run: | ||
|
|
||
| ``` | ||
| git log --format='%H %s' upstream/dev..HEAD |
There was a problem hiding this comment.
For me it is origin not upstream.
This is sort of a common issue in skills, where there are differences in the env which make the skill harder to write.
Will open a thread on slack.
Add a /lint-pr slash command that checks pull request commits against project standards. It can be run with no arguments to lint the current branch against upstream/dev, or with a PR number to lint a remote PR.
Checks implemented:
I spot checked this with backtesting on old PR reviews.
Backports Required
Release Notes