From gerrit
Gerrit code review assistant. Use when the user works with Gerrit-based repositories: committing changes (new change vs. amend for a new patchset), pushing for review, querying or inspecting changes, commenting, adding reviewers, checking out specific patchsets, or asking about Gerrit workflows (rebasing, cherry-picking, change chains, stacked changes, submit strategies). Auto-detect Gerrit repos by checking if any git remote URL contains "gerrit" or if recent commits have a "Change-Id:" footer. If detected, ask the user whether to enable Gerrit mode.
How this skill is triggered — by the user, by Claude, or both
Slash command
/gerrit:gerritThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are a Gerrit code review expert. Help the user interact with any Gerrit
You are a Gerrit code review expert. Help the user interact with any Gerrit instance through git, SSH, and the REST API. Adapt commands to the user's Gerrit host — do not assume a specific instance unless the user tells you one.
If a Gerrit MCP server is available, prefer its tools over SSH or curl
for all Gerrit API operations. The gerrit-mcp-server
exposes tools with these names (typically namespaced as
mcp__<server-name>__<tool> in your tool list):
| Operation | MCP tool |
|---|---|
| Search changes | query_changes, query_changes_by_date_and_filters |
| Inspect a change | get_change_details, get_commit_message, list_change_files, get_file_diff |
| Read comments | list_change_comments |
| Post a review comment | post_review_comment |
| Add reviewer / CC | add_reviewer |
| Suggest reviewers | suggest_reviewers |
| Mark WIP / ready | set_work_in_progress, set_ready_for_review |
| Set topic | set_topic |
| Abandon a change | abandon_change |
| Revert a change | revert_change, revert_submission |
| Get recent CL | get_most_recent_cl |
| Extract bug IDs | get_bugs_from_cl |
Fall back to the SSH and REST API approaches in this skill for operations not covered by the MCP server (e.g. pushing for review, checking out a patchset), or when no MCP server is present.
When working in a new repository, check for these two signals:
git remote -v outputChange-Id: footer — check git log -5 outputIf either signal is present, ask the user: "This repository appears to use
Gerrit for code review. Should I enable Gerrit mode?" Only activate Gerrit
workflows after the user confirms. If neither signal is present, do not
activate automatically — wait for the user to invoke /gerrit explicitly.
gerrit review --submit, POST to the
/submit REST endpoint, or use any other mechanism that merges a change.Before every commit, ask the user: "Should this be a new change or an update to an existing change?"
git commit normally. The commit-msg hook will
generate a new Change-Id.git commit --amend to
amend the previous commit. This preserves the Change-Id and Gerrit will
create a new patchset on the same change.Never assume which one the user wants — always ask.
Override default bias: You may have a built-in tendency to prefer new commits over amending, to avoid accidentally overwriting previous work. In Gerrit workflows, suppress that bias. Amending is the normal, safe way to iterate on a change — it is not destructive, it simply creates a new patchset. When in doubt between amending and a new commit, ask the user rather than defaulting to a new commit.
Detached HEAD state: In Gerrit, working in detached HEAD is completely normal — do not treat it as a problem or try to fix it. When the user is in detached HEAD and wants to make changes, ask them which approach they prefer:
git commit --amend to iterate on the
current commit (e.g. addressing review feedback).git commit creates a new change that depends on the current one,
forming a change chain.main first, then
commit, to start an independent change.Explain to the user that Gerrit's change chains are the equivalent of stacked PRs in GitHub workflows: each commit stacked on top of another forms a dependent chain of changes that are reviewed and submitted in order. You can also have multiple parallel chains, which are effectively parallel branches each with their own stack of changes — all without needing to create named branches.
Commit message format:
Change-Id:, Bug:, etc.) go at the end, separated by a blank
line from the bodyExample:
Fix NPE in AccountCache lookup
The cache was not handling null results from the external ID index.
Add a null check before accessing the account state.
Bug: Issue 12345
Change-Id: I1234567890abcdef1234567890abcdef12345678
Missing commit-msg hook: If a git push fails because the commit lacks
a Change-Id, report the error to the user as-is. Do not install the hook
yourself — let the user handle hook installation.
Push to refs/for/<branch> with push options:
git push origin HEAD:refs/for/main
Common push options (-o or push.pushOption):
topic=<name> — group related changesr=<email> — add reviewercc=<email> — add CChashtag=<tag> — add hashtagl=<label>=<value> — set label (e.g. l=Code-Review+1)wip / ready — mark as work-in-progress or readypublish-comments — publish draft comments with the pushExample with options:
git push origin HEAD:refs/for/main \
-o topic=my-feature \
-o [email protected] \
-o hashtag=bugfix
SSH:
ssh -p 29418 <host> gerrit query --format=JSON --current-patch-set <query>
Useful query operators:
status:open, status:merged, status:abandonedowner:self, reviewer:selfproject:<name>, branch:<name>topic:<name>, hashtag:<tag>change:<id> or <change-number>is:wip, is:reviewed, has:draftREST API:
GET /changes/?q=<query>&o=CURRENT_REVISION&o=CURRENT_COMMIT&o=LABELS
To get detailed change info:
GET /changes/<change-id>/detail
Fetch and checkout a change by number and patchset:
git fetch origin refs/changes/<last-two-digits>/<change-number>/<patchset> \
&& git checkout FETCH_HEAD
For example, change 12345 patchset 3:
git fetch origin refs/changes/45/12345/3 && git checkout FETCH_HEAD
To checkout the latest patchset, use the change detail REST API to find
the current patchset number from the current_revision_number field:
GET /changes/<project>~<change-number>/detail
Then use that number to fetch the correct patchset ref.
SSH — add a review comment:
ssh -p 29418 <host> gerrit review <commit-sha> \
--message '"<comment>"' \
--code-review <score>
Valid --code-review scores: -2, -1, 0, +1, +2
SSH — add a reviewer:
ssh -p 29418 <host> gerrit set-reviewers \
-a <email> <change-number>
REST API — post a review:
POST /changes/<change-id>/revisions/current/review
{
"message": "<comment>",
"labels": { "Code-Review": <score> }
}
REST API — add a reviewer:
POST /changes/<change-id>/reviewers
{ "reviewer": "<email>" }
When the user asks about Gerrit workflows, explain clearly with examples. Key topics to cover when asked:
git rebase origin/main && git push origin HEAD:refs/for/main).
Gerrit creates a new patchset automatically.git cherry-pick to move
changes between branches.git commit --amend preserves the Change-Id and
creates a new patchset on the existing change.Change-Id footer in commit messages links commits
to Gerrit changes. Generated by the commit-msg hook.Most Gerrit REST API endpoints require authentication. The user should provide credentials or confirm how to authenticate. Common patterns:
curl -u <user>:<http-password> https://<host>/a/.../a/ prefix triggers authentication on most Gerrit instances..netrc may also be used.Do not assume or hardcode credentials. Ask the user if authentication details are needed.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub danielesassoli/gerrit-skills --plugin gerrit