Mini Claude Code - 极简教学版 AI 编程助手
Project description
MiniCC
极简版 Claude Code,用于教学。
想知道 Claude Code 这类 AI 编程助手是怎么实现的? 看这个项目就够了。核心代码约 1400 行,架构清晰,注释充分。
能干嘛
- 读写文件、搜索代码、执行 shell 命令
- 创建子任务并行处理
- 终端 UI 界面,支持流式输出
技术栈
- pydantic-ai - Agent 框架
- Textual - TUI 框架
快速开始
# 设置 API Key
export ANTHROPIC_API_KEY="your-key"
# 或 export OPENAI_API_KEY="your-key"
# 直接运行(无需安装)
uvx minicc
# 或者安装后运行
uv pip install minicc
minicc
开发
git clone https://github.com/TokenRollAI/miniCC.git
cd miniCC
uv sync
uv run minicc
项目结构
minicc/
├── app.py # TUI 主程序
├── agent.py # Agent 定义
├── tools.py # 工具实现 (文件操作、搜索、bash)
├── config.py # 配置管理
├── schemas.py # 数据模型
└── ui/ # UI 组件
配置
配置文件在 ~/.minicc/config.json:
{
"provider": "anthropic",
"model": "claude-sonnet-4-20250514"
}
Prompt Cache (Anthropic)
按照 pydantic-ai Anthropic 指南 可以在配置里开启 prompt caching:
{
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"prompt_cache": {
"instructions": true,
"tool_definitions": "1h",
"messages": true
}
}
instructions缓存系统提示词;tool_definitions缓存工具定义;messages缓存最近一条用户消息true表示 5 分钟 TTL,或显式写"5m"/"1h"- Anthropic 最多支持 4 个 cache points,pydantic-ai 会按指南自动裁剪超出的 CachePoint
工具列表
| 工具 | 作用 |
|---|---|
| read_file | 读文件 |
| write_file | 写文件 |
| update_file | 改文件 |
| search_files | 按模式搜索文件 |
| grep | 正则搜索内容 |
| bash | 执行命令 |
| spawn_agent | 创建子任务 |
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
minicc-0.2.2.tar.gz
(167.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
minicc-0.2.2-py3-none-any.whl
(33.1 kB
view details)
File details
Details for the file minicc-0.2.2.tar.gz.
File metadata
- Download URL: minicc-0.2.2.tar.gz
- Upload date:
- Size: 167.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d471975c2ee0280f7c2f5adf8e94573ca2e2c5d5e21f539c6a423c448d29bd75
|
|
| MD5 |
8746102bafb0eb7500978a77c2e6f88d
|
|
| BLAKE2b-256 |
b39dc22af93f41984ace63f961313eed723bdd3e9b321a9226bcbe3916a0f41a
|
File details
Details for the file minicc-0.2.2-py3-none-any.whl.
File metadata
- Download URL: minicc-0.2.2-py3-none-any.whl
- Upload date:
- Size: 33.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a727689b85a1a21d6c808a4ff0e466cef74d12128ef1e4cdc20ca14471b46868
|
|
| MD5 |
118b6510c1165d6f4151f9f010088441
|
|
| BLAKE2b-256 |
287719e52942b39b9d9424ca4578f6b584d0ed10ce0c9c5cacc67e7c056bd74c
|