Skip to content

.github: add low-risk label trigger for Claude review with approval#1095

Merged
hieblmi merged 1 commit intolightninglabs:masterfrom
hieblmi:claude-review-approve
Mar 13, 2026
Merged

.github: add low-risk label trigger for Claude review with approval#1095
hieblmi merged 1 commit intolightninglabs:masterfrom
hieblmi:claude-review-approve

Conversation

@hieblmi
Copy link
Collaborator

@hieblmi hieblmi commented Mar 12, 2026

Summary

Its up to the PR creator to apply the low-risk label after judging the PR impact.
The first PR reviewer(besides claude) must then assess the severity category.
If they aggree claude's green check counts.

  • Adds a claude-approve job triggered by the low-risk label
  • Claude reviews the PR and approves with gh pr review --approve only if no significant issues are found
  • If issues are found, Claude leaves a comment instead of approving
  • The approve job has pull-requests: write permission (scoped only to this job)
  • Existing claude-review job (comment-only) remains unchanged

Triggers

Trigger Job Can approve?
@claude mention claude-review No (read-only)
claude-review label claude-review No (read-only)
low-risk label claude-approve Yes (if no issues found)

Test plan

  • Add low-risk label to a clean PR — Claude should review and approve
  • Add low-risk label to a PR with issues — Claude should comment without approving
  • Verify @claude mention and claude-review label still work as comment-only

@gemini-code-assist
Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

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

LGTM!

Some proposals added.

- Security concerns
- Test coverage

Use the repository's CLAUDE.md for guidance on style and conventions.
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/CLAUDE.md/AGENTS.md/

Comment on lines 6 to 7
pull_request:
types: [labeled, synchronize]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it have access to secrets.CLAUDE_CODE_OAUTH_TOKEN?

Codex thinks that we need to add this so it had access to it in PRs from forks:

   pull_request:
     types: [labeled, synchronize]
+  pull_request_target:
+    types: [labeled, synchronize]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes we have access, the @claude wouldn't work otherwise


claude-approve:
if: |
github.event_name == 'pull_request' &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Then we need to replace pull_request with pull_request_target here

Copy link
Collaborator

Choose a reason for hiding this comment

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

s/CLAUDE.md/AGENTS.md/

Comment on lines +96 to +98
If you find ANY significant issues, do NOT approve. Instead, leave a
comment explaining the problems using:
gh pr comment ${{ github.event.pull_request.number }} --body "Your review findings"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The bot can request changes to undo its previous approval:

            If NOT approving:
              gh pr review ${{ github.event.pull_request.number }} --request-changes --body "Claude review: not eligible for low-risk auto-approval. Include intrinsic PR risk and findings w
ith severities."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point!

uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
Copy link
Collaborator

Choose a reason for hiding this comment

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

I propose to separate intrinsic severity of the PR (e.g. whether it touches any code working with funds) and severity of potential problems found in the PR (where or not PR itself is valid). If any of these is higher than low, do not use auto-approve flow.

Here is the whole prompt:

REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}

Review this pull request thoroughly, checking for:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage

Use the repository's AGENTS.md for guidance on style and conventions.

Classify the PR's intrinsic risk severity using one of:
- critical: must block merge
- high: large blast radius or very sensitive code paths
- medium: meaningful production or maintainability risk
- low: constrained blast radius and straightforward rollback

Intrinsic risk is about the impact and sensitivity of changed code,
even when no concrete bug is found.
Any changes touching fund movement, signing/sweeping, swap state
transitions, security/authz/authn logic, secrets handling, or DB
schema/migrations are at least medium risk.

Also classify each finding using one of:
- critical
- high
- medium
- low
- nit

Decision rule:
- Approve ONLY if intrinsic PR risk is low AND highest finding
  severity is low or nit.
- If intrinsic PR risk is medium/high/critical, DO NOT approve and
  submit a changes-requested review.
- If any finding is medium/high/critical, DO NOT approve and submit
  a changes-requested review.
- If uncertain, treat as medium risk.

If approving:
  gh pr review ${{ github.event.pull_request.number }} --approve --body "Claude review: intrinsic PR risk low and findings low/nit; safe for low-risk path."

If NOT approving:
  gh pr review ${{ github.event.pull_request.number }} --request-changes --body "Claude review: not eligible for low-risk auto-approval. Include intrinsic PR risk and findings with severities."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the great refinement.

@hieblmi hieblmi force-pushed the claude-review-approve branch from 3cefdc1 to 9014843 Compare March 13, 2026 08:00
- Add pull_request_target trigger for fork secret access
- Use pull_request_target in claude-approve if-condition
- Replace CLAUDE.md references with AGENTS.md
- Replace simple approve/comment prompt with comprehensive
  risk-classification prompt (intrinsic PR risk + finding severity)
- Use --request-changes instead of comment when not approving
@hieblmi hieblmi force-pushed the claude-review-approve branch from 9014843 to 06d978c Compare March 13, 2026 08:01
@hieblmi hieblmi merged commit 8640291 into lightninglabs:master Mar 13, 2026
11 checks passed
@hieblmi hieblmi deleted the claude-review-approve branch March 13, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants