Skip to content

Commit d050d52

Browse files
authored
🌚 [claude] Add Claude Code GitHub Workflow (#24)
* "Claude PR Assistant workflow" * "Claude Code Review workflow" * better security * add /CLAUDE.md * add .claude/settings.local.json from www-chicks-net repo
1 parent 05a77ba commit d050d52

File tree

4 files changed

+208
-0
lines changed

4 files changed

+208
-0
lines changed

.claude/settings.local.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"WebFetch(domain:www.chicks.net)",
5+
"WebFetch(domain:developers.facebook.com)",
6+
"WebFetch(domain:github.com)",
7+
"WebFetch(domain:raw.githubusercontent.com)",
8+
"WebFetch(domain:en.wikipedia.org)",
9+
"Bash(gh pr view:*)",
10+
"Bash(gh pr diff:*)",
11+
"Bash(git log:*)",
12+
"WebSearch",
13+
"Bash(markdownlint-cli2:*)",
14+
"Bash(identify:*)"
15+
],
16+
"deny": [],
17+
"ask": []
18+
}
19+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Claude Code Review
2+
3+
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"
12+
13+
# global permissions
14+
permissions: {}
15+
16+
jobs:
17+
claude-review:
18+
# Optional: Filter by PR author
19+
# if: |
20+
# github.event.pull_request.user.login == 'external-contributor' ||
21+
# github.event.pull_request.user.login == 'new-developer' ||
22+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
23+
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
pull-requests: read
28+
issues: read
29+
id-token: write
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 1
36+
37+
- name: Run Claude Code Review
38+
id: claude-review
39+
uses: anthropics/claude-code-action@v1
40+
with:
41+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
42+
prompt: |
43+
REPO: ${{ github.repository }}
44+
PR NUMBER: ${{ github.event.pull_request.number }}
45+
46+
Please review this pull request and provide feedback on:
47+
- Code quality and best practices
48+
- Potential bugs or issues
49+
- Performance considerations
50+
- Security concerns
51+
- Test coverage
52+
53+
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
54+
55+
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
56+
57+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
58+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
59+
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
60+

.github/workflows/claude.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
# global permissions
14+
permissions: {}
15+
16+
jobs:
17+
claude:
18+
if: |
19+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
20+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
21+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
22+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
pull-requests: read
27+
issues: read
28+
id-token: write
29+
actions: read # Required for Claude to read CI results on PRs
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 1
35+
36+
- name: Run Claude Code
37+
id: claude
38+
uses: anthropics/claude-code-action@v1
39+
with:
40+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
41+
42+
# This is an optional setting that allows Claude to read CI results on PRs
43+
additional_permissions: |
44+
actions: read
45+
46+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
47+
# prompt: 'Update the pull request description to include a summary of changes.'
48+
49+
# Optional: Add claude_args to customize behavior and configuration
50+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
51+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
52+
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'
53+

CLAUDE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Repository Purpose
6+
7+
This is a GitHub repository template that implements best practices for open source projects. It's designed to be cloned and customized for new repositories. The template includes GitHub community standards compliance, automated workflows, and a command-line driven development process.
8+
9+
## Development Workflow
10+
11+
This repo uses `just` (command runner) for all development tasks. The workflow is entirely command-line based using `just` and the GitHub CLI (`gh`).
12+
13+
### Standard development cycle
14+
15+
1. `just branch <name>` - Create a new feature branch (format: `$USER/YYYY-MM-DD-<name>`)
16+
2. Make changes and commit (last commit message becomes PR title)
17+
3. `just pr` - Create PR, push changes, and watch checks (waits 10s for GitHub API)
18+
4. `just merge` - Squash merge PR, delete branch, return to main, and pull latest
19+
5. `just sync` - Return to main branch and pull latest (escape hatch)
20+
21+
### Additional commands
22+
23+
- `just` or `just list` - Show all available recipes
24+
- `just prweb` - Open current PR in browser
25+
- `just release <version>` - Create a GitHub release with auto-generated notes
26+
- `just clean_readme` - Generate a clean README from template (strips template documentation)
27+
- `just compliance_check` - Run custom repo compliance checks
28+
- `just utcdate` - Print UTC date in ISO format (used in branch names)
29+
30+
### Git aliases used
31+
32+
The justfile assumes these git aliases exist:
33+
34+
- `git stp` - Show status (likely `status --short` or similar)
35+
- `git pushup` - Push and set upstream tracking
36+
- `git co` - Checkout
37+
38+
## Architecture
39+
40+
### Modular justfile structure
41+
42+
The main `justfile` imports two modules:
43+
44+
- `.just/compliance.just` - Custom compliance checks for repo health
45+
- `.just/gh-process.just` - Git/GitHub workflow automation
46+
47+
### GitHub Actions
48+
49+
Four workflows run on PRs and pushes to main:
50+
51+
- **markdownlint** - Enforces markdown standards using `markdownlint-cli2`
52+
- **checkov** - Security scanning for GitHub Actions
53+
- **actionlint** - Lints GitHub Actions workflow files
54+
- **auto-assign** - Automatically assigns issues
55+
56+
### Markdown linting
57+
58+
Configuration in `.markdownlint.yml`:
59+
60+
- MD013 (line length) is disabled
61+
- MD041 (first line h1) is disabled
62+
- MD042 (no empty links) is disabled
63+
- MD004 (list style) enforces dashes
64+
- MD010 (tabs) ignores code blocks
65+
66+
Run locally: `markdownlint-cli2 **/*.md`
67+
68+
## Template customization
69+
70+
When using this template for a new project, search and replace:
71+
72+
- `fini-net` → your GitHub org
73+
- `template-repo` → your repo name
74+
- `chicks-net` → your references
75+
76+
Run `just clean_readme` to strip template documentation from README.

0 commit comments

Comments
 (0)