claude-code - 💡(How to fix) Fix /code-review skill: silent fallback to main...HEAD reviews other people's commits, and JSON-only output is hard to read

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Two issues with the /code-review skill (used via the slash command in Claude Code):

Root Cause

Two issues with the /code-review skill (used via the slash command in Claude Code):

RAW_BUFFERClick to expand / collapse

Summary

Two issues with the /code-review skill (used via the slash command in Claude Code):

1. Wrong diff scope on long-lived feature branches

The skill instructs the agent to run git diff @{upstream}...HEAD and fall back to main...HEAD only if there's no upstream. The fallback condition is too narrow: if @{upstream} is set but @{upstream}...HEAD is empty (branch is up-to-date with its remote), the agent has nothing to review and silently falls back to main...HEAD anyway. On a long-lived feature branch this pulls in commits authored by other people (merged-but-not-yet-on-main PRs) and reports "findings" in files the user never touched.

Repro:

  • Check out a feature branch that's been alive for a few days, up-to-date with its remote.
  • Have a few uncommitted edits in 2–3 files.
  • Run /code-review medium.
  • Observed: review covers ~24 files including others' merged PRs.
  • Expected: review covers the ~3 working-tree files only.

Suggested fix: When @{upstream} is set, treat @{upstream}...HEAD empty + uncommitted changes as scope = git diff HEAD only. Don't fall back to main.

2. Raw JSON output is not user-readable

The skill's contract returns a JSON array of {file, line, summary, failure_scenario} to the chat. When a human is reading it (no --comment flag), the JSON is dense and slow to parse. The agent has to remember to translate it into prose; today that's not in the skill instructions.

Suggested fix: Add a step at the end: if no downstream consumer (e.g. --comment) is requested, render the findings as a short prose summary grouped by severity, with JSON optional/collapsible.

Environment

  • Claude Code, Opus 4.7 (1M context)
  • macOS

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING