mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-26 08:54:13 +08:00
feat: add claudeArgs input for direct CLI argument passing
- Add claude_args input to action.yml for flexible CLI control - Parse arguments with industry-standard shell-quote library - Maintain proper argument order: -p [claudeArgs] [legacy] [BASE_ARGS] - Keep tag mode defaults (needed for functionality) - Agent mode has no defaults (full user control) - Add comprehensive tests for new functionality - Add example workflow showing usage
This commit is contained in:
@@ -1,39 +1,31 @@
|
||||
name: Claude with Custom Args Example
|
||||
name: Claude Args Example
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
prompt:
|
||||
description: "Prompt for Claude"
|
||||
required: false
|
||||
default: "Respond with a joke"
|
||||
description: 'Prompt for Claude'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
claude-custom:
|
||||
claude-with-custom-args:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: anthropics/claude-code-action@v1
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run Claude with custom arguments
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
mode: agent
|
||||
prompt: ${{ github.event.inputs.prompt }}
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
# Option 1: Simple prompt with custom args
|
||||
prompt: "Review this code and provide feedback"
|
||||
claude_args: "--max-turns 3 --model claude-3-5-sonnet-latest"
|
||||
|
||||
# Option 2: Slash command with custom MCP config
|
||||
# prompt: "/review"
|
||||
# claude_args: "--mcp-config /workspace/custom-mcp.json --max-turns 5"
|
||||
|
||||
# Option 3: Override output format and add custom system prompt
|
||||
# prompt: "Fix the failing tests"
|
||||
# claude_args: "--output-format json --system-prompt 'You are an expert test fixer'"
|
||||
# How it works:
|
||||
# The action will execute: claude -p --verbose --output-format stream-json [your claude_args]
|
||||
# Where the prompt is piped via stdin
|
||||
|
||||
# Benefits:
|
||||
# - Full control over Claude CLI arguments
|
||||
# - Use any Claude feature without waiting for action updates
|
||||
# - Override defaults when needed
|
||||
# - Combine with existing inputs or use standalone
|
||||
|
||||
# New claudeArgs input allows direct CLI argument control
|
||||
# Arguments are passed in the order: -p [claudeArgs] [legacy options] [BASE_ARGS]
|
||||
claude_args: |
|
||||
--max-turns 15
|
||||
--model claude-3-opus-20240229
|
||||
--allowedTools Edit,Read,Write,Bash
|
||||
--disallowedTools WebSearch
|
||||
--system-prompt "You are a senior engineer focused on code quality"
|
||||
Reference in New Issue
Block a user