Skip to content

claude: add slash command skill to lint commits in a PR#30162

Open
dotnwat wants to merge 1 commit into
redpanda-data:devfrom
dotnwat:claude-commit-tidy
Open

claude: add slash command skill to lint commits in a PR#30162
dotnwat wants to merge 1 commit into
redpanda-data:devfrom
dotnwat:claude-commit-tidy

Conversation

@dotnwat
Copy link
Copy Markdown
Member

@dotnwat dotnwat commented Apr 14, 2026

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)

I spot checked this with backtesting on old PR reviews.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v26.1.x
  • v25.3.x
  • v25.2.x

Release Notes

  • none

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]>
@dotnwat dotnwat marked this pull request as ready for review April 14, 2026 23:06
Copilot AI review requested due to automatic review settings April 14, 2026 23:06
@dotnwat dotnwat changed the title [WIP] claude/skill/commit-tidy claude: add slash command skill to lint commits in a PR Apr 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md defining the /lint-pr skill 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.

Comment thread .claude/skills/lint-pr/SKILL.md
Comment thread .claude/skills/lint-pr/SKILL.md
Comment thread .claude/skills/lint-pr/SKILL.md
Comment thread .claude/skills/lint-pr/SKILL.md
@dotnwat dotnwat requested review from a team, andrwng, mmaslankaprv, pgellert and travisdowns and removed request for a team April 15, 2026 19:34
Copy link
Copy Markdown
Contributor

@andrwng andrwng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it falls in this category, but copy-pasted log lines too

Comment on lines +144 to +145
- Backtick-quoted area: same as above but wrapped in backticks
(e.g. `` `kafka` ``, `` `ct/l1` ``)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, didn't realize we had commits like these?

Comment on lines +202 to +205
**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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

@pgellert pgellert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 🔥

@dotnwat
Copy link
Copy Markdown
Member Author

dotnwat commented Apr 17, 2026

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if semgrep rules could cover this basic checks:

  • line lenght
  • format
  • etc
    This would be much faster and cheaper

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like semgrep insetad of claude?

Run:

```
git log --format='%H %s' upstream/dev..HEAD
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants