Welcome to the Claude Code Base Action repository! This GitHub Action allows you to seamlessly integrate Claude Code into your GitHub Actions workflows. With this action, you can create custom workflows that leverage the power of Claude Code, making your automation tasks more efficient and effective.
For simple tagging of @claude in issues and pull requests, check out the Claude Code action and GitHub app.
- Direct Prompt Execution: Run Claude Code with a prompt directly in your workflow.
- File-Based Prompts: Use prompts stored in files for more complex queries.
- Tool Integration: Leverage various tools like Bash, View, and more within your workflows.
- Secure API Key Handling: Use GitHub Secrets to manage your API keys securely.
To get started with the Claude Code Base Action, you need to have a GitHub repository where you want to use this action. Follow these steps to set up your workflow:
- Create a GitHub Repository: If you don't have one, create a new repository on GitHub.
- Add Your API Key: Go to your repository settings and add your
ANTHROPIC_API_KEY
as a secret. - Create a Workflow File: In your repository, create a new YAML file in the
.github/workflows
directory.
You can use the Claude Code Base Action in your workflow file by specifying the action and providing the necessary inputs. Here are a few examples of how to use it:
name: Run Claude Code with Direct Prompt
on: [push]
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Run Claude Code with direct prompt
uses: anthropics/claude-code-base-action@beta
with:
prompt: "Your prompt here"
allowed_tools: "Bash(git:*),View,GlobTool,GrepTool,BatchTool"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
name: Run Claude Code with Prompt File
on: [push]
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Run Claude Code with prompt file
uses: anthropics/claude-code-base-action@beta
with:
prompt_file: "/path/to/prompt.txt"
allowed_tools: "Bash(git:*),View,GlobTool,GrepTool,BatchTool"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
Here are some practical examples to illustrate how to use the Claude Code Base Action effectively.
In this example, you can run a simple prompt to fetch information about your project.
name: Simple Claude Code Example
on: [push]
jobs:
info:
runs-on: ubuntu-latest
steps:
- name: Get Project Info
uses: anthropics/claude-code-base-action@beta
with:
prompt: "What are the main features of this project?"
allowed_tools: "View"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
You can store complex prompts in a text file and reference them in your workflow.
name: File-Based Claude Code Example
on: [push]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- name: Analyze Code
uses: anthropics/claude-code-base-action@beta
with:
prompt_file: "./prompts/analyze_code.txt"
allowed_tools: "Bash(git:*),GlobTool"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
The allowed_tools
input specifies which tools Claude Code can use during execution. You can customize this based on your needs. Here are some examples:
Bash(git:*)
: Allows any git command.View
: Lets Claude Code view files and outputs.GlobTool
: Enables pattern matching for file names.GrepTool
: Allows searching through text.
Always store your API keys securely. Use GitHub Secrets to manage your ANTHROPIC_API_KEY
. This ensures that your key remains private and secure.
If you encounter issues while using the Claude Code Base Action, here are some common troubleshooting steps:
- Check API Key: Ensure your
ANTHROPIC_API_KEY
is set correctly in your repository secrets. - Validate YAML Syntax: Ensure your workflow YAML file is correctly formatted.
- Review Logs: Check the logs of your GitHub Actions run for any error messages.
We welcome contributions to the Claude Code Base Action. If you have suggestions, improvements, or bug fixes, please open an issue or submit a pull request. Follow these steps:
- Fork the repository.
- Create a new branch for your feature or fix.
- Make your changes and commit them.
- Push your changes to your forked repository.
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
To keep up with the latest changes and updates, visit our Releases page. Here, you can download and execute the latest version of the Claude Code Base Action.
For more detailed release notes, check the Releases section in this repository.
Thank you for using the Claude Code Base Action! We hope it enhances your GitHub workflows and helps you achieve your automation goals.