From 35e2aeb18a7d2c6f3e105c02f4849a873b60af95 Mon Sep 17 00:00:00 2001 From: Hinata Oishi <92960051+te19oishi@users.noreply.github.com> Date: Fri, 12 Jun 2026 16:09:03 +0900 Subject: [PATCH] =?UTF-8?q?feat(review-branch):=20Greptile=20CLI=E7=94=A8?= =?UTF-8?q?=E3=81=AE=E3=83=96=E3=83=A9=E3=83=B3=E3=83=81=E3=83=AC=E3=83=93?= =?UTF-8?q?=E3=83=A5=E3=83=BCSkill=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +- review-branch/SKILL.md | 161 +++++++++++++++++++++++ review-branch/references/greptile-cli.md | 57 ++++++++ 3 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 review-branch/SKILL.md create mode 100644 review-branch/references/greptile-cli.md diff --git a/README.md b/README.md index 8102018..5a32c0f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # greptile skills -[Agent Skills](https://agentskills.io) for automated PR review workflows. Supports GitHub, GitLab, and Perforce. Requires `git` + `gh` CLI (GitHub), `glab` CLI (GitLab), or `p4` CLI (Perforce). +[Agent Skills](https://agentskills.io) for automated Greptile review workflows. Supports local branch reviews with Greptile CLI, plus GitHub, GitLab, and Perforce review workflows. ## Skills @@ -8,8 +8,9 @@ |-------|-------------| | [`check-pr`](check-pr/) | Check a PR/MR/CL for unresolved comments, failing checks, incomplete description. Fix and resolve. | | [`greploop`](greploop/) | Loop: trigger Greptile review, fix comments, re-review — until 5/5 confidence and zero comments. | +| [`review-branch`](review-branch/) | Review the current committed branch diff with Greptile CLI before opening a PR/MR. | -Both skills auto-detect the platform (GitHub, GitLab, or Perforce) from the environment. +`check-pr` and `greploop` auto-detect the platform (GitHub, GitLab, or Perforce) from the environment. `review-branch` uses Greptile CLI for local Git branch reviews before a PR/MR exists. ## Requirements @@ -18,8 +19,9 @@ Both skills auto-detect the platform (GitHub, GitLab, or Perforce) from the envi | GitHub | `gh` | [cli.github.com](https://cli.github.com) | | GitLab | `glab` | [gitlab.com/gitlab-org/cli](https://gitlab.com/gitlab-org/cli) | | Perforce | `p4` | [perforce.com/downloads](https://www.perforce.com/downloads/helix-command-line-client-p4) | +| Local branch review | `git` + `greptile` | [Greptile CLI](https://www.greptile.com/docs/code-review/greptile-cli) | -Authenticate before use: `gh auth login`, `glab auth login`, or configure `P4PORT`/`P4USER`/`P4CLIENT` for Perforce. +Authenticate before use: `gh auth login`, `glab auth login`, configure `P4PORT`/`P4USER`/`P4CLIENT` for Perforce, or run `greptile login` for Greptile CLI. ## Install @@ -28,6 +30,7 @@ git clone https://github.com/greptileai/skills.git ~/.claude/skills/greptile cd ~/.claude/skills ln -s greptile/check-pr check-pr ln -s greptile/greploop greploop +ln -s greptile/review-branch review-branch ``` Or as a submodule: @@ -36,13 +39,14 @@ Or as a submodule: git submodule add https://github.com/greptileai/skills.git .skills/greptile ln -s greptile/check-pr .skills/check-pr ln -s greptile/greploop .skills/greploop +ln -s greptile/review-branch .skills/review-branch ``` Claude Code discovers skills by looking for `SKILL.md` files at `~/.claude/skills//SKILL.md`. Since this is a multi-skill repo, symlinks are needed to expose each sub-skill at the expected depth. ## Usage -Invoke by name in your agent (e.g. `/check-pr 123` or `/greploop`). If no PR/MR/CL number is given, both skills auto-detect the PR/MR for the current branch, or the pending changelist for Perforce. +Invoke by name in your agent (e.g. `/check-pr 123`, `/greploop`, or `/review-branch main`). If no PR/MR/CL number is given, `check-pr` and `greploop` auto-detect the PR/MR for the current branch, or the pending changelist for Perforce. `review-branch` reviews the current local Git branch against a base branch with Greptile CLI. For self-hosted GitLab instances whose hostname doesn't contain "gitlab", pass `--vcs gitlab` explicitly. For Perforce, pass `--vcs perforce` if auto-detection fails. diff --git a/review-branch/SKILL.md b/review-branch/SKILL.md new file mode 100644 index 0000000..34742ac --- /dev/null +++ b/review-branch/SKILL.md @@ -0,0 +1,161 @@ +--- +name: review-branch +description: > + Reviews the current local Git branch with Greptile CLI before opening a PR or MR. Compares committed + branch changes against a base branch, reports Greptile findings from the terminal, optionally fixes + actionable issues, and can rerun the CLI review. Use when the user wants a fast pre-PR Greptile + review without creating or triggering a PR/MR review comment, check run, dashboard review, or greploop. +license: MIT +compatibility: Requires git and Greptile CLI installed and authenticated with `greptile login`. +metadata: + author: greptileai + version: "1.0" +allowed-tools: Bash(git:*) Bash(greptile:*) +--- + +# Review Branch + +Run Greptile CLI against the current local branch before opening a PR/MR. This skill is for committed branch diffs only: Greptile CLI ignores uncommitted changes. + +## Inputs + +- **Base branch** (optional): If not provided, use the repository default branch when it can be inferred, otherwise ask the user. +- **Output format** (optional): `agent` by default. Use `json` when another tool needs to parse the result. +- **Loop mode** (optional): If requested, fix actionable findings and rerun Greptile CLI until no actionable findings remain or the user chooses to stop. + +## Instructions + +### 0. Confirm prerequisites + +Run from the repository root or move there first: + +```bash +git rev-parse --show-toplevel +greptile --version +greptile whoami +``` + +If `greptile whoami` fails, ask the user to authenticate with: + +```bash +greptile login +``` + +Do not use PR/MR review triggers for this workflow. In particular, do not post `@greptile review`, do not trigger Greptile through GitHub/GitLab comments, and do not use dashboard or app-based review flows. + +### 1. Determine review scope + +Identify the current branch and working tree state: + +```bash +git branch --show-current +git status --short +``` + +If there are uncommitted changes, tell the user that Greptile CLI will ignore them. Ask whether they want to commit first, or continue with only committed branch changes in scope. + +Choose the base branch: + +```bash +git symbolic-ref --quiet --short refs/remotes/origin/HEAD +``` + +If `origin/HEAD` is unavailable, try `main` or `master`. If the intended base branch is still unclear, ask the user. + +Verify there are committed changes to review: + +```bash +git diff --stat ...HEAD +git rev-list --count ..HEAD +``` + +If there are zero commits against the base branch, stop and report that Greptile CLI has nothing to review. + +### 2. Run Greptile CLI + +For agent-readable text: + +```bash +greptile review -b --agent --no-color +``` + +For machine-readable output: + +```bash +greptile review -b --json --no-color +``` + +To resume the latest unfinished review: + +```bash +greptile review --resume --agent --no-color +``` + +If the user wants inline code context: + +```bash +greptile review -b --diff --context=25 --agent --no-color +``` + +### 3. Categorize findings + +Classify each finding before changing code: + +| Category | Meaning | +|---|---| +| **Actionable** | Correctness, security, maintainability, test, or requirement issue that should be fixed | +| **Needs decision** | Plausible issue, but depends on product intent, API contract, or team tradeoff | +| **Not actionable** | False positive, already addressed, outside the reviewed diff, or only a style preference | + +Report the categories clearly. Do not present a clean Greptile result as covering uncommitted local changes. + +### 4. Fix findings if requested + +If the user asks to fix findings: + +1. Read the surrounding code and relevant project instructions. +2. Make the smallest code change that addresses the actionable issue. +3. Run focused validation that matches the changed surface. +4. Commit only if the user explicitly asks you to commit. + +If the user requested loop mode, rerun Greptile only after the fixes are committed with explicit user approval. If the user does not approve a commit, stop after local validation and report that Greptile was not rerun because the fixes remain uncommitted. + +After the fixes are committed, rerun: + +```bash +greptile review -b --agent --no-color +``` + +Stop when there are no actionable findings, the remaining findings need user/product decision, or the user asks to stop. + +### 5. Prepare for PR/MR creation + +When the branch is ready, summarize the review result and ask before creating or pushing a PR/MR. This skill does not create PRs/MRs by itself; hand off to the user's normal PR/MR creation workflow when explicitly requested. + +## Output format + +```text +Review Branch complete. +Base: main +Branch: feature/example +Greptile command: greptile review -b main --agent --no-color +Actionable findings: 0 +Needs decision: 1 +Not actionable: 2 +Validation: npm test -- auth.test.ts +Next: ready for PR creation when requested +``` + +If not complete: + +```text +Review Branch stopped. +Base: main +Branch: feature/example +Actionable findings remaining: 2 +Reason: product decision needed before changing API behavior +``` + +## Reference + +For exact Greptile CLI flags and examples, see [Greptile CLI Reference](references/greptile-cli.md). diff --git a/review-branch/references/greptile-cli.md b/review-branch/references/greptile-cli.md new file mode 100644 index 0000000..0a6a0e1 --- /dev/null +++ b/review-branch/references/greptile-cli.md @@ -0,0 +1,57 @@ +# Greptile CLI Reference + +Use this reference when exact Greptile CLI flag behavior matters. + +Source: https://www.greptile.com/docs/code-review/greptile-cli + +## Setup + +```bash +npm i -g greptile +greptile --version +greptile login +greptile whoami +greptile logout +``` + +## Review commands + +```bash +greptile review +greptile review -b main +greptile review --resume +greptile review --diff +greptile review --diff --context=25 +``` + +By default, Greptile compares the current branch against the repository default branch, usually `main`, and reviews unmerged committed branch changes. Uncommitted changes are ignored. + +## Output formats + +```bash +greptile review --json +greptile review --agent +greptile review --text +``` + +`--agent` is an alias for `--text`. Plain text is also used automatically when output is piped. + +## Reopen reviews + +```bash +greptile review show +greptile review show REVIEW_ID +``` + +## Useful flags + +| Flag | Purpose | +|---|---| +| `-b, --branch=` | Base branch to compare against | +| `--resume` | Continue the latest unfinished review | +| `--diff` | Show findings inline with relevant code | +| `--context=` | Lines of surrounding code for inline findings. Default: 15 | +| `--json` | Print machine-readable output | +| `--text, --agent` | Print plain text for agent workflows | +| `--width=` | Set output width | +| `--no-color` | Disable colored output |