Work Through Pr Comments
Methodically work through GitHub pull request comments in a conversational workflow, analyzing each comment, presenting solution…
Claude CodeGeneric
---
name: work-through-pr-comments
description: Methodically work through GitHub pull request comments in a conversational workflow, analyzing each comment, presenting solution options, gathering your decisions, and implementing approved changes.
argument-hint: <pr-number> OR <owner/repo> <pr-number>
allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*), AskUserQuestion(*), mcp__github__get_pull_request(*), mcp__github__get_pull_request_comments(*), mcp__github__get_pull_request_reviews(*)
---
# Work Through PR Comments
Methodically work through GitHub pull request comments in a conversational workflow, analyzing each comment, presenting solution options, gathering your decisions, and implementing approved changes.
## Usage
```bash
/work-through-pr-comments <pr-number> # Work through comments on PR in current repo
/work-through-pr-comments <owner/repo> <pr-number> # Work through comments on PR in specific repo
Examples
/work-through-pr-comments 154 # Work through comments on PR #154 in current repo
/work-through-pr-comments labs-solo/aegis-engine 154 # Work through comments on PR #154 in labs-solo/aegis-engine
Workflow Overview
This command implements a conversational, methodical workflow for addressing PR comments:
- Fetch PR Details: Get PR information, reviews, and inline comments
- Analyze Each Comment: For each comment, provide context and analysis
- Present Options: Suggest multiple solution approaches with pros/cons
- Gather Decisions: Ask you which approach to take
- Implement Changes: Make the approved changes
- Verify: Test and validate the changes
- Repeat: Move to next comment until all are addressed
- Commit: Offer to create a single commit with all changes
Input Parameters
Required
- pr-number: The pull request number (e.g.,
154)
Optional
- owner/repo: Repository in format
owner/repo(defaults to current repo detected from git remote)
Step-by-Step Implementation
Step 1: Parse Input and Detect Repository
// Parse command arguments
const args = userInput.trim().split(/\s+/);
let owner: string;
let repo: string;
let prNumber: number;
if (args.length === 1) {
// Format: /work-through-pr-comments 154
// Detect from current git remote
const remoteUrl = await Bash('git config --get remote.origin.url');
// Parse owner/repo from: git@github.com:owner/repo.git or https://github.com/owner/repo.git
const match = remoteUrl.match(/github\.com[:/]([^/]+)\/([^/.]+)/);
if (!match) {
throw new Error(
'Could not detect repository from git remote. Use: /work-through-pr-comments <owner/repo> <pr-number>',
);
}
[, owner, repo] = match;
prNumber = parseInt(args[0]);
} else if (args.length === 2) {
// Format: /work-through-pr-comments owner/repo 154
[owner, repo] = args[0].split('/');
prNumber = parseInt(args[1]);
} else {
throw new Error(
'Usage: /work-through-pr-comments <pr-number> OR /work-through-pr-comments <owner/repo> <pr-number>',
);
}
// Validate PR number
if (isNaN(prNumber) || prNumber <= 0) {
throw new Error(`Invalid PR number: ${args[args.length - 1]}`);
}
console.log(`Analyzing PR #${prNumber} in ${owner}/${repo}...`);
Step 2: Fetch PR Data
Fetch all PR-related data in parallel for efficiency:
// Fetch PR details, comments, and reviews in parallel
const [prDetails, prComments, prReviews] = await Promise.all([
mcp__github__get_pull_request({ owner, repo, pull_number: prNumber }),
mcp__github__get_pull_request_comments({
owner,
repo,
pull_number: prNumber,
}),
mcp__github__get_pull_request_reviews({ owner, repo, pull_number: prNumber }),
]);
console.log(`\n**PR Title**: ${prDetails.title}`);
console.log(`**Author**: ${prDetails.user.login}`);
console.log(`**State**: ${prDetails.state}`);
console.log(`**URL**: ${prDetails.html_url}\n`);
Step 3: Organize and Categorize Comments
Organize comments into categories for clear presentation:
interface Comment {
id: string;
type: 'inline' | 'review';
author: string;
body: string;
path?: string;
line?: number;
position?: number;
created_at: string;
html_url: string;
}
// Collect all comments
const allComments: Comment[] = [];
// Add inline comments (code review comments)
prComments.forEach((comment) => {
allComments.push({
id: `comment-${comment.id}`,
type: 'inline',
author: comment.user.login,
body: comment.body,
path: comment.path,
line: comment.line,
position: comment.position,
created_at: comment.created_at,
html_url: comment.html_url,
});
});
// Add review comments (from review body)
prReviews.forEach((review) => {
if (review.body && review.body.trim()) {
allComments.push({
id: `review-${review.id}`,
type: 'review',
author: review.user.login,
body: review.body,
created_at: review.submitted_at,
html_url: review.html_url,
});
}
});
// Sort by creation date (oldest first)
allComments.sort(
(a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime(),
);
console.log(`Found ${allComments.length} comment(s) to address`);
if (allComments.length === 0) {
console.log('No comments to address!');
return;
}
Step 4: Process Each Comment Conversationally
For each comment, follow the conversational workflow:
// Track decisions and changes
const decisions = [];
const filesToChange = new Set<string>();
for (let i = 0; i < allComments.length; i++) {
const comment = allComments[i];
const commentNum = i + 1;
console.log(`\n${'='.repeat(80)}`);
console.log(`Comment ${commentNum}/${allComments.length}`);
console.log(`${'='.repeat(80)}\n`);
// Display comment context
console.log(`**Author**: ${comment.author}`);
console.log(
`**Type**: ${comment.type === 'inline' ? 'Inline code comment' : 'Gen
```
Maintain Work Through Pr Comments?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Work Through Pr Comments on getagentictools](https://getagentictools.com/loops/labs-solo-work-through-pr-comments?ref=badge) npx agentictools info loops/labs-solo-work-through-pr-comments The second line is the CLI lookup for this page — handy in READMEs and docs.