Prompt directory
Impulse.directory
HomeBrowseStacks
Sign inSign upCreate an account
    command

    PR Fix all

    impulse-lab/pr-fix-allยทv1ยทupdated February 21, 2026
    Leonard Roussard
    Leonard Roussard@lionvsxยทImpulse Lab
    Content
    # PR Fix All Command
    ## Purpose
    Fetch all unresolved PR review comments across a range of PRs, analyze each against the current codebase, group similar issues, and interactively fix them one-by-one with user confirmation.
    ## Execution Steps
    ### Step 1: Gather All Unresolved Comments
    Fetch unresolved comments from all PRs in the specified range specified by the user (e.g. #2 to #5):
    If not specified ask the user a list (#2, #4, #5), a range (#4 to #7) or a mix (#2, #6 to #9, #11).
    `for pr in $(seq 2 18); do
      gh api graphql -f query='
      query($owner: String!, $repo: String!, $pr: Int!) {
        repository(owner: $owner, name: $repo) {
          pullRequest(number: $pr) {
            number
            title
            reviewThreads(first: 100) {
              nodes {
                id
                isResolved
                path
                line
                comments(first: 10) {
                  nodes {
                    author { login }
                    body
                    createdAt
                  }
                }
              }
            }
          }
        }
      }' -f owner=OWNER -f repo=REPO -F pr=$pr
    done
    `
    Store results in a structured format for processing.
    ### Step 2: Validate Each Comment
    For each unresolved comment, spawn a **background agent** to analyze:
    2.1 Check if Outdated
    `Analyze comment from PR #X at file:line
    - Read the CURRENT codebase at that location
    - Compare with what the comment references
    - Determine if the issue was already fixed in a later PR
    - Return: OUTDATED | STILL_RELEVANT
    `
    2.2 Check if Pertinent
    `Analyze if comment is pertinent:
    - Read the related code (API routes, types, schemas)
    - Check if the concern makes sense given the actual implementation
    - Examples of non-pertinent:
      - Comment asks for missing prop but API doesn't return it
      - Comment suggests type that doesn't match actual usage
    - Return: PERTINENT | NOT_PERTINENT (with reason)
    `
    2.3 Find Similar Comments
    `Compare this comment with all other comments:
    - Same file mentioned
    - Same concept/issue described
    - Same fix suggested
    - Group similar comments together
    `
    ### Step 3: Present Summary
    Output a summary of all comments categorized:
    `# PR Fix All Summary
    
    **PRs Analyzed:** #2 - #18
    **Total Unresolved Comments:** <count>
    
    ## Categorization
    
    ### โœ… Already Fixed (Outdated)
    | PR | File:Line | Summary | Fixed In |
    |----|-----------|---------|----------|
    | #3 | api/auth.ts:42 | Missing null check | PR #7 |
    | ... | ... | ... | ... |
    
    ### โŒ Not Pertinent
    | PR | File:Line | Summary | Reason |
    |----|-----------|---------|--------|
    | #5 | types/user.ts:15 | Missing email field | API returns username instead |
    | ... | ... | ... | ... |
    
    ### ๐Ÿ”ง To Fix (<count>)
    | # | PR(s) | File:Line | Summary | Priority |
    |---|-------|-----------|---------|----------|
    | 1 | #2, #7 | db/schema.ts:30 | Missing cascade delete | ๐Ÿ”ด |
    | 2 | #4 | api/chat.ts:88 | Unhandled error case | ๐ŸŸ  |
    | ... | ... | ... | ... | ... |
    
    \-\-\-
    Type `start` to begin fixing issues one-by-one.
    `
    ### Step 3.1: On User `start` - Resolve Outdated/Not Pertinent Comments
    **CRITICAL:** When user types `start`, immediately resolve ALL comments marked as "Already Fixed (Outdated)" or "Not Pertinent":
    1. **For each outdated comment**, resolve and reply:
    2. `gh api graphql -f query='mutation($id: ID!, $body: String!) {
      addPullRequestReviewThreadReply(input: {pullRequestReviewThreadId: $id, body: $body}) { comment { id } }
    }' -f id="THREAD_ID" -f body="This issue was already fixed in PR #X / commit Y."
    
    gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "THREAD_ID"}) { thread { isResolved } } }'
    `
    3. **For each not pertinent comment**, resolve and reply with the reason:
    4. `gh api graphql -f query='mutation($id: ID!, $body: String!) {
      addPullRequestReviewThreadReply(input: {pullRequestReviewThreadId: $id, body: $body}) { comment { id } }
    }' -f id="THREAD_ID" -f body="Not applicable: <reason from analysis>"
    
    gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "THREAD_ID"}) { thread { isResolved } } }'
    `
    5. Show confirmation:
    6. `โœ… Resolved X outdated comments and Y not pertinent comments.
    Now processing Z remaining issues...
    `
    ### Step 4: Interactive Fix Loop
    Process each issue one at a time:
    `\-\-\-
    ## Issue 1 of <total>
    
    ### Comment(s):
    > **PR #2** - @reviewer1 (2024-01-15):
    > "This cascade delete could cause orphaned records..."
    
    > **PR #7** - @reviewer2 (2024-01-20):
    > "Same concern as PR #2 - we need proper cascade handling"
    
    ### Current Code:
    <Show relevant code snippet from current codebase>
    
    ### Proposed Fix:
    <Describe the fix>
    
    ### Files to modify:
    - ๐ŸŸ  `db/schema/course.ts`
    - ๐ŸŸ  `server/routers/course/router.ts`
    
    \-\-\-
    **Is this fix appropriate?**
    - `yes` - Apply fix, stage, commit, and resolve comments
    - `no` - Skip this issue
    - `<feedback>` - Provide guidance for a different approach
    `
    ### Step 5: Apply Fix on Confirmation
    When user responds `yes`, **complete ALL steps below before showing the next issue**:
    1. **Apply the fix** using Edit/Write tools
    2. **Stage the changes:**
    3. `git add <modified-files>
    `
    4. **Commit with reference:**
    5. `git commit -m "fix: <summary>
    
    Addresses review comments from PR #X, #Y
    
    Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>"
    `
    6. **Resolve the comment threads:**
    7. `gh api graphql -f query="mutation { resolveReviewThread(input: {threadId: \"$thread_id\"}) { thread { isResolved } } }"
    `
    8. **Show confirmation message:**
    9. `โœ… **Issue X fixed and committed** (commit: abc1234)
    - Resolved N comment thread(s) on PR #Y, #Z
    `
    10. **Only then proceed to the next issue**
    **IMPORTANT:** Do NOT show the next issue until steps 1-5 are fully completed. Each fix must be atomic - applied, committed, and resolved before moving on.
    ### Step 6: Handle User Feedback
    If user provides feedback instead of `yes`:
    1. Re-analyze with the new context
    2. Propose updated fix
    3. Ask for confirmation again
    If user responds `no` **without explanation**:
    1. Mark issue as skipped (don't resolve comment)
    2. Move to next issue
    If user responds `no` **with explanation** (e.g., "no, because X is already defined elsewhere"):
    1. **Resolve the comment thread(s)** for this issue
    2. **Reply to the thread** with user's explanation, rephrased professionally:
    3. `gh api graphql -f query='mutation($id: ID!, $body: String!) {
      addPullRequestReviewThreadReply(input: {pullRequestReviewThreadId: $id, body: $body}) { comment { id } }
    }' -f id="THREAD_ID" -f body="Not applicable: <user's explanation rephrased>. See `path/to/file` for the existing implementation."
    
    gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "THREAD_ID"}) { thread { isResolved } } }'
    `
    4. Show confirmation:
    5. `โญ๏ธ **Issue X skipped and resolved** - <brief reason>
    `
    6. Move to next issue
    **GOAL: After this command completes, ALL PR comments should be resolved - either by fixing, marking as outdated, or explaining why not applicable.**
    ### Step 7: Final Summary
    After all issues processed:
    `# PR Fix All Complete
    
    ## Applied Fixes
    | # | PR(s) | File | Commit |
    |---|-------|------|--------|
    | 1 | #2, #7 | db/schema.ts | abc1234 |
    | 3 | #4 | api/chat.ts | def5678 |
    
    ## Skipped Issues
    | # | PR | File | Reason |
    |---|-----|------|--------|
    | 2 | #5 | types/user.ts | User skipped |
    
    ## Resolved Threads
    โœ“ Resolved <count> review threads across <count> PRs
    
    ## Validation
    - `pnpm lint` โœ“
    - `pnpm build` โœ“
    `
    ---
    ## Background Agent Instructions
    ### Agent: Comment Validator
    `Task: Validate PR comment against current codebase
    
    Input:
    - PR number
    - File path
    - Line number
    - Comment body
    - All other comments from PRs #2-#18
    
    Output (JSON):
    {
      "status": "OUTDATED" | "STILL_RELEVANT",
      "pertinent": true | false,
      "pertinentReason": "string if false",
      "fixedIn": "PR #X" | null,
      "similarComments": [
        { "pr": 7, "file": "...", "line": 42, "body": "..." }
      ],
      "currentCode": "snippet of current code at location",
      "suggestedFix": "brief description"
    }
    `
    ### Agent: Fix Applier
    `Task: Apply a specific fix to the codebase
    
    Input:
    - Issue description
    - Files to modify
    - Fix approach
    
    Output:
    - Modified files
    - Validation result (lint/build)
    - Commit hash
    `
    ---
    ## Priority Ordering
    Present issues in this priority order:
    1. ๐Ÿ”ด **Security issues** - Authorization, injection, data exposure
    2. ๐Ÿ”ด **Data integrity** - Wrong queries, missing validations, cascade issues
    3. ๐ŸŸ  **Bugs** - Logic errors, race conditions
    4. ๐ŸŸก **UX issues** - Stale state, missing error handling
    5. ๐Ÿ’ก **Minor** - Code style, optimizations
    ---
    ## Safety Guards
    1. **NEVER** apply fixes without explicit user `yes`
    2. **NEVER** skip the pertinence check - always validate against current code
    3. **NEVER** leave comments unresolved - every comment must be resolved with either a fix, an explanation, or marked as outdated
    4. **ALWAYS** show the original comment(s) before proposing a fix
    5. **ALWAYS** commit each fix separately for easy revert
    6. **ALWAYS** reply to resolved threads explaining why (fix applied, outdated, not applicable)
    7. **ALWAYS** use background agents to minimize context pollution
    ## Resolution Rules
    User ResponseAction`start`Resolve all outdated/not pertinent comments with explanations`yes`Apply fix, commit, resolve thread with "Fixed in commit X"`no` (bare)Skip, don't resolve (user may want to handle manually)`no, because...`Resolve thread with user's explanation`<feedback>`Re-propose fix, don't resolve yet
    ---
    ## Context Management
    - Use background agents (`run_in_background: true`) for:
        - Fetching and categorizing all comments
        - Validating each comment against codebase
        - Finding similar comments across PRs
    - Keep in main context:
        - The master list of issues to fix
        - Current issue being discussed with user
        - User's decisions (yes/no/feedback)
    ---
    ## Metadata
    `version: 2026.02.12.2
    `

    Install with the impulse CLI

    $npx @impulselab/directory impulselab/pr-fix-all

    Stats

    Views
    38
    Saves
    0

    Owner

    impulse-logo

    Impulse Lab

    Official artifact