"FastCode: Accelerating and Streamlining Your Code Understanding"
| โก High Performance | ๐ฐ Cost Efficient | ๐ Fast & Scalable |
Features โข Quick Start โข Installation โข MCP Server โข Documentation
FastCode is a token-efficient framework for comprehensive code understanding and analysis: delivering superior speed, exceptional accuracy, and cost-effectiveness for large-scale codebases and software architectures.
๐ Superior Speed Advantage - Runs 3x faster than Cursor and 4x faster than Claude Code.
๐ฐ Significant Cost Savings - Costs 55% less than Cursor and 44% less than Claude Code.
โก Highest Accuracy - Outperforms Cursor and Claude Code with the highest accuracy score.
undefinedClick to watch FastCode in action - See how FastCode analyzes complex codebases with lightning speed.
FastCode introduces a three-phase framework that transforms how LLMs understand and navigate codebases:
undefined๐ Hierarchical Code Units โ Advanced multi-level indexing spanning files, classes, functions, and documentation using AST-based parsing across 8+ programming languages
undefined๐ Hybrid Index โ Seamlessly combines semantic embeddings with keyword search (BM25) for robust and precise code retrieval
undefined๐ Multi-Layer Graph Modeling โ Three interconnected relationship graphs (Call Graph, Dependency Graph, Inheritance Graph) enabling structural navigation across the entire codebase
Finding the right code without opening every file - at lightning speed
undefinedโก Two-Stage Smart Search โ Like having a research assistant that first finds potentially relevant code, then ranks and organizes the best matches for your specific question.
undefined๐ Safe File Browsing โ Explores your project structure securely, understanding folder organization and file patterns without compromising security.
undefined๐ Following Code Connections โ Traces how code pieces connect (up to 2 steps away), like following a trail of breadcrumbs through your codebase.
undefined๐ฏ Code Skimming โ Instead of reading entire files, FastCode just looks at the โheadlinesโ - function names, class definitions, and type hints. This is like reading a bookโs chapter titles instead of every page, saving massive amounts of processing power.
Getting maximum insight while minimizing costs - automatically
undefined๐ Budget-Aware Decision Making โ Considers five key factors before processing: confidence level, query complexity, codebase size, resource cost, and iteration count. Like a cost-conscious financial advisor that weighs all options before making decisions.
undefined๐ Resource-Optimized Learning โ Continuously adapts its approach in real-time, getting more efficient about what information to gather and when to stop. Think of it as an AI that maximizes value and becomes more cost-effective with every query.
undefined๐ฏ Value-First Selection โ Prioritizes high-impact, low-cost information first, like choosing the ripest fruit at the best price. This cost-optimized approach ensures you get maximum value for every token spent until the perfect stopping point is reached.
FastCode has been rigorously tested on four major benchmarks representing real-world software engineering challenges:
| Benchmark | Focus Area | What It Tests |
|---|---|---|
| SWE-QA | Software Engineering Q&A | Complex technical question answering |
| LongCodeQA | Extended Code Analysis | Long-context code understanding |
| LOC-BENCH | Code Localization | Bug detection & feature requests |
| GitTaskBench | Real-World Tasks | Production repository workflows |
โ Superior Accuracy โ Consistently outperforms state-of-the-art baselines across all benchmarks
โ 10x Token Efficiency โ Achieves better results while using up to 90% fewer tokens
โ Real-World Validation โ Proven performance on actual production codebases and workflows
Get FastCode running in under 2 minutes:
# 1. Clone the repository
git clone https://github.com/HKUDS/FastCode.git
cd FastCode
# 2. Install dependencies
pip install -r requirements.txt
# 3. Configure your API keys
cp env.example .env
# Edit .env with your API keys
# 4. Launch the Web UI
python web_app.py --host 0.0.0.0 --port 5000
Open http://localhost:5000 and start asking questions about your code! ๐
FastCode supports Linux, macOS, and Windows. Choose your platform below:
undefined๐ก Recommendation: We recommend using uv for faster and more reliable dependency installation.
undefinedClone FastCodeundefined
git clone https://github.com/HKUDS/FastCode.git
cd FastCode
undefinedInstall Dependenciesundefined
undefinedOption A: Using uv (Recommended)undefined
# Install uv
pip install uv
# create new env with uv
uv venv --python=3.12
source .venv/bin/activate
# Install dependencies with uv
uv pip install -r requirements.txt
undefinedOption B: Using pipundefined
pip install -r requirements.txt
undefinedConfigure Environmentundefined
cp env.example .env
nano .env # or use your preferred editor
Add your API keys:
OPENAI_API_KEY=your_openai_api_key_here
MODEL=gpt-5.2
BASE_URL=https://api.openai.com/v1
undefinedLaunch FastCodeundefined
# Web UI (Recommended)
python web_app.py --host 0.0.0.0 --port 5000
# Or use the CLI
python main.py query --repo-path /path/to/your/repo --query "Your question here"
undefinedClone FastCodeundefined
git clone https://github.com/HKUDS/FastCode.git
cd FastCode
undefinedInstall Dependenciesundefined
undefinedOption A: Using uv (Recommended)undefined
# Install uv
pip install uv
# create new env with uv
uv venv --python=3.12
source .venv/bin/activate
# Install dependencies with uv
uv pip install -r requirements.txt
undefinedOption B: Using pipundefined
pip install -r requirements.txt
undefinedConfigure Environmentundefined
cp env.example .env
nano .env # or use: open -e .env
Add your API keys:
OPENAI_API_KEY=your_openai_api_key_here
MODEL=gemini-3-flash
BASE_URL=https://...
undefinedLaunch FastCodeundefined
# Web UI (Recommended)
python web_app.py --host 0.0.0.0 --port 5000
# Or use the CLI
python main.py query --repo-path /path/to/your/repo --query "Your question here"
undefinedNote for Apple Silicon (M1/M2/M3): All dependencies are compatible with ARM architecture.
undefinedClone FastCodeundefined
git clone https://github.com/HKUDS/FastCode.git
cd FastCode
undefinedInstall Dependenciesundefined
undefinedOption A: Using uv (Recommended)undefined
# Install uv
pip install uv
# create new env with uv
uv venv --python=3.12
.venv\Scripts\activate
# Install dependencies with uv
uv pip install -r requirements.txt
undefinedOption B: Using pipundefined
pip install -r requirements.txt
undefinedConfigure Environmentundefined
copy env.example .env
notepad .env
Add your API keys:
OPENAI_API_KEY=your_openai_api_key_here
MODEL=qwen/qwen3-coder-30b-a3b-instruct
BASE_URL=https://api.openai.com/v1
undefinedLaunch FastCodeundefined
# Web UI (Recommended)
python web_app.py --host 0.0.0.0 --port 5000
# Or use the CLI
python main.py query --repo-path C:\path\to\your\repo --query "Your question here"
undefinedTroubleshooting:undefined
pip install --upgrade certififaiss-cpu fails to install: pip install faiss-cpu --no-cache-dir./run_nanobot.sh (bash script) on Windows, use Git Bash or WSL, and keep .sh files in LF line endings. This repo enforces LF for *.sh via .gitattributes, but older clones may need a one-time re-checkout.The Web UI provides the most intuitive experience:
undefinedLaunch the server:undefined
python web_app.py --host 0.0.0.0 --port 5000
undefinedOpen your browser: Navigate to http://localhost:5000
undefinedLoad a repository: Use the sidebar to index your codebase
undefinedStart asking questions:undefined
For automation and scripting:
# Single repository query
python main.py query --repo-path /path/to/repo --query "Your question"
# Multi-repository query
python main.py query --repos /path/to/repo1 /path/to/repo2 --query "Your question"
# With custom model
python main.py query --repo-path /path/to/repo --query "Your question" --model gpt-4-turbo
Integrate FastCode into your tools with the comprehensive REST API:
# Start the API server
python api.py --host 0.0.0.0 --port 8000
The API provides all features available in the Web UI. Visit http://localhost:8000/docs for interactive API documentation.
undefinedKey API Endpoints:undefined
# List available and loaded repositories
GET /repositories
# Load a repository from URL or local path
POST /load
{
"source": "https://github.com/user/repo",
"is_url": true
}
# Index the loaded repository
POST /index?force=false
# Load and index in one call
POST /load-and-index
{
"source": "/path/to/repo",
"is_url": false
}
# Load multiple existing indexed repositories
POST /load-repositories
{
"repo_names": ["repo1", "repo2"]
}
# Index multiple repositories at once
POST /index-multiple
{
"sources": [
{"source": "https://github.com/user/repo1", "is_url": true},
{"source": "/path/to/repo2", "is_url": false}
]
}
# Upload repository as ZIP file
POST /upload-zip
Content-Type: multipart/form-data
file: <zip_file>
# Upload and index in one call
POST /upload-and-index?force=false
Content-Type: multipart/form-data
file: <zip_file>
# Delete repositories and their indexes
POST /delete-repos
{
"repo_names": ["repo1", "repo2"],
"delete_source": true
}
# Get repository summary
GET /summary
# Query repository (single response)
POST /query
{
"question": "How does authentication work?",
"filters": null,
"repo_filter": ["repo1"],
"multi_turn": false,
"session_id": null
}
# Query with streaming response (SSE)
POST /query-stream
{
"question": "Explain the database schema",
"multi_turn": true,
"session_id": "abc123"
}
# Start a new conversation session
POST /new-session?clear_session_id=old_session
# List all conversation sessions
GET /sessions
# Get conversation history
GET /session/{session_id}
# Delete a conversation session
DELETE /session/{session_id}
# Health check
GET /health
# Get system status
GET /status?full_scan=false
# Clear cache
POST /clear-cache
# Get cache statistics
GET /cache-stats
# Refresh index cache
POST /refresh-index-cache
# Unload current repository
DELETE /repository
undefinedExample Usage:undefined
import requests
# Start a session and query
response = requests.post("http://localhost:8000/load-and-index", json={
"source": "https://github.com/user/repo",
"is_url": True
})
# Query the repository
response = requests.post("http://localhost:8000/query", json={
"question": "Where is the main entry point?",
"multi_turn": False
})
result = response.json()
print(result["answer"])
print(f"Tokens used: {result['total_tokens']}")
FastCode can run as an MCP (Model Context Protocol) server, allowing AI coding assistants like Cursor, Claude Code, and Windsurf to use FastCodeโs repo-level code understanding capabilities directly.
Add the following to your MCP configuration:
Before configuring MCP, make sure FastCode dependencies are installed in the local uv virtual environment:
git clone https://github.com/HKUDS/FastCode.git
cd FastCode
uv venv --python=3.12
source .venv/bin/activate
uv pip install -r requirements.txt
The MCP server should be launched with .venv/bin/python, and it needs OPENAI_API_KEY, MODEL, and BASE_URL.
undefinedCursor (~/.cursor/mcp.json):
{
"mcpServers": {
"fastcode": {
"command": "/path/to/FastCode/.venv/bin/python",
"args": ["/path/to/FastCode/mcp_server.py"],
"env": {
"MODEL": "gpt-5.2",
"BASE_URL": "https://api.openai.com/v1",
"OPENAI_API_KEY": "sk-..."
}
}
}
}
undefinedClaude Code (claude_desktop_config.json):
{
"mcpServers": {
"fastcode": {
"command": "/path/to/FastCode/.venv/bin/python",
"args": ["/path/to/FastCode/mcp_server.py"],
"env": {
"MODEL": "gpt-5.2",
"BASE_URL": "https://api.openai.com/v1",
"OPENAI_API_KEY": "sk-..."
}
}
}
}
Or via claude mcp add (ensure the same env vars are available in your shell):
claude mcp add fastcode -- /path/to/FastCode/.venv/bin/python /path/to/FastCode/mcp_server.py
undefinedSSE transport (for remote / shared deployments):
OPENAI_API_KEY=sk-... MODEL=gpt-5.2 BASE_URL=https://api.openai.com/v1 \
/path/to/FastCode/.venv/bin/python /path/to/FastCode/mcp_server.py --transport sse --port 8080
| Tool | Description |
|---|---|
code_qa |
Core tool โ ask questions about one or more code repositories. Automatically clones (if URL) and indexes repos that havenโt been indexed yet. Supports multi-turn conversations. |
list_indexed_repos |
List all repositories that have been indexed and are available for querying. |
list_sessions |
List all existing conversation sessions with titles and turn counts. |
get_session_history |
Retrieve the full Q&A history of a specific session. |
delete_session |
Delete a conversation session and all its history. |
delete_repo_metadata |
Delete indexed metadata for a repository (.faiss, _metadata.pkl, _bm25.pkl, _graphs.pkl) and remove its entry from repo_overviews.pkl, while keeping the repository source code. |
code_qa Parameters| Parameter | Required | Default | Description |
|---|---|---|---|
question |
Yes | โ | The question to ask about the code |
repos |
Yes | โ | List of repo sources (GitHub URLs or local paths). Multiple repos supported. |
multi_turn |
No | true |
Enable multi-turn conversation mode |
session_id |
No | auto-generated | Session ID for continuing a conversation. Returned in the response of each call. |
repos, FastCode checks if itโs already indexed. If yes, it skips indexing entirely../repos/ and indexes it.multi_turn is enabled (default), previous Q&A context from the same session_id is used for query rewriting and answer generation. The session_id is returned in each response โ pass it back in subsequent calls to continue the conversation.repos and FastCode will search across all of them, using LLM-based repository selection to find the most relevant code.In Cursor or Claude Code, simply ask:
Use FastCode to analyze what this repository at /path/to/repo_name is for.
or
Use FastCode to analyze the authentication flow in https://github.com/user/my-project
The AI assistant will call code_qa with the URL, FastCode will clone and index the repo (if needed), and return a detailed answer with source references.
For follow-up questions, the assistant reuses the same session_id automatically:
Which files would be affected if I change the User model?
FastCode works with multiple LLM providers:
OPENAI_API_KEY=sk-...
MODEL=gpt-4
BASE_URL=https://api.openai.com/v1
OPENAI_API_KEY=sk-or-...
MODEL=google/gemini-flash-1.5
BASE_URL=https://openrouter.ai/api/v1
OPENAI_API_KEY=ollama
MODEL=qwen3-coder-30b_fastcode
BASE_URL=http://localhost:11434/v1
FastCode automatically detects and parses:
FastCode can be integrated with a Feishu (Lark) bot via Nanobot, enabling conversational code repository queries directly within Feishu.
Feishu User โโ Feishu Open Platform โโ Nanobot (WebSocket) โโ FastCode API
(port 18791) (port 8001)
# One-command launch (automatically builds images and generates config on first run)
./run_nanobot.sh
# Subsequent runs auto-detect the current state:
# - Services running โ show status + health check
# - Services stopped โ auto-restart
# - Images not found โ auto-build and start
.env)All API keys and model settings are centralized in the .env file, shared by both services:
# ===== Shared API Configuration =====
OPENAI_API_KEY=sk-or-v1-xxx # Shared by both services
BASE_URL=https://openrouter.ai/api/v1
# ===== FastCode Model (Code Analysis) =====
MODEL=google/gemini-3-flash-preview
# ===== Nanobot Model (Agent Reasoning / Feishu Conversations) =====
NANOBOT_MODEL=minimax/minimax-m2.1
The API key is automatically injected into the Nanobot container via docker-compose.yml environment variables โ no need to duplicate it in nanobot_config.json.
config/config.yaml โ FastCode retrieval and indexing settingsnanobot_config.json)run_nanobot.sh auto-generates this file. You only need to configure Feishu credentials and the systemPrompt here; API keys and model settings are managed centrally via .env.
{
"channels": {
"feishu": {
"enabled": true,
"appId": "cli_xxxxxxxxx",
"appSecret": "your_app_secret"
}
}
}
Nanobot receives Feishu messages via a WebSocket long-lived connection โ no public IP or webhook required.
Go to the Feishu Open Platform โ Create a Custom Enterprise App โ Note the App ID (cli_xxx) and App Secret.
Navigate to App Settings โ App Features โ Enable the โBotโ capability.
Add the following permissions under Permission Management:
| Permission | Description |
|---|---|
im:message |
Read messages |
im:message:send_as_bot |
Send messages as the bot |
im:resource |
Access resource files in messages |
im:chat |
Retrieve group chat information |
โ ๏ธ Note the order: You must start Nanobot to establish the WebSocket connection first, then configure event subscriptions in the Feishu admin console.
appId and appSecret in nanobot_config.json, then start the service (./run_nanobot.sh)connected to wss://msg-frontier.feishu.cn, confirming a successful connectionim.message.receive_v1 (Receive messages)Go to Version Management โ Create a version โ Submit for review (internal enterprise apps can be self-approved) โ Once published, you can chat with the bot in Feishu.
services:
fastcode: # FastCode API (port 8001)
build: .
volumes:
- ./.env:/app/.env:ro
- ./config:/app/config:ro
- ./data:/app/data
- ./repos:/app/repos
nanobot: # Nanobot Gateway (port 18791 โ 18790)
build: ./nanobot
command: ["gateway"]
volumes:
- ./nanobot_config.json:/root/.nanobot/config.json:ro
environment:
- FASTCODE_API_URL=http://fastcode:8001
# API key and model injected from .env
- NANOBOT_PROVIDERS__OPENROUTER__API_KEY=${OPENAI_API_KEY}
- NANOBOT_AGENTS__DEFAULTS__MODEL=${NANOBOT_MODEL}
depends_on:
- fastcode
| Command | Description |
|---|---|
./run_nanobot.sh |
Smart launch (auto-detects state) |
./run_nanobot.sh --build |
Force rebuild images |
./run_nanobot.sh --fg |
Run in foreground (view live logs) |
./run_nanobot.sh stop |
Stop all services |
./run_nanobot.sh restart |
Restart all services |
./run_nanobot.sh logs |
View live logs |
./run_nanobot.sh status |
View service status + health check |
./run_nanobot.sh config |
Re-check / regenerate Nanobot config |
./run_nanobot.sh clean |
Stop and remove containers and images |
On startup, Nanobot automatically registers the following tools via the FASTCODE_API_URL environment variable:
| Tool Name | Function |
|---|---|
fastcode_load_repo |
Load and index a code repository (GitHub URL or local path) |
fastcode_query |
Query code using natural language, with multi-turn conversation support |
fastcode_list_repos |
List loaded / available repositories |
fastcode_status |
View FastCode system status |
fastcode_session |
Manage conversation sessions (create / list / history / delete) |
Chat with the bot in Feishu:
User: https://github.com/user/repo
Bot: โ Repository loaded and indexed (152 files, 3847 code elements)
User: How is the authentication logic implemented in this project?
Bot: This project uses JWT for authentication... [detailed analysis]
User: Which files would be affected by changes to the User model?
Bot: The following 8 files would be affected... [impact analysis]
FastCode uses a novel scouting-first approach that fundamentally differs from traditional code reasoning systems:
Question โ Load Files โ Search โ Load More Files โ Search Again โ ... โ Answer
๐ธ High token cost from repeated file loading
Question โ Build Semantic Map โ Navigate Structure โ Load Targets โ Answer
๐ฐ Minimal token cost with precise targeting
undefinedQuery: โHow does user authentication work in this application?โ
undefinedFastCode Process:undefined
auth.py, middleware.py, user_model.pyundefinedQuery: โWhat would break if I change the User model schema?โ
undefinedFastCode Process:undefined
We welcome contributions! FastCode is built for the community, by the community.
FastCode is released under the MIT License. See LICENSE for details.
If FastCode saves you tokens and time, consider giving us a star! โญ
undefinedBuilt with โค๏ธ for developers who value efficiencyundefined
Thanks for visiting โจ FastCode!