-
Notifications
You must be signed in to change notification settings - Fork 0
Add DeepWork Review GitHub Action #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
4b26b33
f4aa54a
5c3552d
654752c
bc66f07
c682810
f1a5126
1290b16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: DeepWork Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| # Prevent concurrent runs on the same PR | ||
| concurrency: | ||
| group: deepwork-review-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| deepwork-review: | ||
| runs-on: ubuntu-latest | ||
| # Required permissions | ||
| permissions: | ||
| contents: write # push auto-fix commits to the PR branch | ||
| pull-requests: write # post inline PR review comments | ||
|
|
||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # Fetch full history so DeepWork can diff against the base branch | ||
| fetch-depth: 0 | ||
|
nhorton marked this conversation as resolved.
|
||
| # Use the merge ref so we operate on the PR's head commit | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Run DeepWork Review | ||
| uses: Unsupervisedcom/deepwork-action@v1 | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| # Optional overrides: | ||
| # model: claude-sonnet-4-5 | ||
|
nhorton marked this conversation as resolved.
Outdated
|
||
| # max_turns: '50' | ||
| # commit_message: 'chore: apply DeepWork review suggestions [skip ci]' | ||
|
nhorton marked this conversation as resolved.
Outdated
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| scripts/__pycache__/ |
|
nhorton marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,95 @@ | ||
| # deepwork-action | ||
| DeepWork GitHub Action | ||
|
|
||
| A prebuilt GitHub Action that runs [Claude Code](https://docs.anthropic.com/en/docs/claude-code) on a Pull Request with the [DeepWork](https://github.com/Unsupervisedcom/deepwork) plugin installed, triggers the `/review` skill, auto-commits all review-driven improvements back to the PR branch, and posts inline PR review comments explaining each change. | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **DeepWork plugin install** — The action installs the DeepWork plugin from the marketplace using Claude Code's native plugin system, loading all review skills, hooks, and MCP server configuration automatically. | ||
| 2. **DeepWork review** — Claude Code runs the `/review` skill, which reads your `.deepreview` config files to discover review rules, diffs the PR branch, and dispatches parallel review agents scoped to exactly the right files. | ||
| 3. **Apply changes** — Claude applies every suggested improvement (bugs, style, performance, security, docs, refactoring) without asking for confirmation. | ||
| 4. **Auto-commit** — All file changes are committed back to the PR branch under the `deepwork-action[bot]` identity. | ||
| 5. **Inline PR comments** — A GitHub PR review is posted with one inline comment per changed file, describing what was changed and why, so your team can review each improvement. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. **Anthropic API key** — add it as a repository secret named `ANTHROPIC_API_KEY`. | ||
| 2. **`.deepreview` configuration** — place one or more `.deepreview` files in your repository defining your review rules. See the [DeepWork Reviews documentation](https://github.com/Unsupervisedcom/deepwork/blob/main/README_REVIEWS.md) for details. | ||
|
|
||
| ## Usage | ||
|
|
||
| Create a workflow file such as `.github/workflows/deepwork-review.yml`: | ||
|
|
||
| ```yaml | ||
| name: DeepWork Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| concurrency: | ||
| group: deepwork-review-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| deepwork-review: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write # push auto-fix commits to the PR branch | ||
| pull-requests: write # post inline PR review comments | ||
|
|
||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Run DeepWork Review | ||
| uses: Unsupervisedcom/deepwork-action@v1 | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| ``` | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Input | Required | Default | Description | | ||
| |-------|----------|---------|-------------| | ||
| | `anthropic_api_key` | ✅ | — | Anthropic API key for Claude Code | | ||
| | `github_token` | ✅ | — | GitHub token with `contents: write` and `pull-requests: write` | | ||
| | `model` | ❌ | `claude-sonnet-4-5` | Claude model to use | | ||
|
nhorton marked this conversation as resolved.
Outdated
|
||
| | `max_turns` | ❌ | `50` | Maximum agentic turns for Claude Code | | ||
| | `commit_message` | ❌ | `chore: apply DeepWork review suggestions [skip ci]` | Commit message for auto-committed changes | | ||
|
|
||
| ## What Gets Changed | ||
|
|
||
| The action applies **all** suggestions from your `.deepreview` rules, including: | ||
|
|
||
| - Bug fixes and null-safety checks | ||
| - Style and formatting improvements | ||
| - Performance optimisations | ||
| - Security hardening | ||
| - Documentation updates | ||
| - Refactoring suggestions | ||
|
|
||
| If no `.deepreview` rules are configured in the repository, the action exits cleanly without making any changes or commits. | ||
|
|
||
| ## Review Comments | ||
|
|
||
| After pushing the auto-fix commit, the action posts a GitHub PR review with inline comments on each changed file. The comments appear in the **Files Changed** tab and describe what was changed and why, so your team can accept, request modifications, or revert individual changes as needed. | ||
|
|
||
| ## Caching | ||
|
|
||
| Review state is cached per PR using GitHub Actions cache, keyed on the PR number. This means already-passed reviews are not re-run when you push new commits to the same PR — only code that has changed since the last review is re-evaluated. | ||
|
nhorton marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Security | ||
|
|
||
| - Claude Code is installed and run via the official [`anthropics/claude-code-base-action`](https://github.com/anthropics/claude-code-base-action). | ||
| - The action runs with `--dangerously-skip-permissions` in a sandboxed GitHub Actions runner. It has no access to secrets beyond what you explicitly provide. | ||
| - Auto-fix commits are signed with the `deepwork-action[bot]` identity. | ||
| - The `[skip ci]` suffix on the default commit message prevents the action from triggering itself recursively. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems not ideal. Triggering other CI actions from the changes would make sense, and this name is confusing. Can we instead skip commits that are signed by the deepwork-action[bot]` identity?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in f1a5126. Removed |
||
|
|
||
| ## License | ||
|
|
||
| See [LICENSE](LICENSE). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| name: 'DeepWork Review Action' | ||
| description: 'Run DeepWork reviews via Claude Code on a PR, auto-commit improvements, and add inline PR review comments' | ||
| author: 'Unsupervisedcom' | ||
|
|
||
| branding: | ||
| icon: 'check-circle' | ||
| color: 'blue' | ||
|
|
||
| inputs: | ||
| anthropic_api_key: | ||
| description: 'Anthropic API key for Claude Code' | ||
| required: true | ||
| github_token: | ||
| description: 'GitHub token with write access to commit changes and post review comments' | ||
| required: true | ||
| model: | ||
| description: 'Claude model to use (e.g. claude-sonnet-4-5, claude-opus-4-5)' | ||
| required: false | ||
| default: 'claude-sonnet-4-5' | ||
|
nhorton marked this conversation as resolved.
Outdated
|
||
| max_turns: | ||
| description: 'Maximum number of agentic turns for Claude Code' | ||
| required: false | ||
| default: '50' | ||
| commit_message: | ||
| description: 'Commit message for auto-committed review changes' | ||
| required: false | ||
| default: 'chore: apply DeepWork review suggestions [skip ci]' | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| version: 'latest' | ||
|
|
||
| - name: Restore DeepWork review cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: .deepwork/tmp | ||
| # A unique save key per run ensures the cache is always updated with the | ||
| # latest review state after each run. restore-keys picks up the most recent | ||
| # cache for this PR so already-passed reviews are not re-run. | ||
| key: deepwork-review-pr-${{ github.event.pull_request.number }}-${{ github.run_id }} | ||
| restore-keys: | | ||
| deepwork-review-pr-${{ github.event.pull_request.number }}- | ||
|
|
||
| - name: Fetch base branch for git diff | ||
| shell: bash | ||
| run: | | ||
| BASE_REF="${{ github.event.pull_request.base.ref }}" | ||
| if [ -n "$BASE_REF" ]; then | ||
| git fetch origin "$BASE_REF" --depth=1 || \ | ||
| echo "Warning: could not fetch base branch '$BASE_REF'; diff detection may be incomplete" | ||
| fi | ||
|
|
||
| - name: Prepare review run | ||
| shell: bash | ||
| run: | | ||
| # Clean up any leftover changes file from a previous run. | ||
| rm -f /tmp/deepwork_changes.json | ||
|
|
||
| - name: Run DeepWork review with Claude Code | ||
| uses: anthropics/claude-code-base-action@beta | ||
| env: | ||
| GH_TOKEN: ${{ inputs.github_token }} | ||
| with: | ||
| anthropic_api_key: ${{ inputs.anthropic_api_key }} | ||
| prompt_file: ${{ github.action_path }}/prompts/review.txt | ||
| plugin_marketplaces: https://github.com/Unsupervisedcom/deepwork.git | ||
| plugins: deepwork@deepwork-plugins | ||
| claude_args: >- | ||
| --dangerously-skip-permissions | ||
| --model ${{ inputs.model }} | ||
| --max-turns ${{ inputs.max_turns }} | ||
|
|
||
| - name: Commit and push changes | ||
| id: commit | ||
| shell: bash | ||
| env: | ||
| GITHUB_TOKEN: ${{ inputs.github_token }} | ||
| run: | | ||
| git config user.name "deepwork-action[bot]" | ||
| git config user.email "deepwork-action[bot]@users.noreply.github.com" | ||
|
|
||
| # Check for any modified, added, or deleted tracked files | ||
| if git diff --quiet && git diff --cached --quiet \ | ||
| && [ -z "$(git ls-files --others --exclude-standard)" ]; then | ||
| echo "No changes to commit." | ||
| echo "changes_made=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "changes_made=true" >> "$GITHUB_OUTPUT" | ||
|
|
||
| git add -A | ||
| git commit -m "${{ inputs.commit_message }}" | ||
|
|
||
| # Authenticate push via the provided token. | ||
| REPO="${{ github.repository }}" | ||
| git remote set-url origin \ | ||
| "https://x-access-token:${GITHUB_TOKEN}@github.com/${REPO}.git" | ||
| git push | ||
|
|
||
| - name: Post inline PR review comments | ||
| if: steps.commit.outputs.changes_made == 'true' && github.event.pull_request.number != '' | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ inputs.github_token }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
| GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }} | ||
| run: | | ||
| python3 "${{ github.action_path }}/scripts/post-review-comments.py" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /review | ||
|
|
||
| You are running in a fully automated CI environment on a GitHub Pull Request. | ||
| There is NO human watching this session. Follow these critical rules at all times: | ||
|
|
||
| ## Automation Rules (MANDATORY) | ||
|
|
||
| 1. **NEVER use AskUserQuestion** — you are in CI mode; make every decision autonomously. | ||
| 2. **Make ALL changes** suggested by the review findings — not just "obviously good" ones. | ||
| Apply every finding: bugs, style, performance, security, documentation, and refactoring. | ||
| When a finding offers multiple approaches, choose the best one yourself. | ||
| 3. **Iterate** — after making changes, re-run the review until it comes back clean. | ||
| 4. **If no `.deepreview` rules are configured** — output the message "No review rules configured." | ||
| and stop. Do not attempt to configure rules; that is the repository owner's responsibility. | ||
|
|
||
| ## Change Tracking (REQUIRED) | ||
|
|
||
| For every file you modify, append an entry to `/tmp/deepwork_changes.json`. | ||
| Create the file with `{"changes": []}` if it does not yet exist. | ||
|
|
||
| Each entry must follow this exact JSON structure: | ||
|
|
||
| ```json | ||
| { | ||
| "file": "relative/path/to/changed/file", | ||
| "line": <line_number_where_main_change_was_made>, | ||
| "description": "One-sentence description of what was changed", | ||
| "reason": "The review finding that prompted this change" | ||
| } | ||
| ``` | ||
|
|
||
| Write the final file when all changes are complete and the review passes. | ||
|
|
||
| ## Important | ||
|
|
||
| - You have full permission to edit, create, and delete files in this repository. | ||
| - Do NOT commit changes yourself — the CI workflow handles git commit and push. | ||
| - Do NOT push changes yourself — the CI workflow handles git commit and push. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this it the right thing to run on. Shouldn't this run on push and not opened and such?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In GitHub Actions,
pull_request+synchronizeis the "run on push to a PR branch" event — using barepushwould lose all the PR context (github.event.pull_request.number,base.ref, etc.) that the action needs for caching, checkout, and posting review comments.Simplified the types to
[opened, synchronize](droppedreopened) in 1290b16 —synchronizefires on every push to the PR branch, andopenedhandles the initial PR creation.