source dump of claude code
at main 144 lines 5.3 kB view raw
1export const PR_TITLE = 'Add Claude Code GitHub Workflow' 2 3export const GITHUB_ACTION_SETUP_DOCS_URL = 4 'https://github.com/anthropics/claude-code-action/blob/main/docs/setup.md' 5 6export const WORKFLOW_CONTENT = `name: Claude Code 7 8on: 9 issue_comment: 10 types: [created] 11 pull_request_review_comment: 12 types: [created] 13 issues: 14 types: [opened, assigned] 15 pull_request_review: 16 types: [submitted] 17 18jobs: 19 claude: 20 if: | 21 (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || 22 (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || 23 (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || 24 (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) 25 runs-on: ubuntu-latest 26 permissions: 27 contents: read 28 pull-requests: read 29 issues: read 30 id-token: write 31 actions: read # Required for Claude to read CI results on PRs 32 steps: 33 - name: Checkout repository 34 uses: actions/checkout@v4 35 with: 36 fetch-depth: 1 37 38 - name: Run Claude Code 39 id: claude 40 uses: anthropics/claude-code-action@v1 41 with: 42 anthropic_api_key: \${{ secrets.ANTHROPIC_API_KEY }} 43 44 # This is an optional setting that allows Claude to read CI results on PRs 45 additional_permissions: | 46 actions: read 47 48 # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. 49 # prompt: 'Update the pull request description to include a summary of changes.' 50 51 # Optional: Add claude_args to customize behavior and configuration 52 # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md 53 # or https://code.claude.com/docs/en/cli-reference for available options 54 # claude_args: '--allowed-tools Bash(gh pr:*)' 55 56` 57 58export const PR_BODY = `## 🤖 Installing Claude Code GitHub App 59 60This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository. 61 62### What is Claude Code? 63 64[Claude Code](https://claude.com/claude-code) is an AI coding agent that can help with: 65- Bug fixes and improvements 66- Documentation updates 67- Implementing new features 68- Code reviews and suggestions 69- Writing tests 70- And more! 71 72### How it works 73 74Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment. 75Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action. 76 77### Important Notes 78 79- **This workflow won't take effect until this PR is merged** 80- **@claude mentions won't work until after the merge is complete** 81- The workflow runs automatically whenever Claude is mentioned in PR or issue comments 82- Claude gets access to the entire PR or issue context including files, diffs, and previous comments 83 84### Security 85 86- Our Anthropic API key is securely stored as a GitHub Actions secret 87- Only users with write access to the repository can trigger the workflow 88- All Claude runs are stored in the GitHub Actions run history 89- Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits. 90- We can add more allowed tools by adding them to the workflow file like: 91 92\`\`\` 93allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test) 94\`\`\` 95 96There's more information in the [Claude Code action repo](https://github.com/anthropics/claude-code-action). 97 98After merging this PR, let's try mentioning @claude in a comment on any PR to get started!` 99 100export const CODE_REVIEW_PLUGIN_WORKFLOW_CONTENT = `name: Claude Code Review 101 102on: 103 pull_request: 104 types: [opened, synchronize, ready_for_review, reopened] 105 # Optional: Only run on specific file changes 106 # paths: 107 # - "src/**/*.ts" 108 # - "src/**/*.tsx" 109 # - "src/**/*.js" 110 # - "src/**/*.jsx" 111 112jobs: 113 claude-review: 114 # Optional: Filter by PR author 115 # if: | 116 # github.event.pull_request.user.login == 'external-contributor' || 117 # github.event.pull_request.user.login == 'new-developer' || 118 # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' 119 120 runs-on: ubuntu-latest 121 permissions: 122 contents: read 123 pull-requests: read 124 issues: read 125 id-token: write 126 127 steps: 128 - name: Checkout repository 129 uses: actions/checkout@v4 130 with: 131 fetch-depth: 1 132 133 - name: Run Claude Code Review 134 id: claude-review 135 uses: anthropics/claude-code-action@v1 136 with: 137 anthropic_api_key: \${{ secrets.ANTHROPIC_API_KEY }} 138 plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' 139 plugins: 'code-review@claude-code-plugins' 140 prompt: '/code-review:code-review \${{ github.repository }}/pull/\${{ github.event.pull_request.number }}' 141 # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md 142 # or https://code.claude.com/docs/en/cli-reference for available options 143 144`