一键导入
sweep
Check all open PRs, resolve conflicts, update branches, address Claude and Greptile review concerns, fix CI failures, and retrigger reviewers until clean
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Check all open PRs, resolve conflicts, update branches, address Claude and Greptile review concerns, fix CI failures, and retrigger reviewers until clean
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Adopt extracted helpers — find dead symbols from forge, wire them into consumers, replace duplicated inline patterns, and gate on dead-symbol delta (Titan Paradigm Phase 4.5)
Adopt extracted helpers — find dead symbols from forge, wire them into consumers, replace duplicated inline patterns, and gate on dead-symbol delta (Titan Paradigm Phase 4.5)
Validate staged changes — codegraph checks + project lint/build/test, auto-rollback on failure, pass/fail commit gate (Titan Paradigm Phase 4)
Audit codebase files against the 4-pillar quality manifesto using RECON work batches, with batch processing and context budget management (Titan Paradigm Phase 2)
Map a codebase's dependency graph, identify hotspots, name logical domains, propose work batches, and produce a ranked priority queue for autonomous cleanup (Titan Paradigm Phase 1)
Local repo maintenance — clean stale worktrees, remove dirt files, sync with main, update codegraph, prune branches, and verify repo health
| name | sweep |
| description | Check all open PRs, resolve conflicts, update branches, address Claude and Greptile review concerns, fix CI failures, and retrigger reviewers until clean |
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep, Agent |
You are performing a full review sweep across all open PRs in this repository. Your goal is to bring every PR to a clean, mergeable state: no conflicts, CI passing, all reviewer comments addressed, and reviewers re-triggered until satisfied.
Before doing anything else, run /worktree to get an isolated copy of the repo. CLAUDE.md mandates that every session starts with /worktree to prevent cross-session interference. All subsequent steps run inside the worktree.
gh pr list --repo optave/codegraph --state open --json number,title,headRefName,baseRefName,mergeable,statusCheckRollup,reviewDecision --limit 50
Record each PR's number, branch, base, merge status, and CI state.
Each PR is independent work — launch one Agent subagent per PR, all in parallel. Use isolation: "worktree" so each agent gets its own copy of the repo with no cross-PR contamination.
Pass each agent the full PR processing instructions (Steps 2a–2i below) along with the PR number, branch, base, and current state from Step 1. The agent prompt must include all the rules from the Rules section at the bottom of this skill — copy them verbatim, do not paraphrase or summarize.
For each PR, launch an Agent with:
- description: "Review PR #<number>"
- isolation: "worktree"
- prompt: <the full PR processing instructions below, with PR details filled in>
Launch all PR agents in a single message (one tool call per PR) so they run concurrently. Do NOT wait for one to finish before starting the next.
Each agent will return a result summary. Collect all results for the final summary table in Step 3.
The following steps are executed by each subagent for its assigned PR.
gh pr checkout <number>
Check if the PR has conflicts with its base branch:
gh pr view <number> --json mergeable --jq '.mergeable'
If CONFLICTING:
git merge origin/<base-branch>
gh pr view <number>) to understand the PR's purpose and scope.git log --oneline origin/<base-branch>..HEAD -- <file>) to understand why the conflicting line was changed on the PR side. Also check the base branch history (git log --oneline HEAD..origin/<base-branch> -- <file>) to understand why the base version exists.gh api repos/optave/codegraph/pulls/<number>/comments, gh api repos/optave/codegraph/pulls/<number>/reviews, gh api repos/optave/codegraph/issues/<number>/comments) — a reviewer may have requested the change that caused the conflict.git log --oneline HEAD..origin/<base-branch> -- <file>) and read those PR descriptions too if needed.git diff $(git merge-base origin/<base-branch> HEAD) HEAD -- <file>) to see which side introduced an intentional change vs. which side carried stale code.git add .), commit with: fix: resolve merge conflicts with <base-branch># Check nothing was lost from the base branch (main)
git diff origin/<base-branch> -- <file>
# Check nothing was lost from the PR branch (ORIG_HEAD = pre-merge HEAD, set by git automatically)
git diff ORIG_HEAD -- <file>
Review each diff to confirm that intentional changes from both sides survived the merge. If content was dropped, amend the resolution before pushing.gh pr checks <number>
If any checks are failing:
gh run view <run-id> --log-failed
npm testnpm run lintfix: <what was broken and why>gh pr checks <number>
Fetch all review comments from both Claude and Greptile. You MUST check all three endpoints — Claude's feedback often appears in the /reviews and /comments endpoints, not just issue comments:
# PR review comments (inline code comments — Claude and Greptile both use these)
gh api repos/optave/codegraph/pulls/<number>/comments --paginate --jq '.[] | {id: .id, user: .user.login, body: .body, path: .path, line: .line, created_at: .created_at}'
# PR reviews (top-level review bodies — Claude typically posts CHANGES_REQUESTED or COMMENT reviews here)
gh api repos/optave/codegraph/pulls/<number>/reviews --paginate --jq '.[] | {id: .id, user: .user.login, body: .body, state: .state}'
# Issue-style comments (includes @greptileai trigger responses and general discussion)
gh api repos/optave/codegraph/issues/<number>/comments --paginate --jq '.[] | {id: .id, user: .user.login, body: .body, created_at: .created_at}'
Important: Go through the results from ALL three endpoints. Build a complete list of actionable items from every reviewer before starting fixes. Do not skip any reviewer's comments.
Greptile posts a top-level summary (a ### Greptile Summary issue comment carrying a Confidence Score: N/5 and a prose review; occasionally posted as a review body instead). That summary routinely raises actionable findings that are NOT mirrored as inline review comments — e.g. a "Safe to merge after addressing two gaps: First… Second…" paragraph, a per-row concern in the Important Files Changed table ("Two logic gaps: …"), or a "Note on …" caveat. A sweep that only iterates the inline comments from the gather step silently misses these — it is the single most common way a Greptile concern survives a sweep unaddressed.
So treat the summary as a source of findings, not a single comment to reply to. Pull it in full (never truncate — findings hide in the prose):
# Greptile summary as an issue comment (the usual location):
gh api repos/optave/codegraph/issues/<number>/comments --paginate \
--jq '.[] | select(.user.login|test("greptile";"i")) | .body'
# …and as a review body (Greptile sometimes posts the summary here instead):
gh api repos/optave/codegraph/pulls/<number>/reviews --paginate \
--jq '.[] | select(.user.login|test("greptile";"i")) | .body'
From that body, extract every distinct finding as its own actionable item:
< 5 always names at least one gap;For each finding, check whether a matching inline comment exists. If it does, you'll handle it in the address-comments step. If it does NOT, it is still a real finding — add it to your actionable list and fix it (or, if genuinely out of scope, file a tracked follow-up issue and reply). Never assume the inline comments are the complete set — reconcile your fixes against the summary before declaring the PR ready.
You must address comments from all reviewers — Claude (claude-code-review bot), Greptile, and any humans. Do not only address one reviewer's comments and skip another's. Process each reviewer's feedback systematically.
For each review comment — including minor suggestions, nits, style feedback, and optional improvements:
Read the comment carefully. Understand what the reviewer is asking for.
Read the relevant code at the file and line referenced.
Make the change. Even if the comment is marked as "nit" or "suggestion" or "minor" — address it. The goal is zero outstanding comments.
If you disagree with a suggestion (e.g., it would introduce a bug or contradicts project conventions), do NOT silently ignore it. Reply to the comment explaining why you chose a different approach.
If the fix is genuinely out of scope for this PR, you MUST create a GitHub issue to track it before replying. Never reply with "acknowledged as follow-up" or "noted for later" without a tracked issue — untracked deferrals get lost and nobody will ever revisit them. "Genuinely out of scope" means the fix touches a different module not in the PR's diff, requires an architectural decision beyond the PR's mandate, or would introduce unrelated risk. Fixing a variable name, adding a null check, or adjusting a string in a file already in the diff is NOT out of scope — just do it.
# Ensure the follow-up label exists (safe to re-run)
gh label create "follow-up" --color "0e8a16" --description "Deferred from PR review" --repo optave/codegraph 2>/dev/null || true
# Create a tracking issue for the deferred item and capture the issue number
issue_url=$(gh issue create \
--repo optave/codegraph \
--title "follow-up: <concise description of what needs to be done>" \
--body "$(cat <<-'EOF'
Deferred from PR #<number> review.
**Original reviewer comment:** <use the correct permalink format for the comment type: inline review comment → `https://github.com/optave/ops-codegraph-tool/pull/<number>#discussion_r<comment-id>`, top-level review body → `https://github.com/optave/ops-codegraph-tool/pull/<number>#pullrequestreview-<review-id>`, issue-style comment → `https://github.com/optave/ops-codegraph-tool/issues/<number>#issuecomment-<comment-id>`>
**Context:** <why this is out of scope for the current PR and what the fix entails>
EOF
)" \
--label "follow-up")
issue_number=$(echo "$issue_url" | grep -oE '[0-9]+$')
Then reply to the reviewer comment referencing the issue (using $issue_number captured above). Use the same reply mechanism as step 6 below — inline PR review comments use /pulls/<number>/comments/<comment-id>/replies, top-level review bodies and issue-style comments use /issues/<number>/comments:
# For inline PR review comments:
gh api repos/optave/codegraph/pulls/<number>/comments/<comment-id>/replies \
-f body="Out of scope for this PR — tracked in #$issue_number"
# For top-level review bodies or issue-style comments:
gh api repos/optave/codegraph/issues/<number>/comments \
-f body="Out of scope for this PR — tracked in #$issue_number"
Reply to each comment explaining what you did. The reply mechanism depends on where the comment lives:
For inline PR review comments (from Claude, Greptile, or humans — these have a path and line):
gh api repos/optave/codegraph/pulls/<number>/comments/<comment-id>/replies \
-f body="Fixed — <brief description of what was changed>"
For top-level PR review bodies (Claude often leaves a summary review with CHANGES_REQUESTED or COMMENT state — these come from the /reviews endpoint and have no path):
# Reply on the PR conversation thread so the reviewer sees it
gh api repos/optave/codegraph/issues/<number>/comments \
-f body=$'Addressed Claude\'s review feedback:\n- <bullet per item addressed>'
For issue-style comments (includes @greptileai trigger responses):
gh api repos/optave/codegraph/issues/<number>/comments \
-f body="Addressed: <summary of changes made>"
Checklist before moving on: After addressing all comments, verify you haven't missed a reviewer:
# List all unique reviewers who left comments
gh api repos/optave/codegraph/pulls/<number>/comments --paginate --jq '[.[].user.login] | unique | .[]'
gh api repos/optave/codegraph/pulls/<number>/reviews --paginate --jq '[.[].user.login] | unique | .[]'
gh api repos/optave/codegraph/issues/<number>/comments --paginate --jq '[.[].user.login] | unique | .[]'
# Confirm you addressed comments from EVERY reviewer listed
After addressing all comments for a PR:
fix: <what this specific change does> (#<number>)git commit --amend -m "correct message" then git push --force-with-lease.git commit <file1> <file2> -m "msg") instead of staging first.Greptile: Always re-trigger after replying to Greptile comments — whether the comment was actionable or not. First, run the verification script below to confirm all Greptile comments have replies. Then, skip the actual trigger only if Greptile already reacted to your most recent reply with a positive emoji (thumbs up, check, etc.), which means it is already satisfied.
CRITICAL — verify all Greptile comments have replies BEFORE triggering. Posting @greptileai without replying to every comment is worse than not triggering at all — it starts a new review cycle while the old one still has unanswered feedback. Run this check first:
# Step 0: Verify every Greptile inline comment has at least one reply from us
all_comments=$(gh api repos/optave/codegraph/pulls/<number>/comments --paginate)
greptile_comment_ids=$(echo "$all_comments" \
| jq -r '[.[] | select(.user.login == "greptile-apps[bot]" and .in_reply_to_id == null)] | .[].id')
unanswered=()
for cid in $greptile_comment_ids; do
reply_count=$(echo "$all_comments" \
| jq -s "[.[][] | select(.in_reply_to_id == $cid and .user.login != \"greptile-apps[bot]\")] | length")
if [ "$reply_count" -eq 0 ]; then
unanswered+=("$cid")
fi
done
if [ ${#unanswered[@]} -gt 0 ]; then
echo "BLOCKED — ${#unanswered[@]} Greptile comments have no reply: ${unanswered[*]}"
echo "Go back to Step 2e and reply to each one before re-triggering."
exit 1
fi
echo "All Greptile comments have replies — safe to re-trigger."
Do NOT proceed to the re-trigger step below until the check above passes. If any comments are unanswered, go back to Step 2e, reply to each one, then re-run this check.
# Step 1: Check if greptileai left a positive reaction on your most recent reply
last_reply_id=$(gh api repos/optave/codegraph/issues/<number>/comments --paginate \
--jq '[.[] | select(.user.login != "greptile-apps[bot]")] | last | .id')
positive_count=$(gh api repos/optave/codegraph/issues/comments/$last_reply_id/reactions \
--jq '[.[] | select(.user.login == "greptile-apps[bot]" and (.content == "+1" or .content == "hooray" or .content == "heart" or .content == "rocket"))] | length')
# Step 2: If positive reaction exists → skip. Otherwise → re-trigger.
if [ "$positive_count" -gt 0 ]; then
echo "Greptile already reacted positively — skipping re-trigger."
else
gh api repos/optave/codegraph/issues/<number>/comments -f body="@greptileai"
fi
Claude (claude-code-review / claude bot): Only re-trigger if you addressed something Claude specifically suggested. If you did:
gh api repos/optave/codegraph/issues/<number>/comments \
-f body="@claude"
If all changes were only in response to Greptile feedback, do NOT re-trigger Claude.
After re-triggering:
At the end of processing, the subagent MUST return a structured result with these fields so the main agent can build the summary table:
PR: #<number>
Branch: <branch-name>
Conflicts: resolved | none
CI: green | red | pending
Comments Addressed: <count>
Issues: <comma-separated list of #<n> follow-up issues, or "none">
Reviewers Re-triggered: <list>
Status: ready | needs-work | needs-human-review | skipped
Notes: <any issues encountered>
After all subagents complete, collect their results and output a summary table:
| PR | Branch | Conflicts | CI | Comments Addressed | Issues | Reviewers Re-triggered | Status |
|----|--------|-----------|----|--------------------|--------|----------------------|--------|
| #N | branch | resolved/none | green/red | N comments | #X, #Y or none | greptile, claude | ready/needs-work |
If any subagent failed or returned an error, note it in the Status column as agent-error with the failure reason.
git merge <base> to resolve conflicts.git push --force-with-lease), (2) guard-git blocks staged files not in session edit log → use git commit <file1> <file2> -m "msg" with explicit paths, (3) branch name validation fails → you're on the wrong branch.Confidence Score: N/5 with N < 5 always names at least one gap in prose, and those gaps frequently have no inline comment. Extract every finding from the summary and fix it (or file a tracked follow-up). Missing a summary-only finding is the #1 way a Greptile concern survives a sweep — reconcile your fixes against the summary before declaring the PR ready.@greptileai without replying to every Greptile comment first. Before posting the re-trigger, run the Step 2g verification script to confirm zero unanswered Greptile comments. Triggering a new review while old comments are unanswered is a blocking violation — it creates review noise and signals that feedback was ignored. Reply first, verify, then trigger.src/ or test changes from a merged feature branch), flag it immediately. Split the unrelated changes into a separate branch and PR. Do not proceed with review until the PR is scoped correctly — scope creep is not acceptable.follow-up label and include the issue link in your reply. Untracked acknowledgements are the same as ignoring the comment — they will never be revisited.