A Go implementation of Claude Code - an AI-powered CLI tool that brings the power of Claude to your terminal.
- 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
git clone https://github.com/houruizhe/go-claude-code.git
cd go-claude-code
make buildThe binary will be created at bin/claude.
make installCLAUDE_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)
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"
}
}
}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
}
}
}# 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/claudeexit,quit- Exit the programclear- Clear conversation historyhelp- Show help messagetools- List available tools
Execute shell commands:
claude> Run ls -la
Read file contents:
claude> Read the file at /path/to/file.txt
Write content to a file:
claude> Create a new file at /path/to/file.txt with content "Hello, World!"
Edit an existing file:
claude> Replace "old text" with "new text" in /path/to/file.txt
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
make buildmake runmake testmake fmtMIT License
Contributions are welcome! Please feel free to submit a Pull Request.
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.
Anthropic provider:
claude-sonnet-4-20250514(default)claude-opus-4-20250514claude-haiku-4-20250514
Volcengine provider:
ep-20241125174025-l8jx8(default)- Other custom inference endpoints
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