mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 14:24:13 +08:00
feat: improve examples and migration guide with GitHub context (#505)
* feat: improve documentation with solutions guide and GitHub context - Add comprehensive solutions.md with 9 complete use case examples - Fix migration guide examples to include required GitHub context - Update examples missing GitHub context (workflow-dispatch-agent, claude-modes) - Enhance README with prominent Solutions & Use Cases section - Document tracking comment behavior change in automation mode - All PR review examples now include REPO and PR NUMBER context Fixes issues reported in discussions #490 and #491 where: - Migration examples were dysfunctional without GitHub context - Users lost PR review capability after v0.x migration - Missing explanation of tracking comment removal in agent mode 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: apply prettier formatting to fix CI Co-authored-by: kashyap murali <km-anthropic@users.noreply.github.com> * refactor: streamline examples and remove implementation details - Remove 5 redundant examples (57% reduction: 12→7 files) - Deleted: claude.yml, claude-auto-review.yml, claude-modes.yml, claude-args-example.yml, auto-fix-ci-signed/ - Rename examples for clarity - pr-review-with-tracking.yml → pr-review-comprehensive.yml - claude-pr-path-specific.yml → pr-review-filtered-paths.yml - claude-review-from-author.yml → pr-review-filtered-authors.yml - workflow-dispatch-agent.yml → manual-code-analysis.yml - auto-fix-ci/auto-fix-ci.yml → ci-failure-auto-fix.yml - Update all examples from @v1-dev to @v1 - Remove implementation details (agent mode references) from docs - Delete obsolete DIY Progress Tracking section - Add track_progress documentation and examples Addresses PR feedback about exposing internal implementation details and consolidates redundant examples into focused, clear use cases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: apply prettier formatting to fix CI Applied prettier formatting to 3 files to resolve CI formatting issues. Co-authored-by: kashyap murali <km-anthropic@users.noreply.github.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: kashyap murali <km-anthropic@users.noreply.github.com> Co-authored-by: Kashyap Murali <13315300+katchu11@users.noreply.github.com>
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
name: Auto Fix CI Failures (Signed Commits)
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["CI"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
actions: read
|
||||
issues: write
|
||||
id-token: write # Required for OIDC token exchange
|
||||
|
||||
jobs:
|
||||
auto-fix-signed:
|
||||
if: |
|
||||
github.event.workflow_run.conclusion == 'failure' &&
|
||||
github.event.workflow_run.pull_requests[0] &&
|
||||
!startsWith(github.event.workflow_run.head_branch, 'claude-auto-fix-ci-signed-')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.workflow_run.head_branch }}
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Generate fix branch name
|
||||
id: branch
|
||||
run: |
|
||||
BRANCH_NAME="claude-auto-fix-ci-signed-${{ github.event.workflow_run.head_branch }}-${{ github.run_id }}"
|
||||
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
|
||||
# Don't create branch locally - MCP tools will create it via API
|
||||
echo "Generated branch name: $BRANCH_NAME (will be created by MCP tools)"
|
||||
|
||||
- name: Get CI failure details
|
||||
id: failure_details
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const run = await github.rest.actions.getWorkflowRun({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
});
|
||||
|
||||
const jobs = await github.rest.actions.listJobsForWorkflowRun({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
});
|
||||
|
||||
const failedJobs = jobs.data.jobs.filter(job => job.conclusion === 'failure');
|
||||
|
||||
let errorLogs = [];
|
||||
for (const job of failedJobs) {
|
||||
const logs = await github.rest.actions.downloadJobLogsForWorkflowRun({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
job_id: job.id
|
||||
});
|
||||
errorLogs.push({
|
||||
jobName: job.name,
|
||||
logs: logs.data
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
runUrl: run.data.html_url,
|
||||
failedJobs: failedJobs.map(j => j.name),
|
||||
errorLogs: errorLogs
|
||||
};
|
||||
|
||||
- name: Fix CI failures with Claude (Signed Commits)
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
env:
|
||||
CLAUDE_BRANCH: ${{ steps.branch.outputs.branch_name }}
|
||||
BASE_BRANCH: ${{ github.event.workflow_run.head_branch }}
|
||||
with:
|
||||
prompt: |
|
||||
/fix-ci-signed
|
||||
Failed CI Run: ${{ fromJSON(steps.failure_details.outputs.result).runUrl }}
|
||||
Failed Jobs: ${{ join(fromJSON(steps.failure_details.outputs.result).failedJobs, ', ') }}
|
||||
PR Number: ${{ github.event.workflow_run.pull_requests[0].number }}
|
||||
Branch Name: ${{ steps.branch.outputs.branch_name }}
|
||||
Base Branch: ${{ github.event.workflow_run.head_branch }}
|
||||
Repository: ${{ github.repository }}
|
||||
|
||||
Error logs:
|
||||
${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }}
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
use_commit_signing: true
|
||||
claude_args: "--allowedTools 'Edit,MultiEdit,Write,Read,Glob,Grep,LS,Bash(bun:*),Bash(npm:*),Bash(npx:*),Bash(gh:*),mcp__github_file_ops__commit_files,mcp__github_file_ops__delete_files'"
|
||||
@@ -1,148 +0,0 @@
|
||||
---
|
||||
description: Analyze and fix CI failures with signed commits using MCP tools
|
||||
allowed_tools: Edit,MultiEdit,Write,Read,Glob,Grep,LS,Bash(bun:*),Bash(npm:*),Bash(npx:*),Bash(gh:*),mcp__github_file_ops__commit_files,mcp__github_file_ops__delete_files
|
||||
---
|
||||
|
||||
# Fix CI Failures with Signed Commits
|
||||
|
||||
You are tasked with analyzing CI failure logs and fixing the issues using MCP tools for signed commits. Follow these steps:
|
||||
|
||||
## Context Provided
|
||||
|
||||
$ARGUMENTS
|
||||
|
||||
## Important Context Information
|
||||
|
||||
Look for these key pieces of information in the arguments:
|
||||
|
||||
- **Failed CI Run URL**: Link to the failed CI run
|
||||
- **Failed Jobs**: List of jobs that failed
|
||||
- **PR Number**: The PR number to comment on
|
||||
- **Branch Name**: The fix branch you're working on
|
||||
- **Base Branch**: The original PR branch
|
||||
- **Error logs**: Detailed logs from failed jobs
|
||||
|
||||
## CRITICAL: Use MCP Tools for Git Operations
|
||||
|
||||
**IMPORTANT**: You MUST use MCP tools for all git operations to ensure commits are properly signed. DO NOT use `git` commands directly via Bash.
|
||||
|
||||
- Use `mcp__github_file_ops__commit_files` to commit and push changes
|
||||
- Use `mcp__github_file_ops__delete_files` to delete files
|
||||
|
||||
## Step 1: Analyze the Failure
|
||||
|
||||
Parse the provided CI failure information to understand:
|
||||
|
||||
- Which jobs failed and why
|
||||
- The specific error messages and stack traces
|
||||
- Whether failures are test-related, build-related, or linting issues
|
||||
|
||||
## Step 2: Search and Understand the Codebase
|
||||
|
||||
Use MCP search tools to locate the failing code:
|
||||
|
||||
- Use `mcp_github_file_ops_server__search_files` or `mcp_github_file_ops_server__file_search` to find failing test names or functions
|
||||
- Use `mcp_github_file_ops_server__read_file` to read source files mentioned in error messages
|
||||
- Review related configuration files (package.json, tsconfig.json, etc.)
|
||||
|
||||
## Step 3: Apply Targeted Fixes
|
||||
|
||||
Make minimal, focused changes:
|
||||
|
||||
- **For test failures**: Determine if the test or implementation needs fixing
|
||||
- **For type errors**: Fix type definitions or correct the code logic
|
||||
- **For linting issues**: Apply formatting using the project's tools
|
||||
- **For build errors**: Resolve dependency or configuration issues
|
||||
- **For missing imports**: Add the necessary imports or install packages
|
||||
|
||||
Requirements:
|
||||
|
||||
- Only fix the actual CI failures, avoid unrelated changes
|
||||
- Follow existing code patterns and conventions
|
||||
- Ensure changes are production-ready, not temporary hacks
|
||||
- Preserve existing functionality while fixing issues
|
||||
|
||||
## Step 4: Verify Fixes Locally
|
||||
|
||||
Run available verification commands using Bash:
|
||||
|
||||
- Execute the failing tests locally to confirm they pass
|
||||
- Run the project's lint command (check package.json for scripts)
|
||||
- Run type checking if available
|
||||
- Execute any build commands to ensure compilation succeeds
|
||||
|
||||
## Step 5: Commit and Push Changes Using MCP
|
||||
|
||||
**CRITICAL**: You MUST use MCP tools for committing and pushing:
|
||||
|
||||
1. Prepare all your file changes (using Edit/MultiEdit/Write tools as needed)
|
||||
2. **Use `mcp__github_file_ops__commit_files` to commit and push all changes**
|
||||
- Pass the file paths you've edited in the `files` array
|
||||
- Set `message` to describe the specific fixes (e.g., "Fix CI failures: remove syntax errors and format code")
|
||||
- The MCP tool will automatically create the branch specified in "Branch Name:" from the context and push signed commits
|
||||
|
||||
**IMPORTANT**: The MCP tool will create the branch from the context automatically. The branch name from "Branch Name:" in the context will be used.
|
||||
|
||||
Example usage:
|
||||
|
||||
```
|
||||
mcp__github_file_ops__commit_files with:
|
||||
- files: ["src/utils/retry.ts", "src/other/file.ts"] // List of file paths you edited
|
||||
- message: "Fix CI failures: [describe specific fixes]"
|
||||
```
|
||||
|
||||
Note: The branch will be created from the Base Branch specified in the context.
|
||||
|
||||
## Step 6: Create PR Comment (REQUIRED - DO NOT SKIP)
|
||||
|
||||
**CRITICAL: You MUST create a PR comment after pushing. This step is MANDATORY.**
|
||||
|
||||
After successfully pushing the fixes, you MUST create a comment on the original PR to notify about the auto-fix. DO NOT end the task without completing this step.
|
||||
|
||||
1. Extract the PR number from the context provided in arguments (look for "PR Number:" in the context)
|
||||
2. **MANDATORY**: Execute the gh CLI command below to create the comment
|
||||
3. Verify the comment was created successfully
|
||||
|
||||
**YOU MUST RUN THIS COMMAND** (replace placeholders with actual values from context):
|
||||
|
||||
```bash
|
||||
gh pr comment PR_NUMBER --body "## 🤖 CI Auto-Fix Available (Signed Commits)
|
||||
|
||||
Claude has analyzed the CI failures and prepared fixes with signed commits.
|
||||
|
||||
[**→ Create pull request to fix CI**](https://github.com/OWNER/REPO/compare/BASE_BRANCH...FIX_BRANCH?quick_pull=1)
|
||||
|
||||
_This fix was generated automatically based on the [failed CI run](FAILED_CI_RUN_URL)._"
|
||||
```
|
||||
|
||||
**IMPORTANT REPLACEMENTS YOU MUST MAKE:**
|
||||
|
||||
- Replace `PR_NUMBER` with the actual PR number from "PR Number:" in context
|
||||
- Replace `OWNER/REPO` with the repository from "Repository:" in context
|
||||
- Replace `BASE_BRANCH` with the branch from "Base Branch:" in context
|
||||
- Replace `FIX_BRANCH` with the branch from "Branch Name:" in context
|
||||
- Replace `FAILED_CI_RUN_URL` with the URL from "Failed CI Run:" in context
|
||||
|
||||
**DO NOT SKIP THIS STEP. The task is NOT complete until the PR comment is created.**
|
||||
|
||||
## Step 7: Final Verification
|
||||
|
||||
**BEFORE CONSIDERING THE TASK COMPLETE**, verify you have:
|
||||
|
||||
1. ✅ Fixed all CI failures
|
||||
2. ✅ Committed the changes using `mcp_github_file_ops_server__push_files`
|
||||
3. ✅ Verified the branch was pushed successfully
|
||||
4. ✅ **CREATED THE PR COMMENT using `gh pr comment` command from Step 6**
|
||||
|
||||
If you have NOT created the PR comment, go back to Step 6 and execute the command.
|
||||
|
||||
## Important Guidelines
|
||||
|
||||
- Always use MCP tools for git operations to ensure proper commit signing
|
||||
- Focus exclusively on fixing the reported CI failures
|
||||
- Maintain code quality and follow the project's established patterns
|
||||
- If a fix requires significant refactoring, document why it's necessary
|
||||
- When multiple solutions exist, choose the simplest one that maintains code quality
|
||||
- **THE TASK IS NOT COMPLETE WITHOUT THE PR COMMENT**
|
||||
|
||||
Begin by analyzing the failure details provided above.
|
||||
@@ -1,127 +0,0 @@
|
||||
---
|
||||
description: Analyze and fix CI failures by examining logs and making targeted fixes
|
||||
allowed_tools: Edit,MultiEdit,Write,Read,Glob,Grep,LS,Bash(git:*),Bash(bun:*),Bash(npm:*),Bash(npx:*),Bash(gh:*)
|
||||
---
|
||||
|
||||
# Fix CI Failures
|
||||
|
||||
You are tasked with analyzing CI failure logs and fixing the issues. Follow these steps:
|
||||
|
||||
## Context Provided
|
||||
|
||||
$ARGUMENTS
|
||||
|
||||
## Important Context Information
|
||||
|
||||
Look for these key pieces of information in the arguments:
|
||||
|
||||
- **Failed CI Run URL**: Link to the failed CI run
|
||||
- **Failed Jobs**: List of jobs that failed
|
||||
- **PR Number**: The PR number to comment on
|
||||
- **Branch Name**: The fix branch you're working on
|
||||
- **Base Branch**: The original PR branch
|
||||
- **Error logs**: Detailed logs from failed jobs
|
||||
|
||||
## Step 1: Analyze the Failure
|
||||
|
||||
Parse the provided CI failure information to understand:
|
||||
|
||||
- Which jobs failed and why
|
||||
- The specific error messages and stack traces
|
||||
- Whether failures are test-related, build-related, or linting issues
|
||||
|
||||
## Step 2: Search and Understand the Codebase
|
||||
|
||||
Use search tools to locate the failing code:
|
||||
|
||||
- Search for the failing test names or functions
|
||||
- Find the source files mentioned in error messages
|
||||
- Review related configuration files (package.json, tsconfig.json, etc.)
|
||||
|
||||
## Step 3: Apply Targeted Fixes
|
||||
|
||||
Make minimal, focused changes:
|
||||
|
||||
- **For test failures**: Determine if the test or implementation needs fixing
|
||||
- **For type errors**: Fix type definitions or correct the code logic
|
||||
- **For linting issues**: Apply formatting using the project's tools
|
||||
- **For build errors**: Resolve dependency or configuration issues
|
||||
- **For missing imports**: Add the necessary imports or install packages
|
||||
|
||||
Requirements:
|
||||
|
||||
- Only fix the actual CI failures, avoid unrelated changes
|
||||
- Follow existing code patterns and conventions
|
||||
- Ensure changes are production-ready, not temporary hacks
|
||||
- Preserve existing functionality while fixing issues
|
||||
|
||||
## Step 4: Verify Fixes Locally
|
||||
|
||||
Run available verification commands:
|
||||
|
||||
- Execute the failing tests locally to confirm they pass
|
||||
- Run the project's lint command (check package.json for scripts)
|
||||
- Run type checking if available
|
||||
- Execute any build commands to ensure compilation succeeds
|
||||
|
||||
## Step 5: Commit and Push Changes
|
||||
|
||||
After applying ALL fixes:
|
||||
|
||||
1. Stage all modified files with `git add -A`
|
||||
2. Commit with: `git commit -m "Fix CI failures: [describe specific fixes]"`
|
||||
3. Document which CI jobs/tests were addressed
|
||||
4. **CRITICAL**: Push the branch with `git push origin HEAD` - You MUST push the branch after committing
|
||||
|
||||
## Step 6: Create PR Comment (REQUIRED - DO NOT SKIP)
|
||||
|
||||
**CRITICAL: You MUST create a PR comment after pushing. This step is MANDATORY.**
|
||||
|
||||
After successfully pushing the fixes, you MUST create a comment on the original PR to notify about the auto-fix. DO NOT end the task without completing this step.
|
||||
|
||||
1. Extract the PR number from the context provided in arguments (look for "PR Number:" in the context)
|
||||
2. **MANDATORY**: Execute the gh CLI command below to create the comment
|
||||
3. Verify the comment was created successfully
|
||||
|
||||
**YOU MUST RUN THIS COMMAND** (replace placeholders with actual values from context):
|
||||
|
||||
```bash
|
||||
gh pr comment PR_NUMBER --body "## 🤖 CI Auto-Fix Available
|
||||
|
||||
Claude has analyzed the CI failures and prepared fixes.
|
||||
|
||||
[**→ Create pull request to fix CI**](https://github.com/OWNER/REPO/compare/BASE_BRANCH...FIX_BRANCH?quick_pull=1)
|
||||
|
||||
_This fix was generated automatically based on the [failed CI run](FAILED_CI_RUN_URL)._"
|
||||
```
|
||||
|
||||
**IMPORTANT REPLACEMENTS YOU MUST MAKE:**
|
||||
|
||||
- Replace `PR_NUMBER` with the actual PR number from "PR Number:" in context
|
||||
- Replace `OWNER/REPO` with the repository from "Repository:" in context
|
||||
- Replace `BASE_BRANCH` with the branch from "Base Branch:" in context
|
||||
- Replace `FIX_BRANCH` with the branch from "Branch Name:" in context
|
||||
- Replace `FAILED_CI_RUN_URL` with the URL from "Failed CI Run:" in context
|
||||
|
||||
**DO NOT SKIP THIS STEP. The task is NOT complete until the PR comment is created.**
|
||||
|
||||
## Step 7: Final Verification
|
||||
|
||||
**BEFORE CONSIDERING THE TASK COMPLETE**, verify you have:
|
||||
|
||||
1. ✅ Fixed all CI failures
|
||||
2. ✅ Committed the changes
|
||||
3. ✅ Pushed the branch with `git push origin HEAD`
|
||||
4. ✅ **CREATED THE PR COMMENT using `gh pr comment` command from Step 6**
|
||||
|
||||
If you have NOT created the PR comment, go back to Step 6 and execute the command.
|
||||
|
||||
## Important Guidelines
|
||||
|
||||
- Focus exclusively on fixing the reported CI failures
|
||||
- Maintain code quality and follow the project's established patterns
|
||||
- If a fix requires significant refactoring, document why it's necessary
|
||||
- When multiple solutions exist, choose the simplest one that maintains code quality
|
||||
- **THE TASK IS NOT COMPLETE WITHOUT THE PR COMMENT**
|
||||
|
||||
Begin by analyzing the failure details provided above.
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
|
||||
- name: Fix CI failures with Claude
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
prompt: |
|
||||
/fix-ci
|
||||
@@ -1,30 +0,0 @@
|
||||
name: Claude Args Example
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
prompt:
|
||||
description: "Prompt for Claude"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
claude-with-custom-args:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run Claude with custom arguments
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
with:
|
||||
prompt: ${{ github.event.inputs.prompt }}
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
# claude_args provides direct CLI argument control
|
||||
# This allows full customization of Claude's behavior
|
||||
claude_args: |
|
||||
--max-turns 15
|
||||
--model claude-opus-4-1-20250805
|
||||
--allowedTools Edit,Read,Write,Bash
|
||||
--disallowedTools WebSearch
|
||||
--system-prompt "You are a senior engineer focused on code quality"
|
||||
@@ -1,48 +0,0 @@
|
||||
name: Claude PR Auto Review
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
jobs:
|
||||
auto-review:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Automatic PR Review
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
prompt: |
|
||||
REPO: ${{ github.repository }}
|
||||
PR NUMBER: ${{ github.event.pull_request.number }}
|
||||
|
||||
Please review this pull request.
|
||||
|
||||
Note: The PR branch is already checked out in the current working directory.
|
||||
|
||||
Focus on:
|
||||
- Code quality and best practices
|
||||
- Potential bugs or issues
|
||||
- Performance considerations
|
||||
- Security implications
|
||||
- Test coverage
|
||||
- Documentation updates if needed
|
||||
- Verify that README.md and docs are updated for any new features or config changes
|
||||
|
||||
Provide constructive feedback with specific suggestions for improvement.
|
||||
Use `gh pr comment:*` for top-level comments.
|
||||
Use `mcp__github_inline_comment__create_inline_comment` to highlight specific areas of concern.
|
||||
Only your GitHub comments that you post will be seen, so don't submit your review as a normal message, just as comments.
|
||||
If the PR has already been reviewed, or there are no noteworthy changes, don't post anything.
|
||||
|
||||
claude_args: |
|
||||
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*)"
|
||||
@@ -1,54 +0,0 @@
|
||||
name: Claude Automatic Mode Detection Examples
|
||||
|
||||
on:
|
||||
# Events for interactive mode (responds to @claude mentions)
|
||||
issue_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, labeled]
|
||||
pull_request:
|
||||
types: [opened]
|
||||
# Events for automation mode (runs with explicit prompt)
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 0 * * 0" # Weekly on Sunday
|
||||
|
||||
jobs:
|
||||
# Interactive Mode - Activated automatically when no prompt is provided
|
||||
interactive-mode-example:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: anthropics/claude-code-action@v1-dev
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
# Interactive mode (auto-detected when no prompt):
|
||||
# - Scans for @claude mentions in comments, issues, and PRs
|
||||
# - Only acts when trigger phrase is found
|
||||
# - Creates tracking comments with progress checkboxes
|
||||
# - Perfect for: Interactive Q&A, on-demand code changes
|
||||
|
||||
# Automation Mode - Activated automatically when prompt is provided
|
||||
automation-mode-scheduled-task:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: anthropics/claude-code-action@v1-dev
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
prompt: |
|
||||
Check for outdated dependencies and security vulnerabilities.
|
||||
Create an issue if any critical problems are found.
|
||||
# Automation mode (auto-detected when prompt provided):
|
||||
# - Works with any GitHub event
|
||||
# - Executes immediately without waiting for @claude mentions
|
||||
# - No tracking comments created
|
||||
# - Perfect for: scheduled maintenance, automated reviews, CI/CD tasks
|
||||
@@ -1,62 +0,0 @@
|
||||
name: Claude Code
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
if: |
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
id-token: write
|
||||
actions: read # Required for Claude to read CI results on PRs
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
# This is an optional setting that allows Claude to read CI results on PRs
|
||||
additional_permissions: |
|
||||
actions: read
|
||||
|
||||
# Optional: Customize the trigger phrase (default: @claude)
|
||||
# trigger_phrase: "/claude"
|
||||
|
||||
# Optional: Trigger when specific user is assigned to an issue
|
||||
# assignee_trigger: "claude-bot"
|
||||
|
||||
# Optional: Configure Claude's behavior with CLI arguments
|
||||
# claude_args: |
|
||||
# --model claude-opus-4-1-20250805
|
||||
# --max-turns 10
|
||||
# --allowedTools "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)"
|
||||
# --system-prompt "Follow our coding standards. Ensure all new code has tests. Use TypeScript for new files."
|
||||
|
||||
# Optional: Advanced settings configuration
|
||||
# settings: |
|
||||
# {
|
||||
# "env": {
|
||||
# "NODE_ENV": "test"
|
||||
# }
|
||||
# }
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Check for duplicate issues
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
prompt: |
|
||||
Analyze this new issue and check if it's a duplicate of existing issues in the repository.
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Triage issue with Claude
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
prompt: |
|
||||
You're an issue triage assistant for GitHub issues. Your task is to analyze the issue and select appropriate labels from the provided list.
|
||||
|
||||
@@ -28,10 +28,13 @@ jobs:
|
||||
fetch-depth: 2 # Need at least 2 commits to analyze the latest
|
||||
|
||||
- name: Run Claude Analysis
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
prompt: |
|
||||
REPO: ${{ github.repository }}
|
||||
BRANCH: ${{ github.ref_name }}
|
||||
|
||||
Analyze the latest commit in this repository.
|
||||
|
||||
${{ github.event.inputs.analysis_type == 'summarize-commit' && 'Task: Provide a clear, concise summary of what changed in the latest commit. Include the commit message, files changed, and the purpose of the changes.' || '' }}
|
||||
74
examples/pr-review-comprehensive.yml
Normal file
74
examples/pr-review-comprehensive.yml
Normal file
@@ -0,0 +1,74 @@
|
||||
name: PR Review with Progress Tracking
|
||||
|
||||
# This example demonstrates how to use the track_progress feature to get
|
||||
# visual progress tracking for PR reviews, similar to v0.x agent mode.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, ready_for_review, reopened]
|
||||
|
||||
jobs:
|
||||
review-with-tracking:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: PR Review with Progress Tracking
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
# Enable progress tracking
|
||||
track_progress: true
|
||||
|
||||
# Your custom review instructions
|
||||
prompt: |
|
||||
REPO: ${{ github.repository }}
|
||||
PR NUMBER: ${{ github.event.pull_request.number }}
|
||||
|
||||
Perform a comprehensive code review with the following focus areas:
|
||||
|
||||
1. **Code Quality**
|
||||
- Clean code principles and best practices
|
||||
- Proper error handling and edge cases
|
||||
- Code readability and maintainability
|
||||
|
||||
2. **Security**
|
||||
- Check for potential security vulnerabilities
|
||||
- Validate input sanitization
|
||||
- Review authentication/authorization logic
|
||||
|
||||
3. **Performance**
|
||||
- Identify potential performance bottlenecks
|
||||
- Review database queries for efficiency
|
||||
- Check for memory leaks or resource issues
|
||||
|
||||
4. **Testing**
|
||||
- Verify adequate test coverage
|
||||
- Review test quality and edge cases
|
||||
- Check for missing test scenarios
|
||||
|
||||
5. **Documentation**
|
||||
- Ensure code is properly documented
|
||||
- Verify README updates for new features
|
||||
- Check API documentation accuracy
|
||||
|
||||
Provide detailed feedback using inline comments for specific issues.
|
||||
Use top-level comments for general observations or praise.
|
||||
|
||||
# Tools for comprehensive PR review
|
||||
claude_args: |
|
||||
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"
|
||||
|
||||
# When track_progress is enabled:
|
||||
# - Creates a tracking comment with progress checkboxes
|
||||
# - Includes all PR context (comments, attachments, images)
|
||||
# - Updates progress as the review proceeds
|
||||
# - Marks as completed when done
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Review PR from Specific Author
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
prompt: |
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Claude Code Review
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
prompt: |
|
||||
Reference in New Issue
Block a user