Add settings option to ClaudeCodeOptions (#100)
Some checks are pending
Lint / lint (push) Waiting to run
Test / test (3.10) (push) Waiting to run
Test / test (3.11) (push) Waiting to run
Test / test (3.12) (push) Waiting to run
Test / test (3.13) (push) Waiting to run

## Summary
- Add `settings` field to `ClaudeCodeOptions` to expose the `--settings`
CLI flag
- Allow SDK users to specify custom settings configuration path

## Changes
- Added `settings: str | None = None` field to `ClaudeCodeOptions`
dataclass
- Added CLI argument conversion logic in `SubprocessCLITransport` to
pass `--settings` flag to Claude Code CLI

## Test plan
- [x] All existing tests pass
- [x] Linting passes (`python -m ruff check`)
- [x] Type checking passes (`python -m mypy src/`)

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Dickson Tsai 2025-07-30 23:59:21 -07:00 committed by GitHub
parent 472aa23aae
commit df94948edc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View file

@ -1,5 +1,13 @@
# Changelog
## 0.0.18
- Add `ClaudeCodeOptions.settings` for `--settings`
## 0.0.17
- Remove dependency on asyncio for Trio compatibility
## 0.0.16
- Introduce ClaudeSDKClient for bidirectional streaming conversation

View file

@ -118,6 +118,9 @@ class SubprocessCLITransport(Transport):
if self._options.resume:
cmd.extend(["--resume", self._options.resume])
if self._options.settings:
cmd.extend(["--settings", self._options.settings])
if self._options.mcp_servers:
cmd.extend(
["--mcp-config", json.dumps({"mcpServers": self._options.mcp_servers})]

View file

@ -127,3 +127,4 @@ class ClaudeCodeOptions:
model: str | None = None
permission_prompt_tool_name: str | None = None
cwd: str | Path | None = None
settings: str | None = None