A CLI-based AI coding agent written in Go, powered by LLMs via a streaming REPL interface.
- Interactive REPL — Built on
linerlibrary with full line editing, history navigation (up/down arrows), ANSI-styled colored output; Ctrl+C interrupts current LLM call and rolls back conversation state - LLM Streaming — Wraps OpenAI-compatible API via
openai-goSDK with streaming text completions and function calling (tool use) - Plan Mode — Automatically detects complex tasks (refactor, migrate, multi-file implementation, etc.), decomposes them into multi-step plans executed sequentially; plans persisted as JSON to
~/.claudego/plans/, resumable by plan ID - Built-in Tools — Plugin-style
ToolRegistryarchitecture withbashtool (dangerous command detection: blocksrm -rf /, fork bombs, remote script injection, etc.) andfile_handlertool (read/write/edit files); extensible with custom tools - Graph Workflow Runtime — New
pkg/graphpackage provides a LangGraph-style workflow layer with shared state, deterministic edges, conditional routing, loop protection, execution trace, and LLM-backed nodes - Conversation State Management — Checkpoint-based rollback mechanism preserves conversation history integrity across interrupts
- Rotating Logs — Structured logging via
logruswith daily file rotation, 7-day retention
cmd/claudego/main.go — REPL entry point, signal handling, command routing
internal/loop/agent.go — Agent loop: streams LLM responses, executes tools
internal/plan/ — Plan mode (create, execute, persist)
├── plan.go — Plan data structure
├── planner.go — Plan creator
└── executor.go — Plan executor
internal/tools/ — Tool registry + built-in tools
├── registry.go — Tool registry
├── base_tool.go — Tool base interface
├── bash.go — bash tool (dangerous command detection)
├── file.go — file_handler tool
└── task.go — Task tool
internal/config/ — JSON config loader
pkg/llm/ — LLM client wrapping openai-go SDK
pkg/conversation/ — Conversation state with checkpoint/rollback
pkg/ui/ — CLI styling, markdown rendering, streaming output
pkg/logger/ — Singleton logger (logrus)
pkg/graph/ — Graph workflow runtime for supervisor/expert agent orchestration
pkg/skill/ — Skill extension system
├── skill_registry.go — Skill registry
├── loader.go — Markdown loader (folder-based structure supported)
├── executor.go — Skill executor (LLM integration)
└── handler.go — Skill matching and execution entry point
pkg/types/ — Shared type definitions
pkg/interfaces/ — Core interface definitions (ToolInterface, LLMInterface)
git clone https://github.com/yizhigopher/learn-claude-with-go.git
cd learn-claude-with-go
go build -o claudego ./cmd/claudegoCreate ~/.claudego/config.json:
{
"api_key": "your-api-key",
"base_url": "https://api.deepseek.com/v1",
"model": "deepseek-chat",
"permissions": {
"allow": ["file_handler(read:*)"],
"ask": ["bash(*)", "file_handler(write:*)"],
"deny": ["bash(sudo *)", "file_handler(*:.env*)"]
},
"hooks": {
"PreToolUse": [
{
"matcher": "bash",
"hooks": [
{"type": "command", "command": "$HOME/.claudego/hooks/pre-bash.sh"}
]
}
]
}
}api_key— Your LLM provider API keybase_url— OpenAI-compatible API endpointmodel— Model name (e.g.deepseek-chat,gpt-4o)
ClaudeGo checks every tool call before execution. Permission rules support allow, ask, and deny; deny wins over all other rules.
Built-in defaults allow file reads, ask before file writes and bash commands, allow load_skill and todo_manager, and ask for unknown tools. Choosing "always allow this session" only affects the current process and does not modify the config file.
ClaudeGo supports command hooks for SessionStart, PreToolUse, and PostToolUse. Hooks receive event JSON on stdin. PreToolUse can block a tool by exiting with code 2 or by printing JSON with hookSpecificOutput.permissionDecision set to deny.
./claudego| Command | Description |
|---|---|
q / exit |
Quit the session |
/plan <goal> |
Force plan mode for a specific goal |
/skill <name> [args] |
Execute a skill extension |
ClaudeGo automatically detects complex tasks (refactor, migrate, implement, build, etc.) and switches to plan mode.
When plan mode activates:
- The agent analyzes your goal and creates a step-by-step plan
- Steps are displayed and saved to
~/.claudego/plans/ - Each step executes in sequence with LLM + tool access
- Press
Ctrl+Cto interrupt — conversation rolls back to the last checkpoint - Resume a paused plan with the saved plan ID
ClaudeGo supports custom skills defined via Markdown files stored in ~/.claudego/skills/.
Skill file format:
---
name: skill-name
description: Description of what this skill does
---
# Skill Name
[LLM prompt content]Loaded skills can be invoked via /skill skill-name or triggered via auto-completion in conversation.
bash — Execute shell commands
- Dangerous commands are blocked:
rm -rf /,sudo,shutdown, fork bombs, piping remote scripts, etc.
file_handler — Read, write, and edit files
Press Ctrl+C during any LLM call to interrupt. The conversation state is rolled back to the checkpoint before the current query, preserving the integrity of your conversation history.
pkg/graph is a lightweight orchestration layer for building domain-specific multi-step agents on top of the existing LLMClient and ToolRegistry interfaces.
Core concepts:
graph.Stateis the shared memory passed across all nodesgraph.AddEdgemodels deterministic transitionsgraph.AddConditionalEdgesenables supervisor-style routinggraph.Command{Goto: ...}lets a node hand off dynamicallygraph.NewLLMNode(...)wraps the existing LLM client into a reusable node
Minimal example:
g := graph.New(graph.WithMaxSteps(16))
_ = g.AddNode("supervisor", func(ctx context.Context, state *graph.State) (*graph.Command, error) {
domain, _ := graph.Value[string](state, "domain")
return &graph.Command{Goto: domain}, nil
})
_ = g.AddNode("legal", func(ctx context.Context, state *graph.State) (*graph.Command, error) {
state.Set("answer", "legal specialist handled the request")
return nil, nil
})
_ = g.AddNode("medical", func(ctx context.Context, state *graph.State) (*graph.Command, error) {
state.Set("answer", "medical specialist handled the request")
return nil, nil
})
_ = g.SetEntryPoint("supervisor")
_ = g.AddEdge("legal", graph.End)
_ = g.AddEdge("medical", graph.End)
result, err := g.Run(ctx, map[string]any{"domain": "legal"})You can also build a node from the existing LLM abstraction:
node, _ := graph.NewLLMNode(graph.LLMNodeConfig{
Client: llmClient,
Registry: toolRegistry,
SystemPrompt: "You are a legal compliance specialist.",
BuildUserPrompt: func(state *graph.State) string {
task, _ := graph.Value[string](state, "task")
return task
},
ResponseKey: "specialist_output",
})- openai-go — LLM API client
- liner — Line editing for REPL
- logrus — Logging
- go-playground/validator — Input validation
claudego/
├── cmd/claudego/main.go # Application entry point
├── internal/
│ ├── loop/agent.go # Agent loop
│ ├── plan/ # Plan mode (create, execute, persist)
│ ├── tools/ # Tool registry + built-in tools
│ └── config/ # Configuration loader
├── pkg/
│ ├── llm/ # LLM client
│ ├── graph/ # Graph workflow runtime
│ ├── conversation/ # Conversation state
│ ├── ui/ # CLI output styling
│ ├── logger/ # Logging
│ ├── skill/ # Skill extension system
│ ├── types/ # Shared types
│ └── interfaces/ # Core interface definitions
└── utils/ # Utilities
MIT


