From a9d9ad3612d6d61922fb1af719a32b9f1366f3f2 Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Tue, 15 Jul 2025 14:00:26 -0700 Subject: [PATCH] feat: add settings input support (#276) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add settings input to action.yml that accepts JSON string or file path - Pass settings parameter to claude-code-base-action - Update README with comprehensive settings documentation - Add link to official Claude Code settings documentation - Document precedence rules for model and tool permissions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude --- README.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ action.yml | 5 +++++ 2 files changed, 65 insertions(+) diff --git a/README.md b/README.md index 36c82df..f56d8ba 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ jobs: | `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` | | `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` | | `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" | +| `settings` | Claude Code settings as JSON string or path to settings JSON file | No | "" | | `additional_permissions` | Additional permissions to enable. Currently supports 'actions: read' for viewing workflow results | No | "" | \*Required when using direct Anthropic API (default and when not using Bedrock or Vertex) @@ -571,6 +572,65 @@ Use a specific Claude model: # ... other inputs ``` +### Claude Code Settings + +You can provide Claude Code settings to customize behavior such as model selection, environment variables, permissions, and hooks. Settings can be provided either as a JSON string or a path to a settings file. + +#### Option 1: Settings File + +```yaml +- uses: anthropics/claude-code-action@beta + with: + settings: "path/to/settings.json" + # ... other inputs +``` + +#### Option 2: Inline Settings + +```yaml +- uses: anthropics/claude-code-action@beta + with: + settings: | + { + "model": "claude-opus-4-20250514", + "env": { + "DEBUG": "true", + "API_URL": "https://api.example.com" + }, + "permissions": { + "allow": ["Bash", "Read"], + "deny": ["WebFetch"] + }, + "hooks": { + "PreToolUse": [{ + "matcher": "Bash", + "hooks": [{ + "type": "command", + "command": "echo Running bash command..." + }] + }] + } + } + # ... other inputs +``` + +The settings support all Claude Code settings options including: + +- `model`: Override the default model +- `env`: Environment variables for the session +- `permissions`: Tool usage permissions +- `hooks`: Pre/post tool execution hooks +- And more... + +For a complete list of available settings and their descriptions, see the [Claude Code settings documentation](https://docs.anthropic.com/en/docs/claude-code/settings). + +**Notes**: + +- The `enableAllProjectMcpServers` setting is always set to `true` by this action to ensure MCP servers work correctly. +- If both the `model` input parameter and a `model` in settings are provided, the `model` input parameter takes precedence. +- The `allowed_tools` and `disallowed_tools` input parameters take precedence over `permissions` in settings. +- In a future version, we may deprecate individual input parameters in favor of using the settings file for all configuration. + ## Cloud Providers You can authenticate with Claude using any of these three methods: diff --git a/action.yml b/action.yml index ee0506b..c9e8616 100644 --- a/action.yml +++ b/action.yml @@ -60,6 +60,10 @@ inputs: description: "Custom environment variables to pass to Claude Code execution (YAML format)" required: false default: "" + settings: + description: "Claude Code settings as JSON string or path to settings JSON file" + required: false + default: "" # Auth configuration anthropic_api_key: @@ -160,6 +164,7 @@ runs: anthropic_api_key: ${{ inputs.anthropic_api_key }} claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }} claude_env: ${{ inputs.claude_env }} + settings: ${{ inputs.settings }} env: # Model configuration ANTHROPIC_MODEL: ${{ inputs.model || inputs.anthropic_model }}