A hand-written, fully-commented claude code clone you can actually read
CodeAgent is a terminal coding agent whose real product is the source itself — a complete agent loop in Chinese plain-language comments, built to be learned from and forked.

What it does
CodeAgent is a terminal AI coding assistant: you give it natural-language instructions and it reads code, edits files, runs commands, and iterates until the job is done. It supports OpenAI-compatible and Anthropic endpoints (DeepSeek by default), with a cheap auxiliary model handling compression, retrieval, and memory extraction. The pitch is explicit: this is a from-scratch, line-by-line implementation of the claude code experience — not a wrapper — with every module annotated in plain Chinese so the code reads like a tutorial.
The interesting bit
The self-learning pipeline is the unusual part: it observes conversation trajectories and distills reusable skills from them, activated by conditions like touched file paths. Combined with tiered context compression (L1 light trimming to L4 deep summarization) and cache-prefix-friendly message injection, it’s a working lab for context engineering.
Key highlights
- Tool self-registration: drop a module in
tools/and it registers; toolsets control what the model sees - Approval panels for dangerous commands, with injection-shape detection (
$(), process substitution) escalated to review - Subagents with worktree isolation, team mode with a message bus, and a deterministic workflow engine with spend caps
- Long-term memory via
MEMORY.md+ JSONL, retrieved results injected temporarily without polluting history - MCP support via project-level
.mcp.json, plus secret scanning, SSRF guards, and optional bwrap sandbox on Linux
Caveats
- Windows-first: Linux runs (with sandbox support) but macOS is described as theoretically usable, not thoroughly tested
- Comments and docs are Chinese-first; the English README exists but the code commentary is the main teaching material
- At ~500 stars, it’s a young project — the author invites bug-fix PRs, which tells you something
Verdict
If you want to understand how a real coding agent works from the inside — the loop, the compression, the permission model — this is a genuinely readable specimen. If you just want a polished production assistant, the established options have more mileage.
Frequently asked
- What is Harvil1/codeAgent?
- CodeAgent is a terminal coding agent whose real product is the source itself — a complete agent loop in Chinese plain-language comments, built to be learned from and forked.
- Is codeAgent open source?
- Yes — Harvil1/codeAgent is open source, released under the MIT license.
- What language is codeAgent written in?
- Harvil1/codeAgent is primarily written in Python.
- How popular is codeAgent?
- Harvil1/codeAgent has 503 stars on GitHub.
- Where can I find codeAgent?
- Harvil1/codeAgent is on GitHub at https://github.com/Harvil1/codeAgent.