Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Claude in This Repository

## How Claude Is Used

Claude runs automatically on every pull request via GitHub Actions. It does **not** need to be invoked manually — it triggers on its own whenever a PR is opened, updated, marked ready for review, or reopened.

Draft PRs are skipped. Claude will begin reviewing once a PR is marked ready for review.

## What Triggers a Review

The workflow fires on these PR events:

- `opened` — a new PR is created
- `synchronize` — new commits are pushed to an existing PR
- `ready_for_review` — a draft PR is promoted to ready
- `reopened` — a previously closed PR is reopened

## What Claude Does

Claude reviews the pull request and posts its feedback as a PR comment. Only one review runs at a time per PR — if a new commit is pushed while a review is in progress, the in-flight review is cancelled and a fresh one starts.

## Workflow Location

The GitHub Actions workflow is defined at:

```
.github/workflows/claude-pr-review.yml
```

## Required Secrets

The workflow requires the following secrets to be configured in the repository (or organization) settings:

| Secret | Purpose |
| --------------------------- | ---------------------------------------------------------------------- |
| `ANTHROPIC_CODE_REVIEW_KEY` | Anthropic API key used to authenticate Claude |
| `GITHUB_TOKEN` | Automatically provided by GitHub Actions; used to post review comments |

## Permissions

Claude's workflow runs with the following GitHub permissions:

- `contents: read` — to check out and read the code
- `pull-requests: write` — to post review comments on the PR

## Notes for Contributors

- You do not need to do anything to trigger a review — it runs automatically.
- If you push additional commits, the previous review job will be cancelled and a new one will start.
- Claude's comments will appear in the PR alongside human reviewer comments.
- Claude's feedback is advisory. Merging decisions remain with human reviewers.
5 changes: 5 additions & 0 deletions claude/github-integration/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "github-integration",
"description": "Bootstraps Claude Code integration into a repository",
"version": "1.0.0"
}
60 changes: 60 additions & 0 deletions claude/github-integration/skills/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: init-repo
description: Bootstrap Claude Code integration into a repository. Sets up CLAUDE.md, .claude/settings.json, and a GitHub Actions workflow so that @claude automatically reviews PRs using the ANTHROPIC_CODE_REVIEW_KEY secret. Use when onboarding a new repo to Claude Code.
allowed-tools: Read, Write, Bash, Glob
---

Bootstrap Claude Code integration into the current repository.

## Steps

1. **Confirm this is a git repo**
Run `git rev-parse --show-toplevel`. If it fails, stop and tell the user.

2. **Detect the tech stack**
Check for these files in the repo root:
- `package.json` → Node/JS/TS
- `Gemfile` → Ruby
- `go.mod` → Go
- `pyproject.toml` or `requirements.txt` → Python
- `Cargo.toml` → Rust
- `pom.xml` or `build.gradle` → Java

3. **Create CLAUDE.md**
If one doesn't exist, create it with this content:

```
# [repo name]

[One-line description]

## Build & Test

[Fill in based on detected stack — e.g. npm test, bundle exec rspec]

## Key Conventions

[Leave blank for the user to fill in]
```

If one already exists, leave it untouched and note it was skipped.

4. **Create .claude/settings.json**
If one doesn't exist, run `mkdir -p .claude` to ensure the directory exists, then write `.claude/settings.json` based on the detected stack:
- Node: allow `Bash(npm:*)`, `Bash(npx:*)`
- Ruby: allow `Bash(bundle:*)`, `Bash(rake:*)`, `Bash(rspec:*)`
- Python: allow `Bash(python:*)`, `Bash(pytest:*)`, `Bash(pip:*)`
- Go: allow `Bash(go:*)`
- Default (unknown stack): write an empty `allowedTools` array
If one already exists, leave it untouched and note it was skipped.

5. **Create the GitHub Actions workflow**
- If `.github/workflows/claude-pr.yml` already exists, leave it untouched and note it was skipped.
- If it doesn't exist, run `mkdir -p .github/workflows/` if needed, then read `${CLAUDE_PLUGIN_ROOT}/claude-pr.yml` and write its contents to `.github/workflows/claude-pr.yml`.
- If `${CLAUDE_PLUGIN_ROOT}/claude-pr.yml` cannot be read, stop and tell the user.

6. **Print a summary** of what was created and what was already in place. Include:
- Which files were created vs skipped (already existed)
- Always append a reminder that ANTHROPIC_CODE_REVIEW_KEY must exist in this repo's GitHub secrets, and that if it doesn't, the user should add it via: GitHub repo → Settings → Secrets
and variables → Actions → New repository secret
- Note that once the workflow is in place, every non-draft pull request will automatically receive a Claude code review when opened or updated
23 changes: 23 additions & 0 deletions claude/github-integration/skills/claude-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Claude PR Review
on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]

jobs:
review:
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
concurrency:
group: claude-review-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- uses: puppetlabs/claude-plugin/.github/actions/review-action@main
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_CODE_REVIEW_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
Loading