Go Claude Code
claude code, written in Go
Ask AI about Go Claude Code
Powered by Claude Β· Grounded in docs
I know everything about Go Claude Code. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Go Claude Code
A Go implementation of Claude Code - an AI-powered CLI tool that brings the power of Claude to your terminal.
Features
- Interactive Chat: Chat with Claude in an interactive REPL
- File Operations: Read, write, and edit files
- Terminal Commands: Execute shell commands directly
- Tool System: Extensible tool architecture
- MCP Support: Connect to Model Context Protocol servers
- Conversation History: Persist and manage conversation history
Installation
Build from source
git clone https://github.com/houruizhe/go-claude-code.git
cd go-claude-code
make build
The binary will be created at bin/claude.
Install to GOPATH
make install
Configuration
Environment Variables
CLAUDE_PROVIDER: API provider to use -anthropic(default) orvolcengineANTHROPIC_API_KEY: Your Anthropic API key (required when using Anthropic provider)CLAUDE_MODEL: Model to use (default:claude-sonnet-4-20250514for Anthropic)CLAUDE_MAX_TOKENS: Maximum tokens for responses (default: 4096)CLAUDE_TEMPERATURE: Temperature for responses (default: 0.0)CLAUDE_ALLOWED_PATHS: Colon-separated list of allowed file pathsCLAUDE_SHELL_ENABLED: Enable/disable shell tool (default: true)VOLCENGINE_API_KEY: Your Volcengine API key (required when using Volcengine provider)VOLCENGINE_MODEL: Volcengine model to use (default:ep-20241125174025-l8jx8)VOLCENGINE_BASE_URL: Volcengine API base URL (default:https://ark.cn-beijing.volces.com/api/v3)
Configuration File
Create a configuration file at ~/.claude-code/config.json:
Using Anthropic provider (default):
{
"provider": "anthropic",
"anthropic": {
"apiKey": "your-api-key",
"model": "claude-sonnet-4-20250514",
"maxTokens": 4096,
"temperature": 0.0
},
"cli": {
"prompt": "claude> ",
"historyFile": "~/.claude-code/history.json",
"logLevel": "info"
},
"tools": {
"allowedPaths": ["/home/user/projects"],
"shell": {
"enabled": true,
"timeout": "2m"
}
}
}
Using Volcengine provider:
{
"provider": "volcengine",
"volcengine": {
"apiKey": "your-volcengine-api-key",
"model": "ep-20241125174025-l8jx8",
"maxTokens": 4096,
"temperature": 0.0,
"baseUrl": "https://ark.cn-beijing.volces.com/api/v3"
},
"cli": {
"prompt": "claude> ",
"historyFile": "~/.claude-code/history.json",
"logLevel": "info"
},
"tools": {
"allowedPaths": ["/home/user/projects"],
"shell": {
"enabled": true,
"timeout": "2m"
}
}
}
MCP Servers Configuration
Create MCP servers configuration at ~/.claude-code/servers.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed"],
"enabled": true
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"enabled": true
}
}
}
Usage
Basic Chat
# Using Anthropic (default)
export ANTHROPIC_API_KEY=sk-ant-xxx
./bin/claude
# Using Volcengine
export CLAUDE_PROVIDER=volcengine
export VOLCENGINE_API_KEY=your-volcengine-api-key
./bin/claude
Commands
exit,quit- Exit the programclear- Clear conversation historyhelp- Show help messagetools- List available tools
Built-in Tools
Bash Tool
Execute shell commands:
claude> Run ls -la
File Read Tool
Read file contents:
claude> Read the file at /path/to/file.txt
File Write Tool
Write content to a file:
claude> Create a new file at /path/to/file.txt with content "Hello, World!"
File Edit Tool
Edit an existing file:
claude> Replace "old text" with "new text" in /path/to/file.txt
Project Structure
go-claude-code/
βββ cmd/claude/ # CLI entry point
βββ pkg/
β βββ api/ # API clients (Anthropic, Volcengine)
β βββ cli/ # REPL implementation
β βββ tools/ # Tool system
β β βββ builtin/ # Built-in tools
β β βββ mcp/ # MCP client
β βββ config/ # Configuration management
β βββ conversation/ # Conversation history
β βββ utils/ # Utilities
βββ internal/
β βββ protocol/
β βββ mcp/ # MCP protocol definitions
βββ config/ # Example configurations
Development
Build
make build
Run
make run
Test
make test
Format
make fmt
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
FAQ
How to get an API key?
For Anthropic: Visit the Anthropic Console to sign up and get your API key.
For Volcengine: Visit the Volcengine Console to sign up and get your API key.
Which models are supported?
Anthropic provider:
claude-sonnet-4-20250514(default)claude-opus-4-20250514claude-haiku-4-20250514
Volcengine provider:
ep-20241125174025-l8jx8(default)- Other custom inference endpoints
How to switch between providers?
Set the CLAUDE_PROVIDER environment variable or configure it in your config file:
# Using Anthropic (default)
export CLAUDE_PROVIDER=anthropic
# Using Volcengine
export CLAUDE_PROVIDER=volcengine
