he-yufeng/CoreCoder

Minimal AI coding agent (~1,000 lines of Python) inspired by Claude Code. Works with any LLM. Think NanoGPT for coding agents. Formerly NanoCoder.

What it solves

CoreCoder is a minimal, readable implementation of a coding agent. It aims to demystify the complex architecture of production-grade coding assistants (like Claude Code or Cursor) by providing a tiny, fully functional engine that developers can read, understand, and fork to build their own custom agents.

How it works

At its core, the project is a while loop that interacts with a Large Language Model (LLM). The agent sends a prompt to the model, executes the tools the model requests, feeds the results back into the context, and repeats this process until a final answer is reached.

Key technical decisions include:

  • Unique-match editing: Instead of relying on line numbers (which are prone to error), the edit_file tool uses search-and-replace on unique snippets of code.
  • Three-tier context compaction: To manage finite context windows, it trims long tool outputs first, then summarizes older turns, and finally performs aggressive compaction when the window is nearly full.
  • Tool-based sub-agent constraint: Sub-agents are restricted by simply withholding the agent tool, preventing recursive spawning.

Who it’s for

It is designed for developers who want to learn how coding agents work under the hood and those who wish to have a lightweight, hackable foundation to build their own AI coding tools.

Highlights

  • Extreme readability: The engine is approximately 1,081 lines of Python, allowing it to be read in a single afternoon.
  • Comprehensive toolset: Includes tools for bash execution, file reading/writing, editing, globbing, grep, and task tracking.
  • LLM agnostic: Supports OpenAI-compatible APIs, DeepSeek, Ollama, and others via LiteLLM.
  • Educational focus: Accompanied by a series of eight bilingual essays that walk through the source code and agent architecture.

相关

  • 项目
  • 项目
  • 项目
  • 项目
  • 项目