Skip to main content
skill CX Codex

gerrit — Claude Code skill: Gerrit code review via git-review

Hands Gerrit work to the agent: upload patchsets, fetch changes for local review, and read query results as markdown.

MIT 135 installs ★ 13 updated 2026-10-25

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add odyssey4me/agent-skills --skill gerrit -a claude-code
Open on GitHub

What gerrit does

The skill splits Gerrit work in two. Read-only calls go through a Python wrapper at scripts/gerrit.py that queries Gerrit over SSH and prints the answer as markdown: changes list, changes view 12345, changes diff, changes search and projects list, with --limit on the list commands.

Writes stay with git-review. A plain git review pushes the current branch, git commit --amend followed by another git review adds a patchset, and git review -d 12345 brings someone else's change into a local branch named review/username/topic. Reviewers go in with --reviewers.

Setup takes pip install git-review plus Python and an SSH key registered in Gerrit. The username sits in git config --global gitreview.username; host, port and project go into .gitreview, which git review -s can generate for you. No outbound HTTPS or SSH to the Gerrit host means no remote commands at all — the skill treats those failures as network trouble and leaves credentials alone.

What it helps with

  • push a branch to Gerrit with reviewers attached
  • fetch change 12345 and run the tests against it
  • inspect the diff of one patchset
  • search open changes inside a project
  • upload a fresh patchset after review comments

Example prompts for the agent

  • Send the current branch to Gerrit under the topic auth-refactor and add user1,user2 as reviewers.
  • Download change 12345 and list the files it touches.
  • Search open changes in myproject and show me the results.

How to install gerrit

1Skills CLI (Vercel)

npx skills add odyssey4me/agent-skills --skill gerrit -a claude-code

2Manually: put the files in place

~/.claude/skills/gerrit/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/gerrit/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about gerrit

How do I install the gerrit skill in Claude Code?

Run npx skills add odyssey4me/agent-skills --skill gerrit -a claude-code. The skill file lands at ~/.claude/skills/gerrit/SKILL.md.

What does the gerrit skill do?

It gives the agent Gerrit commands: list and view changes, diff a patchset, run a search query, list projects. Uploads and amendments are handled through git-review.

What has to be in place before the first command?

git-review installed with pip install git-review, Python for the wrapper script, and an SSH key uploaded to Gerrit. Remote calls also need outbound access to the review host.

Source text

SKILL.md · MIT
---
name: gerrit
description: Submit, amend, and review Gerrit changes using git-review CLI. Use when asked to submit a patchset, download a change, rebase a change request, check CR status, or manage code reviews in Gerrit.
metadata:
  author: odyssey4me
  version: "0.3.1"
  category: code-hosting
  tags: "code-review, patches"
  complexity: lightweight
license: MIT
---

# Gerrit Skill

This skill provides Gerrit code review integration using `git-review` with a Python wrapper for markdown-formatted query output on read/view operations. Action commands (submit, review, abandon) should use `git-review` or SSH commands directly.

## Network access

Gerrit commands require outbound HTTPS to the configured Gerrit REST API. Git fetch/push and git-review require HTTPS or SSH to the configured review and repository hosts. Remote operations require outbound network access. If the agent environment restricts it, obtain access through that environment's approval or network controls before the first remote command, reusing authorization already granted. Local help and file processing do not need network access. Skill instructions do not grant network permission. Report DNS, connection, and timeout failures as network errors; do not reset credentials to resolve them. If approved access also fails, stop and report it. Authentication and permission errors require user action.

## Resolving script paths

`SKILL_DIR` in the examples is the directory containing this loaded `SKILL.md`.
Set it to that absolute path before running commands; do not assume the agent
sets this shell variable. Quote the script path if it contains spaces.

## Prerequisites

**Install git-review**: `pip install git-review` — [docs](https://docs.opendev.org/opendev/git-review/latest/installation.html)

## Authentication

git-review uses SSH for authentication with Gerrit servers.

```bash
# Configure Gerrit username (if different from local user)
git config --global gitreview.username yourgerrituser

# Test SSH connection
ssh -p 29418 [email protected] gerrit version

# Add SSH key to Gerrit
# 1. Generate SSH key if needed: ssh-keygen -t ed25519
# 2. Copy public key: cat ~/.ssh/id_ed25519.pub
# 3. Add to Gerrit: Settings > SSH Keys
```

Gerrit supports multiple authentication methods:
- **SSH** (recommended): Used by git-review for all operations
- **HTTP/HTTPS**: For web UI and REST API access (set password in Settings > HTTP Password)

See [Gerrit Authentication](https://gerrit-review.googlesource.com/Documentation/user-upload.html#ssh) for details.

## Initial Setup

### Configure Repository

```bash
# One-time setup for a repository
git review -s

# Or manually create .gitreview file in repository root
cat > .gitreview <<EOF
[gerrit]
host=review.example.com
port=29418
project=myproject
defaultbranch=main
EOF
```

See [Installation Guide](https://docs.opendev.org/opendev/git-review/latest/installation.html) for details.

## Script Usage

The wrapper script (`scripts/gerrit.py`) uses Gerrit SSH query commands and formats output as markdown. Connection details are read from `.gitreview` or provided via `--host`/`--port`/`--username` flags. See [permissions.md](references/permissions.md) for read/write classification of each command.

```bash
# Check Gerrit SSH access
$SKILL_DIR/scripts/gerrit.py check

# Changes
$SKILL_DIR/scripts/gerrit.py changes list
$SKILL_DIR/scripts/gerrit.py changes view 12345
$SKILL_DIR/scripts/gerrit.py changes diff 12345
$SKILL_DIR/scripts/gerrit.py changes diff 12345 --patchset 3
$SKILL_DIR/scripts/gerrit.py changes search "status:open project:myproject"

# Projects
$SKILL_DIR/scripts/gerrit.py projects list
```

All commands support `--limit N` for list commands (default 30).

Global connection options: `--host`, `--port` (default 29418), `--username`.

## Commands (Direct git-review Usage)

For action commands, use `git-review` or SSH commands directly:

### Submitting Changes

```bash
git review                          # Submit current branch for review
git review -t topic-name            # Submit with topic
git review -f                       # Submit and close local branch
git review --reviewers user1,user2  # Add reviewers
git review -n                       # Dry-run (show what would be done)
```

Full reference: [git-review usage](https://docs.opendev.org/opendev/git-review/latest/usage.html)

### Downloading Changes

```bash
git review -d 12345                 # Download change 12345
git review -d 12345,3               # Download patchset 3 of change 12345
git review -x 12345                 # Cherry-pick change (no branch)
git review -m 12345                 # Compare local changes to remote
```

Downloads create a local branch named `review/username/topic`.

### Updating Changes

```bash
# Make changes to downloaded review
git commit --amend
git review                          # Upload new patchset

# Update to latest patchset
git review -d 12345                 # Re-download updates the branch
```

### Advanced Options

```bash
git review -R                       # Don't rebase (submit as-is)
git review -D                       # Draft mode (WIP changes)
git review --no-cache               # Skip local cache
git review -v                       # Verbose output
git review --track                  # Track remote branch
```

## Configuration

### Per-Repository Settings

File: `.gitreview` (repository root)
```ini
[gerrit]
host=review.example.com
port=29418
project=myproject/subproject
defaultbranch=main
defaultremote=origin
```

### Global Settings

```bash
# Set Gerrit username
git config --global gitreview.username myuser

# Set default remote
git config --global gitreview.remote gerrit

# Configure scheme (ssh/http/https)
git config --global gitreview.scheme ssh
```

Configuration stored in `~/.gitconfig`

## Examples

### Daily Workflow

```bash
# Start work on new feature
git checkout -b feature-branch
# ... make changes ...
git commit -m "Add new feature"

# Submit for review
git review -t feature-topic
# Verify submission
$SKILL_DIR/scripts/gerrit.py changes list  # confirm change appears

# Address review comments
# ... make changes ...
git commit --amend
git review
# Verify new patchset uploaded
$SKILL_DIR/scripts/gerrit.py changes view <change-number>
```

### Reviewing Others' Changes

```bash
# Download change for review
git review -d 12345
# Verify download
$SKILL_DIR/scripts/gerrit.py changes view 12345

# Test the change
# ... run tests, verify code ...

# Return to main branch
git checkout main
git branch -D review/user/topic
```

### Working with Topics

```bash
# Submit with topic
git review -t authentication-refactor
# Verify submission
$SKILL_DIR/scripts/gerrit.py changes list

# All related changes will be grouped under this topic
git commit -m "Part 2: Update tests"
git review -t authentication-refactor
```

See [common-workflows.md](references/common-workflows.md) for more examples.

## Advanced Usage

See [advanced-usage.md](references/advanced-usage.md) for SSH commands, JSON output, and multi-server configuration.

## Model Guidance

This skill wraps an official CLI. A fast, lightweight model is sufficient.

## Troubleshooting

See [troubleshooting.md](references/troubleshooting.md) for common issues and fixes.

## Official Documentation

- **git-review Manual**: <https://docs.opendev.org/opendev/git-review/latest/>
- **git-review Repository**: <https://opendev.org/opendev/git-review>
- **Gerrit Documentation**: <https://gerrit-review.googlesource.com/Documentation/>
- **Gerrit SSH Commands**: <https://gerrit-review.googlesource.com/Documentation/cmd-index.html>

© odyssey4me · MIT · odyssey4me/agent-skills

Similar skills

All skills for Code review and refactoring →

From the same set6

Project sponsors

Companies that keep this analytics open