Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat(claude): Add Claude Code GitHub Actions workflow

Maximilian Roos74b122d4a224
diff --git a/.github/workflows/claude.yaml b/.github/workflows/claude.yaml
new file mode 100644
index 000000000..91cd0472c
--- /dev/null
+++ b/.github/workflows/claude.yaml
@@ -0,0 +1,106 @@
+name: Claude Code
+
+on:
+ issue_comment:
+ types: [created]
+ pull_request_review_comment:
+ types: [created]
+
+# Consistent with ci.yml for cache compatibility
+env:
+ CARGO_TERM_COLOR: always
+ CLICOLOR_FORCE: 1
+ RUSTFLAGS: "-C debuginfo=0"
+ RUSTDOCFLAGS: "-Dwarnings"
+
+jobs:
+ claude:
+ # Only run when comment contains @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'))
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write # Allow pushing commits
+ pull-requests: write # Allow commenting and updating PRs
+ issues: write # Allow commenting on issues
+ id-token: write
+ actions: read # Required for Claude to read CI results on PRs
+ steps:
+ - name: πŸ“‚ Checkout code
+ uses: actions/checkout@v5
+ with:
+ # Fix: Checkout PR branch for issue_comment events instead of default branch
+ ref:
+ ${{ github.event.issue.pull_request && format('refs/pull/{0}/head',
+ github.event.issue.number) || github.ref }}
+ fetch-depth: 0 # Get more history for better context
+ fetch-tags: true
+
+ - name: πŸ”§ Configure git for Claude
+ run: |
+ git config --global user.name "Claude Code"
+ git config --global user.email "[email protected]"
+
+ # Rust is pre-installed on ubuntu-latest, but we ensure consistent toolchain
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@stable
+ with:
+ components: rustfmt, clippy
+
+ - name: Install cargo-insta
+ uses: baptiste0928/cargo-install@v3
+ with:
+ crate: cargo-insta
+
+ - name: Install cargo-nextest
+ uses: baptiste0928/cargo-install@v3
+ with:
+ crate: cargo-nextest
+
+ - name: πŸ’° Cache
+ uses: Swatinem/rust-cache@v2
+ with:
+ prefix-key: ${{ hashFiles('Cargo.lock') }}
+ save-if: false
+
+ - name: Install Tier 1 shells (bash, zsh, fish)
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y zsh fish
+
+ - name: πŸ€– Run Claude Code
+ id: claude
+ uses: anthropics/claude-code-action@v1
+ with:
+ anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+
+ # This is an optional setting that allows Claude to read CI results on PRs
+ additional_permissions: |
+ actions: read
+
+ # Grant Claude full permissions to execute commands
+ # Also include system prompt with project context via claude_args
+ claude_args: |
+ --allowedTools Bash,Edit,Read,Write,Glob,Grep,WebSearch,WebFetch
+ --system-prompt "You are helping with the worktrunk project in a GitHub Actions environment.
+ Follow the project guidelines in CLAUDE.md.
+ After making changes, ensure tests pass with 'cargo insta test --test-runner=nextest' and lints with 'cargo clippy --all-targets --all-features -- -D warnings' and 'cargo fmt --all --check'.
+
+ For CI failure diagnosis:
+ - Use 'gh run list' and 'gh run view' to check CI status
+ - Look for specific error messages in failing jobs
+ - Check the test output for detailed failure information
+ - When fixing issues, verify changes with the appropriate test commands
+ - Once local test commands work, push to the PR
+ - Then: iterate between monitoring CI, fixing any remaining issues, monitoring CI
+ - Don't return until we're confident that we've done everything we can
+
+ Available test commands:
+ - 'cargo insta test --test-runner=nextest' - Run all tests with snapshot testing
+ - 'cargo clippy --all-targets --all-features -- -D warnings' - Run linter
+ - 'cargo fmt --all --check' - Check formatting
+ - 'cargo doc --no-deps' - Build documentation
+
+ This project is a git worktree manager that integrates with shells (bash, zsh, fish).
+ Pay attention to shell integration, output formatting (anstyle), and snapshot tests."