{"id":28622774,"url":"https://github.com/anthropics/claude-code-base-action","last_synced_at":"2025-06-14T02:08:06.292Z","repository":{"id":294261646,"uuid":"986420616","full_name":"anthropics/claude-code-base-action","owner":"anthropics","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-10T21:57:01.000Z","size":77,"stargazers_count":157,"open_issues_count":6,"forks_count":467,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-10T22:31:00.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anthropics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-19T15:25:00.000Z","updated_at":"2025-06-10T21:48:37.000Z","dependencies_parsed_at":"2025-06-10T22:24:20.995Z","dependency_job_id":"7243fae6-2982-45c6-b3b9-da2cfea45dd5","html_url":"https://github.com/anthropics/claude-code-base-action","commit_stats":null,"previous_names":["anthropics/claude-code-base-action"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/anthropics/claude-code-base-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthropics%2Fclaude-code-base-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthropics%2Fclaude-code-base-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthropics%2Fclaude-code-base-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthropics%2Fclaude-code-base-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthropics","download_url":"https://codeload.github.com/anthropics/claude-code-base-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthropics%2Fclaude-code-base-action/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259409892,"owners_count":22852953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-12T06:01:47.036Z","updated_at":"2025-06-14T02:08:06.286Z","avatar_url":"https://github.com/anthropics.png","language":"TypeScript","readme":"# Claude Code Base Action\n\nThis GitHub Action allows you to run [Claude Code](https://www.anthropic.com/claude-code) within your GitHub Actions workflows. You can use this to build any custom workflow on top of Claude Code.\n\nFor simply tagging @claude in issues and PRs out of the box, [check out the Claude Code action and GitHub app](https://github.com/anthropics/claude-code-action).\n\n## Usage\n\nAdd the following to your workflow file:\n\n```yaml\n# Using a direct prompt\n- name: Run Claude Code with direct prompt\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Your prompt here\"\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n\n# Or using a prompt from a file\n- name: Run Claude Code with prompt file\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt_file: \"/path/to/prompt.txt\"\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n\n# Or limiting the conversation turns\n- name: Run Claude Code with limited turns\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Your prompt here\"\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n    max_turns: \"5\" # Limit conversation to 5 turns\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n\n# Using custom system prompts\n- name: Run Claude Code with custom system prompt\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Build a REST API\"\n    system_prompt: \"You are a senior backend engineer. Focus on security, performance, and maintainability.\"\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n\n# Or appending to the default system prompt\n- name: Run Claude Code with appended system prompt\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Create a database schema\"\n    append_system_prompt: \"After writing code, be sure to code review yourself.\"\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n\n# Using custom environment variables\n- name: Run Claude Code with custom environment variables\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Deploy to staging environment\"\n    claude_env: |\n      ENVIRONMENT: staging\n      API_URL: https://api-staging.example.com\n      DEBUG: true\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n```\n\n## Inputs\n\n| Input                  | Description                                                                                       | Required | Default                      |\n| ---------------------- | ------------------------------------------------------------------------------------------------- | -------- | ---------------------------- |\n| `prompt`               | The prompt to send to Claude Code                                                                 | No\\*     | ''                           |\n| `prompt_file`          | Path to a file containing the prompt to send to Claude Code                                       | No\\*     | ''                           |\n| `allowed_tools`        | Comma-separated list of allowed tools for Claude Code to use                                      | No       | ''                           |\n| `disallowed_tools`     | Comma-separated list of disallowed tools that Claude Code cannot use                              | No       | ''                           |\n| `max_turns`            | Maximum number of conversation turns (default: no limit)                                          | No       | ''                           |\n| `mcp_config`           | Path to the MCP configuration JSON file                                                           | No       | ''                           |\n| `system_prompt`        | Override system prompt                                                                            | No       | ''                           |\n| `append_system_prompt` | Append to system prompt                                                                           | No       | ''                           |\n| `claude_env`           | Custom environment variables to pass to Claude Code execution (YAML multiline format)             | No       | ''                           |\n| `model`                | Model to use (provider-specific format required for Bedrock/Vertex)                               | No       | 'claude-3-7-sonnet-20250219' |\n| `anthropic_model`      | DEPRECATED: Use 'model' instead                                                                   | No       | 'claude-3-7-sonnet-20250219' |\n| `timeout_minutes`      | Timeout in minutes for Claude Code execution                                                      | No       | '10'                         |\n| `anthropic_api_key`    | Anthropic API key (required for direct Anthropic API)                                             | No       | ''                           |\n| `use_bedrock`          | Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API                       | No       | 'false'                      |\n| `use_vertex`           | Use Google Vertex AI with OIDC authentication instead of direct Anthropic API                     | No       | 'false'                      |\n| `use_node_cache`       | Whether to use Node.js dependency caching (set to true only for Node.js projects with lock files) | No       | 'false'                      |\n\n\\*Either `prompt` or `prompt_file` must be provided, but not both.\n\n## Outputs\n\n| Output           | Description                                                |\n| ---------------- | ---------------------------------------------------------- |\n| `conclusion`     | Execution status of Claude Code ('success' or 'failure')   |\n| `execution_file` | Path to the JSON file containing Claude Code execution log |\n\n## Environment Variables\n\nThe following environment variables can be used to configure the action:\n\n| Variable       | Description                                           | Default |\n| -------------- | ----------------------------------------------------- | ------- |\n| `NODE_VERSION` | Node.js version to use (e.g., '18.x', '20.x', '22.x') | '18.x'  |\n\nExample usage:\n\n```yaml\n- name: Run Claude Code with Node.js 20\n  uses: anthropics/claude-code-base-action@beta\n  env:\n    NODE_VERSION: \"20.x\"\n  with:\n    prompt: \"Your prompt here\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n```\n\n## Custom Environment Variables\n\nYou can pass custom environment variables to Claude Code execution using the `claude_env` input. This allows Claude to access environment-specific configuration during its execution.\n\nThe `claude_env` input accepts YAML multiline format with key-value pairs:\n\n```yaml\n- name: Deploy with custom environment\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Deploy the application to the staging environment\"\n    claude_env: |\n      ENVIRONMENT: staging\n      API_BASE_URL: https://api-staging.example.com\n      DATABASE_URL: ${{ secrets.STAGING_DB_URL }}\n      DEBUG: true\n      LOG_LEVEL: debug\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n```\n\n### Features:\n\n- **YAML Format**: Use standard YAML key-value syntax (`KEY: value`)\n- **Multiline Support**: Define multiple environment variables in a single input\n- **Comments**: Lines starting with `#` are ignored\n- **GitHub Secrets**: Can reference GitHub secrets using `${{ secrets.SECRET_NAME }}`\n- **Runtime Access**: Environment variables are available to Claude during execution\n\n### Example Use Cases:\n\n```yaml\n# Development configuration\nclaude_env: |\n  NODE_ENV: development\n  API_URL: http://localhost:3000\n  DEBUG: true\n\n# Production deployment\nclaude_env: |\n  NODE_ENV: production\n  API_URL: https://api.example.com\n  DATABASE_URL: ${{ secrets.PROD_DB_URL }}\n  REDIS_URL: ${{ secrets.REDIS_URL }}\n\n# Feature flags and configuration\nclaude_env: |\n  FEATURE_NEW_UI: enabled\n  MAX_RETRIES: 3\n  TIMEOUT_MS: 5000\n```\n\n## Using MCP Config\n\nYou can provide a custom MCP configuration file to dynamically load MCP servers:\n\n```yaml\n- name: Run Claude Code with MCP config\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Your prompt here\"\n    mcp_config: \"path/to/mcp-config.json\"\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n```\n\nThe MCP config file should follow this format:\n\n```json\n{\n  \"mcpServers\": {\n    \"server-name\": {\n      \"command\": \"node\",\n      \"args\": [\"./server.js\"],\n      \"env\": {\n        \"API_KEY\": \"your-api-key\"\n      }\n    }\n  }\n}\n```\n\nYou can combine MCP config with other inputs like allowed tools:\n\n```yaml\n# Using multiple inputs together\n- name: Run Claude Code with MCP and custom tools\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Access the custom MCP server and use its tools\"\n    mcp_config: \"mcp-config.json\"\n    allowed_tools: \"Bash(git:*),View,mcp__server-name__custom_tool\"\n    timeout_minutes: \"15\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n```\n\n## Example: PR Code Review\n\n```yaml\nname: Claude Code Review\n\non:\n  pull_request:\n    types: [opened, synchronize]\n\njobs:\n  code-review:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n\n      - name: Run Code Review with Claude\n        id: code-review\n        uses: anthropics/claude-code-base-action@beta\n        with:\n          prompt: \"Review the PR changes. Focus on code quality, potential bugs, and performance issues. Suggest improvements where appropriate. Write your review as markdown text.\"\n          allowed_tools: \"Bash(git diff --name-only HEAD~1),Bash(git diff HEAD~1),View,GlobTool,GrepTool,Write\"\n          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n\n      - name: Extract and Comment PR Review\n        if: steps.code-review.outputs.conclusion == 'success'\n        uses: actions/github-script@v7\n        with:\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n          script: |\n            const fs = require('fs');\n            const executionFile = '${{ steps.code-review.outputs.execution_file }}';\n            const executionLog = JSON.parse(fs.readFileSync(executionFile, 'utf8'));\n\n            // Extract the review content from the execution log\n            // The execution log contains the full conversation including Claude's responses\n            let review = '';\n\n            // Find the last assistant message which should contain the review\n            for (let i = executionLog.length - 1; i \u003e= 0; i--) {\n              if (executionLog[i].role === 'assistant') {\n                review = executionLog[i].content;\n                break;\n              }\n            }\n\n            if (review) {\n              github.rest.issues.createComment({\n                issue_number: context.issue.number,\n                owner: context.repo.owner,\n                repo: context.repo.repo,\n                body: \"## Claude Code Review\\n\\n\" + review + \"\\n\\n*Generated by Claude Code*\"\n              });\n            }\n```\n\nCheck out additional examples in [`./examples`](./examples).\n\n## Using Cloud Providers\n\nYou can authenticate with Claude using any of these three methods:\n\n1. Direct Anthropic API (default) - requires API key\n2. Amazon Bedrock - requires OIDC authentication and automatically uses cross-region inference profiles\n3. Google Vertex AI - requires OIDC authentication\n\n**Note**:\n\n- Bedrock and Vertex use OIDC authentication exclusively\n- AWS Bedrock automatically uses cross-region inference profiles for certain models\n- For cross-region inference profile models, you need to request and be granted access to the Claude models in all regions that the inference profile uses\n- The Bedrock API endpoint URL is automatically constructed using the AWS_REGION environment variable (e.g., `https://bedrock-runtime.us-west-2.amazonaws.com`)\n- You can override the Bedrock API endpoint URL by setting the `ANTHROPIC_BEDROCK_BASE_URL` environment variable\n\n### Model Configuration\n\nUse provider-specific model names based on your chosen provider:\n\n```yaml\n# For direct Anthropic API (default)\n- name: Run Claude Code with Anthropic API\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Your prompt here\"\n    model: \"claude-3-7-sonnet-20250219\"\n    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n\n# For Amazon Bedrock (requires OIDC authentication)\n- name: Configure AWS Credentials (OIDC)\n  uses: aws-actions/configure-aws-credentials@v4\n  with:\n    role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}\n    aws-region: us-west-2\n\n- name: Run Claude Code with Bedrock\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Your prompt here\"\n    model: \"anthropic.claude-3-7-sonnet-20250219-v1:0\"\n    use_bedrock: \"true\"\n\n# For Google Vertex AI (requires OIDC authentication)\n- name: Authenticate to Google Cloud\n  uses: google-github-actions/auth@v2\n  with:\n    workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}\n    service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}\n\n- name: Run Claude Code with Vertex AI\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Your prompt here\"\n    model: \"claude-3-7-sonnet@20250219\"\n    use_vertex: \"true\"\n```\n\n## Example: Using OIDC Authentication for AWS Bedrock\n\nThis example shows how to use OIDC authentication with AWS Bedrock:\n\n```yaml\n- name: Configure AWS Credentials (OIDC)\n  uses: aws-actions/configure-aws-credentials@v4\n  with:\n    role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}\n    aws-region: us-west-2\n\n- name: Run Claude Code with AWS OIDC\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Your prompt here\"\n    use_bedrock: \"true\"\n    model: \"anthropic.claude-3-7-sonnet-20250219-v1:0\"\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n```\n\n## Example: Using OIDC Authentication for GCP Vertex AI\n\nThis example shows how to use OIDC authentication with GCP Vertex AI:\n\n```yaml\n- name: Authenticate to Google Cloud\n  uses: google-github-actions/auth@v2\n  with:\n    workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}\n    service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}\n\n- name: Run Claude Code with GCP OIDC\n  uses: anthropics/claude-code-base-action@beta\n  with:\n    prompt: \"Your prompt here\"\n    use_vertex: \"true\"\n    model: \"claude-3-7-sonnet@20250219\"\n    allowed_tools: \"Bash(git:*),View,GlobTool,GrepTool,BatchTool\"\n```\n\n## Security Best Practices\n\n**⚠️ IMPORTANT: Never commit API keys directly to your repository! Always use GitHub Actions secrets.**\n\nTo securely use your Anthropic API key:\n\n1. Add your API key as a repository secret:\n\n   - Go to your repository's Settings\n   - Navigate to \"Secrets and variables\" → \"Actions\"\n   - Click \"New repository secret\"\n   - Name it `ANTHROPIC_API_KEY`\n   - Paste your API key as the value\n\n2. Reference the secret in your workflow:\n   ```yaml\n   anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n   ```\n\n**Never do this:**\n\n```yaml\n# ❌ WRONG - Exposes your API key\nanthropic_api_key: \"sk-ant-...\"\n```\n\n**Always do this:**\n\n```yaml\n# ✅ CORRECT - Uses GitHub secrets\nanthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n```\n\nThis applies to all sensitive values including API keys, access tokens, and credentials.\nWe also recommend that you always use short-lived tokens when possible\n\n## License\n\nThis project is licensed under the MIT License—see the LICENSE file for details.\n","funding_links":[],"categories":["HarmonyOS","TypeScript","GitHub Integration","官方仓库","Official Resources"],"sub_categories":["Windows Manager","What are Claude Skills?"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthropics%2Fclaude-code-base-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthropics%2Fclaude-code-base-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthropics%2Fclaude-code-base-action/lists"}