Skip to content

Commit 9c52312

Browse files
ducpm2303claude
andcommitted
feat: add GitHub Actions workflows and PR review template
.github/workflows/validate.yml: - Runs validate-plugins.sh on every push/PR to main - Validates all JSON files (marketplace, plugin manifests, hooks) - Checks version consistency across all plugin manifests .github/workflows/pr-review.yml: - Reviews PRs to this repo using claude-code-action@v1 - Checks SKILL.md quality, globs specificity, hook safety, version consistency, and references/ split recommendations templates/java-pr-review.yml: - Copy-paste template for users to add to their Java projects - Runs security scan (OWASP), performance scan (N+1), and code review on every PR touching .java or build files - Posts structured comment with severity-coded findings table README: added GitHub Actions section with setup instructions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bd15eea commit 9c52312

4 files changed

Lines changed: 257 additions & 0 deletions

File tree

.github/workflows/pr-review.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: PR Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'plugins/**/*.md'
8+
- 'plugins/**/*.json'
9+
- 'scripts/**'
10+
11+
concurrency:
12+
group: pr-review-${{ github.event.pull_request.number }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
review:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- uses: anthropics/claude-code-action@v1
27+
with:
28+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
29+
prompt: |
30+
Review this pull request to the claude-java-plugins repository.
31+
32+
Focus specifically on:
33+
1. **SKILL.md quality** — does the description start with a verb and include trigger phrases? Is content version-gated where needed (Java 8+, Spring Boot 3.x+)?
34+
2. **rules/*.md** — do new rule files have a `globs:` frontmatter that is as specific as possible?
35+
3. **commands/*.md** — does the command description clearly state what it does and when to use it?
36+
4. **hooks.json** — is the shell command safe? No destructive operations, no data exfiltration?
37+
5. **plugin.json** — are name, version, description present? Is the version consistent with marketplace.json?
38+
6. **References** — if a SKILL.md is over 80 lines, suggest moving templates to references/
39+
40+
Format your review as:
41+
## Summary
42+
One paragraph overview of what changed.
43+
44+
## Issues
45+
For each issue: `file:line — [SEVERITY] description and suggestion`
46+
Severities: `REQUIRED` (must fix), `SUGGESTED` (quality improvement), `NOTE` (informational)
47+
48+
## Looks Good
49+
Highlight anything well done.
50+
51+
Do NOT comment on prose style or subjective wording choices.

.github/workflows/validate.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Validate Plugins
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Validate plugin structure
16+
run: |
17+
chmod +x scripts/validate-plugins.sh
18+
./scripts/validate-plugins.sh
19+
20+
- name: Validate JSON files
21+
run: |
22+
echo "Checking marketplace.json..."
23+
jq empty .claude-plugin/marketplace.json
24+
echo "Checking all plugin.json files..."
25+
for f in plugins/*/.claude-plugin/plugin.json; do
26+
echo " $f"
27+
jq empty "$f"
28+
done
29+
echo "Checking all hooks.json files..."
30+
for f in plugins/*/hooks/hooks.json; do
31+
echo " $f"
32+
jq empty "$f"
33+
done
34+
echo "All JSON valid."
35+
36+
- name: Check version consistency
37+
run: |
38+
MARKETPLACE_VERSION=$(jq -r '.metadata.version' .claude-plugin/marketplace.json)
39+
echo "Marketplace version: $MARKETPLACE_VERSION"
40+
FAIL=0
41+
for f in plugins/*/.claude-plugin/plugin.json; do
42+
PLUGIN_VERSION=$(jq -r '.version' "$f")
43+
PLUGIN_NAME=$(jq -r '.name' "$f")
44+
if [ "$PLUGIN_VERSION" != "$MARKETPLACE_VERSION" ]; then
45+
echo "VERSION MISMATCH: $PLUGIN_NAME is $PLUGIN_VERSION, marketplace is $MARKETPLACE_VERSION"
46+
FAIL=1
47+
else
48+
echo " OK: $PLUGIN_NAME @ $PLUGIN_VERSION"
49+
fi
50+
done
51+
exit $FAIL

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,31 @@ brew install jdtls # macOS
153153

154154
---
155155

156+
## GitHub Actions — Automated PR Review
157+
158+
Use the same skills that run locally to automatically review every Java PR in CI.
159+
160+
### Quick setup
161+
162+
1. Copy [`templates/java-pr-review.yml`](templates/java-pr-review.yml) to `.github/workflows/java-pr-review.yml` in your Java project
163+
2. Add `ANTHROPIC_API_KEY` to your repo secrets (Settings → Secrets → Actions)
164+
3. Push — every PR touching `.java` or build files gets an automated review
165+
166+
### What gets reviewed
167+
168+
Every PR automatically checks:
169+
- **Code quality** — naming, logic errors, null risks, resource leaks
170+
- **Security** — OWASP Top 10, hardcoded secrets, SQL injection, missing `@Valid`
171+
- **Performance** — N+1 queries, eager fetch on collections, missing pagination
172+
173+
Results are posted as a single structured comment with severity-coded findings.
174+
175+
### Our own CI
176+
177+
This repo runs `.github/workflows/validate.yml` on every push — it runs `validate-plugins.sh` and verifies version consistency across all plugin manifests.
178+
179+
---
180+
156181
## Contributing
157182

158183
See [CONTRIBUTING.md](CONTRIBUTING.md) for a full authoring guide covering skills, rules, commands, and agents.

templates/java-pr-review.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# ============================================================
2+
# Java PR Review — powered by claude-java-plugins
3+
# ============================================================
4+
# Copy this file to .github/workflows/java-pr-review.yml
5+
# in your Java project.
6+
#
7+
# Requirements:
8+
# 1. Add ANTHROPIC_API_KEY to your repo secrets:
9+
# Settings → Secrets and variables → Actions → New secret
10+
# 2. Install claude-java-plugins:
11+
# /plugin marketplace add ducpm2303/claude-java-plugins
12+
# /plugin install java-core@java-plugins
13+
# /plugin install java-spring@java-plugins # if Spring Boot project
14+
# /plugin install java-quality@java-plugins # for security + perf + test review
15+
#
16+
# What it does:
17+
# - Reviews every PR that touches Java/build files
18+
# - Runs security scan (OWASP Top 10)
19+
# - Runs performance scan (N+1, threading, memory)
20+
# - Checks test quality and coverage gaps
21+
# - Posts a consolidated review comment on the PR
22+
# ============================================================
23+
24+
name: Java PR Review
25+
26+
on:
27+
pull_request:
28+
types: [opened, synchronize]
29+
paths:
30+
- '**/*.java'
31+
- '**/pom.xml'
32+
- '**/build.gradle'
33+
- '**/build.gradle.kts'
34+
35+
# Cancel in-progress runs on the same PR to save API costs
36+
concurrency:
37+
group: java-pr-review-${{ github.event.pull_request.number }}
38+
cancel-in-progress: true
39+
40+
jobs:
41+
java-review:
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: read
45+
pull-requests: write
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0 # full history for better diff context
51+
52+
- uses: anthropics/claude-code-action@v1
53+
with:
54+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
55+
# Optional: pin to a specific model for cost control
56+
# claude_args: --model claude-sonnet-4-6
57+
prompt: |
58+
You are reviewing a Java pull request. Analyse only the changed files
59+
in this PR (do not review unchanged files).
60+
61+
Run these three checks in sequence. Complete all three before posting.
62+
63+
---
64+
65+
## Check 1 — Code Review (java-core)
66+
67+
For each changed .java file:
68+
- Logic errors, null pointer risks, or incorrect control flow
69+
- Naming violations: classes should be PascalCase, methods camelCase,
70+
constants SCREAMING_SNAKE_CASE
71+
- Version-inappropriate patterns (flag Java 8 idioms if project uses Java 17+)
72+
- Resource leaks (unclosed streams, connections)
73+
- Missing or incorrect exception handling
74+
75+
---
76+
77+
## Check 2 — Security Scan (java-quality)
78+
79+
- Hardcoded credentials, API keys, or tokens in source code
80+
- SQL string concatenation (SQL injection risk)
81+
- Missing @Valid on @RequestBody parameters
82+
- Logging of passwords, tokens, or PII
83+
- Weak cryptography (MD5, SHA-1, DES)
84+
- @CrossOrigin(origins = "*") in non-test code
85+
86+
---
87+
88+
## Check 3 — Performance Scan (java-quality)
89+
90+
- @OneToMany or @ManyToMany without FetchType.LAZY
91+
- Repository method calls inside loops (N+1 pattern)
92+
- findAll() without Pageable on large entity tables
93+
- String concatenation inside loops (use StringBuilder)
94+
- Creating DateTimeFormatter, Pattern, or ObjectMapper inside methods
95+
96+
---
97+
98+
## Output Format
99+
100+
Post a single consolidated comment structured as:
101+
102+
### Java PR Review
103+
104+
**Summary:** [1-2 sentences about the overall change]
105+
106+
**Security** — [CLEAN / X issue(s) found]
107+
**Performance** — [CLEAN / X issue(s) found]
108+
**Code Quality** — [CLEAN / X issue(s) found]
109+
110+
---
111+
112+
#### Issues (sorted by severity)
113+
114+
| Severity | File | Finding |
115+
|----------|------|---------|
116+
| 🔴 CRITICAL | `path/File.java:42` | SQL injection risk: string concat in query |
117+
| 🟠 HIGH | `path/File.java:18` | N+1: repository call inside loop |
118+
| 🟡 MEDIUM | `path/File.java:55` | Missing @Valid on request body |
119+
| 🔵 NOTE | `path/File.java:10` | Consider using var (Java 10+) |
120+
121+
#### Positive Notes
122+
[Highlight anything done well — good patterns, good test coverage, correct use of version features]
123+
124+
---
125+
126+
Rules:
127+
- Only report actual findings, not hypothetical ones
128+
- Do NOT comment on formatting, whitespace, or import order (use a linter for that)
129+
- Do NOT repeat findings — one entry per issue
130+
- If all three checks are clean, post a short "LGTM" comment with a brief summary

0 commit comments

Comments
 (0)