gerrit について
Gerrit スキルは git-review を使ったコードレビューを支援し、クエリと表示の結果を Python ラッパーで Markdown に整形します。読み取り操作と、変更の送信、レビュー、放棄などの操作を分けています。
主な機能
- 01Gerrit コードレビュー連携
- 02クエリと表示結果の Markdown 整形
- 03git-review と SSH による操作コマンド
- 04リポジトリ設定の案内
- 05認証設定の案内
活用シーン
- 01Gerrit のレビュー情報の検索や表示
- 02変更の送信または放棄
- 03git-review 用リポジトリの設定
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ odyssey4me/ agent-skills --skill gerritインストール後、Claude Code で/gerritを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/advanced-usage.mdcommon-workflows.mdpermissions.mdtroubleshooting.mdscripts/gerrit.py詳細
Gerrit スキル
このスキルは、読み取り/表示操作で Markdown 形式のクエリ出力を生成する Python ラッパーと git-review を使用して、Gerrit のコードレビューと連携します。アクションコマンド(submit、review、abandon)では、git-review または SSH コマンドを直接使用してください。
ネットワークアクセス
Gerrit コマンドには、設定された Gerrit REST API へのアウトバウンド HTTPS 接続が必要です。Git の fetch/push と git-review には、設定されたレビューおよびリポジトリのホストへの HTTPS または SSH 接続が必要です。リモート操作にはアウトバウンドネットワークアクセスが必要です。エージェント環境でアクセスが制限されている場合は、最初のリモートコマンドを実行する前に、その環境の承認またはネットワーク制御を通じてアクセスを取得し、すでに許可されている認証を再利用してください。ローカルでのヘルプ表示やファイル処理にはネットワークアクセスは不要です。スキルの指示によってネットワークアクセスが許可されることはありません。DNS、接続、タイムアウトの失敗はネットワークエラーとして報告してください。解決のために認証情報をリセットしないでください。承認されたアクセスでも失敗する場合は、作業を中止して報告してください。認証エラーや権限エラーへの対応には、ユーザーの操作が必要です。
スクリプトパスの解決
例にある SKILL_DIR は、この読み込み済みの SKILL.md があるディレクトリです。
コマンドを実行する前に絶対パスを設定してください。エージェントが
このシェル変数を設定するとは想定しないでください。スクリプトパスに空白が含まれる場合は、引用符で囲んでください。
前提条件
git-review のインストール:pip install git-review — ドキュメント
認証
git-review は、Gerrit サーバーへの認証に SSH を使用します。
# 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 は複数の認証方式をサポートしています。
- SSH(推奨):git-review がすべての操作に使用します
- HTTP/HTTPS:Web UI および REST API へのアクセスに使用します(Settings > HTTP Password でパスワードを設定します)
詳細は Gerrit Authentication を参照してください。
初期設定
リポジトリの設定
# 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
詳細は インストールガイド を参照してください。
スクリプトの使用方法
ラッパースクリプト(scripts/gerrit.py)は、Gerrit の SSH クエリコマンドを使用し、出力を Markdown 形式に整えます。接続の詳細は .gitreview から読み込むか、--host/--port/--username フラグで指定します。各コマンドの読み取り/書き込みの分類については、permissions.md を参照してください。
# 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
一覧表示コマンドでは、すべてのコマンドで --limit N を指定できます(デフォルトは 30 です)。
グローバルな接続オプション:--host、--port(デフォルトは 29418)、--username。
コマンド(git-review を直接使用)
アクションコマンドでは、git-review または SSH コマンドを直接使用してください。
変更の送信
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)
完全なリファレンス:git-review の使用方法
変更のダウンロード
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
ダウンロードすると、review/username/topic という名前のローカルブランチが作成されます。
変更の更新
# 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
詳細オプション
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
設定
リポジトリごとの設定
ファイル:.gitreview(リポジトリのルート)
[gerrit]
host=review.example.com
port=29418
project=myproject/subproject
defaultbranch=main
defaultremote=origin
グローバル設定
# 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
設定は ~/.gitconfig に保存されます。
例
日常的なワークフロー
# 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>
他のユーザーの変更をレビューする
# 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
トピックを扱う
# 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
その他の例は common-workflows.md を参照してください。
高度な使用方法
SSH コマンド、JSON 出力、複数サーバーの設定については、advanced-usage.md を参照してください。
モデルに関するガイダンス
このスキルは公式 CLI をラップしています。高速で軽量なモデルで十分です。
トラブルシューティング
よくある問題と解決方法については、troubleshooting.md を参照してください。
公式ドキュメント
- git-review マニュアル:https://docs.opendev.org/opendev/git-review/latest/
- git-review リポジトリ:https://opendev.org/opendev/git-review
- Gerrit ドキュメント:https://gerrit-review.googlesource.com/Documentation/
- Gerrit SSH コマンド:https://gerrit-review.googlesource.com/Documentation/cmd-index.html