Files
claude-code-action/docs/custom-automations.md
Ashwin Bhat 0d9513b3b3 refactor: restructure documentation into organized docs directory (#383)
- Move FAQ.md to docs/faq.md
- Create structured documentation files:
  - setup.md: Manual setup and custom GitHub app instructions
  - usage.md: Basic usage and workflow configuration
  - custom-automations.md: Automation examples
  - configuration.md: MCP servers and advanced settings
  - experimental.md: Execution modes and network restrictions
  - cloud-providers.md: AWS Bedrock and Google Vertex setup
  - capabilities-and-limitations.md: Features and constraints
  - security.md: Security information
- Condense README.md to overview with links to detailed docs
- Keep CONTRIBUTING.md, SECURITY.md, CODE_OF_CONDUCT.md at top level
2025-08-03 21:16:50 -07:00

3.2 KiB

Custom Automations

These examples show how to configure Claude to act automatically based on GitHub events, without requiring manual @mentions.

Supported GitHub Events

This action supports the following GitHub events (learn more GitHub event triggers):

  • pull_request - When PRs are opened or synchronized
  • issue_comment - When comments are created on issues or PRs
  • pull_request_comment - When comments are made on PR diffs
  • issues - When issues are opened or assigned
  • pull_request_review - When PR reviews are submitted
  • pull_request_review_comment - When comments are made on PR reviews
  • repository_dispatch - Custom events triggered via API (coming soon)
  • workflow_dispatch - Manual workflow triggers (coming soon)

Automated Documentation Updates

Automatically update documentation when specific files change (see examples/claude-pr-path-specific.yml):

on:
  pull_request:
    paths:
      - "src/api/**/*.ts"

steps:
  - uses: anthropics/claude-code-action@beta
    with:
      direct_prompt: |
        Update the API documentation in README.md to reflect
        the changes made to the API endpoints in this PR.

When API files are modified, Claude automatically updates your README with the latest endpoint documentation and pushes the changes back to the PR, keeping your docs in sync with your code.

Author-Specific Code Reviews

Automatically review PRs from specific authors or external contributors (see examples/claude-review-from-author.yml):

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review-by-author:
    if: |
      github.event.pull_request.user.login == 'developer1' ||
      github.event.pull_request.user.login == 'external-contributor'
    steps:
      - uses: anthropics/claude-code-action@beta
        with:
          direct_prompt: |
            Please provide a thorough review of this pull request.
            Pay extra attention to coding standards, security practices,
            and test coverage since this is from an external contributor.

Perfect for automatically reviewing PRs from new team members, external contributors, or specific developers who need extra guidance.

Custom Prompt Templates

Use override_prompt for complete control over Claude's behavior with variable substitution:

- uses: anthropics/claude-code-action@beta
  with:
    override_prompt: |
      Analyze PR #$PR_NUMBER in $REPOSITORY for security vulnerabilities.

      Changed files:
      $CHANGED_FILES

      Focus on:
      - SQL injection risks
      - XSS vulnerabilities
      - Authentication bypasses
      - Exposed secrets or credentials

      Provide severity ratings (Critical/High/Medium/Low) for any issues found.

The override_prompt feature supports these variables:

  • $REPOSITORY, $PR_NUMBER, $ISSUE_NUMBER
  • $PR_TITLE, $ISSUE_TITLE, $PR_BODY, $ISSUE_BODY
  • $PR_COMMENTS, $ISSUE_COMMENTS, $REVIEW_COMMENTS
  • $CHANGED_FILES, $TRIGGER_COMMENT, $TRIGGER_USERNAME
  • $BRANCH_NAME, $BASE_BRANCH, $EVENT_TYPE, $IS_PR