by gakonst
Building blocks for frontier OpenAI agents in Rust. Nanocodex empowers you with Codex-level performance anywhere.
# Add to your Claude Code skills
git clone https://github.com/gakonst/nanocodexnanocodex is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by gakonst. Building blocks for frontier OpenAI agents in Rust. Nanocodex empowers you with Codex-level performance anywhere. It has 321 GitHub stars.
nanocodex's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/gakonst/nanocodex" and add it to your Claude Code skills directory (see the Installation section above).
nanocodex is primarily written in Rust. It is open-source under gakonst on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh nanocodex against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
Install · Agent API · Thesis · Components · VM-backed tools · Documentation
Install the Nanocodex CLI on macOS or Linux:
curl -fsSL https://nanocodex.paradigm.xyz | bash
Or add the Rust SDK to an application:
cargo add nanocodex
Switch the installed CLI between builds:
nanocodex update # latest stable release
nanocodex update 0.2.0 # exact release, including downgrades
nanocodex update --nightly # latest nightly
nanocodex update --pr 50 # verified on-demand PR artifact
nanocodex update --path ./nanocodex # trusted local binary
Downloaded builds are retained under ~/.nanocodex/versions. Running
nanocodex update 0.2.0 again switches to the cached binary without another
download. A stable launcher keeps nanocodex update available even while an
older binary is active, and ~/.nanocodex/current points to the selected
version.
PR artifacts require an authenticated gh CLI and an already completed
on-demand artifact workflow for that PR.
use nanocodex::{Nanocodex, OpenAi};
let openai = OpenAi::new(std::env::var("OPENAI_API_KEY")?)?;
let (agent, mut events) = Nanocodex::builder(openai)
.instructions(
"You are a Rust coding agent. Make focused changes, preserve unrelated work, \
and run relevant tests before finishing.",
)
.workspace(std::env::current_dir()?)
.build()?;
let event_task = tokio::spawn(async move {
while let Some(event) = events.recv().await {
eprintln!("event {}: {:?}", event.seq, event.kind);
if event.kind.is_terminal() {
break;
}
}
});
// Alternative: stream this turn's response as it arrives:
// use futures_util::StreamExt;
// use nanocodex::agent::events::{AgentEventData, AssistantEvent};
// let mut turn = agent.prompt("Find and fix the failing parser test.").await?;
// while let Some(event) = turn.next().await {
// if let AgentEventData::Assistant(AssistantEvent::Delta(delta)) = event.data()? {
// print!("{}", delta.text);
// }
// }
let result = agent
.prompt("Find and fix the failing parser test.")
.await?
.await?;
event_task.await?;
println!("{}", result.final_message());
The first await accepts and orders the prompt. The second waits for its typed
TurnResult. Follow-on prompts automatically reuse the agent's retained
history, WebSocket, tools, shell sessions, and prompt-cache identity.
agent.clone() is a cheap handle to that same session; the independently
returned AgentEvents stream is the session-wide event firehose.
Nanocodex supports gpt-5.6-sol (the default) and gpt-5.6-luna. Select the
model with .model(Model::Luna) when creating an agent. The model is fixed for
that thread: switching later would invalidate the provider checkpoint and
require an inefficient replay of the complete retained context.
The non-TUI desktop example owns the default microphone and speaker directly
in Rust, using the same VoiceSessionBuilder as the production TUI:
nanocodex auth login # once; shares ~/.codex/auth.json with Codex
cargo run -p nanocodex-examples --bin voice
The lower adapter leaves device and media ownership outside Nanocodex. It reads 24 kHz mono PCM16 little-endian audio from stdin, writes the same format to stdout, and keeps transcripts and agent events on stderr:
cargo run -p nanocodex-examples --bin realtime-pipe < microphone.pcm > speaker.pcm
# Equivalently, compose any live capture/decoder and playback/encoder:
capture-s16le | cargo run --quiet -p nanocodex-examples --bin realtime-pipe | play-s16le
Both retain one coding-agent session. A spoken request starts work while idle;
a follow-up received during that work atomically steers the active turn at its
next safe model boundary. Both use shared Codex/ChatGPT subscription auth, not
an API key. Set NANOCODEX_AUTH_FILE to override the normal Codex credential
path.
Agent infrastructure is easier to understand and reuse when each piece has a sharp owner and a useful API of its own. An OpenAI client should work without an agent loop. Tools should work without a CLI. The high-level agent should compose those pieces rather than hide another implementation of them.
Nanocodex makes a small number of deliberate choices—Rust, Tower, typed protocols, owned lifecycle state, and builder APIs—then keeps the boundaries boring.
We do not try to outsmart behavior that frontier models and Codex already make
explicit. Context management, AGENTS.md, compaction, cache identity, tool
shapes, continuation, reconnect replay, cancellation, and process cleanup are
parts of the model-facing contract.
Nanocodex carries those invariants into a smaller, library-first API while leaving application policy with the caller.
Representative cargo bench workloads, OpenTelemetry traces, differential
tests, and end-to-end evals keep the harness honest. The goal is simple: normal
agent turns should be model- and network-latency bound, with token usage and
estimated USD cost visible at the same typed boundary as the result.
nanocodex Alloy-style facade and prelude
├── agent nanocodex-agent
│ ├── oai nanocodex-oai-api
│ └── tools nanocodex-tools
│ └── macros nanocodex-tools-macros
├── oai nanocodex-oai-api
├── tools nanocodex-tools
└── observability nanocodex-observability (optional)
The facade provides the canonical common imports. Each lower crate is also designed to be useful directly, without importing the higher orchestration layer.
nanocodexThe thin facade reexports the golden agent path at the crate root and keeps
detailed APIs under nanocodex::agent, nanocodex::oai, and
nanocodex::tools. Its prelude contains only the common types needed to build
an agent.
Facade guide · API documentation
nanocodex-agentThe batteries-included lifecycle: an owned private driver, a cheap cloneable
Nanocodex handle, typed Turn and TurnResult values, and an optional event
stream. It owns prompt ordering, the tool loop, AGENTS.md discovery,
compaction timing, cancellation, snapshots, and branching through spawn,
fork, and fork_from.
Callers never pass previous messages, response IDs, or tool results back into the agent.
Agent guide · API documentation
nanocodex-oai-apiThe complete OpenAI boundary: API-key and ChatGPT authentication, typed Responses protocol values, a persistent WebSocket transport, client-owned context, continuation and replay, automatic pricing, and a generic Tower client.
Its standalone OpenAi -> Session -> ResponseTurn -> Response path provides a
managed conversation without taking on agent policy. Custom Tower layers and
services remain concrete and nameable—no boxing or global client is required.
OpenAI API guide · API documentation
nanocodex-toolsThe model-facing tool runtime: the Tool contract, heterogeneous Tools
registry, standard workspace tools, shell and process lifecycle, Code Mode,
deferred tool_search, remote dispatch, and MCP. MCP is always available on
native targets.
Applications can implement Tool directly or use the reexported #[tool]
macro. The separate nanocodex-tools-macros package exists only for Rust's
procedural-macro boundary.
Tools guide · API documentation
nanocodex-observabilityApplication-owned tracing and OpenTelemetry setup for the data already flowing through the agent. It provides structured lifecycle, model, tool, usage, cost, cache, and latency telemetry without changing the core runtime path.
Enable the facade's observability feature or depend on the component
directly.
Observability guide · API documentation
Components whose public contracts are still maturing live under
crates/experimental/:
| Package | Responsibility |
|---|---|
nanocodex-voice |
Desktop GPT Realtime audio and reusable voice-to-agent lifecycle |
nanocodex-vm |
VM lifecycle and images plus retained guest-backed workspace tools |
The CLI is a consumer of these crates. Voice and VM-backed tools remain thin, opt-in adapters over the stable library contracts.
The CLI/TUI, Python package, Node/browser package, React bindings, and examples are thin consumers of the same owned session API. They do not define a second agent protocol.
[Examples](examples