skills/ah-review-code/SKILL.md
Review code with the "ah" prefix. Use for "ah review code", "ah review code 123", "ah review", "ah code review", "ah review my changes", or "ah review this PR" (even without "code"). Reviews correctness, maintainability, and adherence to project standards for local branch changes or remote Pull Requests (by ID or URL).
npx skillsauth add arinhubcom/arinhub ah-review-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Orchestrate comprehensive code review. Run multiple review strategies in parallel, merge and dedup findings into review file. Supports remote PRs and local branch changes.
123, #123, or full URL. Omitted = review local changes.main, develop). Auto-detected if not provided.gh auth status
If command fails, stop and ask the user to authenticate with gh auth login.
MODE=pr.MODE=local.REPO_NAME=$(basename -s .git "$(git remote get-url origin)")
REVIEWS_DIR=~/.agents/arinhub/code-reviews
DIFFS_DIR=~/.agents/arinhub/diffs
Create ${REVIEWS_DIR} and ${DIFFS_DIR} if they do not exist.
If MODE=pr:
MODE=pr
PR_NUMBER=<extracted from user input>
REVIEW_ID=${MODE}-${REPO_NAME}-${PR_NUMBER}
REVIEW_FILE=${REVIEWS_DIR}/code-review-${REVIEW_ID}.md
# Get the PR branch name, base branch, URL, and title from PR metadata (single API call).
PR_META=$(gh pr view ${PR_NUMBER} --json headRefName,baseRefName,url,title)
PR_BRANCH=$(echo "$PR_META" | jq -r '.headRefName')
PR_BASE=$(echo "$PR_META" | jq -r '.baseRefName')
PR_URL=$(echo "$PR_META" | jq -r '.url')
PR_TITLE=$(echo "$PR_META" | jq -r '.title')
If MODE=local:
Auto-detect base branch using this priority order:
gh pr view --json baseRefName -q '.baseRefName' 2>/dev/nullgh repo view --json defaultBranchRef -q '.defaultBranchRef.name' 2>/dev/nullmainMODE=local
BRANCH_NAME=$(git branch --show-current | tr '/' '-')
REVIEW_ID=${MODE}-${REPO_NAME}-branch-${BRANCH_NAME}
REVIEW_FILE=${REVIEWS_DIR}/code-review-${REVIEW_ID}.md
BASE_BRANCH=<resolved from priority above>
# Find the point where the current branch diverged from the base branch.
MERGE_BASE=$(git merge-base "${BASE_BRANCH}" HEAD)
Collision avoidance: Check whether a review file or any subagent files for this REVIEW_ID already exist. If so, append sequential number suffix to produce unique REVIEW_ID.
BASE_REVIEW_ID=${REVIEW_ID}
if compgen -G "${REVIEWS_DIR}/code-review-${BASE_REVIEW_ID}.md" > /dev/null 2>&1 || \
compgen -G "${REVIEWS_DIR}/subagent-*-${BASE_REVIEW_ID}.md" > /dev/null 2>&1; then
N=1
while compgen -G "${REVIEWS_DIR}/code-review-${BASE_REVIEW_ID}-${N}.md" > /dev/null 2>&1 || \
compgen -G "${REVIEWS_DIR}/subagent-*-${BASE_REVIEW_ID}-${N}.md" > /dev/null 2>&1; do
N=$((N + 1))
done
REVIEW_ID=${BASE_REVIEW_ID}-${N}
REVIEW_FILE=${REVIEWS_DIR}/code-review-${REVIEW_ID}.md
fi
If MODE=pr:
Create review file with header:
# PR Review: ${REPO_NAME} #${PR_NUMBER}
**Date:** <current date>
**Repo:** ${REPO_NAME}
**Branch:** ${PR_BRANCH}
**Base Branch:** ${PR_BASE}
**PR Number:** ${PR_NUMBER}
**PR Title:** ${PR_TITLE}
**PR Link:** ${PR_URL}
## Issues
<!-- Issues from parallel review agents merged below. No duplicates. -->
If MODE=local:
Create review file with header:
# Local Review: ${REPO_NAME} (${BRANCH_NAME})
**Date:** <current date>
**Repo:** ${REPO_NAME}
**Branch:** ${BRANCH_NAME}
**Base Branch:** ${BASE_BRANCH} (merge base: ${MERGE_BASE})
## Issues
<!-- Issues from parallel review agents merged below. No duplicates. -->
Save diff to shared file so subagents can read it.
If MODE=pr:
DIFF_FILE=${DIFFS_DIR}/diff-${REVIEW_ID}.diff
gh pr diff ${PR_NUMBER} > ${DIFF_FILE}
If MODE=local:
Diff from merge base (resolved in Step 2) to current working tree. Captures all feature-branch changes — committed and uncommitted — relative to source branch. Note: untracked files (new files not yet git add-ed) are not included in diff. To include new files, stage them first with git add -N <file> (intent-to-add) before running review.
DIFF_FILE=${DIFFS_DIR}/diff-${REVIEW_ID}.diff
git diff "${MERGE_BASE}" > "${DIFF_FILE}"
After saving diff, check its size:
DIFF_LINES=$(wc -l < "${DIFF_FILE}")
git diff "${MERGE_BASE}" -- <paths> (local) or gh pr diff ${PR_NUMBER} | filterdiff -i '<pattern>' (PR mode, if filterdiff available, otherwise filter manually)Check whether diff contains React code via quick grep — no subagent needed.
HAS_REACT=false
if grep -qE '\.(tsx|jsx)\b' "${DIFF_FILE}" || \
grep -qE "from ['\"]react['\"]|from ['\"]react-dom|require\(['\"]react['\"]" "${DIFF_FILE}" || \
grep -qE '<[A-Z][a-zA-Z]+|React\.createElement|use(State|Effect|Ref|Memo|Callback|Context|Reducer|LayoutEffect)\b' "${DIFF_FILE}"; then
HAS_REACT=true
fi
Covers file extensions (.tsx, .jsx), React imports, JSX elements (uppercase tags), React.createElement, common hooks. Grep runs in milliseconds even on large diffs — no reason to delegate to a subagent.
Spawn all subagents in a single turn so they run concurrently. Includes both review subagents (A–D) and requirements coverage subagent (E) — they are independent.
Each review subagent writes to its own dedicated file:
SUBAGENT_FILE=${REVIEWS_DIR}/subagent-<agent-name>-${REVIEW_ID}.md
Where <agent-name> is one of: code-reviewer, octocode-roast, pr-review-toolkit, react-doctor.
Before launching subagents, read issue format spec from issue-format.md and embed its full content directly into each review subagent prompt (A–D). Ensures subagents have the format regardless of current working directory.
Shared context for review subagents (A–D):
Every review subagent prompt must include:
A diff file at
${DIFF_FILE}contains all the changes to review. Do not switch branches, rungh pr checkout, or modify the working tree. Do not submit any review.Output: Write your findings to
${SUBAGENT_FILE}(your dedicated output file). Use the issue format specification embedded in your prompt above.
Delegation rule (applies to ALL subagents A–E): Launch every subagent on Opus with low effort. Each subagent's sole job: invoke its assigned skill and return whatever the skill produces. Do NOT perform analysis yourself. Do NOT write review logic, diagnostic logic, or generate findings manually. Each skill contains its own methodology — delegate to it completely.
Worktree isolation for PR mode: In MODE=pr, launch review subagents A–D with isolation: "worktree" so they get isolated repo copy checked out to PR branch. Avoids touching user's working tree — no stashing, no checkout, no risk of interrupted state. Worktree cleaned up automatically when subagent finishes. In MODE=local, do not use worktree isolation — working tree already contains the changes.
HAS_REACT=true: spawn five subagents (A, B, C, D, E).HAS_REACT=false: spawn four subagents (A, B, C, E) — skip Subagent D.${REVIEWS_DIR}/subagent-code-reviewer-${REVIEW_ID}.md/code-reviewer${REVIEWS_DIR}/subagent-octocode-roast-${REVIEW_ID}.md/octocode-roastcode review${REVIEWS_DIR}/subagent-pr-review-toolkit-${REVIEW_ID}.md/pr-review-toolkit:review-prall parallelHAS_REACT=true)${REVIEWS_DIR}/subagent-react-doctor-${REVIEW_ID}.md/react-doctor/ah-verify-requirements-coverageIf MODE=pr: Pass PR ${PR_NUMBER} and ${DIFF_FILE} as arguments to skill. If linked issue number identified during review (e.g., from PR body or metadata), pass it too to avoid redundant API lookups. Skill resolves linked issue on its own if no issue number provided.
If MODE=local: Pass ${DIFF_FILE} as argument to skill. Skill attempts to extract linked issue number from branch name (e.g., feature/42-description, fix/42, issue-42-description). If no issue determined, skill skips coverage verification and reports no linked issue found.
As subagent results come in, check each:
## Subagent Failures section and continue with results from remaining agents:## Subagent Failures
- **octocode-roast**: Timed out after 10 minutes. Issues from this agent are not included.
Review is aborted only if all review subagents (A–D) fail. If at least one produces results, proceed with what is available.
Read all subagent output files (${REVIEWS_DIR}/subagent-*-${REVIEW_ID}.md) and merge them following the four-step fingerprint-and-group algorithm in dedup-algorithm.md (parse issues, build (path, line_bucket, concern_category) fingerprints, group/deduplicate, then format each kept issue's **File:** field as a markdown link).
Append deduplicated issues to review file, grouped by severity. Use format defined in review-format.md.
Skip this step if HAS_REACT=false.
Follow instructions in react-health-report.md.
Append requirements coverage report (returned by Subagent E in Step 6) to review file:
## Requirements Coverage
<coverage report content from ah-verify-requirements-coverage>
If Subagent E failed or returned no data, note that coverage data is unavailable.
Skip this step if MODE=local.
Wait for Step 11 — do not proceed until requirements coverage report has been appended to review file.
Follow instructions in submit-pr-review.md.
The subagent returns an Issues Table — append it to the end of ${REVIEW_FILE}.
If MODE=pr:
Present a summary:
ah-submit-code-review subagent in Step 12)If MODE=local:
Present review file (${REVIEW_FILE}) content to user and a summary:
react-doctor subagent launched only when diff contains React code (detected via grep in Step 5). Avoids unnecessary React diagnostics on non-React changes.MODE=pr, subagents use worktree isolation — user's working tree never modified. No stashing, no checkout, no restore step needed.~/.agents/arinhub/code-reviews/ for future reference and audit.~/.agents/arinhub/diffs/, shared read-only across all subagents.MODE=local, Step 12 (Submit PR Review) is skipped — review output only to review file and presented to user.development
Use when: (1) building a skill/command that orchestrates other skills by spawning subagents, (2) a delegated sub-skill reads git working-tree state (e.g. `git branch --show-current`) instead of taking it as an argument, (3) a sub-skill is supposed to "reflect on this session" / capture session learnings (like revise-claude-md) but runs in a subagent, (4) base branch ends up wrong or a session-reflection step sees an empty/trivial context. Keywords: orchestrator, subagent isolated context, git branch --show-current, base branch checkout, revise-claude-md, this session.
development
Run the full ArinHub feature-development pipeline end-to-end with the "ah" prefix. Use for "ah workflow", "ah run workflow", "ah full workflow", a GitHub issue URL to take from issue to PR, or any request to run the whole ah pipeline at once. Takes a feature description + issue number + base branch, OR a GitHub issue URL (resolved via references/resolve-gh-issue.md). Sequentially launches subagents: ah-create-prd-adr -> ah-create-tasks -> ah-implement-tasks -> optional ah-check-qa verification -> ah-finalize-code (creates the PR), anchored with /goal and guarded by retry + escalation.
testing
Verify that a PR or local changes fully implement requirements from a linked GitHub issue, with the "ah" prefix. Use for "ah verify requirements coverage", "ah verify requirements coverage issue 42", "ah verify requirements coverage PR 123", or both ("PR 123, issue 42").
development
Submit a completed code review with line-specific comments and suggestions to a GitHub PR, with the "ah" prefix. Use for "ah submit code review 123".