Skip to content

Conversation

osterman
Copy link
Member

@osterman osterman commented Sep 7, 2025

what

  • Add a specialized Claude Code agent pr-review-remediator for automated PR review remediation
  • Create comprehensive agent in .claude/agents/pr-review-remediator.md with intelligent feedback analysis
  • Add slash command /fix-pr for quick PR remediation with cross-references
  • Implement CodeRabbit integration with AI prompt prioritization and validation framework
  • Add CodeQL security alert monitoring and remediation commands
  • Implement PR Semver Labels detection and automated suggestion logic
  • Add GitHub comment resolution to document and close addressed feedback
  • Handle deleted files properly in all PR operations
  • Enhance with robust bash patterns, strict mode, and improved error handling

why

  • Automate the repetitive task of addressing PR review feedback and CI/CD failures
  • Reduce manual effort in fixing linting issues, test failures, and security alerts
  • Ensure consistent application of project standards (CLAUDE.md requirements)
  • Speed up PR iteration cycles by providing validated, actionable remediation plans
  • Leverage CodeRabbit's AI prompts for understanding issues rather than blindly copying code
  • Provide intelligent label suggestions for semantic versioning requirements
  • Close the feedback loop by documenting what was fixed and resolving comments

Key Features

🤖 Intelligent CodeRabbit Integration

  • Prioritizes "Prompt for AI Agents" sections for understanding intent
  • Fetches both issue comments and inline review comments
  • Validates all suggestions against CLAUDE.md requirements with detailed checklist
  • Implements fixes based on understanding, not raw code copying
  • Presents analysis with clear Valid/Questionable/Skip categorization

🎯 Smart Targeted Operations

  • Only lints changed files in the PR (uses --new-from-rev=origin/main)
  • Excludes deleted files to prevent errors (uses GitHub API status filtering)
  • Runs tests only for affected packages with proper deduplication
  • Checks file existence before all operations
  • Uses robust bash patterns with IFS= and here-strings for reliability
  • Includes set -euo pipefail for bash strict mode error handling

🔒 Security & Compliance

  • CodeQL Integration: Fetches PR-specific security alerts with severity details
  • PR Semver Labels: Automated detection and suggestion based on commit patterns
  • Enhanced label logic recognizes breaking changes, features, and patches
  • Excludes .claude/ directory from documentation-only detection

💬 GitHub Comment Resolution

  • Reply to addressed comments with details of what was fixed
  • Post summary comments showing all remediated issues
  • Mark review threads as resolved using GitHub GraphQL API
  • Link fixes to commits for complete traceability
  • Creates audit trail of automated remediations

🛡️ Safety Controls

  • Always requires user approval before making changes
  • Never modifies golden snapshots in tests/test-cases/
  • Creates feature branches (never pushes to main)
  • Comprehensive validation checklist with ✅ and ⚠️ indicators
  • Tests fixes locally before committing

📊 Enhanced Analysis

  • Fetches all PR comments (CodeRabbit, human reviewers, inline comments)
  • Monitors GitHub status checks (tests, security, coverage, labels)
  • Creates actionable remediation plans with clear reasoning
  • Tracks progress using TodoWrite tool
  • YAML list format for tools for better parsing

Usage

# Method 1: Direct agent invocation
/agent pr-review-remediator

# Method 2: Slash command (action-oriented)
/fix-pr 1440

# Method 3: Natural language
"Please fix issues in PR #1440 based on review feedback"

Example Workflow

  1. Gather: Agent fetches PR status, checks, and all feedback sources
  2. Parse: Extracts and prioritizes CodeRabbit AI prompts over raw diffs
  3. Validate: Checks each suggestion against comprehensive project standards
  4. Analyze: Checks for conflicts, side effects, and backward compatibility
  5. Present: Shows categorized plan (✅ Valid, ⚠️ Needs Review, ❌ Skip)
  6. Approve: User reviews and approves specific fixes
  7. Implement: Agent applies approved changes following CLAUDE.md requirements
  8. Verify: Runs validation suite (lint changed files, test affected packages, build)
  9. Document: Posts summary of fixes and replies to addressed comments
  10. Resolve: Marks GitHub review threads as resolved

Recent Enhancements

Based on CodeRabbit Feedback (Dog-fooding)

  • ✅ Fixed markdown linting violations (MD026, MD040)
  • ✅ Standardized placeholder usage to <PR_NUMBER> throughout
  • ✅ Converted tools to YAML list format
  • ✅ Added inline comment fetching examples
  • ✅ Improved bash loop patterns for robustness
  • ✅ Enhanced label detection with more comprehensive patterns
  • ✅ Expanded validation checklist with detailed criteria

Critical Fixes

  • Deleted files handling: Filter by status != "removed" to prevent errors
  • File existence checks: Verify files exist before format/lint/test operations
  • Command naming: Renamed from /analyze-pr to /fix-pr for clarity
  • Comment resolution: Added Phase 5 workflow to document and resolve feedback

File Structure

.claude/
├── agents/
│   └── pr-review-remediator.md    # Main PR review remediation agent
├── commands/
│   └── fix-pr.md                  # Slash command to fix PR issues
└── README.md                       # Documentation

references

  • Implements feedback handling patterns discussed in team reviews
  • Follows Claude Code agent best practices with YAML frontmatter
  • Successfully dog-fooded on its own PR to validate functionality
  • Addresses the need for automated PR feedback response at scale
  • Closes the feedback loop with comment resolution capabilities

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

Summary by CodeRabbit

  • Documentation
    • Added a Claude PR Remediation documentation suite: agent spec, a slash-command for requesting fixes, and an overarching README describing usage and workflows.
    • Documents user-facing invocation methods (agent, slash-command, natural prompts), CI/CD status monitoring, prioritized handling of AI and human review feedback, smart linting of changed files, validation/safety controls, example workflows, and customization guidance.
    • Notes a minor discrepancy in the customization reference.

- Add pr-review-handler agent to analyze CodeRabbit and human feedback
- Prioritize AI prompts over code diffs for better understanding
- Implement smart linting that only checks changed files
- Add safety controls requiring user approval before changes
- Create slash command for quick PR analysis
- Include comprehensive documentation and examples

The agent intelligently parses CodeRabbit's "Prompt for AI Agents" sections
to understand the intent behind suggestions, then implements fixes according
to project standards (CLAUDE.md) rather than blindly copying code.

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
@osterman osterman requested review from a team as code owners September 7, 2025 14:32
@github-actions github-actions bot added the size/l Large size PR label Sep 7, 2025
Copy link
Contributor

coderabbitai bot commented Sep 7, 2025

📝 Walkthrough

Walkthrough

Adds a new .claude documentation suite for an automated PR remediation workflow: a pr-review-remediator agent spec, a slash-command fix-pr, and an overarching README describing invocation methods, validation rules, linting scope, status-check analysis, approval gating, and operational guidance.

Changes

Cohort / File(s) Summary
Documentation root
.claude/README.md
New README describing directory structure, usage (direct agent, /fix-pr, manual prompts), features, workflows, commands, validation process, safety controls, and customization notes (notes a customization path discrepancy referencing analyze-pr.md vs fix-pr.md).
Agent spec
.claude/agents/pr-review-remediator.md
New agent blueprint defining responsibilities: parse CodeRabbit & human feedback, monitor GitHub status checks, generate remediation plans with validation, require user approval, lint only changed (non-deleted) files, avoid golden-test changes, and provide response/templates for reporting and thread resolution.
Command spec
.claude/commands/fix-pr.md
New CLAUDE command fix-pr spec: fetch PR comments/statuses, identify failing checks, synthesize remediation plan (recommend using pr-review-remediator), present for approval, and run targeted lint/tests before committing fixes.

Sequence Diagram(s)

sequenceDiagram
    participant User as Developer / Reviewer
    participant CLI as Slash Command (/fix-pr)
    participant Agent as pr-review-remediator
    participant Repo as GitHub Repo
    participant CI as CI/CD & Tests

    CLI->>Agent: /fix-pr <PR>
    Agent->>Repo: fetch PR metadata, changed files, comments
    Agent->>Repo: parse CodeRabbit & human review comments
    Agent->>CI: check status checks, failing jobs
    Agent-->>Agent: generate remediation plan & validation summary
    Agent->>User: present plan (Requires approval)
    alt User approves
        User->>Agent: approve
        Agent->>Repo: create feature branch & apply fixes (commits)
        Agent->>CI: run lint/tests on changed files
        CI-->>Agent: results (pass/fail)
        Agent->>Repo: post remediation report & resolve threads
    else User rejects / requests changes
        User->>Agent: modify plan / cancel
        Agent->>User: update plan or abort
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • aknysh
  • Gowiem
  • RoseSecurity
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch agent-to-fix-reivew-comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (8)
.claude/commands/analyze-pr.md (2)

14-15: Link to the agent spec for quick cross-nav.

Add a relative link so readers can jump straight to the agent details.

-Use the pr-review-handler agent if available.
+Use the pr-review-handler agent if available (see ../agents/pr-review-handler.md).

6-13: Parameterize the repository to improve reuse.

Consider templating the repo owner/name so this command can be reused across forks.

-Please analyze PR #{{PR_NUMBER}} in the cloudposse/atmos repository:
+Please analyze PR #{{PR_NUMBER}} in the {{REPO:cloudposse/atmos}} repository:
.claude/README.md (2)

7-14: Add a language to fenced block (markdownlint MD040).

Declare this tree as text to satisfy linters.

-```
+```text
 .claude/
 ├── agents/
 │   └── pr-review-handler.md    # Main PR review and remediation agent
 ├── commands/
 │   └── analyze-pr.md           # Slash command for quick PR analysis
 └── README.md                   # This file

---

`37-39`: **Add a language to fenced block (markdownlint MD040).**

Mark the quoted example as text.


```diff
-```
+```text
 "Please analyze PR #1440 for review feedback and failing checks"

</blockquote></details>
<details>
<summary>.claude/agents/pr-review-handler.md (4)</summary><blockquote>

`98-104`: **Remove trailing colon from heading (markdownlint MD026).**

Also declare the following fence as text (MD040).


```diff
-#### Example AI Prompt from CodeRabbit:
+#### Example AI Prompt from CodeRabbit
-```
+```text
 🤖 Prompt for AI Agents
...

---

`231-249`: **Make file iteration robust to spaces and quote paths.**

Use read -r with quoting to avoid word-splitting bugs.


```diff
-# 2. Apply specific fixes to changed files
-for file in $CHANGED_FILES; do
-  if [[ $file == *.go ]]; then
-    # Format only if it's a Go file that was changed
-    gofumpt -w $file
-    goimports -w $file
-  fi
-done
+# 2. Apply specific fixes to changed files
+while IFS= read -r file; do
+  if [[ $file == *.go ]]; then
+    # Format only if it's a Go file that was changed
+    gofumpt -w "$file"
+    goimports -w "$file"
+  fi
+done <<< "$CHANGED_FILES"
 
-# 3. Run tests for changed packages
-for file in $CHANGED_FILES; do
-  if [[ $file == *.go ]]; then
-    pkg_dir=$(dirname $file)
-    go test ./$pkg_dir -v
-  fi
-done
+# 3. Run tests for changed packages
+while IFS= read -r file; do
+  if [[ $file == *.go ]]; then
+    pkg_dir=$(dirname "$file")
+    go test "./$pkg_dir" -v
+  fi
+done <<< "$CHANGED_FILES"

385-406: Standardize placeholder to <PR_NUMBER> for consistency.

Unify placeholder usage across the doc.

-# Get changed files in PR
-gh pr view <PR> --repo cloudposse/atmos --json files --jq '.files[].path'
+# Get changed files in PR
+gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path'
 
 # Lint only changed files (project's Makefile already does this)
 make lint
 
 # Find CodeRabbit comments
-gh api repos/cloudposse/atmos/issues/<PR>/comments \
+gh api repos/cloudposse/atmos/issues/<PR_NUMBER>/comments \
   --jq '.[] | select(.user.login == "coderabbitai")'
 
 # Check specific test
 go test ./pkg/merge -run TestMergeWithNilConfig -v
 
 # Validate build
 make build
 
 # Check PR status
-gh pr checks <PR> --repo cloudposse/atmos
+gh pr checks <PR_NUMBER> --repo cloudposse/atmos
 
 # View failing check logs
-gh run view <RUN_ID> --repo cloudposse/atmos --log-failed
+gh run view <RUN_ID> --repo cloudposse/atmos --log-failed

37-48: Clarify linting guidance to avoid redundant invocations.

Since make lint already uses --new-from-rev, suggest removing the per-file example or add a note that it’s optional.

-# Or manually for specific files:
-golangci-lint run --new-from-rev=origin/main
-
-# For a specific file:
-golangci-lint run path/to/changed/file.go
+# Or manually (only if running outside Makefile context):
+# golangci-lint run --new-from-rev=origin/main
+# golangci-lint run path/to/changed/file.go
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f2781b5 and 9483e2c.

📒 Files selected for processing (3)
  • .claude/README.md (1 hunks)
  • .claude/agents/pr-review-handler.md (1 hunks)
  • .claude/commands/analyze-pr.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-handler.md

98-98: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


99-99: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

.claude/README.md

7-7: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


37-37: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build (macos-latest, macos)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Summary
🔇 Additional comments (1)
.claude/README.md (1)

60-63: Confirmed make lint uses targeted linting. The Makefile’s golangci-lint run on line 27 includes --new-from-rev=origin/main as documented.

coderabbitai[bot]
coderabbitai bot previously approved these changes Sep 7, 2025
Copy link

codecov bot commented Sep 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.95%. Comparing base (4cdbe27) to head (6ae31e2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1465   +/-   ##
=======================================
  Coverage   55.94%   55.95%           
=======================================
  Files         274      274           
  Lines       28936    28936           
=======================================
+ Hits        16189    16190    +1     
+ Misses      10955    10952    -3     
- Partials     1792     1794    +2     
Flag Coverage Δ
unittests 55.95% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Fix loop syntax to properly handle newline-separated output from gh pr view
- Deduplicate directories when running tests to avoid redundant test runs
- Use proper quoting and read -r for robust file path handling
- Test all commands to ensure they work correctly

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
.claude/agents/pr-review-handler.md (6)

98-111: Fix markdownlint nits: heading colon and missing fenced language.

Remove trailing colon in the heading and specify a language for the fenced block to satisfy MD026 and MD040.

Apply:

-#### Example AI Prompt from CodeRabbit:
+#### Example AI Prompt from CodeRabbit

-```
+```text
 🤖 Prompt for AI Agents
 ...

---

`138-138`: **Renumber list step to avoid duplicate "3."**

This step follows 1–4; make it 5 for clarity.


```diff
-3. **Present analysis to user**:
+5. **Present analysis to user**:

270-276: Correct count: header says 4 files but lists 5.

Align the header with the list.

-### Changed Files (4 files)
+### Changed Files (5 files)

85-96: Prefer structured parsing over grep.

Use JSON + jq to reliably extract sections; grep is brittle across formatting changes.

-# Extract AI Agent prompts (PREFERRED)
-gh pr view <PR_NUMBER> --repo cloudposse/atmos --comments | \
-  grep -A 50 "Prompt for AI Agents"
-
-# Extract actionable comments section
-gh pr view <PR_NUMBER> --repo cloudposse/atmos --comments | \
-  grep -A 100 "Actionable comments posted"
-
-# Only use code diffs as reference, not for direct application
-gh pr view <PR_NUMBER> --repo cloudposse/atmos --comments | \
-  grep -A 20 "Committable suggestion"
+# Extract AI Agent prompts (PREFERRED)
+gh pr view <PR_NUMBER> --repo cloudposse/atmos --json comments \
+  --jq '.comments[].body | select(test("(?s)🤖 Prompt for AI Agents"))'
+
+# Extract actionable comments section
+gh pr view <PR_NUMBER> --repo cloudposse/atmos --json comments \
+  --jq '.comments[].body | select(test("(?i)Actionable comments posted"))'
+
+# Only use code diffs as reference, not for direct application
+gh pr view <PR_NUMBER> --repo cloudposse/atmos --json comments \
+  --jq '.comments[].body | select(test("(?i)Committable suggestion"))'

245-255: Harden directory extraction loop.

Quote vars, skip blanks, and handle spaces in filenames.

-CHANGED_DIRS$(echo "$CHANGED_FILES" | while read -r file; do
+CHANGED_DIRS=$(echo "$CHANGED_FILES" | while IFS= read -r file; do
   if [[ $file == *.go ]]; then
-    dirname "$file"
+    dirname -- "$file"
   fi
-done | sort -u)
+done | sed '/^$/d' | sort -u)
 
-echo "$CHANGED_DIRS" | while read -r pkg_dir; do
+echo "$CHANGED_DIRS" | while IFS= read -r pkg_dir; do
   if [[ -n $pkg_dir ]]; then
     go test "./$pkg_dir" -v
   fi
 done

391-415: Unify placeholders: use <PR_NUMBER> consistently.

Mixed use of and <PR_NUMBER> can confuse users.

-# Get changed files in PR
-gh pr view <PR> --repo cloudposse/atmos --json files --jq '.files[].path'
+# Get changed files in PR
+gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path'
 
-# Find CodeRabbit comments
-gh api repos/cloudposse/atmos/issues/<PR>/comments \
+# Find CodeRabbit comments
+gh api repos/cloudposse/atmos/issues/<PR_NUMBER>/comments \
   --jq '.[] | select(.user.login == "coderabbitai")'
 
 # Check specific test
 go test ./pkg/merge -run TestMergeWithNilConfig -v
 
 # Validate build
 make build
 
 # Run acceptance tests
 make testacc
 
-# Check PR status
-gh pr checks <PR> --repo cloudposse/atmos
+# Check PR status
+gh pr checks <PR_NUMBER> --repo cloudposse/atmos
 
 # View failing check logs
 gh run view <RUN_ID> --repo cloudposse/atmos --log-failed
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9483e2c and 5759931.

📒 Files selected for processing (1)
  • .claude/agents/pr-review-handler.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-handler.md

98-98: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


99-99: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (3)
.claude/agents/pr-review-handler.md (3)

34-48: Nice: linting only changed files is called out explicitly.

Clear guidance that aligns with repo practices; reduces noise and speeds CI.


10-29: Strong, scoped responsibilities and safety controls.

Well-structured remit, explicit user-approval gate, and golden-snapshot protection.


231-259: Runner environment verified: all required commands available.
gh, golangci-lint, go, gofumpt, goimports, and gh pr checks are present and functional.

coderabbitai[bot]
coderabbitai bot previously approved these changes Sep 7, 2025
- Add specific commands to fetch CodeQL alerts for a PR
- Include commands to get detailed alert information (severity, file, line)
- Add example script to check for security issues in a PR
- Provide commands for analyzing CodeQL scan results
- Test all commands to ensure they work correctly

The agent can now properly detect and report security vulnerabilities
found by CodeQL in pull requests, with detailed information about
severity, location, and remediation guidance.

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
@osterman osterman added the no-release Do not create a new release (wait for additional code changes) label Sep 7, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
.claude/agents/pr-review-handler.md (6)

7-7: Use a YAML list for tools (clearer, less parser-ambiguous).

Represent tools as a sequence instead of a comma-separated string.

-tools: Read, Grep, Glob, Bash, Edit, MultiEdit, Write, WebFetch, Task, TodoWrite
+tools:
+  - Read
+  - Grep
+  - Glob
+  - Bash
+  - Edit
+  - MultiEdit
+  - Write
+  - WebFetch
+  - Task
+  - TodoWrite

98-101: Fix markdownlint issues: heading punctuation + missing code fence language.

Remove trailing colon and add a language for the fenced block.

-#### Example AI Prompt from CodeRabbit:
+#### Example AI Prompt from CodeRabbit
-
-```
+```text
 🤖 Prompt for AI Agents

138-156: Numbering glitch: step “Present analysis to user” should be 5.

Maintains correct ordered list after steps 1–4.

-3. **Present analysis to user**:
+5. **Present analysis to user**:

270-276: Count mismatch: header says 4 files but lists 5.

Align the header with the list.

-### Changed Files (4 files)
+### Changed Files (5 files)

61-66: Consider adding API call for inline review comments (JSON).

‘gh pr view --json reviews’ gives review bodies, not individual inline comments. Add an example to fetch review comments as structured JSON.

 # Get CodeRabbit's review with detailed feedback
 gh pr view <PR_NUMBER> --repo cloudposse/atmos --json reviews \
   --jq '.reviews[] | select(.author.login == "coderabbitai") | .body'
+#
+# (Optional) Inline review comments as JSON:
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/comments \
+  --jq '.[] | select(.user.login == "coderabbitai") | .body'

443-476: Normalize placeholder to <PR_NUMBER> for consistency.

Keeps docs consistent and reduces copy/paste errors.

-gh pr view <PR> --repo cloudposse/atmos --json files --jq '.files[].path'
+gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path'
@@
-gh pr checks <PR> --repo cloudposse/atmos
+gh pr checks <PR_NUMBER> --repo cloudposse/atmos
@@
-  -f ref="refs/pull/<PR>/head" \
+  -f ref="refs/pull/<PR_NUMBER>/head" \
@@
-  --jq '.[] | select(.ref == "refs/pull/<PR>/head")' \
+  --jq '.[] | select(.ref == "refs/pull/<PR_NUMBER>/head")' \
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5759931 and b068987.

📒 Files selected for processing (1)
  • .claude/agents/pr-review-handler.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-handler.md

98-98: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


99-99: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Summary
🔇 Additional comments (1)
.claude/agents/pr-review-handler.md (1)

40-45: Guardrail implemented: lint target uses --new-from-rev=origin/main

Verified that the Makefile’s lint recipe includes golangci-lint run --new-from-rev=origin/main on line 27, so no change needed.

coderabbitai[bot]
coderabbitai bot previously approved these changes Sep 7, 2025
- Add detailed instructions for handling failed PR Semver Labels check
- Include commands to check current labels and add appropriate ones
- Provide automated label detection based on file changes and commit messages
- Add clear guidance on when to use patch, minor, major, or no-release labels
- Update example workflow to show handling of missing labels
- Test all commands to ensure they work correctly

The agent now properly detects and remediates the PR Semver Labels check
failure, which is a common CI blocker. It can analyze changes and suggest
the appropriate semantic versioning label.

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
.claude/agents/pr-review-handler.md (5)

138-155: Renumber step (3 → 5).

Numbering restarts mid-section; fix for clarity.

-3. **Present analysis to user**:
+5. **Present analysis to user**:

277-283: Sync item count with heading.

Heading says “4 files” but lists 5. Prefer removing the count to avoid drift.

-### Changed Files (4 files)
+### Changed Files

62-66: Also fetch inline review comments (file-level).

Reviews’ bodies can be empty; include the PR review-comments endpoint.

 gh pr view <PR_NUMBER> --repo cloudposse/atmos --json reviews \
   --jq '.reviews[] | select(.author.login == "coderabbitai") | .body'
+
+# Get inline review comments (per-file)
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/comments \
+  --jq '.[] | select(.user.login == "coderabbitai") | {path, line: .line, body: .body}'

239-266: Harden bash snippets.

Add strict mode and ensure base ref exists before using --new-from-rev.

-# 1. Run linting ONLY on changed files
+set -euo pipefail
+
+# 1. Run linting ONLY on changed files
+git fetch origin main --quiet || true
 make lint  # This already uses --new-from-rev=origin/main

495-513: Broaden label detection heuristics and treat .claude/ as docs.

Covers future non-.md files in .claude/ and Go code outside pkg/.

-CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path')
-NON_DOC_FILES=$(echo "$CHANGED_FILES" | grep -v -E '\.(md|mdx|txt)$|^website/|^docs/|^\.github/' | wc -l)
+CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path')
+NON_DOC_FILES=$(echo "$CHANGED_FILES" | grep -v -E '\.(md|mdx|txt)$|^website/|^docs/|^\.github/|^\.claude/' | wc -l)
 
 if [[ $NON_DOC_FILES -eq 0 ]]; then
   echo "Suggested label: no-release (documentation/CI changes only)"
-elif echo "$CHANGED_FILES" | grep -q "^pkg/.*\.go$"; then
+elif echo "$CHANGED_FILES" | grep -q -E '^(pkg|cmd|internal)/.*\.go$'; then
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b068987 and 2222765.

📒 Files selected for processing (1)
  • .claude/agents/pr-review-handler.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-handler.md

98-98: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


99-99: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


454-454: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary

osterman and others added 2 commits September 7, 2025 12:28
- Rename pr-review-handler to pr-review-remediator to better reflect its purpose
- The agent actively remediates (fixes) issues, not just handles them
- Update description to emphasize remediation and fixing capabilities
- Update all references in README.md and analyze-pr.md command
- Improve agent description to focus on action-oriented remediation

The new name pr-review-remediator clearly indicates that this agent:
- Actively fixes and corrects issues found in reviews
- Remediates CI/CD failures and test issues
- Takes action to resolve problems, not just analyze them

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
- Fix MD026: Remove trailing colon from heading
- Fix MD040: Add language specifiers to code blocks
- Standardize placeholder usage to <PR_NUMBER> throughout
- Improve markdown compliance and consistency
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
.claude/agents/pr-review-remediator.md (4)

278-284: Fix count mismatch in example.

Header says 4 files but 5 are listed. Update header.

-### Changed Files (4 files)
+### Changed Files (5 files)

455-463: Resolve markdownlint MD026: remove trailing punctuation in heading.

The subheading ends with a colon.

-#### Required Labels (choose ONE):
+#### Required Labels (choose ONE)

140-157: Close fenced block correctly.

A code block opened as markdown is closed with “```text”. Close with plain backticks.

-Ready to proceed with valid suggestions? [y/n]
-```text
+Ready to proceed with valid suggestions? [y/n]
+```

241-249: Clarify “lint only changed files.”

golangci-lint --new-from-rev=origin/main is diff-aware but scans the repo; it doesn’t strictly limit to specific filenames. Keep Makefile usage, or show per-file invocation to minimize scope.

Option:

-# Or manually for specific files:
-golangci-lint run --new-from-rev=origin/main
-
-# For a specific file:
-golangci-lint run path/to/changed/file.go
+# Or manually for specific files (strict):
+# xargs passes only changed Go files to golangci-lint
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files --paginate \
+  --jq '.[] | select(.status != "removed" and (.filename | endswith(".go"))) | .filename' \
+| xargs -r golangci-lint run --fast
.claude/README.md (1)

36-39: Add language to fenced block (markdownlint MD040).

Specify a language for the “Manual Invocation” snippet.

-```
+"```text
 "Please analyze PR #1440 for review feedback and failing checks"
-```
+```"
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2222765 and 26acfc6.

📒 Files selected for processing (3)
  • .claude/README.md (1 hunks)
  • .claude/agents/pr-review-remediator.md (1 hunks)
  • .claude/commands/analyze-pr.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .claude/commands/analyze-pr.md
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-remediator.md

455-455: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

.claude/README.md

37-37: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Summary
🔇 Additional comments (3)
.claude/agents/pr-review-remediator.md (1)

2-2: Align agent name with PR title/commands.

PR text references “pr-review-handler” while this doc defines “pr-review-remediator.” Standardize to one name (agent id, file names, examples, and slash commands).

.claude/README.md (2)

20-23: Verify agent identifier consistency.

Examples use “pr-review-remediator” while the PR title/description mention “pr-review-handler.” Align the identifier everywhere (agent name, command examples, and docs).


9-13: Confirm referenced command doc exists.

README references .claude/commands/analyze-pr.md. Ensure it’s added in this PR and paths match.

- Add cross-reference link between command and agent spec
- Convert tools to YAML list format for better parsing
- Add inline review comment fetching examples
- Improve bash loop patterns with IFS and here-strings
- Add bash strict mode (set -euo pipefail) for reliability
- Enhance label detection with more patterns and .claude exclusion
- Expand validation checklist with detailed criteria
- Improve step numbering consistency
- Filter out deleted files using GitHub API file status
- Add file/directory existence checks before operations
- Use 'gh api pulls/files' with status != 'removed' filter
- Add graceful skipping for deleted files in format/lint/test
- Show file change summary (added/modified/removed counts)
- Update both agent and README with correct commands

This prevents errors when trying to format, lint, or test files
that have been deleted in the PR.
- Rename /analyze-pr to /fix-pr for clarity and action-oriented naming
- Update command description to 'Fix issues' instead of 'Analyze'
- Update all references in README.md
- Better alignment with agent's remediation purpose

The command name now clearly indicates it will take action to fix
issues, not just analyze them.
- Add Phase 5: Resolve Addressed Comments workflow
- Include commands to reply to CodeRabbit comments with fixes
- Add summary comment posting after remediation
- Include GraphQL queries to mark review threads as resolved
- Add to Core Responsibilities: Document Resolutions
- Provide examples of resolution messages with commit refs

This allows the agent to close the loop by documenting what was
fixed and marking conversations as resolved on GitHub.
- Add detailed section 'When to Use no-release Label'
- List specific file patterns that don't affect the binary
- Clarify that no-release is for changes NOT affecting Atmos binary
- Update automated detection to check for Go code in pkg/cmd/internal
- Improve detection patterns to differentiate binary vs non-binary changes
- Add examples of what requires vs doesn't require a release

This provides clear guidance on when to use no-release (docs/CI/tooling)
versus patch/minor/major labels (actual code changes).
- Include tools/ in the list of directories that don't require a release
- Update NON_RELEASE_PATTERN regex to include ^tools/
- Clarify that development tooling includes tools/ directory

The tools/ directory contains development utilities that don't affect
the Atmos binary and should use the no-release label.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
.claude/agents/pr-review-remediator.md (1)

700-705: Update “Get changed files” reference to exclude removed files (repeat of earlier concern).

Mirror the status-based filter here to avoid deleted paths sneaking into examples.

-# Get changed files in PR
-gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path'
+# Get changed, non-removed files in PR
+gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
+  --jq '.files[] | select(.status != "removed") | .path'
+# Or:
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files --paginate \
+  --jq '.[] | select(.status != "removed") | .filename'
🧹 Nitpick comments (4)
.claude/agents/pr-review-remediator.md (4)

67-73: Use read-loop instead of word-splitting; quote variables.

Avoid for file in $CHANGED_FILES to handle spaces/newlines robustly.

-for file in $CHANGED_FILES; do
-  if [[ -f "$file" && "$file" == *.go ]]; then
-    golangci-lint run "$file"
-  fi
-done
+while IFS= read -r file; do
+  if [[ -f "$file" && "$file" == *.go ]]; then
+    golangci-lint run "$file"
+  fi
+done <<< "$CHANGED_FILES"

114-125: Grepping rendered comments is brittle; prefer structured JSON.

grep -A on pretty output can break with formatting changes. Use gh api and jq to extract “Prompt for AI Agents” blocks.

-gh pr view <PR_NUMBER> --repo cloudposse/atmos --comments | \
-  grep -A 50 "Prompt for AI Agents"
+gh api repos/cloudposse/atmos/issues/<PR_NUMBER>/comments \
+  --jq '.[] | select(.user.login | test("coderabbit";"i")) | .body' | \
+  awk '/^🤖 Prompt for AI Agents/{flag=1} flag{print} /^```/{if (printed++) exit}'

591-599: Fix markdownlint MD026: remove trailing punctuation in heading.

Drop the colon at the end of the heading.

-#### Required Labels (choose ONE):
+#### Required Labels (choose ONE)

196-204: Consistent placeholders: prefer PR_NUMBER variable or <PR_NUMBER>, not both.

Minor polish for copy/paste-ability across blocks.

-PR_NUMBER=1440
-gh pr view $PR_NUMBER --repo cloudposse/atmos --json files,title,state
+PR_NUMBER=<PR_NUMBER>
+gh pr view "$PR_NUMBER" --repo cloudposse/atmos --json files,title,state
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 26acfc6 and cb744c0.

📒 Files selected for processing (3)
  • .claude/README.md (1 hunks)
  • .claude/agents/pr-review-remediator.md (1 hunks)
  • .claude/commands/fix-pr.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .claude/commands/fix-pr.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .claude/README.md
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-07T15:13:17.797Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T15:13:17.797Z
Learning: Use "no-release" label for documentation-only PRs and ensure all CI checks pass before review.

Applied to files:

  • .claude/agents/pr-review-remediator.md
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
PR: cloudposse/atmos#808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.

Applied to files:

  • .claude/agents/pr-review-remediator.md
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-remediator.md

591-591: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build (macos-latest, macos)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Summary
🔇 Additional comments (2)
.claude/agents/pr-review-remediator.md (2)

320-369: Note required permission for resolving threads.

Call out that the token must have “pull_requests: write” and “contents: write” for the mutation to succeed.

Would you like me to add a short prerequisites block listing required GH_TOKEN scopes?


1-19: Solid agent scaffold and toolchain.

Front matter and tool list are clear and aligned with the workflow.

Comment on lines +53 to +63
```bash
# Get list of changed files in PR (excluding deleted files)
# The files array includes: additions, deletions, and path
# We filter for added, modified, or renamed files only
CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
--jq '.files[] | select(.deletions >= 0 and .additions > 0) | .path')

# Alternative: Use gh api for more detailed file status
CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files \
--jq '.[] | select(.status != "removed") | .filename')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Changed-files filter can miss modified-only deletions and may include wrong entries. Standardize on status filter.

The .additions > 0 heuristic drops legit edits that only remove lines and can misclassify. Use .status != "removed" (or explicit added/modified/renamed). Also align the gh pr view variant to filter by status, not counts.

-# Get list of changed files in PR (excluding deleted files)
-# The files array includes: additions, deletions, and path
-# We filter for added, modified, or renamed files only
-CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
-  --jq '.files[] | select(.deletions >= 0 and .additions > 0) | .path')
+# Get list of changed files in PR (excluding deleted files)
+# Prefer filtering by file "status" to avoid false positives/negatives
+CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
+  --jq '.files[] | select(.status != "removed") | .path')
 
 # Alternative: Use gh api for more detailed file status
-CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files \
-  --jq '.[] | select(.status != "removed") | .filename')
+CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files --paginate \
+  --jq '.[] | select(.status != "removed") | .filename')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```bash
# Get list of changed files in PR (excluding deleted files)
# The files array includes: additions, deletions, and path
# We filter for added, modified, or renamed files only
CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
--jq '.files[] | select(.deletions >= 0 and .additions > 0) | .path')
# Alternative: Use gh api for more detailed file status
CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files \
--jq '.[] | select(.status != "removed") | .filename')
# Get list of changed files in PR (excluding deleted files)
# Prefer filtering by file "status" to avoid false positives/negatives
CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
--jq '.files[] | select(.status != "removed") | .path')
# Alternative: Use gh api for more detailed file status
CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files --paginate \
--jq '.[] | select(.status != "removed") | .filename')
🤖 Prompt for AI Agents
In .claude/agents/pr-review-remediator.md around lines 53 to 63, the GH files
filter uses .additions > 0 which will miss PRs that only remove lines and can
include incorrect entries; replace the heuristic with a status-based filter
(e.g., select(.status != "removed") or explicit status checks for
"added","modified","renamed") for both gh pr view and gh api variants so the
script consistently includes any non-removed files and excludes deleted ones.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
.claude/agents/pr-review-remediator.md (1)

53-73: “Changed files” snippet can include false positives; unify on status-based filter.

The gh pr view filter using additions>0 can miss modified files (net deletions) and still include edge cases. Prefer the REST “status != removed” approach everywhere.

-# Get list of changed files in PR (excluding deleted files)
-# The files array includes: additions, deletions, and path
-# We filter for added, modified, or renamed files only
-CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
-  --jq '.files[] | select(.deletions >= 0 and .additions > 0) | .path')
-
-# Alternative: Use gh api for more detailed file status
-CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files \
-  --jq '.[] | select(.status != "removed") | .filename')
+# Get list of changed files in PR (exclude deleted via status)
+CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files \
+  --jq '.[] | select(.status != "removed") | .filename')
🧹 Nitpick comments (9)
.claude/commands/fix-pr.md (2)

14-15: Align agent naming with PR title (/analyze-pr vs /fix-pr; pr-review-handler vs pr-review-remediator).

Docs say “pr-review-remediator,” PR title/summary say “pr-review-handler” and “/analyze-pr”. This split will confuse users and scripts.

Minimal fix (keep both names discoverable):

-Use the pr-review-remediator agent if available (see ../agents/pr-review-remediator.md).
+Use the pr-review-remediator agent (aka pr-review-handler) if available
+(see ../agents/pr-review-remediator.md). Both `/agent pr-review-remediator`
+and `/agent pr-review-handler` may be supported depending on repo config.

16-20: Add missing safety checks to the top-level “Focus on” list.

Surface the two most error-prone items here to reinforce guardrails.

 Focus on:
 - Validating CodeRabbit suggestions make sense
 - Only linting changed files
 - Following Atmos coding standards from CLAUDE.md
 - Providing clear reasoning for each suggestion
+ - Ensuring a valid PR Semver label is set (patch|minor|major|no-release)
+ - Never modifying golden snapshots under tests/test-cases/ or tests/testdata/
.claude/agents/pr-review-remediator.md (7)

1-19: Tooling list: add Git (used in later steps).

Subsequent snippets invoke git; list it explicitly for clarity.

 tools:
   - Read
   - Grep
   - Glob
   - Bash
+  - Git
   - Edit
   - MultiEdit
   - Write
   - WebFetch
   - Task
   - TodoWrite

81-95: Match CodeRabbit’s actual login and stabilize the API used for reviews.

The bot often appears as coderabbitai[bot]. Also, cli “reviews” JSON typically exposes user.login in REST; align selectors.

-# Get CodeRabbit's main review comment
-gh api repos/cloudposse/atmos/issues/<PR_NUMBER>/comments \
-  --jq '.[] | select(.user.login == "coderabbitai") | .body'
+# Get CodeRabbit's main review comment
+gh api repos/cloudposse/atmos/issues/<PR_NUMBER>/comments \
+  --jq '.[] | select(.user.login | startswith("coderabbitai")) | .body'

-# Get CodeRabbit's review with detailed feedback
-gh pr view <PR_NUMBER> --repo cloudposse/atmos --json reviews \
-  --jq '.reviews[] | select(.author.login == "coderabbitai") | .body'
+# Get CodeRabbit's review bodies (REST)
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/reviews \
+  --jq '.[] | select(.user.login | startswith("coderabbitai")) | .body'
 
-# Get inline review comments (per-file)
-gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/comments \
-  --jq '.[] | select(.user.login == "coderabbitai") | {path, line: .line, body: .body}'
+# Get inline review comments (per-file)
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/comments \
+  --jq '.[] | select(.user.login | startswith("coderabbitai")) | {path, line: .line, body: .body}'

Also applies to: 89-95


283-318: Guard external tools before use (gofumpt/goimports).

Avoid failures on environments missing formatters.

 set -euo pipefail
 git fetch origin main --quiet || true
 make lint  # This already uses --new-from-rev=origin/main

+# Ensure formatters are available
+command -v gofumpt >/dev/null 2>&1 || { echo "gofumpt not found; skipping formatting."; SKIP_FMT=1; }
+command -v goimports >/dev/null 2>&1 || { echo "goimports not found; skipping imports fix."; SKIP_IMP=1; }
+
 # 2. Apply specific fixes to changed files only (skip deleted files)
 while IFS= read -r file; do
   if [[ -n "$file" && "$file" == *.go && -f "$file" ]]; then
     # Format only if it's a Go file that exists on disk
     echo "Formatting: $file"
-    gofumpt -w "$file"
-    goimports -w "$file"
+    [[ "${SKIP_FMT:-0}" != 1 ]] && gofumpt -w "$file"
+    [[ "${SKIP_IMP:-0}" != 1 ]] && goimports -w "$file"

414-420: Fix sample count mismatch (“4 files” vs 5 listed).

Small doc polish.

-### Changed Files (4 files)
+### Changed Files (5 files)

591-599: markdownlint MD026: remove trailing colon in heading.

Avoid trailing punctuation in headings.

-#### Required Labels (choose ONE):
+#### Required Labels (choose ONE)

675-680: Unify “changed files” reference to exclude deleted entries.

Mirror the earlier status-based approach here to prevent acting on removed files.

-# Get changed files in PR
-gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path'
+# Get changed files in PR (exclude deleted)
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files \
+  --jq '.[] | select(.status != "removed") | .filename'

506-516: Note on forks: some API mutations need elevated permissions.

Add a one-liner caveat to set expectations when tokens lack scopes on forked PRs.

 ## Safety Controls
 ...
 - **ALWAYS** create feature branches for fixes
+ - Note: On forked PRs, some GitHub API calls (e.g., resolving threads,
+   posting replies) may be limited by token scopes.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 26acfc6 and 6becc06.

📒 Files selected for processing (3)
  • .claude/README.md (1 hunks)
  • .claude/agents/pr-review-remediator.md (1 hunks)
  • .claude/commands/fix-pr.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .claude/README.md
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-01-25T03:51:57.689Z
Learnt from: Listener430
PR: cloudposse/atmos#934
File: tests/fixtures/scenarios/docs-generate/README.md.gotmpl:99-118
Timestamp: 2025-01-25T03:51:57.689Z
Learning: For the cloudposse/atmos repository, changes to template contents should be handled in dedicated PRs and are typically considered out of scope for PRs focused on other objectives.

Applied to files:

  • .claude/commands/fix-pr.md
  • .claude/agents/pr-review-remediator.md
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
PR: cloudposse/atmos#808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.

Applied to files:

  • .claude/agents/pr-review-remediator.md
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Run golangci-lint and fix any issues before submitting a pull request

Applied to files:

  • .claude/agents/pr-review-remediator.md
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-remediator.md

591-591: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: [localstack] demo-localstack
  • GitHub Check: Acceptance Tests (windows-latest, windows)
  • GitHub Check: Acceptance Tests (ubuntu-latest, linux)
  • GitHub Check: Acceptance Tests (macos-latest, macos)
  • GitHub Check: Summary

…ot] suffix

- Replace exact match 'coderabbitai' with case-insensitive contains
- Use '.user.login | ascii_downcase | contains("coderabbit")'
- Handle variations like 'CodeRabbitAI', 'coderabbitai[bot]', etc.
- Update all occurrences in agent and README files
- Fix both .user.login and .author.login field checks

This ensures the agent reliably finds CodeRabbit comments regardless
of how the bot account name appears (with [bot] suffix or different casing).
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
.claude/agents/pr-review-remediator.md (3)

53-63: Changed-files query can include deleted files and miss large PRs; standardize on status filter with pagination.

Replace the heuristic and prefer the pulls API with --paginate to avoid failures on removed files and >100 file diffs. (Matches prior feedback.)

-# Get list of changed files in PR (excluding deleted files)
-# The files array includes: additions, deletions, and path
-# We filter for added, modified, or renamed files only
-CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
-  --jq '.files[] | select(.deletions >= 0 and .additions > 0) | .path')
-
-# Alternative: Use gh api for more detailed file status
-CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files \
-  --jq '.[] | select(.status != "removed") | .filename')
+# Get list of changed files in PR (excluding deleted files) — status-based with pagination
+CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files --paginate \
+  --jq '.[] | select(.status != "removed") | .filename')

81-95: Match CodeRabbit login case-insensitively (“coderabbitai[bot]”, etc.).

Prevents missing comments across installations. (Matches prior feedback.)

-  --jq '.[] | select(.user.login == "coderabbitai") | .body'
+  --jq '.[] | select(.user.login | test("coderabbit"; "i")) | .body'
-  --jq '.reviews[] | select(.author.login == "coderabbitai") | .body'
+  --jq '.reviews[] | select(.author.login | test("coderabbit"; "i")) | .body'
-  --jq '.[] | select(.user.login == "coderabbitai") | {path, line: .line, body: .body}'
+  --jq '.[] | select(.user.login | test("coderabbit"; "i")) | {path, line: .line, body: .body}'
-  --jq '.[] | select(.user.login == "coderabbitai")'
+  --jq '.[] | select(.user.login | test("coderabbit"; "i"))'
-  --jq '.[] | select(.user.login == "coderabbitai") | .id' | head -1)
+  --jq '.[] | select(.user.login | test("coderabbit"; "i")) | .id' | head -1)
-  --jq '.[] | select(.user.login == "coderabbitai") | .id'
+  --jq '.[] | select(.user.login | test("coderabbit"; "i")) | .id'
-        select(.comments.nodes[0].author.login == "coderabbitai" and .isResolved == false)'
+        select((.comments.nodes[0].author.login | test("coderabbit"; "i")) and (.isResolved == false))'

Also applies to: 219-221, 327-329, 375-377, 401-403


648-656: Regex bug: extension pattern anchored to start of filename.

Use end-of-string extension match to properly detect docs-only changes. (Matches prior feedback.)

-NON_RELEASE_PATTERN='^\.(md|mdx|txt)$|^website/|^docs/|^\.github/|^\.claude/|^\.cursor/|^tools/|^examples/|^\.vscode/'
+NON_RELEASE_PATTERN='\.(md|mdx|txt)$|^website/|^docs/|^\.github/|^\.claude/|^\.cursor/|^tools/|^examples/|^\.vscode/'
🧹 Nitpick comments (6)
.claude/agents/pr-review-remediator.md (6)

67-73: Use read-loop to avoid word-splitting bugs on filenames.

Safer/more consistent with later sections.

-for file in $CHANGED_FILES; do
-  if [[ -f "$file" && "$file" == *.go ]]; then
-    golangci-lint run "$file"
-  fi
-done
+while IFS= read -r file; do
+  if [[ -f "$file" && "$file" == *.go ]]; then
+    golangci-lint run "$file"
+  fi
+done <<< "$CHANGED_FILES"

206-211: Add --paginate to list endpoints to handle >100 items.

Ensures complete results for large PRs and long comment threads.

Examples:

-gh api repos/cloudposse/atmos/pulls/$PR_NUMBER/files --jq '
+gh api repos/cloudposse/atmos/pulls/$PR_NUMBER/files --paginate --jq '
-gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/comments \
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/comments --paginate \
-gh api repos/cloudposse/atmos/code-scanning/alerts \
+gh api repos/cloudposse/atmos/code-scanning/alerts --paginate \

Also applies to: 325-332, 374-377, 541-546, 548-558, 560-568, 571-585, 620-641, 648-651, 669-683, 700-702, 706-709, 726-735


591-599: Remove trailing colon in heading (markdownlint MD026).

Keeps docs lint-clean.

-#### Required Labels (choose ONE):
+#### Required Labels (choose ONE)

195-203: Harden Phase 1 script with strict mode.

Adds safety and consistent failure behavior.

 ```bash
-# 1. Get PR details and changed files
+# 1. Get PR details and changed files
+set -euo pipefail
+IFS=$'\n\t'
 PR_NUMBER=1440
 gh pr view $PR_NUMBER --repo cloudposse/atmos --json files,title,state

700-705: Key Commands: prefer status-based file listing here too.

Avoid showcasing the naive variant that includes deleted files.

-# Get changed files in PR
-gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path'
+# Get changed files in PR (excluding deleted)
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files --paginate \
+  --jq '.[] | select(.status != "removed") | .filename'

707-709: Unify placeholder naming (<PR_NUMBER> vs ).

Prevents copy/paste errors.

-gh api repos/cloudposse/atmos/issues/<PR>/comments \
+gh api repos/cloudposse/atmos/issues/<PR_NUMBER>/comments \
-  -f ref="refs/pull/<PR>/head" \
+  -f ref="refs/pull/<PR_NUMBER>/head" \

Also applies to: 728-729

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6becc06 and 4fc8fc9.

📒 Files selected for processing (1)
  • .claude/agents/pr-review-remediator.md (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
PR: cloudposse/atmos#808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.

Applied to files:

  • .claude/agents/pr-review-remediator.md
📚 Learning: 2025-09-07T15:13:17.797Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T15:13:17.797Z
Learning: Use "no-release" label for documentation-only PRs and ensure all CI checks pass before review.

Applied to files:

  • .claude/agents/pr-review-remediator.md
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-remediator.md

591-591: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Summary
🔇 Additional comments (1)
.claude/agents/pr-review-remediator.md (1)

1-19: Solid doc structure and goals.

Clear responsibilities, safety rails, and Atmos conventions. Nice.

Comment on lines +189 to +191
```text

## Detailed Workflow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix mismatched code fences (closing with “```text”).

Breaks Markdown rendering; close with plain triple backticks.

-```text
+```

Also applies to: 271-273, 491-493, 768-770

🤖 Prompt for AI Agents
In .claude/agents/pr-review-remediator.md around lines 189-191 (also fix
occurrences at 271-273, 491-493, 768-770): mismatched Markdown code fences are
closed with "```text" instead of plain "```" which breaks rendering; replace
each closing fence that currently reads "```text" with a plain closing triple
backtick "```" so every fenced block begins with "```text" (if intended) and
ends with "```", ensuring proper opening and closing pairs for valid Markdown.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (6)
.claude/agents/pr-review-remediator.md (6)

189-191: Fix mismatched code fence (closing with ```text).

Close with plain triple backticks to render properly.

-```text
+```

271-273: Fix mismatched code fence (closing with ```text).

-```text
+```

491-493: Fix mismatched code fence (closing with ```text).

-```text
+```

768-770: Fix mismatched code fence (closing with ```text).

-```text
+```

53-63: Use status-based changed-files filter only; drop additions/deletions heuristic.

The .additions > 0 approach will miss edits that remove lines and can misclassify. Standardize on the pulls API with --paginate and status != "removed" to avoid deleted files.

 # Get list of changed files in PR (excluding deleted files)
-# The files array includes: additions, deletions, and path
-# We filter for added, modified, or renamed files only
-CHANGED_FILES=$(gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files \
-  --jq '.files[] | select(.deletions >= 0 and .additions > 0) | .path')
-
-# Alternative: Use gh api for more detailed file status
-CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files \
-  --jq '.[] | select(.status != "removed") | .filename')
+# Prefer the pulls API and filter by file status
+CHANGED_FILES=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files --paginate \
+  --jq '.[] | select(.status != "removed") | .filename')

648-656: Regex bug: extension pattern anchored to start.

^\.(md|mdx|txt)$ only matches dotfiles named literally .md. Match file extensions at end of name.

-NON_RELEASE_PATTERN='^\.(md|mdx|txt)$|^website/|^docs/|^\.github/|^\.claude/|^\.cursor/|^tools/|^examples/|^\.vscode/'
+NON_RELEASE_PATTERN='\.(md|mdx|txt)$|^website/|^docs/|^\.github/|^\.claude/|^\.cursor/|^tools/|^examples/|^\.vscode/'
🧹 Nitpick comments (4)
.claude/agents/pr-review-remediator.md (4)

591-599: Remove trailing colon in heading (MD026).

Fix markdownlint “no-trailing-punctuation”.

-#### Required Labels (choose ONE):
+#### Required Labels (choose ONE)

699-705: Changed-files command should exclude deleted entries.

The gh pr view ... --json files --jq '.files[].path' variant can include removed files. Recommend the pulls API with status filter.

-# Get changed files in PR
-gh pr view <PR_NUMBER> --repo cloudposse/atmos --json files --jq '.files[].path'
+# Get changed, non-removed files in PR
+gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/files --paginate \
+  --jq '.[] | select(.status != "removed") | .filename'

706-709: Be explicit with placeholders and repo; add pagination.

Use <PR_NUMBER> consistently and pass --repo for clarity; paginate large PRs.

-gh api repos/cloudposse/atmos/issues/<PR>/comments \
-  --jq '.[] | select(.user.login | ascii_downcase | contains("coderabbit"))'
+gh api repos/cloudposse/atmos/issues/<PR_NUMBER>/comments --paginate \
+  --jq '.[] | select(.user.login | ascii_downcase | contains("coderabbit"))'

327-339: Reply to all matching review comments, not just the first.

Handling only head -1 can miss others. Iterate safely.

-COMMENT_ID=$(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/comments \
-  --jq '.[] | select(.user.login | ascii_downcase | contains("coderabbit")) | .id' | head -1)
-
-# Reply to the comment explaining what was done
-gh api repos/cloudposse/atmos/pulls/comments/$COMMENT_ID/replies \
-  --method POST \
-  -f body="✅ **Resolved**: Fixed by applying the following changes:
+for COMMENT_ID in $(gh api repos/cloudposse/atmos/pulls/<PR_NUMBER>/comments \
+  --jq '.[] | select(.user.login | ascii_downcase | contains("coderabbit")) | .id'); do
+  gh api repos/cloudposse/atmos/pulls/comments/$COMMENT_ID/replies \
+    --method POST \
+    -f body="✅ **Resolved**: Fixed by applying the following changes:
 - Added period to comment as per CLAUDE.md requirements
 - Updated error handling to use static errors from errors/errors.go
 - Ensured all comments are complete sentences
 
 Commit: \`abc123def\` - fix: address CodeRabbit review feedback"
+done
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4fc8fc9 and 6ae31e2.

📒 Files selected for processing (2)
  • .claude/README.md (1 hunks)
  • .claude/agents/pr-review-remediator.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .claude/README.md
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
PR: cloudposse/atmos#808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.

Applied to files:

  • .claude/agents/pr-review-remediator.md
📚 Learning: 2025-09-07T15:13:17.797Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T15:13:17.797Z
Learning: Use "no-release" label for documentation-only PRs and ensure all CI checks pass before review.

Applied to files:

  • .claude/agents/pr-review-remediator.md
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Run golangci-lint and fix any issues before submitting a pull request

Applied to files:

  • .claude/agents/pr-review-remediator.md
🪛 markdownlint-cli2 (0.17.2)
.claude/agents/pr-review-remediator.md

591-591: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Summary
🔇 Additional comments (4)
.claude/agents/pr-review-remediator.md (4)

81-95: Good: resilient CodeRabbit author matching.

Case-insensitive match with [bot] variants handled correctly.


200-204: Good: status-based file filter with pagination-ready pattern.

This avoids acting on deleted files. Keep it as the canonical snippet.


284-287: Good: strict mode and scoped linting.

Solid defaults; aligns with CLAUDE.md and repo Makefile behavior.


571-585: Good: CodeQL alert counting and summary.

Straightforward detection for PR ref; adequate for docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-release Do not create a new release (wait for additional code changes) size/l Large size PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant