Skip to main content

nanoPyCodeAgent

English | 简体中文

A nano code agent built in pure Python.

"What I cannot create, I do not understand." — Richard Feynman, 1988

Usage

nanoPyCodeAgent requires Python 3.13 or newer.

How to Run

There are a few ways to run it — pick whichever fits your workflow.

Run without installing

Use uvx to run the latest release without installing anything:

uvx nanoPyCodeAgent

Run after installing

Install it as a persistent command-line tool, then run it from anywhere:

uv tool install nanoPyCodeAgent   # or: pipx install nanoPyCodeAgent
nanoPyCodeAgent

Run one task and exit

Give it a task and it works through it on its own, with no prompt and nothing to confirm — the shape a script or a benchmark harness needs:

nanoPyCodeAgent -p "add a --version flag and run the tests"
nanoPyCodeAgent --prompt-file task.md
printf "%s" "$TASK" | nanoPyCodeAgent

The task is carried out in the current directory. --max-turns N caps how many model replies one run may spend (50 by default).

Add --trajectory PATH to save that headless Agent Run as one complete ATIF-v1.7 JSON document without changing stdout:

nanoPyCodeAgent -p "read README.md and summarize it" \
  --trajectory ./trajectory.json

The option creates the requested file with owner-only permissions (0600) after the run reaches a terminal state. It refuses to overwrite an existing path. Trajectories may contain the task, model replies, tool arguments, and tool results, so treat them as sensitive data.

A run like this exits 0 whenever the agent actually ran — including when it gave up or ran out of turns with the task unfinished, which is for whatever checks the result to judge. A non-zero exit means the run could not happen at all: 1 for missing credentials or an API that kept refusing, 2 for a misused command line.

Every Agent Run also writes a replayable internal Event Journal under ~/.nanoPyCodeAgent/journals/. These JSONL files can contain prompts, model replies, repository content, and tool results, so treat them as sensitive; the directory is user-only (0700) and each file is 0600. Journals are not public run output or trajectories, and they are not rotated automatically yet.

Run a branch or tagged version

Run an unreleased branch or a specific release tag straight from GitHub:

# latest commit on a branch
uvx --from "git+https://github.com/minixalpha/nanoPyCodeAgent@main" nanoPyCodeAgent

# a specific tag
uvx --from "git+https://github.com/minixalpha/nanoPyCodeAgent@v0.1.0" nanoPyCodeAgent

Configuration

Credentials and the model come from two sources: environment variables and an optional user-level config file at ~/.nanoPyCodeAgent/settings.json. Environment variables take precedence — the config file only fills in keys you have not set in the environment.

The config file mirrors Claude Code's settings: put the values under an env object. Empty or whitespace-only values are ignored.

{
  "env": {
    "ANTHROPIC_API_KEY": "",
    "ANTHROPIC_AUTH_TOKEN": "",
    "ANTHROPIC_BASE_URL": "",
    "ANTHROPIC_MODEL": ""
  }
}
Variable Required Default Description
ANTHROPIC_API_KEY One credential required — Your Anthropic API key, or an API key accepted by a third-party service.
ANTHROPIC_AUTH_TOKEN One credential required — A bearer token used instead of ANTHROPIC_API_KEY; OpenRouter recommends this mode for its Anthropic-compatible endpoint.
ANTHROPIC_BASE_URL No https://api.anthropic.com Point the SDK at a non-official / proxy endpoint. Leave it unset to use the official API — an empty value breaks requests.
ANTHROPIC_MODEL No claude-sonnet-4-6 Override the model. An empty or whitespace-only value falls back to the default.

How to Update

Upgrade an installed tool to the latest release:

uv tool upgrade nanoPyCodeAgent   # or: pipx upgrade nanoPyCodeAgent

Releasing

For maintainers: see docs/RELEASING.md for the release process and prerequisites.

Metadata

Release files for nanoPyCodeAgent 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nanoPyCodeAgent 0.8.0
File Size Uploaded
nanopycodeagent-0.8.0.tar.gz 564.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nanoPyCodeAgent 0.8.0
File Interpreter ABI Platform
nanopycodeagent-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 605.3 kB

Release files / nanopycodeagent-0.8.0.tar.gz

Download URL nanopycodeagent-0.8.0.tar.gz
Size 564.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c5f4001df010c5f0758454f717d02c252fcfdfeb51987d32ea28c3114bdd082b
BLAKE2b-256 checksum
How to use checksums
9b85986dba0d77b009b41e08761560c7e6a7704ef1257f48b075fa87ee1d79e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","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":true}

Release files / nanopycodeagent-0.8.0-py3-none-any.whl

Download URL nanopycodeagent-0.8.0-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9299ccd0a2a078e87900b4c221538fc5e789223602c49e68acafe8ae691b0b02
BLAKE2b-256 checksum
How to use checksums
07e22cae3863e18eab95e567d6d881315834824763d1a6d7bd84feb7d8a0baab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","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":true}

Release history Release notifications | RSS feed

0.9.0

2 release files

This release

0.8.0 This release

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page