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') || github.event.label.name
      == 'claude'))
    permissions:
      actions: read
      contents: read
      id-token: write
      issues: read
      pull-requests: read
    runs-on: ubuntu-latest
    steps:
    - env:
        CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
      name: Ensure CLAUDE_CODE_OAUTH_TOKEN secret is configured
      run: "if [ -z \"${CLAUDE_CODE_OAUTH_TOKEN}\" ]; then\n  echo \"::error::Secret\
        \ 'CLAUDE_CODE_OAUTH_TOKEN' is not set. Add it under Settings → Secrets and\
        \ variables → Actions (repo-level, or org-level with 'All repositories' visibility\
        \ to cover every repo).\"\n  exit 1\nfi\n"
    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        fetch-depth: 1
    - id: claude
      name: Run Claude Code
      uses: anthropics/claude-code-action@v1
      with:
        additional_permissions: 'actions: read

          '
        claude_args: --allowedTools "Bash(gh pr create:*),Bash(gh pr list:*)" --append-system-prompt
          "Whenever you push commits to a branch, always finish by opening a pull
          request against the default branch with gh pr create (check gh pr list --head
          <branch> first; if one already exists, pushing was enough)."
        claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
        label_trigger: claude
name: Claude Code
'on':
  issue_comment:
    types:
    - created
  issues:
    types:
    - opened
    - labeled
  pull_request_review:
    types:
    - submitted
  pull_request_review_comment:
    types:
    - created
