Hi 👋 thanks a lot for this great project - it's a really nice use case to be able to run Claude Code in a repository!
Is there a way to dynamically select the model that Claude Code should use by specifying it in the comment? For example like so:
@claude opus please fix this bug
I've tried the following configuration but without success:
name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
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')))
runs-on: ubuntu-latest
needs: install-dependencies
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Parse model from comment
id: parse-model
run: |
COMMENT_BODY="${{ github.event.comment.body || github.event.review.body || github.event.issue.body || github.event.issue.title }}"
# Simple syntax: @claude opus @claude sonnet
if echo "$COMMENT_BODY" | grep -qi "\b@claude\s+opus\b"; then
MODEL="claude-opus-4-20250514"
echo "model=$MODEL" >> $GITHUB_OUTPUT
echo "Using model: $MODEL"
elif echo "$COMMENT_BODY" | grep -qi "\b@claude\s+sonnet\b"; then
MODEL="claude-sonnet-4-20250514"
echo "model=$MODEL" >> $GITHUB_OUTPUT
echo "Using model: $MODEL"
fi
- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
model: ${{ steps.parse-model.outputs.model }}
additional_permissions: |
actions: read
claude_env: |
ANTHROPIC_BASE_URL: ${{ vars.ANTHROPIC_BASE_URL }}
When I then comment and see Claude Code running in GH, it defaults back to Sonnet:

Hi 👋 thanks a lot for this great project - it's a really nice use case to be able to run Claude Code in a repository!
Is there a way to dynamically select the model that Claude Code should use by specifying it in the comment? For example like so:
I've tried the following configuration but without success:
When I then comment and see Claude Code running in GH, it defaults back to Sonnet: