Nanocode walks you through training your own AI coding agent from scratch. Salman Mohammadi, a maintainer of the Levanter JAX training library, built it by adapting Andrej Karpathy's nanochat framework with a focus on agentic coding behaviors. The whole thing runs on JAX and targets Google's TPU hardware. Train a 1.3 billion parameter model in roughly 9 hours for about $200, or a smaller 477 million parameter version in 1.5 hours for $34. The project uses Anthropic's Constitutional AI approach. You write a SOUL.md file defining how the model should behave, generate synthetic training data from that spec, then apply preference optimization to align outputs with your defined personality. Think of it as writing a constitution your model has to follow. Nanocode includes special tokens for tool calling and ships with Read, Edit, and Grep tools for UNIX file operations. Mohammadi mixed in coding data from The Stack-V2 at a 1:5 ratio, boosting code tokenization efficiency by about 50% over the original nanochat tokenizer. Google's TRC program offers free access to pre-emptible TPUs for a month, and new Google Cloud accounts get $300 in credits. Mohammadi reported spot instances were rarely interrupted during his three-month access period, sometimes staying up for a week or more. But the project isn't perfect. One Hacker News commenter noted that the example Python code generation used list comprehension to create a new list rather than modifying in-place as the prompt requested. Code generation accuracy remains tricky even when you train your own model.
Nanocode: Train Your Own Claude Code Agent for $200
A GitHub project from Salman Mohammadi showing how to train your own Claude Code-like coding agent using Constitutional AI, JAX, and TPUs. Adapted from Andrej Karpathy's nanochat, it trains a 1.3B parameter model in ~9 hours for $200. Includes special tokens for tool calling with Read, Edit, and Grep tools for UNIX environments.