Skip to content

Conversation

@dicksontsai
Copy link
Collaborator

Summary

  • Adds extra_args field to ClaudeCodeOptions to support passing arbitrary CLI flags
  • Enables forward compatibility with future CLI flags without requiring SDK updates
  • Supports both valued flags (--flag value) and boolean flags (--flag)

Changes

  • Add extra_args: dict[str, str | None] field to ClaudeCodeOptions
  • Implement logic in SubprocessCLITransport to handle extra args:
    • None values create boolean flags (e.g., {"verbose": None}--verbose)
    • String values create flags with arguments (e.g., {"output": "json"}--output json)
  • Add comprehensive tests for the new functionality

Test plan

  • Added unit tests for settings file path handling
  • Added unit tests for settings JSON object handling
  • Added unit tests for extra_args with both valued and boolean flags
  • All tests pass (python -m pytest tests/)
  • Type checking passes (python -m mypy src/)

🤖 Generated with Claude Code

- Add extra_args dict field to pass arbitrary CLI flags
- Support both valued flags (--flag value) and boolean flags (--flag)
- Add comprehensive tests for the new functionality
- Allows SDK to work with future CLI flags without code changes

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

Co-Authored-By: Claude <[email protected]>
@dicksontsai dicksontsai requested a review from blois August 4, 2025 22:13
@dicksontsai dicksontsai merged commit 9fc8300 into main Aug 5, 2025
6 checks passed
rushilpatel0 pushed a commit to codegen-sh/claude-code-sdk-python that referenced this pull request Aug 17, 2025
…nthropics#111)

## Summary
- Adds `extra_args` field to `ClaudeCodeOptions` to support passing
arbitrary CLI flags
- Enables forward compatibility with future CLI flags without requiring
SDK updates
- Supports both valued flags (`--flag value`) and boolean flags
(`--flag`)

## Changes
- Add `extra_args: dict[str, str | None]` field to `ClaudeCodeOptions`
- Implement logic in `SubprocessCLITransport` to handle extra args:
- `None` values create boolean flags (e.g., `{"verbose": None}` →
`--verbose`)
- String values create flags with arguments (e.g., `{"output": "json"}`
→ `--output json`)
- Add comprehensive tests for the new functionality

## Test plan
- [x] Added unit tests for settings file path handling
- [x] Added unit tests for settings JSON object handling
- [x] Added unit tests for extra_args with both valued and boolean flags
- [x] All tests pass (`python -m pytest tests/`)
- [x] Type checking passes (`python -m mypy src/`)

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

Co-authored-by: Claude <[email protected]>
Signed-off-by: Rushil Patel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants