You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary: Consolidate duplicated GraphQL review-thread pagination logic into a shared shell helper, then migrate both PR-review and mention-in-PR scripts to use it.
Problem
Two production scripts independently implement nearly identical paginated GraphQL fetch logic for review threads and nested comments, which increases maintenance cost and drift risk:
claude-workflows/pr-review/scripts/pr-existing-comments.sh (previously had inline fetch_review_threads_page, fetch_thread_comments_page, and pagination loops)
claude-workflows/mention-in-pr/scripts/gh-get-review-threads.sh (still has the same structure)
claude-workflows/pr-review/scripts/pr-existing-comments.sh had the same logic before the PoC extraction (now replaced by helper call at :23-25 and :64-79).
UV_CACHE_DIR=/tmp/gh-aw/agent/uv-cache PATH="/tmp/gh-aw/agent/uvenv/bin:$PATH" make test โ (53 passed)
Incremental Rollout Plan
This refactor can be completed incrementally:
Done (PoC): Extract helper and migrate pr-existing-comments.sh.
Next slice: Migrate claude-workflows/mention-in-pr/scripts/gh-get-review-threads.sh to the shared helper while preserving JSON output contract.
Remaining work: Add focused regression coverage for helper-driven behavior in both workflows and remove any residual duplicated pagination code.
Risks and Mitigations
Risk: Output-shape regressions in consumer scripts. Mitigation: Preserve existing field lists per caller and keep tests asserting exact structure.
Risk: Over-generalized helper interface becomes hard to read. Mitigation: Keep helper scope strictly to pagination/fetch; leave filtering/formatting in caller scripts.
๐๏ธ Refactor Proposal
Summary: Consolidate duplicated GraphQL review-thread pagination logic into a shared shell helper, then migrate both PR-review and mention-in-PR scripts to use it.
Problem
Two production scripts independently implement nearly identical paginated GraphQL fetch logic for review threads and nested comments, which increases maintenance cost and drift risk:
claude-workflows/pr-review/scripts/pr-existing-comments.sh(previously had inlinefetch_review_threads_page,fetch_thread_comments_page, and pagination loops)claude-workflows/mention-in-pr/scripts/gh-get-review-threads.sh(still has the same structure)Concrete evidence:
claude-workflows/mention-in-pr/scripts/gh-get-review-threads.sh:27-180contains duplicate page-fetch + cursor loops (THREADS_AFTER,HAS_NEXT_THREADS, nested comment pagination).claude-workflows/pr-review/scripts/pr-existing-comments.shhad the same logic before the PoC extraction (now replaced by helper call at:23-25and:64-79).git log --since="60 days ago" -- claude-workflows/pr-review/scripts/pr-existing-comments.sh claude-workflows/mention-in-pr/scripts/gh-get-review-threads.shshows shared fix commit707fc67(โpaginate GraphQL review thread fetches in PR helper scriptsโ).Proposed Approach
Create a shared helper that encapsulates:
reviewThreadspages.commentspages.Keep each workflow script as a thin adapter that supplies only field selections/output shaping and workflow-specific filtering behavior.
Proof of Concept
I partially implemented this refactor on one representative slice (
pr-review) to verify viability.Files changed:
claude-workflows/scripts/gh-fetch-review-threads.sh(new shared helper)claude-workflows/pr-review/scripts/pr-existing-comments.sh(migrated to helper)Before โ After:
pr-existing-comments.shcarried ~170 lines of inline pagination/query logic.Shared abstraction now lives in:
claude-workflows/scripts/gh-fetch-review-threads.sh:3-184Verification:
make lintโUV_CACHE_DIR=/tmp/gh-aw/agent/uv-cache PATH="/tmp/gh-aw/agent/uvenv/bin:$PATH" make testโ (53 passed)Incremental Rollout Plan
This refactor can be completed incrementally:
pr-existing-comments.sh.claude-workflows/mention-in-pr/scripts/gh-get-review-threads.shto the shared helper while preserving JSON output contract.Risks and Mitigations
Mitigation: Preserve existing field lists per caller and keep tests asserting exact structure.
Mitigation: Keep helper scope strictly to pagination/fetch; leave filtering/formatting in caller scripts.
Evidence
claude-workflows/mention-in-pr/scripts/gh-get-review-threads.sh:27-180claude-workflows/pr-review/scripts/pr-existing-comments.sh:23-25,64-79claude-workflows/scripts/gh-fetch-review-threads.sh:3-184707fc67(recent co-change fix across both scripts)Note
๐ Integrity filter blocked 26 items
The following items were blocked because they don't meet the GitHub integrity level.
search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter:What is this? | From workflow: Trigger Refactor Opportunist
Give us feedback! React with ๐ if perfect, ๐ if helpful, ๐ if not.