Summary
A deep review of src/claude/ (2,774 lines across 8 files) against claude-agent-sdk v0.1.31 reveals that ~68% (~1,880 lines) duplicates or over-complicates native SDK functionality.
Full analysis: docs/SDK_DUPLICATION_REVIEW.md
Key Findings
| # |
Finding |
Impact |
Lines Affected |
| 1 |
Using query() instead of ClaudeSDKClient — we built a 340-line SessionManager with temp IDs and swap logic for what the SDK handles natively |
HIGH |
~330 |
| 2 |
ToolMonitor validates tools reactively during streaming; SDK's can_use_tool blocks before execution |
HIGH |
~425 |
| 3 |
Maintaining two complete backends (SDK 513 lines + CLI subprocess 594 lines + parser 338 lines) with identical dataclasses and extraction logic |
HIGH |
~1,012 |
| 4 |
Not using max_budget_usd — cost tracked in 4 places but never enforced |
MEDIUM |
~10 |
| 5 |
Manual disallowed_tools checking — SDK has native option |
MEDIUM |
~15 |
| 6 |
Bash substring blocklist (>, ` |
, &, ;) blocks legitimate shell usage; should use can_use_tool` + sandbox |
MEDIUM |
Proposed Phases
| Phase |
What |
Risk |
| 1 |
Low-risk cleanup: dead state, ResultMessage.result, pass disallowed_tools to SDK options |
None |
| 2 |
Remove CLI subprocess backend (integration.py, parser.py, fallback logic) |
Medium — upgrade SDK first |
| 3 |
Replace ToolMonitor with can_use_tool callback |
Medium — write tests first |
| 4 |
Switch query() to ClaudeSDKClient for multi-turn conversations |
High — prototype first |
| 5 |
Final cleanup: CLI discovery, consolidate dataclasses |
Low |
Prerequisites
Target State
| File |
Before |
After |
integration.py |
594 |
deleted |
parser.py |
338 |
deleted |
session.py |
340 |
~90 |
monitor.py |
333 |
~50 |
facade.py |
568 |
~270 |
sdk_integration.py |
513 |
~410 |
| Total |
2,774 |
~900 |
Summary
A deep review of
src/claude/(2,774 lines across 8 files) againstclaude-agent-sdkv0.1.31 reveals that ~68% (~1,880 lines) duplicates or over-complicates native SDK functionality.Full analysis:
docs/SDK_DUPLICATION_REVIEW.mdKey Findings
query()instead ofClaudeSDKClient— we built a 340-line SessionManager with temp IDs and swap logic for what the SDK handles nativelyToolMonitorvalidates tools reactively during streaming; SDK'scan_use_toolblocks before executionmax_budget_usd— cost tracked in 4 places but never enforceddisallowed_toolschecking — SDK has native option>, `,&,;) blocks legitimate shell usage; should usecan_use_tool` + sandboxProposed Phases
ResultMessage.result, passdisallowed_toolsto SDK optionsintegration.py,parser.py, fallback logic)ToolMonitorwithcan_use_toolcallbackquery()toClaudeSDKClientfor multi-turn conversationsPrerequisites
claude-agent-sdkto latest (currently on 0.1.31)ClaudeSDKClientlifecycle management (one client per user? per directory?)Target State
integration.pyparser.pysession.pymonitor.pyfacade.pysdk_integration.py