/commentreply Command
Processes PR comments with technical fixes and generates threaded GitHub responses.
/plugin marketplace add jleechanorg/claude-commands/plugin install claude-commands@claude-commands-marketplaceWhen this command is invoked, YOU (Claude) must execute these steps immediately: This is NOT documentation - these are COMMANDS to execute right now. Use TodoWrite to track progress through multi-phase workflows.
Action Steps:
Action Steps:
### Phase 3: Step 2: Claude Analysis & Reply Generation (CORE RESPONSIBILITY)
**Action Steps:**
**Claude MUST**:
1. **Read each comment content** from the JSON data
2. **Analyze technical issues** raised in each comment
3. **Implement actual fixes** using Edit/MultiEdit tools when code changes needed
4. **Generate technical responses** addressing specific points raised
5. **Write reply JSON file** to `/tmp/{branch_name}/replies.json` with structure:
```json
{
"replies": [
{
"comment_id": "comment_id_from_fetch",
"reply_text": "[AI responder] ā
**Issue Fixed** (Commit: abc1234)\n\n> Original comment text...\n\n**Analysis**: ...\n**Fix Applied**: ...",
"in_reply_to": "parent_comment_id_if_threaded"
}
]
}
Action Steps: ā DONE: Architecture Question Resolved (Commit: ab82741b)
Question: "Should we have this and the md file and the py file? How do all 3 work together?"
Analysis: Three-file architecture provides clear separation of concerns:
File Architecture Explained:
commentreply (shell script): Entry point with argument parsing and auto-detectioncommentreply.md (this file): Complete workflow documentation and Claude instructionscommentreply.py (Python implementation): Secure GitHub API posting with threadingIntegration Flow:
### Discovery Phase (MANDATORY)
**Action Steps:**
```bash
### Implementation Phase (MANDATORY)
**Action Steps:**
1. **ā
Map ALL instances**: Document each occurrence and required fix
2. **ā
Fix ALL instances**: Not just obvious ones - systematic coverage required
3. **ā FORBIDDEN**: Partial pattern fixes that miss related usage
### Verification Phase (MANDATORY)
**Action Steps:**
```bash
### Phase 8: š EXECUTION FLOW
**Action Steps:**
```mermaid
graph TD
A["/commentfetch loads JSON"] --> B["Claude reads comments"]
B --> C["Claude analyzes technical issues"]
C --> D["Claude implements fixes"]
D --> E["Claude generates responses"]
E --> F["Claude writes /tmp/branch/replies.json"]
F --> G["Python reads replies.json"]
G --> H["Python posts with GitHub API threading"]
H --> I["Verify coverage"]
šÆ Purpose: Systematically process ALL PR comments with real technical responses and GitHub threading
# User runs shell command
./commentreply [args]
ā
# Shell script auto-detects repo context, calls Python
python3 commentreply.py "$OWNER" "$REPO" "$PR_NUMBER"
ā
# Python reads JSON data that Claude analyzed (per this .md file)
# Posts responses via secure GitHub API with proper threading
Why Three Files Are Necessary:
š§ GitHub API Endpoints: GitHub provides two methods for posting replies to PR review comments:
POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies
body parameterPOST /repos/{owner}/{repo}/pulls/{pull_number}/comments
body and in_reply_to parametersin_reply_to, replies-to-replies not supportedā DONE: Parameter Alignment Fixed (Commit: ab82741b)
Issue: "Remove the undefined ${branch_name} and fourth positional argument - commentreply.py only accepts three positional args"
Analysis: Documentation was misaligned with actual Python script implementation.
Fix Applied:
${branch_name} variable referencegit branch --show-current/tmp/<branch>/responses.json internally
# Get repo info and pass to Python script
OWNER=$(gh repo view --json owner --jq .owner.login)
REPO=$(gh repo view --json name --jq .name)
PR_NUMBER=$(gh pr view --json number --jq .number)
# Python reads comment data and handles secure API posting with threading
python3 .claude/commands/commentreply.py "$OWNER" "$REPO" "$PR_NUMBER"
Verification: Script signature matches documentation exactly
For each comment, Claude must:
ā NOT DONE: Placeholder Response Prevention (Current: ab82741b)
Issue: "Docs forbid generic responses, but the Python path posts placeholders"
Analysis: Current implementation posts "CLAUDE RESPONSE NEEDED" when no response exists, violating documented prohibition against generic acknowledgments.
Why NOT DONE:
Recommended Future Fix: Modify Python to skip posting entirely when no Claude response exists, or update documentation to explicitly allow diagnostic placeholders.
Current Implementation:
git diff to verify changes were madeā ļø MANDATORY: When fixing patterns/variables mentioned in comments, apply systematic verification to prevent incomplete implementations.
grep -n "problematic_pattern" target_file.py rg "problematic_pattern" . --type py -A 2 -B 2
# Prove ALL instances addressed before declaring complete
git add -A && git diff --cached | grep -E "(\+|\-)" | grep "problematic_pattern"
git show HEAD | grep -A 3 -B 3 "problematic_pattern"
all_comments vs processed_comments - must fix ALL usage (success criteria AND error reporting)šØ LESSON: Incomplete pattern fixes create false confidence - always verify completeness with evidence
šØ MANDATORY: [AI responder] TAG REQUIREMENT ALL responses MUST begin with the tag [AI responder] to distinguish AI-generated responses from manual human responses.
Create technical responses that:
[AI responder] ā
**Performance Fix Applied** (Commit: abc1234)
> The get_git_commit_hash() function is called multiple times...
**Analysis**: You're absolutely right about the inefficiency.
**Fix Implemented**:
- ā
Moved get_git_commit_hash() call to start of processing
- ā
Pass commit hash as parameter to avoid repeated git commands
- ā
Reduced from 3+ git calls to 1 git call per run
**Performance Impact**: ~67% reduction in git command execution
**Verification**: `git show abc1234 -- path/to/file.py`
[AI responder] ā
**Security Issue Fixed** (Commit: def5678)
> Using f-string with json.dumps() output in shell command is unsafe...
**Analysis**: Valid security concern about shell injection vulnerability.
**Security Fix Applied**:
- ā
Replaced dangerous echo 'json' | bash -c approach
- ā
Implemented secure tempfile + gh --input mechanism
- ā
Eliminated JSON embedding in shell command strings
**Verification**: `git show def5678 -- .claude/commands/commentreply.py`
[AI responder] ā
**Code Structure Improved** (Commit: ghi9012)
> Add strict mode and tool checks to fail fast...
**Implementation**:
- ā
Added set -Eeuo pipefail for fail-fast error handling
- ā
Added python3/gh CLI availability checks
- ā
Proper exit codes when required tools missing
**Verification**: `git show ghi9012 -- .claude/commands/commentreply`
Before processing any comments:
/tmp/{branch}/comments.json (from commentfetch)/tmp/{branch}/replies.json (structured reply data)/commentfetch must run first to populate JSON dataThis streamlined workflow ensures Claude focuses on technical analysis and implementation while Python handles the complex GitHub API security and threading requirements.