1- # Amber Automatic Code Review
2- #
3- # Uses memory system to apply repository-specific standards
4- # Comments appear from github-actions[bot]
5- #
6- # Required GitHub Secret:
7- # - CLAUDE_CODE_OAUTH_TOKEN: OAuth token for Claude Code
8-
9- name : Amber Automatic Code Review
1+ name : Amber Auto Review
102
113on :
12- pull_request_target :
13- types : [opened, synchronize]
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - main
10+ workflow_dispatch :
1411
1512jobs :
16- amber- review :
13+ review :
1714 runs-on : ubuntu-latest
18- permissions :
19- contents : write
20- pull-requests : write
21- issues : write
22- id-token : write
23- actions : read
24-
2515 steps :
26- - name : Checkout PR head
27- uses : actions/checkout@v6
28- with :
29- repository : ${{ github.event.pull_request.head.repo.full_name }}
30- ref : ${{ github.event.pull_request.head.ref }}
31- fetch-depth : 0
32-
33- - name : Minimize old Claude review comments
34- continue-on-error : true
35- env :
36- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
37- run : |
38- REPO="${{ github.repository }}"
39- PR_NUMBER="${{ github.event.pull_request.number }}"
40-
41- echo "Finding previous Claude Code Review comments to minimize..."
42-
43- # Get all comment IDs from github-actions[bot] with "Claude Code Review" at the start
44- # Using startswith() to avoid matching code blocks or inline mentions
45- COMMENT_IDS=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" \
46- --jq '.[] | select(.user.login == "github-actions[bot]" and (.body | startswith("# Claude Code Review"))) | .node_id')
47-
48- if [ -z "$COMMENT_IDS" ]; then
49- echo "No old Claude Code Review comments found"
50- exit 0
51- fi
52-
53- # Minimize each comment with error handling
54- # Use here-string to avoid subshell variable scoping issues with pipe
55- COUNT=0
56- ERRORS=0
57- while read -r id; do
58- if [ -n "$id" ]; then
59- if gh api graphql -f query='mutation($id: ID!) { minimizeComment(input: {subjectId: $id, classifier: OUTDATED}) { minimizedComment { isMinimized } } }' -f id="$id" 2>&1; then
60- echo "✓ Minimized $id"
61- ((COUNT++))
62- else
63- echo "✗ Failed to minimize $id" >&2
64- ((ERRORS++))
65- fi
66- fi
67- done <<< "$COMMENT_IDS"
68-
69- echo "Minimized $COUNT comment(s), $ERRORS error(s)"
70-
71- - name : Run Amber Code Review (with memory system)
72- id : amber-review
73- uses : anthropics/claude-code-action@v1
74- with :
75- claude_code_oauth_token : ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
76- github_token : ${{ secrets.GITHUB_TOKEN }}
77- allowed_non_write_users : ' *'
78- claude_args : |
79- --allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh issue list:*)"
80- prompt : |
81- REPO: ${{ github.repository }}
82- PR NUMBER: ${{ github.event.pull_request.number }}
83-
84- Load the following memory system files to understand repository standards:
85-
86- 1. Read CLAUDE.md (master project instructions)
87- 2. Read .claude/context/backend-development.md
88- 3. Read .claude/context/frontend-development.md
89- 4. Read .claude/context/security-standards.md
90- 5. Read .claude/patterns/k8s-client-usage.md
91- 6. Read .claude/patterns/error-handling.md
92- 7. Read .claude/patterns/react-query-usage.md
93-
94- After loading all memory files, perform a comprehensive code review following the standards and patterns you just loaded.
95-
96- Focus on:
97- 1. **Code Quality** - Does it follow CLAUDE.md patterns?
98- 2. **Security** - Check security standards (user token auth, RBAC, token redaction)
99- 3. **Performance** - Any bottlenecks?
100- 4. **Testing** - Adequate coverage?
101- 5. **Architecture** - Follows project structure from memory context?
102- 6. **Error Handling** - Follows error handling patterns?
103-
104- Use `gh pr comment` to post your review with this format:
105-
106- # Claude Code Review
107-
108- ## Summary
109- [Brief overview]
110-
111- ## Issues by Severity
112-
113- ### 🚫 Blocker Issues
114- [Must fix before merge]
115-
116- ### 🔴 Critical Issues
117- [Should fix before merge]
118-
119- ### 🟡 Major Issues
120- [Important to address]
121-
122- ### 🔵 Minor Issues
123- [Nice-to-have improvements]
124-
125- ## Positive Highlights
126- [Things done well]
127-
128- ## Recommendations
129- [Prioritized action items]
130-
131- - name : Add workflow link with memory system visibility
132- if : steps.amber-review.conclusion == 'success'
133- uses : actions/github-script@v8
134- env :
135- RUN_ID : ${{ github.run_id }}
136- GITHUB_SERVER_URL : ${{ github.server_url }}
137- GITHUB_REPOSITORY : ${{ github.repository }}
138- with :
139- script : |
140- const prNumber = context.payload.pull_request.number;
141- const runId = process.env.RUN_ID;
142- const serverUrl = process.env.GITHUB_SERVER_URL;
143- const repository = process.env.GITHUB_REPOSITORY;
144-
145- // Find review comment
146- const comments = await github.rest.issues.listComments({
147- owner: context.repo.owner,
148- repo: context.repo.repo,
149- issue_number: prNumber
150- });
151-
152- const reviewComment = comments.data
153- .filter(c => c.user.login === 'github-actions[bot]' && c.body.startsWith('# Claude Code Review'))
154- .sort((a, b) => new Date(b.created_at) - new Date(a.created_at))[0];
155-
156- if (!reviewComment) {
157- console.log('No review comment found');
158- return;
159- }
160-
161- if (reviewComment.body.includes('View AI decision process')) {
162- console.log('Transparency link already added');
163- return;
164- }
165-
166- const transparencySection = '\n\n---\n🔍 [View AI decision process](' + serverUrl + '/' + repository + '/actions/runs/' + runId + ') (logs available for 90 days)\n\n' +
167- '<details>\n' +
168- '<summary>📋 View memory system files loaded (click to expand)</summary>\n\n' +
169- '### What Amber Loaded for Code Review\n\n' +
170- 'Amber automatically loaded these repository standards from the memory system:\n\n' +
171- '1. **CLAUDE.md** - Master project instructions, development standards\n' +
172- '2. **backend-development.md** - Go backend, K8s integration patterns\n' +
173- '3. **frontend-development.md** - NextJS, Shadcn UI, React Query patterns\n' +
174- '4. **security-standards.md** - Auth, RBAC, token handling\n' +
175- '5. **k8s-client-usage.md** - User token vs service account patterns\n' +
176- '6. **error-handling.md** - Consistent error patterns\n' +
177- '7. **react-query-usage.md** - Data fetching patterns\n\n' +
178- '**Impact**: This review used your repository\'s specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines.\n\n' +
179- '</details>';
180-
181- const updatedBody = reviewComment.body + transparencySection;
182-
183- await github.rest.issues.updateComment({
184- owner: context.repo.owner,
185- repo: context.repo.repo,
186- comment_id: reviewComment.id,
187- body: updatedBody
188- });
16+ - name : Check out code
17+ uses : actions/checkout@v2
18918
190- console.log('Added transparency link to review comment');
19+ - name : Run review
20+ run : echo 'Running auto review...'
0 commit comments