forked from ChrisWiles/claude-code-showcase
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathscheduled-claude-code-quality.yml
More file actions
157 lines (133 loc) · 5.35 KB
/
scheduled-claude-code-quality.yml
File metadata and controls
157 lines (133 loc) · 5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Scheduled - Code Quality Review
on:
schedule:
# Run every Sunday at 8 AM UTC
- cron: '0 8 * * 0'
workflow_dispatch:
inputs:
num_dirs:
description: 'Number of random directories to review'
required: false
default: '3'
concurrency:
group: ${{ github.workflow }}-${{ github.run_id }}
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
jobs:
select-directories:
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.select.outputs.directories }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Select random directories
id: select
run: |
NUM_DIRS="${{ github.event.inputs.num_dirs || '3' }}"
# Find directories in src that have TypeScript files
DIRS=$(find src -type d -exec sh -c 'ls "$1"/*.ts "$1"/*.tsx 2>/dev/null | grep -v -E "\.(test|spec|stories)\." | head -1' _ {} \; 2>/dev/null | \
xargs -I {} dirname {} | \
sort -u | \
shuf -n "$NUM_DIRS")
if [ -z "$DIRS" ]; then
echo "No suitable directories found"
echo "directories=[]" >> $GITHUB_OUTPUT
exit 0
fi
# Convert to JSON array
JSON_DIRS=$(echo "$DIRS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "directories=$JSON_DIRS" >> $GITHUB_OUTPUT
echo "Selected directories:"
echo "$DIRS"
review-directory:
needs: select-directories
if: needs.select-directories.outputs.directories != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
directory: ${{ fromJson(needs.select-directories.outputs.directories) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate branch name
id: branch
run: |
DIR_SLUG=$(echo "${{ matrix.directory }}" | sed 's/[^a-zA-Z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | cut -c1-30)
BRANCH_NAME="claude/code-quality-${DIR_SLUG}-$(date +%Y%m%d)"
echo "name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Claude Code Quality Review
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
model: claude-opus-4-5-20251101
timeout_minutes: 45
base_branch: main
branch_prefix: claude/code-quality-
track_progress: true
prompt: |
# Weekly Code Quality Review
You are performing a scheduled code quality review of a specific directory.
## Target Directory
**Review: `${{ matrix.directory }}`**
## Your Tasks
1. **Read the code review standards**: Read `.claude/agents/code-reviewer.md` for the full checklist
2. **Analyze all files in the directory**:
- List all .ts and .tsx files (excluding .test., .spec., .stories.)
- Read each file thoroughly
- Apply the review checklist
3. **Focus on finding and FIXING issues**:
- TypeScript strict mode violations (any types, missing types)
- React anti-patterns (bad useEffect, unnecessary memoization)
- Code style issues (mutations, deep nesting, poor naming)
- Missing error handling
- Security issues
- Performance problems
4. **Make the fixes yourself**:
- Don't just report issues - FIX THEM
- Use Edit tool to update files
- Ensure fixes don't break anything
5. **Run verification**:
- `npm run lint` - verify no lint errors introduced
- If errors occur, fix them or revert changes
6. **Create PR if fixes were made**:
- Create a branch from main
- Commit all fixes with descriptive message
- PR title: "fix(${{ matrix.directory }}): code quality improvements"
- PR body should list fixes applied
## Guidelines
- Be thorough but focused on this directory only
- Fix issues that are clear improvements
- Don't refactor working code just for style
- If no issues found, report that and skip PR creation
claude_args: |
--max-turns 35
--allowedTools "Read,Write,Edit,Glob,Grep,Bash(git:*),Bash(gh:*),Bash(npm run lint*)"
report-completion:
needs: [select-directories, review-directory]
if: always()
runs-on: ubuntu-latest
steps:
- name: Summary
run: |
echo "## Code Quality Review Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Reviewed directories:" >> $GITHUB_STEP_SUMMARY
echo '${{ needs.select-directories.outputs.directories }}' | jq -r '.[]' | while read dir; do
echo "- \`$dir\`" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "Check for any PRs created by this workflow." >> $GITHUB_STEP_SUMMARY