A minimal AI coding agent powered by Anthropic's Claude with a modular frontend architecture.
🌐 Landing Page: https://lldong.github.io/tiny-trae
Tiny Trae has been designed with a clean separation between the core agent logic and the frontend interface. This allows for easy extension with different types of user interfaces.
- Agent Core: Handles AI conversation logic and tool execution in a separate goroutine
- Frontend Interface: Defines how different UIs can interact with the agent
- Message System: Structured communication between core and frontend
- TUI Frontend: Terminal user interface implementation using bubbletea
- TUI: Terminal user interface with rich interface using bubbletea
For detailed architecture information, see ARCHITECTURE.md.
This project is a simple AI coding agent implemented in Go. It uses the Anthropic API to interact with a large language model (Claude) to help with software engineering tasks. The agent can execute a predefined set of tools based on the model's response.
- Interactive Chat: Chat with the agent from your terminal.
- Non-interactive mode: Provide input directly from the command line.
- Tool Execution: The agent can execute the following tools:
read_file: Read the contents of a file.list_files: List files and directories.edit_file: Modify files by searching and replacing text.ripgrep: Search for text patterns within files.bash: Execute shell commands.
- Extensible: Easily add new tools to the agent.
- Go 1.x
- An Anthropic API key
- ripgrep: This tool is used by the
ripgrepcommand. You can install it by following the instructions in the ripgrep repository. For example, on macOS you can use Homebrew:brew install ripgrep
-
Clone the repository:
git clone <repository-url> cd tiny-trae
-
Install dependencies:
go mod tidy
-
Set up your Anthropic API key:
export ANTHROPIC_API_KEY="your-api-key"
You can also set
ANTHROPIC_BASE_URLif you are using a proxy. -
Run the agent:
go run main.go
or
go build -o tiny-trae
To run the agent in interactive mode, simply run the executable:
./tiny-traeThe agent will prompt you for input.
To run the agent in non-interactive mode, use the -p flag to provide a prompt:
./tiny-trae -p "your prompt here"The agent will process the prompt and exit.
You can use this agent with OpenRouter by using anthropic-proxy.
-
Start the proxy:
OPENROUTER_API_KEY=your-api-key COMPLETION_MODEL="anthropic/claude-sonnet-4" npx anthropic-proxy -
Run the agent: In a separate terminal, run the following command:
ANTHROPIC_BASE_URL=http://0.0.0.0:3000 ./tiny-trae
The agent starts a conversation with the user. The user's message is sent to the Anthropic API, and the model can either respond with text or a request to use a tool. If it's a tool-use request, the agent executes the tool and sends the result back to the model. This loop continues until the user exits the program.
The agent currently supports the following tools:
read_file: Reads the entire content of a specified file.list_files: Lists all files and directories within a given path.edit_file: Edits a file by replacing a specified string with a new one.ripgrep: Searches for a pattern in files usingrg.bash: Executes a given command in a bash shell.
You can extend the agent by adding new ToolDefinition structs and including them in the tools slice in the main function.