.claude/skills/step-02-analyze-pr/SKILL.md
# step-02-analyze-pr ## What it does Opens the PR on GitHub, reads the title and description, and gathers high-level context about what the PR changes and why. This context is essential for evaluating the review comment accurately. ## Prerequisites - Step 01 completed (inputs parsed into `task_info.md`) ## Context > See `docs/steps/step1.md` and `docs/steps/step3.md` for reference. ## Arguments - `id` (required): Task ID ## Instructions ### 1. Recover context Find the task directory and r
npx skillsauth add Pepe39/chameleon-pr .claude/skills/step-02-analyze-prInstall 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.
Opens the PR on GitHub, reads the title and description, and gathers high-level context about what the PR changes and why. This context is essential for evaluating the review comment accurately.
task_info.md)See
docs/steps/step1.mdanddocs/steps/step3.mdfor reference.
id (required): Task IDFind the task directory and read task_info.md to get PR URL, nwo, head_sha, file_path, diff_line.
Update progress.md: step 02 status = "in-progress", Started = {timestamp ISO 8601}.
The head_sha from the task inputs is the tip of the PR branch, but the review comment may have been made on an earlier commit within the PR. Use the GitHub API to resolve the exact commit the comment was anchored to.
gh api repos/{nwo}/pulls/comments/{comment_id} --jq '.original_commit_id'
comment_commit.task_info.md:
Warning: Could not resolve comment_commit from GitHub API. This may indicate a force push that removed the original commit. Set
comment_committo the API-returned value anyway. Do NOT silently fall back tohead_sha.
task_info.md Input Data section: set **Comment Commit:** to the resolved value.The pipeline uses comment_commit (not head_sha) for cloning the repo and verifying whether the problem exists. head_sha is still used for the PR diff (section 3) because the diff should reflect the full PR scope.
After resolving comment_commit, verify it exists in the PR's commit history:
gh api repos/{nwo}/pulls/{pr_number}/commits --paginate --jq '.[].sha' | grep -Fxq "{comment_commit}"
task_info.md:
Force Push Detected: The original commit ({comment_commit}) does not appear in the PR commit history. The comment is orphaned. Set a flag
orphan = truefor step-03. Skip the repo clone (section 5). Step-03 will evaluate using only the comment body and suggestion block.
Use gh CLI to get PR details:
# Extract PR number from the URL
# e.g., https://github.com/owner/repo/pull/123 -> 123
gh pr view {pr_number} --repo {nwo} --json title,body,files,additions,deletions,changedFiles
Extract and record:
Important: The diff must reflect the PR state at head_sha from the task inputs, not the current PR state. The PR may have been updated after the comment was made, so gh pr diff (which returns the current diff) can be stale or different.
Use the GitHub compare API to get the diff at the exact head_sha:
gh api repos/{nwo}/compare/main...{head_sha} --jq '.files[] | {filename, patch, status}'
If the above fails or returns incomplete data, fall back in this order:
gh pr diff {pr_number} --repo {nwo}curl -sL https://github.com/{nwo}/pull/{pr_number}.diff (works for public repos with no auth, add -H "Authorization: Bearer $GH_TOKEN" for private)Both fallbacks return the current PR diff, not the one at head_sha. If you use either, add a warning to task_info.md:
Warning: Diff fetched from current PR state, not from head_sha. The PR may have been updated after the comment was made. Verify diff accuracy against the comment's diff_hunk if results seem inconsistent.
Save the full diff to tasks/{date}/{id}/work/pr_diff.txt for reference.
From the diff, extract the section relevant to file_path and diff_line:
Clone the repository at the exact commit the reviewer commented on, so that subsequent steps see the code as it was when the comment was made.
Use comment_commit (resolved in section 2). If step 2b flagged the task as orphan (force push detected), skip this section entirely. The repo clone is not needed for orphan comments.
# Ensure clean state (handles interrupted reruns)
rm -rf "tasks/{date}/{id}/work/repo"
# Shallow clone of the exact commit the comment was made on
# IMPORTANT: Use git -C to avoid changing the working directory.
# Do NOT cd into the repo dir — cd does not persist across Bash tool
# calls and subsequent git commands would run in the project root,
# overwriting the project's own remote.
git init "tasks/{date}/{id}/work/repo"
git -C "tasks/{date}/{id}/work/repo" remote add origin "https://github.com/{nwo}.git"
git -C "tasks/{date}/{id}/work/repo" fetch --depth=1 origin {comment_commit}
git -C "tasks/{date}/{id}/work/repo" checkout FETCH_HEAD
After checkout, verify the commit matches comment_commit:
ACTUAL_SHA=$(git -C "tasks/{date}/{id}/work/repo" rev-parse HEAD)
if [ "$ACTUAL_SHA" != "{comment_commit}" ]; then
echo "SHA MISMATCH: expected {comment_commit}, got $ACTUAL_SHA"
fi
Verification outcomes:
Clone fails (network error, auth issue, repo too large):
- **Repo Clone:** FAILED — {error summary}gh api contents method.Clone succeeds but SHA does not match comment_commit:
- **Repo Clone:** SHA MISMATCH — expected {comment_commit}, got {actual_sha}Clone succeeds and SHA matches:
- **Repo Clone:** OK — work/repo/ (verified at {comment_commit})Add analysis section:
## Analysis
### PR Context
- **PR Title:** {title}
- **PR Description:** {description summary — 1-2 sentences}
- **Files Changed:** {N} files, +{additions} -{deletions}
- **Comment Commit:** {comment_commit} (resolved from original_commit_id) | fallback to head_sha
- **Repo Clone:** OK — work/repo/ (verified at {comment_commit}) | SHA MISMATCH | FAILED
- **Changed Files List:**
- {file1}
- {file2}
- ...
### Target File
- **File:** {file_path}
- **Diff Line:** {diff_line}
- **Language:** {coding_language}
Update progress.md: step 02 status = "done", Completed = {timestamp ISO 8601}, Current Step = 03 - Analyze Comment.
Note: The repo clone at work/repo/ is cleaned up by run.md after the task completes or the user stops.
testing
step-09-recheck
development
# step-08-generate-output ## What it does Compiles all four axis labels into the final JSON output, validates consistency, and generates the deliverable file ready for submission. ## Prerequisites - Steps 04-07 completed (all four axes labeled) ## Context > See `docs/steps/step10.md` for the submission checklist. ## Arguments - `id` (required): Task ID ## Instructions ### 1. Recover context Read `task_info.md` — extract all four labels and their reasoning from the Labels section. Update
testing
# step-07-label-advanced ## What it does Labels Axis 4 — Advanced. Derives the Advanced label from Context Scope using a deterministic mapping. ## Prerequisites - Step 06 completed (Context Scope labeled) ## Context > See `docs/axis-4-advanced.md` for the mapping rule and definitions. > See `DOCUMENTATION.md` section 7 (Axis 4) for the rationale. ## Arguments - `id` (required): Task ID ## Instructions ### 1. Recover context Read `task_info.md` — specifically the Context Scope label from s
documentation
# step-06-label-context-scope ## What it does Labels Axis 3 — Context Scope. Determines what level of context a reviewer would need to confidently make this comment and documents all evidence used. ## Prerequisites - Step 05 completed (Severity labeled) ## Context > See `docs/axis-3-context-scope.md` for definitions, evaluation criteria, and examples. > See `docs/steps/step8.md` for the step-by-step process. > See `DOCUMENTATION.md` sections 8 (FAQ), 9 (Common Mistakes), and 10 (Tips) for edg