Mai Code — AI skill for Claude Code
Mai-code作为Mai的个人项目,是一个从零实现的、类 Claude Code 的本地 AI Agent 运行时(mini 版).
How to install Mai Code
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open Maijintao/Mai-Code and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Mai Code does
Mai-code作为Mai的个人项目,是一个从零实现的、类 Claude Code 的本地 AI Agent 运行时(mini 版).
Alternatives in AI
- Cc Mini — Ultra-light Harness scaffolding for AI agents, a mini version of claude code 825 ★
- Mini Agent — A mini AI agent CLI, similar to Claude Code and Gemini CLI 98 ★
- Claudomat Mini — Battle-tested operating system for shipping product with LLM coding agents 74 ★
README
MaiCode
一个从零实现的、类 Claude Code 的**本地 AI Agent 运行时(mini 版)**。
它不是"调用一次大模型 API"的 Demo,而是把 AI 编程 Agent(Claude Code / Codex / Cursor 这一类)背后最核心的运行机制,用一套完整的本地系统落地:
- 用户输入一个目标,Agent 自主规划下一步并逐步执行
- 模型不只返回文本,还能主动发起工具调用
- 工具调用带参数校验、权限审批、失败分类与重试
- 执行过程不是黑盒,而是通过事件流实时展示到 TUI
- 每次 run 都留下 events、trace、session 记录,方便复盘和排查
- 多轮会话不是简单拼接历史,而是有 thread、notes、context 分层记忆
- 上下文快爆了,不是粗暴截断,而是有水位检测和 compact 压缩
- 复杂任务可以交给子 Agent(Subagents),外部工具通过 MCP 接入
架构
**双进程架构**:常驻守护进程 `mai-core` 真正执行任务,`Mai`(CLI)和 `mai-tui`(TUI)作为客户端通过类型化 IPC 协议接入。
mai-core (daemon)
└─ 监听 127.0.0.1:7437 (TCP)
↑ JSON-RPC 2.0 over NDJSON
Mai (CLI) mai-tui (TUI)
一条完整的运行链路:
用户目标
→ CLI / TUI
→ JSON-RPC over NDJSON(TCP)
→ mai-core daemon
→ AgentRunner
→ AgentLoop (ReAct)
→ LLM Provider ←→ 大模型 API
→ ToolRegistry
↓
PermissionManager → 工具调用 → 结果回填
→ EventBus(事件流分发)
→ Session Store(会话记忆)
→ TUI 实时渲染 / events.jsonl 持久化 / trace 回放
**系统分层架构:**
flowchart TB
subgraph Client[客户端层]
CLI[Mai CLI]
TUI[Mai TUI
textual]
end
subgraph IPC[IPC 传输层 JSON-RPC 2.0 over NDJSON / TCP]
direction LR
SOCK[Socket Server
127.0.0.1:7437]
IPCB[IPC Broadcaster
事件广播]
end
subgraph Core[mai-core Daemon]
RUNNER[AgentRunner]
LOOP[AgentLoop ReAct]
subgraph Modules[核心模块]
LLM[LLM Provider
流式调用]
TOOLS[ToolRegistry
内置工具 bash/read/write/list]
PERM[PermissionManager
权限审批/重试]
EVT[EventBus
事件分发/持久化]
SESS[Session Manager
thread/notes 分层记忆]
CMP[Compactor
上下文压缩/水位检测]
SKILL[Skills Loader]
SUB[Subagent Registry
多 Agent 编排]
MCP[MCP Client
外部工具接入]
TRACE[Trace Provider
可回放追踪]
end
end
subgraph Storage[持久化]
EVTF[events.jsonl]
TRACEF[traces/*.jsonl]
CFG[~/.mai/config.toml]
POLICY[~/.mai/policy.toml]
Related Skills
Homebrew Core
HarmonyOS(OHOS aarch64)Homebrew tap:真机验证、签名开箱即用的开发工具链——AI 编码 CLI(opencode / claude-code)、Bun 运行时、Node 多版本管理、终端
G Mini Agent
G-Mini Agent 🖥️👁️🗣️ Asistente IA open-source que VE tu pantalla, HACE CLIC automático y HABLA en tiempo rea
Mac Mini LLM Experiment
Experimenting with local LLM coding agents on a 24GB Mac Mini — what works, what doesn't, and why
SKILL.Es
Delega trabajo al CLI de OpenAI Codex (cuota de ChatGPT, NO tu plan de Claude). AUTO para exploración de repo
Mach Person
Machiavelli — add a new person to the corporate ontology, run a mini-interview for relations, and review LLM-s
Ground Truth Evals
An LLM eval harness graded by computed ground truth, not an LLM judge. Worked example: poker, served to models
Related Agents
Mailer Agent
Creates Action Mailer emails with previews, templates, and delivery tests following Rails conventions. Use whe
Orca
Lead-developer orchestrator. Watches a project's GitHub issues, plans, dispatches work to subagent workers, tr
ZeroClaw Android
Run AI agents 24/7 on your Android phone. Native Rust core, 25+ providers (OpenAI, Claude, Gemini, Groq, DeepS