skills/ah-submit-code-review/SKILL.md
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".
npx skillsauth add arinhubcom/arinhub ah-submit-code-reviewInstall 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.
Submit structured code review with line-specific comments to GitHub PR. Identifies issues in current chat session or review file, checks duplicate comments, submits review.
123#123https://github.com/owner/repo/pull/123ah-review-code (e.g., ~/.agents/arinhub/code-reviews/code-review-pr-my-app-123.md). If provided, extract issues from this file instead of current chat session.Extract PR number from user input. Strip # prefix or parse number from URL. Resolve repo owner and name for API calls.
PR_NUMBER=<extracted number>
REPO_OWNER=$(gh repo view --json owner -q '.owner.login')
REPO_NAME=$(basename -s .git "$(git remote get-url origin)")
gh pr view $PR_NUMBER --json number,title,body,baseRefName,headRefName,files,url
Check whether coverage data already available:
## Requirements Coverage section. If yes, extract coverage percentage and summary -- done.ah-verify-requirements-coverage invocation (sections starting ## Requirements Coverage:). If found, use it -- done./ah-verify-requirements-coverage skill:
If subagent cannot find linked issue (e.g., PR body has no closing keywords, no explicit issue reference), proceed without coverage data -- main review comment will note coverage data unavailable.
Retrieve all existing review comments to prevent duplication. Use
scripts/gh-summarize.sh wrapper (resolve path relative to this SKILL.md's
directory) -- projects each item to a few fields, truncates long bodies,
caps item count so busy PR does not flood context (true total
printed to stderr):
# Inline review comments (id, path, line, truncated body, user)
<skill_dir>/scripts/gh-summarize.sh \
"repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/comments" \
'{id, path, line, body, user: .user.login}'
Also fetch top-level review bodies:
<skill_dir>/scripts/gh-summarize.sh \
"repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/reviews" \
'{id, body, state, user: .user.login}'
Each emitted line is one compact JSON object. For deduplication (Step 6) only
path/line/body of each existing comment matters.
Get issue list from one source (priority order):
ah-review-code orchestrator), read file and extract all issues from ## Issues section.For each issue, record:
severity: One of High Priority, Medium Priority, Low Prioritytitle: Short descriptive title (e.g., "Unvalidated user input passed to SQL query")path: Relative file pathfile_in_diff: Whether file appears in PR diff (true or false). Issues with file_in_diff: false cannot be posted as inline thread comments -- included in main review body instead (see Step 8).line: Specific line number in new version of file. For multi-line issues, this is the last line of range.start_line (optional): First line of multi-line range. Set only when issue spans more than one line.explanation: Concise, actionable comment explaining issue (the "why", not just the "what")suggestion (optional): Raw replacement code for concrete fix. Set only for simple, contiguous changes (see Suggestion conversion rules). When set, this code replaces lines start_line (or line) through line verbatim. Do not include ```suggestion fences -- added automatically in Step 8. For complex suggestions (multiple diff blocks or non-contiguous changes), do not set this field; instead append diff block(s) to explanation.When issue list comes from review file (source 1 above), file uses
different format than submission API. Read
references/parse-review-file.md for
field-mapping table and suggestion-conversion rules (when to emit GitHub
suggestion vs. append diff to explanation). Skip that reference when
issues come from current chat session (source 2).
For each issue from Step 5, compare against existing comments from Step 4:
path and line (or nearby range +/- 5 lines) already addresses same concernSubmit single review via GitHub API. Review consists of one main review comment with individual thread comments appearing as conversation threads anchored to specific lines in diff.
Main review comment (body): You MUST use the Read tool to read references/main-review-comment.md before composing the main review body. Follow its template and formatting exactly.
Thread comments (comments[].body): You MUST use the Read tool to read references/thread-comment.md before composing any thread comment. Follow its template and formatting exactly.
Before building payload, split deduplicated issues into two groups:
file_in_diff: true): Posted as thread comments anchored to specific lines in diff.file_in_diff: false): Cannot be posted as thread comments (API would reject them). Instead appended to main review body as dedicated section. However, only include a non-diff issue if directly relevant to PR body context (e.g., the change described in PR description or files/features the PR touches) or requirements coverage context (e.g., a requirement from linked issue the PR should address). If a non-diff issue falls outside both contexts, drop it -- do not include in review body. The issues table in Step 9 will still list all non-diff issues, but "Reason" column will explain why any non-diff issue was excluded from review body."REQUEST_CHANGES" if any issue (inline or non-diff) with severity High Priority or Medium Priority remains after deduplication."APPROVE" if all remaining issues (inline and non-diff) are Low Priority only.Each entry in comments uses one of two shapes depending on whether issue targets a single line or a range of lines:
Single-line comment -- targets exactly one line in diff:
{
"path": "src/auth.ts",
"line": 42,
"side": "RIGHT",
"body": "<thread-comment>"
}
Required fields: path, line, side.
Multi-line comment -- targets range from start_line through line (both inclusive, both must be within same diff hunk):
{
"path": "src/utils.ts",
"start_line": 10,
"line": 14,
"start_side": "RIGHT",
"side": "RIGHT",
"body": "<thread-comment>"
}
Required fields: path, start_line, line, start_side, side. Suggestion content replaces all lines from start_line through line verbatim.
Run before submission:
jq . >/dev/null)path, line, side: "RIGHT"start_line and start_side: "RIGHT"line (and start_line for ranges) falls inside PR diff hunk for that filebody that includes suggestion contains ```suggestion ``` fences wrapping raw replacement code```suggestion\n```) only when intent is to delete selected line(s)Build JSON payload with all comments (single-line and multi-line mixed) and submit:
gh api repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/reviews \
--method POST \
--input - <<'EOF'
{
"event": "<APPROVE or REQUEST_CHANGES per 'Determining event type' above>",
"body": "<main-review-comment>",
"comments": [
{
"path": "src/auth.ts",
"line": 42,
"side": "RIGHT",
"body": "<thread-comment>"
},
{
"path": "src/utils.ts",
"start_line": 10,
"line": 14,
"start_side": "RIGHT",
"side": "RIGHT",
"body": "<thread-comment>"
}
]
}
EOF
If API returns error (e.g., 422 Unprocessable Entity):
path/line that is invalid).line or start_line falls outside PR diff hunk. For each failing comment:
gh pr diff $PR_NUMBER and locate @@ headers for the file).line value falls within one of hunk ranges. If not, adjust line to nearest valid line within hunk, or drop comment if no valid line exists.Present summary of review submission to user, including:
You MUST output a markdown table listing every issue from Step 5 with submission status and reason. Never omit this table, even when all issues skipped. Use this format:
| # | Severity | File | Line(s) | Title | Status | Reason |
| --- | --------------- | ------------------- | ------- | ------------------------------ | -------------- | --------------------------------- |
| 1 | High Priority | src/auth.ts | 42 | Unvalidated input | Submitted | — |
| 2 | Medium Priority | src/utils.ts | 10-14 | Missing null check | Skipped | Duplicate of existing comment |
| 3 | Medium Priority | src/api.ts | 88 | Unused variable | Skipped | Line outside diff hunk |
| 4 | Medium Priority | src/db.ts | 22 | SQL injection risk | Failed | API error 422 — retry also failed |
| 5 | Low Priority | src/validators.ts | 15-22 | Shared helper duplicates logic | In review body | File not in diff |
Status values:
—file_in_diff: false), so issue included in main review body under "Additional issues outside the diff" section. Reason: File not in diffIf no review submitted (Step 7), explain no new issues found beyond existing review comments and still show table with all issues marked skipped. List all issues in descending severity order (High → Medium → Low).
line field in review comments must reference a line that appears in diff -- comments on unchanged lines will be rejected by APIstart_line and line together to define range being replaced; both must be within diff hunk```suggestion\n```) means "delete these lines"```suggestion ``` replaces selected line(s) verbatim -- ensure correct indentation and formattingdevelopment
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
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).