Skip to content

Commit 64306d2

Browse files
committed
chore(workflows): run Claude review once per PR and on manual trigger
- Update workflow to trigger only on PR open/reopen and manual comment - Add concurrency group to ensure single review per PR at a time - Improve documentation and add workflow example for clarity - Move request tracing info to README and update troubleshooting steps
1 parent c4662f9 commit 64306d2

5 files changed

Lines changed: 172 additions & 127 deletions

File tree

.github/workflows/claude-code-review.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
name: Claude Code Review
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize]
6-
# Optional: Only run on specific file changes
7-
# paths:
8-
# - "src/**/*.ts"
9-
# - "src/**/*.tsx"
10-
# - "src/**/*.js"
11-
# - "src/**/*.jsx"
4+
pull_request_target:
5+
types: [opened, reopened]
6+
issue_comment:
7+
types: [created]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: "claude-review-${{ github.event.pull_request.number || github.event.issue.number }}"
12+
cancel-in-progress: false
1213

1314
jobs:
1415
claude-review:
15-
# Optional: Filter by PR author
16-
# if: |
17-
# github.event.pull_request.user.login == 'external-contributor' ||
18-
# github.event.pull_request.user.login == 'new-developer' ||
19-
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
16+
if: |
17+
github.event_name == 'pull_request_target' ||
18+
(github.event_name == 'issue_comment' &&
19+
github.event.issue.pull_request &&
20+
contains(github.event.comment.body, '@claude'))
2021
2122
runs-on: ubuntu-latest
2223
permissions:
2324
contents: read
24-
pull-requests: read
25-
issues: read
25+
pull-requests: write
26+
issues: write
2627
id-token: write
2728

2829
steps:
2930
- name: Checkout repository
3031
uses: actions/checkout@v4
3132
with:
32-
fetch-depth: 1
33+
fetch-depth: 0
34+
ref: ${{ github.event.pull_request.head.sha || github.event.pull_request.merge_commit_sha }}
3335

3436
- name: Run Claude Code Review
3537
id: claude-review

CLAUDE.md

Lines changed: 40 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,45 @@
22

33
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44

5+
## PROJECT STRUCTURE
6+
7+
```
8+
claude-code-yolo/
9+
├── CLAUDE.md # This file - project guidance for Claude
10+
├── README.md # Main documentation
11+
├── CHANGELOG.md # Version history
12+
├── DEV-LOGS.md # Development journal
13+
├── TODO.md # Task tracking
14+
├── install.sh # One-line installer script
15+
├── Makefile # Build automation
16+
├── Dockerfile # Container image definition
17+
├── .dockerignore # Docker build exclusions
18+
├── docker-entrypoint.sh # Container startup script
19+
├── .gitignore # Git exclusions
20+
├── claude.sh # Main wrapper script (local/Docker modes)
21+
├── claude-yolo # Quick YOLO mode wrapper
22+
├── claudeb.sh # Bedrock authentication helper
23+
24+
├── .github/ # GitHub automation
25+
│ ├── ISSUE_TEMPLATE.md # Bug report template
26+
│ └── workflows/ # GitHub Actions
27+
│ ├── ci.yml # Pull request checks
28+
│ ├── release.yml # Release automation
29+
│ ├── claude.yml # Claude @mention handler
30+
│ └── claude-code-review.yml # Automated code review
31+
32+
├── workflows/ # Development workflows
33+
│ ├── GIT-COMMIT.md # Commit guidelines
34+
│ ├── GITHUB-PR.md # PR creation process
35+
│ └── PRE-RELEASE.md # Release checklist
36+
37+
└── references/ # Documentation and research
38+
├── chats/ # AI conversation logs
39+
├── claude-code/ # Official Claude Code repo reference
40+
├── claude-code-docs/ # Official documentation
41+
└── code-reviews/ # AI code review examples
42+
```
43+
544
## PROJECT PURPOSE
645

746
**Claude Code YOLO wraps the Claude CLI in Docker to safely enable `--dangerously-skip-permissions` without compromising your local machine.**
@@ -102,8 +141,7 @@ Docker container automatically translates `127.0.0.1` and `localhost` to `host.d
102141
* "Invalid API key" - Mount both `~/.claude` and `~/.claude.json`
103142
* Proxy not working - Localhost auto-translates to `host.docker.internal`
104143
* Permission denied - Container copies auth files with proper permissions
105-
* Wrong auth method - Use explicit flags: `--claude`, `--api-key`, `--bedrock`
106-
* Claude refuses dangerous permissions - YOLO mode runs as non-root + adds `--dangerously-skip-permissions`
144+
* Claude refuses dangerous permissions on root user - YOLO mode runs as non-root + adds `--dangerously-skip-permissions`
107145
* Running in home directory - Script warns and requires confirmation, always cd to project first
108146

109147
## Development Tools Included
@@ -114,112 +152,3 @@ Docker container automatically translates `127.0.0.1` and `localhost` to `host.d
114152
**Editors**: vim, neovim, nano
115153
**Shell**: zsh with oh-my-zsh and plugins
116154
**Claude**: claude, claude-trace pre-installed
117-
118-
## Request Tracing Support
119-
120-
Claude Code YOLO integrates with [claude-trace](https://github.com/badlogic/lemmy/tree/main/apps/claude-trace) for detailed request logging and debugging.
121-
122-
**Installation:**
123-
```bash
124-
npm install -g @mariozechner/claude-trace
125-
```
126-
127-
**Usage:**
128-
```bash
129-
# Enable tracing in local mode
130-
./claude.sh --trace .
131-
132-
# Enable tracing in YOLO mode
133-
./claude.sh --yolo --trace .
134-
135-
# Bedrock with tracing
136-
./claudeb.sh --trace .
137-
```
138-
139-
**Features:**
140-
- Logs all Claude API requests and responses
141-
- Saves trace files to `.claude-trace/` directory
142-
- Includes full request/response headers and timing
143-
- Useful for debugging authentication issues and API usage
144-
145-
## Common Development Commands
146-
147-
### Building and Testing
148-
```bash
149-
# Build Docker image
150-
make build
151-
152-
# Rebuild without cache
153-
make rebuild
154-
155-
# Test the built image
156-
make test
157-
158-
# Test with current directory mounted
159-
make test-local
160-
161-
# Build and test in one command
162-
make build-test
163-
164-
# Open development shell
165-
make dev
166-
```
167-
168-
### Running Claude
169-
```bash
170-
# Quick YOLO mode (recommended)
171-
./claude-yolo . # Local script
172-
claude-yolo . # If installed globally
173-
174-
# Full wrapper options
175-
./claude.sh --yolo . # YOLO mode in Docker
176-
./claude.sh . # Local mode (no Docker)
177-
./claude.sh --api-key . # Use API key auth
178-
./claude.sh --bedrock . # Use AWS Bedrock
179-
./claude.sh --vertex . # Use Google Vertex AI
180-
./claude.sh --shell # Open shell in container
181-
./claude.sh --trace . # Enable request tracing
182-
```
183-
184-
### Container Management
185-
```bash
186-
# Clean up Docker artifacts
187-
make clean
188-
189-
# Deep clean including BuildKit cache
190-
make clean-all
191-
192-
# Show image information and size
193-
make info
194-
195-
# Check build context size
196-
make context-size
197-
198-
# Lint Dockerfile (requires hadolint)
199-
make lint
200-
```
201-
202-
## Debug and Troubleshooting Commands
203-
204-
### Authentication Debugging
205-
```bash
206-
# Test different auth methods with tracing
207-
./claude.sh --claude --trace . # OAuth debugging
208-
./claude.sh --api-key --trace . # API key debugging
209-
./claude.sh --bedrock --trace . # Bedrock debugging
210-
211-
# Use dedicated Bedrock helper script
212-
./claudeb.sh --trace . # Bedrock with model conversion
213-
```
214-
215-
### Container Debugging
216-
```bash
217-
# Open shell in container for debugging
218-
make shell
219-
220-
# Check container environment
221-
docker run --rm -it lroolle/claude-code-yolo:latest bash -c "env | sort"
222-
223-
# Verify development tools
224-
docker run --rm lroolle/claude-code-yolo:latest bash -c 'python --version && node --version && go version'
225-
```

DEV-LOGS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55

66
## Issue Analysis: 2025-06-23
77

8+
### [enhancement-completed] Claude Code Review workflow simplification
9+
10+
**Problem**: Overcomplicated workflow with manual duplicate detection using GitHub CLI.
11+
12+
**Solution**: Adopted ChatGPT pattern with critical fixes:
13+
- `pull_request_target` → enables secret access for `ANTHROPIC_API_KEY`
14+
- Concurrency groups → automatic duplicate prevention
15+
- Proper checkout ref → works for comment-triggered reviews
16+
- Removed complex GitHub CLI duplicate detection logic
17+
18+
**Result**: 50% fewer lines, more reliable, follows GitHub best practices.
19+
20+
**Status**: ✅ **COMPLETED**
21+
22+
---
23+
24+
## Issue Analysis: 2025-06-23
25+
826
### [enhancement-completed] Clean startup message redesign
927

1028
**Problem**: Startup messages were excessively verbose (65+ lines) with poor UX.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ claude-yolo -v ~/.terraform.d:/root/.terraform.d
117117
- **Request Tracing**: Debug with `--trace` flag using claude-trace
118118
- **Docker Socket**: Optional mounting with `CLAUDE_YOLO_DOCKER_SOCKET=true`
119119

120+
121+
### Request Tracing by @badlogic `claude-trace`
122+
123+
Claude Code YOLO integrates with [claude-trace](https://github.com/badlogic/lemmy/tree/main/apps/claude-trace) for detailed request logging and debugging.
124+
120125
## Docker Images
121126

122127
Claude Code YOLO is available from multiple container registries:
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# 1. **Trigger strategy**
2+
3+
# * **Auto review**: run on `pull_request_target` only when the PR is **opened** or **re-opened**—not on every push (`synchronize`).
4+
# * **Opt-in re-review**: listen on `issue_comment` and run again only if the comment body contains `/claude-review`.
5+
# * Optional `workflow_dispatch` makes the “Run workflow” button available in the UI.
6+
7+
# 2. **One job per PR at a time**
8+
9+
# * Use `concurrency.group = "claude-review-${PR_NUMBER}"`; `cancel-in-progress: false` lets earlier runs finish while preventing duplicate parallel runs.
10+
11+
# 3. **Job guard**
12+
13+
# * Single job guarded with an `if:` expression so it fires only for the two allowed scenarios above.
14+
15+
# 4. **Minimal permissions**
16+
17+
# * `pull-requests: write` → post review comments.
18+
# * `issues: write` → reply to the `/claude-review` trigger comment.
19+
20+
# 5. **Run the Claude action**
21+
22+
# * Swap the placeholder `anthropic-ai/claude-code-review@v1` for whatever revision you actually use.
23+
24+
# 6. **(Optional) Reply to manual trigger**
25+
26+
# * A short “review queued” reply helps contributors know their command was accepted.
27+
28+
# The finished workflow file **`.github/workflows/claude-review.yml`** is now in the canvas—feel free to tweak the action version, the trigger phrase, or remove the reply step if you don’t need it.
29+
30+
# ---
31+
32+
# Auto‑run Claude code review exactly once per PR, and allow opt‑in re‑reviews
33+
name: "Claude Code Review"
34+
35+
on:
36+
# --- automatic run ---
37+
# Trigger only when a PR is first opened or later re‑opened.
38+
pull_request_target:
39+
types: [opened, reopened]
40+
41+
# --- manual re‑review ---
42+
# Listen for a PR comment that contains the magic string "/claude-review".
43+
issue_comment:
44+
types: [created]
45+
46+
# Optional: enable the "Run workflow" button in the Actions tab.
47+
workflow_dispatch:
48+
49+
# Ensure one review job per PR runs at a time under the same key
50+
concurrency:
51+
group: "claude-review-${{ github.event.pull_request.number || github.event.issue.number }}"
52+
cancel-in-progress: false
53+
54+
jobs:
55+
review:
56+
# Gate so we only execute on our two allowed scenarios
57+
if: |
58+
github.event_name == 'pull_request_target' ||
59+
(github.event_name == 'issue_comment' &&
60+
github.event.issue.pull_request &&
61+
contains(github.event.comment.body, '/claude-review'))
62+
63+
permissions:
64+
pull-requests: write # allow action to post PR comments
65+
issues: write # allow replying to the trigger comment
66+
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- name: 📥 Checkout code
71+
uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
# Use the PR head SHA when the workflow is comment‑triggered
75+
ref: ${{ github.event.pull_request.head.sha || github.event.pull_request.merge_commit_sha }}
76+
77+
- name: 🤖 Run Claude review
78+
# Replace with the actual action that invokes Claude
79+
uses: anthropic-ai/claude-code-review@v1
80+
with:
81+
pull_request: "${{ github.event.pull_request.number || github.event.issue.number }}"
82+
83+
- name: 🗨️ Acknowledge manual trigger
84+
if: github.event_name == 'issue_comment'
85+
env:
86+
COMMENT_ID: "${{ github.event.comment.id }}"
87+
run: |
88+
gh api \
89+
-X POST \
90+
-F body='👋 Claude review queued.' \
91+
/repos/${{ github.repository }}/issues/comments/${COMMENT_ID}/replies

0 commit comments

Comments
 (0)