mars3142 81207143f3 initial
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2026-04-28 16:07:35 +02:00
2026-04-28 16:07:35 +02:00
2026-04-28 16:07:35 +02:00
2026-04-28 16:07:35 +02:00
2026-04-28 16:07:35 +02:00
2026-04-28 16:07:35 +02:00

claude-review

A Gitea composite action that reviews pull requests using Claude AI. It reads review instructions from a prompt file in your target branch, sends the PR diff to the Claude API, and posts the result as a PR comment.

Usage

Create .gitea/workflows/claude-review.yml in any repository you want to enable reviews for:

name: Claude Code Review

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: mars3142/claude-review@v1
        with:
          api_key: ${{ secrets.CLAUDE_API_KEY }}
          gitea_token: ${{ secrets.GITEA_TOKEN }}

Inputs

Input Required Default Description
api_key yes Anthropic API key
gitea_token yes Gitea token for posting comments (GITEA_TOKEN is set automatically by Gitea Actions)
prompt_file no .claude/review-prompt.md Path to the review instructions file, resolved from the target branch
model no claude-sonnet-4-6 Claude model ID to use

Setup

1. Add the API key secret

In the target repository go to Settings → Secrets and add:

GITEA_TOKEN is injected automatically by Gitea Actions and requires no manual setup.

2. Add the prompt file to your target branch

The action reads the review instructions from a file in your target branch (e.g. main). This ensures that only instructions committed to the main line are used, regardless of what a PR author puts in their branch.

Copy the example and adjust it to your needs:

cp review-prompt.example.md .claude/review-prompt.md
git add .claude/review-prompt.md
git commit -m "Add Claude review prompt"
git push

If you prefer a different path, pass it via the prompt_file input:

- uses: mars3142/claude-review@v1
  with:
    api_key: ${{ secrets.CLAUDE_API_KEY }}
    gitea_token: ${{ secrets.GITEA_TOKEN }}
    prompt_file: docs/review-instructions.md

3. Open a pull request

The action triggers automatically on every PR that is opened, updated, or reopened. It will post a comment with the review once it completes.

How it works

  1. Fetch branches — both the target branch and the PR head are fetched, with a fallback to refs/pull/<number>/head for cross-fork PRs.
  2. Read prompt — the instructions file is read directly from the target branch via git show, so the caller's working tree is not affected.
  3. Generate diff — a three-dot diff (base...head) is computed, capturing only the changes introduced by the PR. Diffs larger than 80 KB are truncated with a notice.
  4. Call Claude — the prompt and diff are sent to the Claude API as a single user message.
  5. Post comment — the response is posted to the PR via the Gitea REST API.

Prompt file

The prompt file is plain text or Markdown. It becomes the user message sent to Claude, with the diff appended at the end. See review-prompt.example.md for a ready-to-use starting point.

Requirements

  • Gitea with Actions enabled
  • An Anthropic API key with access to the chosen model
  • jq and curl available on the runner (both are present on ubuntu-latest)
S
Description
No description provided
Readme 32 KiB
Languages
Markdown 100%