A small terminal coding agent written in Python
Project description
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
- Snapshot context: Every turn starts from a clean workspace snapshot instead of a bloated chat replay.
- File memory: Recent reads and edits stay available as focused, line-numbered file ranges.
- Anchored edits:
line:hashanchors catch stale edits before they touch the wrong code. - Symbol index: Jump from names to outlines, references, and changed files without searching blindly.
- Tool recall: Big outputs are bounded in the prompt but still recallable later by
tr.N. - Terminal-native UI: Model picking, history search, confirmations, live command output, and status all stay in the terminal.
Install
uv tool install nanocode-cli
For local development:
uv sync --extra dev
uv run nanocode
Usage
Start the CLI:
nanocode
Useful arguments:
--config <path>: use a TOML config file.--init-config: create a default config file.--yolo: skip confirmations for mutating tools.-v,--version: show the version.
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,Search. - Code index:
InspectCode. - Edit:
CreateFile,Edit. - Shell:
Bash,Git. - Tool results:
Recall,Forget.
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.<name>]: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.
Context Design
Each model request is built manually as one system message and one user message. The user message is a structured context snapshot, ordered from stable sections to volatile sections so provider prompt caching can reuse the prefix.
model request
+--------------------------------------------------+
| system |
| concise agent contract and tool rules |
+--------------------------------------------------+
| user |
| Environment |
| State |
| Summary |
| Recent Conversation |
| Tool Result Index |
| File Context |
| Discovery Context |
| Error Feedback |
| Latest Tool Results |
| Current User Request |
+--------------------------------------------------+
Core rules:
- File Context is rebuilt dynamically from active
ReadandEditresults. - Newer file lines overwrite older lines; edit invalidations clear stale ranges.
- File lines are checked against current file stat or line hash before being shown.
- Discovery Context contains
SearchandInspectCodeleads, not source truth. - Large tool outputs are bounded in context and can be recalled by
tr.N. - Error Feedback keeps only recent failed tool calls.
Forgetremoves stale result keys from the active tool result store.
Safety
nanocode can edit files and run shell commands in the environment where it is started. It does not provide sandbox protection. Run it inside your own sandbox, container, VM, or other isolated environment when needed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nanocode_cli-0.5.1.tar.gz.
File metadata
- Download URL: nanocode_cli-0.5.1.tar.gz
- Upload date:
- Size: 45.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f10a42a49fe061398c24171d472a6d190ed17a48c3a29c6f321a7bc5e180672
|
|
| MD5 |
05ff084a44c26baddaaacb90ccdfcfff
|
|
| BLAKE2b-256 |
19fc160caec7038bd4444ed36a9459d68b12ffe35e51a79e27149bc2412364a7
|
File details
Details for the file nanocode_cli-0.5.1-py3-none-any.whl.
File metadata
- Download URL: nanocode_cli-0.5.1-py3-none-any.whl
- Upload date:
- Size: 43.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96a953ffdad067479acf53489b79979aeb71dc968ad2178b7dee387ce3db37f6
|
|
| MD5 |
503a910a73368dd50a8cbb2479e1aa2d
|
|
| BLAKE2b-256 |
342a5958cba495f29a785a9a8e2a27d31762d3be43f7298db3815cdc66523a4f
|