HeyCode is an interactive, AI-powered coding assistant designed to help developers build and edit codebases directly from their command line. Running entirely within your terminal, HeyCode pairs a premium Terminal User Interface (TUI) with a robust backend agent that can analyze context (PLAN mode) and apply file edits or execute terminal command workflows (BUILD mode) using Google Gemini models.
Note
Local-First Architecture: HeyCode is self-contained. No cloud database server, no cloud authentication, and no external services (except your API keys) are required. Everything runs locally on your machine.
HeyCode is organized as a monorepo containing the following packages:
packages/cli: The interactive Terminal User Interface (TUI) powered by React and@opentui/core/@opentui/react. It features streaming AI responses, past session browsing, configurable color themes, and quick-access command menus. On startup, it automatically boots an embedded Hono server on a random free port β no separate server process is needed.packages/server: A Bun-powered Hono web server that processes and routes chat streams, integrates the Vercel AI SDK, executes local file tools, and stores sessions using Drizzle ORM.packages/database: Drizzle ORM schema and migrations targeting a local SQLite database stored at~/.heycode/heycode.db. No external database is required.packages/shared: Shared configurations, TypeScript interfaces, Zod validation schemas, and tool definitions used across the CLI and server.
- Zero-Config Install: A single
npm install -g heycode-cliis all you need. No database server, no cloud account setup. Just add the API keys and use it. - Local-First Storage: All session history is stored in a local SQLite file at
~/.heycode/heycode.db, giving you complete ownership and privacy. - Multi-Instance Support: Run multiple
heycodeinstances simultaneously in different terminals. Each boots on a distinct random port and safely shares the same local SQLite database via WAL mode. - Interactive Terminal UI (TUI): A rich, responsive UI built with React inside the terminal, enabling side-by-side chat streaming, session loading, status spinners, and command menus.
- Dual Agent Modes:
PLANMode: A safe, read-only analysis mode allowing the AI to query repository information usingreadFile,listDirectory,glob,grep, andwebSearch.BUILDMode: An action-oriented execution mode where the AI can create and edit files (writeFile,editFile), run terminal tasks (bash), and perform web searches.
- Git-Backed Version Control (Fork, Revert, & Undo): Every message automatically creates a shadow Git checkpoint in your workspace. Easily revert files back to any previous prompt state, fork a new session branch, or type
/undoto discard the last turn and revert your changes. - Inline Diff Previews: Automatic, inline visual unified diff previews for all file creations (
writeFile) and edits (editFile) rendered directly in the chat flow, color-coded for optimal readability. - Web Search Integration: Powered by the official Exa SDK, allowing the agent to fetch highly relevant programming solutions, library APIs, and latest documentation snippets from the internet.
- AGENTS.md Custom Instructions: Place an
AGENTS.mdfile in your workspace root to inject project-specific rules, style guides, or build commands directly into the AI's system prompt context. - Multi-Provider AI Support: Works with Google Gemini models (e.g.
gemini-2.5-flash,gemini-3.5-flash,gemini-2.5-flash-lite), Groq high-speed models (e.g.openai/gpt-oss-120b,qwen/qwen3-32b), OpenAI models (e.g.gpt-5.5,gpt-5.4), and Anthropic models (e.g.claude-sonnet-4-6,claude-opus-4-8).
- Bun β required as the runtime
- A Google Gemini, Groq, OpenAI, or Anthropic API Key
- (Optional) An Exa API Key for web search capabilities
npm install -g heycode-cliHeyCode reads its configuration from ~/.heycode/config.json. The ~/.heycode directory is created automatically on first launch. Just create the config.json file inside it:
{
"GOOGLE_GENERATIVE_AI_API_KEY": "AIzaSy...",
"GROQ_API_KEY": "...",
"OPENAI_API_KEY": "...",
"ANTHROPIC_API_KEY": "...",
"EXA_API_KEY": "..."
}Note
You only need to provide the API keys for the model providers you intend to use (e.g. only GOOGLE_GENERATIVE_AI_API_KEY if using Gemini models). EXA_API_KEY is optional and only needed if you want web search capabilities.
heycodeThat's it! On the first launch, HeyCode will automatically:
- Create the
~/.heycode/data directory. - Initialize and migrate the local SQLite database.
- Start an embedded server on a random free port.
- Open the TUI in your terminal.
- Bun (version 1.0 or higher)
- Google Gemini API Key
-
Clone the repository:
git clone https://github.com/Rupak182/hey-code.git cd hey-code -
Install dependencies:
bun install
-
Configure API keys globally: Create
~/.heycode/config.json(the directory is auto-created on first launch):{ "GOOGLE_GENERATIVE_AI_API_KEY": "AIzaSy...", "GROQ_API_KEY": "...", "OPENAI_API_KEY": "...", "ANTHROPIC_API_KEY": "...", "EXA_API_KEY": "..." }Alternatively, create a local
.envfile in the project root with the same keys. Only the keys for the providers you wish to use are required. -
Run in development mode:
bun run dev:cli
The CLI will boot the embedded server automatically. No separate server terminal is needed.
By default, the agent operates in the directory from which the CLI is launched. To target a different codebase:
- Via
~/.heycode/config.json:{ "HEYCODE_CWD": "/path/to/your/target-project" } - Via
.envfile:HEYCODE_CWD=/path/to/your/target-project
- By running from the target directory:
cd /path/to/your/target-project heycode
You can steer the agent's behavior by placing an AGENTS.md file in the root of your target project.
When AGENTS.md is present in the CWD:
- Its contents are automatically loaded as custom project instructions and appended to the system prompt.
- An
AGENTS.md Specificationblock is included to instruct the agent on scope, precedence, and rule hierarchy. - If no
AGENTS.mdfile is found, it is completely skipped to save prompt tokens.
Note
Git Checkpoint Isolation: Each workspace directory gets its own hidden shadow Git repository located at ${HEYCODE_CWD}/.heycode/git. Git checkpoints and branches are completely isolated to each individual directory. If you change your workspace directory, the session history in the database persists, but you can only perform revert/fork operations on sessions that match your currently active directory.
HeyCode supports Model Context Protocol (MCP), enabling you to dynamically connect external tools (like filesystem servers, database interfaces, or APIs) directly to the AI agent.
HeyCode automatically loads MCP server configurations from:
- Workspace-specific config:
heycode.jsonin your workspace root. - Global user-config:
~/.heycode/mcp.json.
Below is an example config (heycode.json) to register a filesystem tool server:
{
"mcp": {
"filesystem": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/your/workspace"
],
"enabled": true
}
}
}stdio: Spawns a local executable. Requires"command"(e.g.npx,python3,node) and optional"args"and"env"variables.sse: Connects to a remote server. Requires"url"(e.g.http://localhost:5000/sse).
- Automatic Namespace: Dynamic tools are registered with a namespace prefix based on the server name:
serverName__toolName(e.g.,filesystem__read_file). - Dynamic Prompt Injection: Descriptions and schemas of active tools are automatically appended to the LLM's system instructions.
To visually browse your local SQLite database using Drizzle Studio:
bun db:studiocd packages/cli
bun run build # Compiles CLI and bundles SQL migrations into dist/
npm publishInside the HeyCode TUI, type / to open the command menu. Supported commands include:
| Command | Description |
|---|---|
/new |
Start a new AI coding session |
/agents |
Switch agent mode (PLAN / BUILD) |
/models |
Select between supported AI models (Gemini / Groq) |
/sessions |
Browse and restore past conversation sessions |
/mcps |
View and monitor active Model Context Protocol (MCP) server statuses |
/theme |
Change the TUI color theme |
/undo |
Discard the last user message and revert code changes |
/exit |
Quit the TUI application |
This implementation is based on learning from NightCode.