Issue: Refactor Claude Code Provider to Use Direct API Calls Like Gemini CLI #1504
hellosunghyun
started this conversation in
2. Design improvements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Current Problem with Claude Code Implementation
The current Claude Code implementation has several reliability and maintainability issues:
1. Process Management Complexity
The current approach spawns external CLI processes with complex stdin/stdout management, which introduces multiple failure points including process timeouts, buffer overflows, and platform-specific issues.
2. Error-Prone Process Communication
Writing JSON to stdin and parsing stdout streams is fragile and can fail due to race conditions, partial data, or process termination issues.
Proposed Solution: Follow Gemini CLI Pattern
The Gemini CLI implementation demonstrates a much cleaner approach:
1. Direct HTTP API Calls
Instead of spawning processes, Gemini CLI makes direct authenticated HTTP requests to Google's API endpoints, which is more reliable and easier to debug.
2. Robust OAuth Authentication
The OAuth credential management with automatic token refresh is more robust than relying on CLI authentication state.
3. Cleaner Response Processing
Direct API responses are easier to parse and handle than CLI stdout streams.
Benefits of the Proposed Change
Implementation Considerations
While this change would require investigating if Anthropic provides similar OAuth-based API access like Google does for Gemini, the architectural benefits make it worth exploring. The current CLI-based approach introduces unnecessary complexity and potential failure points that could be eliminated with a direct API implementation.
The Gemini CLI implementation shows this pattern works well and provides a good template for how Claude Code could be refactored for better reliability and maintainability.
If necessary, I will contribute.
Beta Was this translation helpful? Give feedback.
All reactions