claude-code-sdk-python/examples
Ashwin Bhat 507e22cb4a
feat: add agents and setting sources support (#182)
## Summary
- Add support for custom agent definitions via `agents` option
- Add support for controlling setting sources via `setting_sources`
option
- Add `/commit` slash command to project
- Add examples demonstrating both features
- Add e2e tests for verification

## Changes

### Core Implementation
- Add `AgentDefinition` and `SettingSource` types to `types.py`
- Add `agents` and `setting_sources` fields to `ClaudeCodeOptions`
- Update subprocess CLI transport to pass `--agents` and
`--setting-sources` flags
- **Default behavior**: When `setting_sources` is not provided, pass
empty string (no settings loaded)
- Handle empty `setting_sources` array correctly (pass empty string to
CLI)

### Examples
- `examples/agents.py`: Demonstrates custom agent definitions with
different tools and models
- `examples/setting_sources.py`: Shows how setting sources control which
settings are loaded
  - Default behavior (no settings)
  - User-only settings
  - User + project settings

### Tests
- Add e2e tests verifying agents and setting_sources functionality
- Test default behavior (no settings loaded)
- Test filtering by setting source
- Use `output_style` checking to verify settings loaded/not loaded
- Tests use temporary directories for isolated testing

### Project Config
- Add `.claude/commands/commit.md` slash command for git commits

## Test Plan
- [x] E2E tests added for all new functionality
- [ ] CI tests pass
- [ ] Examples run successfully

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-26 12:52:46 -07:00
..
agents.py feat: add agents and setting sources support (#182) 2025-09-26 12:52:46 -07:00
hooks.py Hooks: Clean up types and implement example (#153) 2025-09-08 13:45:21 -07:00
include_partial_messages.py Add support for streaming partial messages via include_partial_messages option (#168) 2025-09-17 16:32:21 -07:00
mcp_calculator.py Update changelog, readme, and examples for custom tools and hooks (#162) 2025-09-12 08:14:34 -07:00
quick_start.py cost_usd -> total_cost_usd in example 2025-06-25 15:18:52 -04:00
setting_sources.py feat: add agents and setting sources support (#182) 2025-09-26 12:52:46 -07:00
streaming_mode.py Remove max thinking tokens (#144) 2025-09-12 02:22:01 -07:00
streaming_mode_ipython.py feat: Add in-process SDK MCP server support (#142) 2025-09-03 08:29:32 -07:00
streaming_mode_trio.py Make streaming implementation trio-compatible (#84) 2025-07-22 23:31:42 -07:00
tool_permission_callback.py Add custom tool callbacks and e2e tests (#157) 2025-09-08 08:51:40 -07:00