GitHub - hit9/nanocode: A lightweight terminal-based AI coding assistant · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
hit9
nanocode
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
master
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>689 Commits<br>689 Commits
.github/workflows
.github/workflows
snapshots
snapshots
tests
tests
.gitignore
.gitignore
CHANGELOG.md
CHANGELOG.md
LICENSE
LICENSE
MANIFEST.in
MANIFEST.in
Makefile
Makefile
README.md
README.md
README.zh-CN.md
README.zh-CN.md
nanocode.py
nanocode.py
pyproject.toml
pyproject.toml
View all files
Repository files navigation
nanocode
A small terminal coding agent written in Python.
简体中文
nanocode is pre-1.0 software. Commands, configuration, and tool behavior may change before a stable release.
Features
Live turn control : Add follow-up input while the agent is still working, without losing the current tool flow.
File-state brain : Reads and edits build a current, line-numbered view of the files that matter now.
Stale-edit protection : line:hash anchors reject edits when the target code has drifted.
Project-aware navigation : Use the symbol index to jump through outlines, references, and changed files quickly.
Recoverable context : Tool output stays bounded in the prompt, while raw tr.N results remain recallable.
Cache-aware context : Stable sections stay early and noisy working state stays late to improve prompt-cache reuse.
Focused working memory : Note separates goal, plan, and known facts from noisy execution logs.
Terminal-first workflow : Model selection, history search, confirmations, live command output, appended input, and status all stay in one CLI.
Install
uv tool install nanocode-cli
Upgrade:
uv tool upgrade nanocode-cli
For local development:
uv sync --extra dev<br>uv run nanocode
Usage
Start the CLI:
nanocode
Useful arguments:
--config : use a TOML config file.
--init-config: create a default config file.
--yolo: skip confirmations for mutating tools.
-v, --version: show the version.
During a running turn, the +> prompt accepts follow-up input for the next model request.
Commands
/help: show commands and tools.
/status: show runtime status.
/config: show active config.
/api [auto|chat|anthropic]: show or set provider API format.
/debug [on|off]: toggle model I/O debug traces.
/compact: compact context now.
/index [force]: sync or rebuild the code symbol index.
/provider [NAME]: show or set provider.
/model [MODEL]: show or set model.
/reason: choose reasoning effort.
/set KEY VALUE: set provider/runtime values.
/yolo: toggle tool confirmations.
/exit, /quit: exit.
Interactive selectors support j/k, arrows, / search, Enter, and Esc. Input supports history, completion, and Ctrl-R history search.
Tools
File: Read, LineCount, List, Find, Search.
Code index: InspectCode.
Edit: Edit creates or patches file content.
Shell: Bash, Git.
Tool results: Recall.
Working notes: Note.
Read, Search, and InspectCode return line anchors where useful. Edit uses current line:hash anchors to reject stale edits.
Configuration
Run:
nanocode --init-config
Default config location is ~/.nanocode/config.toml.
Main fields:
[provider] active = "name"
[provider.]: url, key, model, api, prompt_cache_key, available_models, reasoning, chat_reasoning, temperature, timeout
[paths] data_dir
[runtime] shell_timeout, max_agent_steps, max_context_tokens, yolo
api = "auto" chooses between Chat Completions and Anthropic Messages using provider/model profiles. prompt_cache_key = "auto" derives a stable key from provider, model, workspace, and tool schema names.
Tested Providers
The following providers have been tested with nanocode:
deepseek : DeepSeek API
opencode : OpenCode API
aliyun : Alibaba Cloud (Tongyi Qianwen) API via Chat Completions
llama.cpp : Local inference via llama.cpp server
Context Design
Each model request is built manually from explicit messages. Stable context comes first, conversation stays as messages, working...