Skip to main content

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.

nanocode screenshot

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:hash anchors 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, Find, 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 Turn Conversation                     |
+--------------------------------------------------+

Core rules:

  • File Context is rebuilt dynamically from active Read and Edit results.
  • 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 Find, Search, and InspectCode leads, 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.
  • Forget removes 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanocode_cli-0.5.4.tar.gz (47.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanocode_cli-0.5.4-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

Details for the file nanocode_cli-0.5.4.tar.gz.

File metadata

  • Download URL: nanocode_cli-0.5.4.tar.gz
  • Upload date:
  • Size: 47.1 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

Hashes for nanocode_cli-0.5.4.tar.gz
Algorithm Hash digest
SHA256 cb98b9a62acaa74b98e7e2fc8c710783523ba3907dd747e7037a44a484c44c17
MD5 403eeff70f656f98afb9560a7767c51d
BLAKE2b-256 8a67f83035bac539a2143b189ec85c20bb7a5051c478a2c5b1eb502b1680cdcb

See more details on using hashes here.

File details

Details for the file nanocode_cli-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: nanocode_cli-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 45.1 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

Hashes for nanocode_cli-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6348f1f0f7a2c3af523cb521facdeffa74c31ba32fca26c925de2b6a67164a90
MD5 2293fe791a8c43b7b1d445e4c451292f
BLAKE2b-256 d8e83b31eef4e3443bfb1a7de2a7b5b570d9c6027d32a8ef0ea586f6918f54a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page