Claude Code API is a Rust-based API gateway for Claude Code CLI. It enables operations teams to automate code generation, analysis, and optimization tasks. Integrates with existing workflows to streamline development processes and improve efficiency.
git clone https://github.com/ZhangHanDong/claude-code-api-rs.gitClaude Code API is a Rust-based gateway that exposes Claude Code CLI functionality through an OpenAI-compatible REST API. Built on the cc-sdk, it provides connection pooling, conversation management, multimodal support, and streaming responses. Operations teams use it to automate code generation, analysis, and optimization within existing workflows. The API supports multiple Claude models (Opus, Sonnet, Haiku) and integrates with standard OpenAI client libraries, making it easy to add Claude capabilities to development pipelines without rewriting client code.
1. **Install the API**: Run `cargo install claude-code-api-rs` and verify with `claude-code-api --version`. Ensure you have Rust 1.60+ installed. 2. **Configure Access**: Set up your API key in `~/.claude-code-api/config.toml` with permissions for your target repository. Example: ```toml [auth] api_key = "your-api-key-here" [defaults] project_root = "/path/to/your/project" ``` 3. **Execute Commands**: Use the API to run commands via the CLI or programmatically. For CLI usage: ```bash claude-code-api exec --command "cargo clippy --all-targets --all-features" ``` 4. **Process Output**: Pipe results to analysis tools or scripts. For example, to generate a flamegraph: ```bash claude-code-api flamegraph --output perf.svg --command "cargo bench" ``` 5. **Integrate with CI/CD**: Add the API to your pipeline. Example GitHub Actions step: ```yaml - name: Run Performance Analysis run: | claude-code-api exec --command "cargo test --release" claude-code-api analyze --metrics --output report.json ``` **Tips**: - Use `--timeout` flag for long-running commands to prevent hangs - Store frequently used commands in a `commands.json` file for reuse - Combine with `jq` for JSON output processing: `claude-code-api exec --json | jq '.metrics'`
Automate code generation workflows using Claude models via familiar OpenAI API
Build multi-turn conversation systems with session persistence
Process images alongside text for code review and documentation analysis
Integrate Claude into existing development tools that support OpenAI API
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/ZhangHanDong/claude-code-api-rsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Use the Claude Code API (claude-code-api-rs) to [TASK]. Execute the following commands: [COMMANDS]. Analyze the output and provide [OUTPUT_REQUIREMENTS]. Example: 'Use the Claude Code API to analyze the performance bottlenecks in the /src/api directory of the Rust project at /home/user/projects/my-api. Execute `cargo clippy`, `cargo test --release`, and `cargo flamegraph`. Analyze the results and provide a prioritized list of optimizations with estimated impact.'
## Performance Optimization Report for my-api Project ### Analysis Results 1. **Cargo Clippy Output**: Identified 12 warnings, primarily in the `/src/handlers/auth.rs` file where `unwrap()` calls were used in production code. These could lead to runtime panics under edge-case scenarios. 2. **Test Suite Performance**: - Total test time: 4.2s (target: <3s) - `test_auth_flow` took 1.8s (43% of total time) due to synchronous database calls - Parallel test execution reduced time by 22% but still exceeds target 3. **Flamegraph Analysis**: - Top hotspot: `serde_json::from_str` in `/src/models/user.rs` (28% CPU usage) - Secondary hotspot: `tokio::spawn` in `/src/workers/queue.rs` (15% CPU usage) ### Recommended Actions 1. **Critical**: Replace all `unwrap()` calls in auth handlers with proper error propagation. Expected impact: Eliminates potential crashes in production. 2. **High Priority**: Implement async database operations in `test_auth_flow`. Expected impact: Reduces test time by ~1.2s. 3. **Medium Priority**: Optimize `serde_json` parsing by using `simd-json` crate. Expected impact: 15-20% reduction in JSON parsing time. ### Implementation Plan ```rust // Before let user: User = serde_json::from_str(&response)?; // After let user: User = simd_json::from_str(&mut response.as_bytes_mut())?; ``` ### Estimated Effort - Critical fixes: 2 hours - High priority: 4 hours - Medium priority: 6 hours ### Success Metrics - Clippy warnings reduced to 0 - Test suite time <3s - Flamegraph shows no single hotspot >10% CPU usage
Pioneering accessible, high-performance AI models
AI assistant built for thoughtful, nuanced conversation
Get more done every day with Microsoft Teams – powered by AI
Automate your spreadsheet tasks with AI power
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan