Skip to main content

Mini-Code-Agent

PyPI version Python 3.11+ License: MIT Tests

A terminal-based coding agent inspired by Claude Code — built from scratch in Python, fully open-source, and designed to be readable.

中文文档 (Chinese)


Why Mini-Code-Agent?

Claude Code Mini-Code-Agent
Cost model Subscription ($) Pay-per-token — built-in cost dashboard (/cost)
Conversation control Server-side, no undo Local — /undo rollback + /fork branching
Extensibility Closed Open tools/hooks/skills/MCP
Transparency Black box /trace shows every decision in real time
Codebase Proprietary ~4,200 lines of readable Python, MIT licensed

Features

🔧 8 Built-in Tools — read/write/edit/delete files, bash, glob, grep, spawn agents

🤖 Multi-Agent/spawn parallel agents, /team auto-planned orchestration, strong/weak model mixing

💰 Cost Dashboard — per-model input/output pricing, session + all-time ledger, budget warnings at 80%/100%

Undo & Fork/undo rolls back conversation AND file changes; /fork branches into a new session

🎬 Record & Replay/record captures tool sequences, /replay re-runs them with zero LLM calls + {{template}} variables

🧠 Memory — LLM auto-extracts preferences at session end, injects them next session; manual /memory add too

📋 Persistent Tasks/todo with dependency tracking (--after), survives restarts

🔌 MCP Protocol — stdio + HTTP transport, connect any MCP-compatible tool server via config

🎨 Themes — dark/light/default, markdown heading colors follow theme

📄 Context-Aware — auto-reads CLAUDE.md / AGENT.md project instructions at startup

Quick Start

Install

pip install mini-code-agent

Or from source:

git clone https://github.com/ccxxxyy/mini-code-agent.git
cd mini-code-agent
uv sync
uv run mini

Configure

Set your LLM API key (any OpenAI-compatible provider):

# Environment variable
export OPENAI_API_KEY="sk-..."
export OPENAI_BASE_URL="https://api.deepseek.com/v1"  # optional: non-OpenAI provider

# Or .env file (auto-loaded)
echo 'OPENAI_API_KEY=sk-...' > .env

# Or CLI
mini --api-key "sk-..." --base-url "https://api.deepseek.com/v1" --model "deepseek-chat"

Run

mini          # start the agent
mini --help   # see all options

Commands

Command What it does
/help List all commands
/status Session info (model, tokens, cost)
/model [name] View or switch LLM model
/cost [turns|reset] Cost dashboard: per-model breakdown, budget tracking
/todo [add|done|start|delete|clear] Persistent task list with dependency graph
/undo [N] Roll back N turns — files restored too
/fork [N] Branch conversation into a new session
/record start|stop|cancel|list|delete Record tool call sequences
/replay <name> [k=v ...] Replay recorded sequence with template variables
/spawn <task> Dispatch background sub-agent
/team <task> Auto-plan and parallel-execute with sub-agents
/trace [on|off] Show agent internals (phases, permissions, timing)
/explain [on|off] Show tool usage explanations
/audit [on|off|verify] Audit logging with hash-chain integrity
/theme [dark|light|default] Switch color theme
/memory [add <text>] View or add persistent memories
/session save|list|load|delete Session management
/skill [activate|deactivate] Manage skill packs
/compact Compress conversation history
/clear Clear conversation
/exit Exit

Configuration

All settings via ~/.mini-agent/config.toml (user) or .mini-agent/config.toml (project):

[llm]
model = "deepseek-chat"
temperature = 0.0

[cost]
budget = 5.0
[cost.pricing.deepseek-chat]
input = 2.0
output = 8.0

[mcp.servers.github]
url = "http://localhost:8080/mcp"
transport = "http"
headers = { Authorization = "Bearer ghp_..." }

See config.toml.example for all options. Full guide: docs/config-guide.md.

Architecture

mini-code-agent/
├── src/mini_agent/
│   ├── core/        # Agent loop, sub-agents, teams, planner, cost tracker
│   ├── tools/       # 8 built-in tools + MCP protocol (stdio + HTTP)
│   ├── memory/      # Context compression, persistent memory, file snapshots
│   ├── security/    # Permissions, path guard, git worktree isolation
│   ├── ui/          # Rich terminal rendering, themes, prompt toolkit
│   ├── extensions/  # Slash commands, skills, hooks
│   ├── llm/         # Provider abstraction (OpenAI-compatible)
│   ├── config/      # Layered config loading (TOML + env + CLI)
│   └── models/      # Dataclasses (messages, events, config, sessions)
├── tests/           # 415 tests, 83%+ coverage
├── skills/          # 4 built-in skill packs
├── experiments/     # Compression A/B + model mixing experiments
└── docs/            # 11 documentation files (incl. agent-architecture.md)

Design philosophy: Five layers (UI → Engine → Tools → Memory → Security) decoupled via EventBus. All I/O is async. Zero vendor SDK dependency — just httpx.

S01–S20 Coverage

This project implements 19 of 20 mechanisms from the learn-claude-code harness checklist. See docs/agent-architecture.md for a deep dive into what each layer solves and why.

✅ S01 Agent Loop · S02 Tool Use · S03 Permission · S04 Hooks · S05 Planning · S06 Subagent · S07 Skill Loading · S08 Context Compression · S09 Memory · S10 System Prompt · S11 Error Recovery · S12 Task System · S13 Background Tasks · S15 Agent Teams · S16 Team Protocols · S17 Autonomous Agents · S18 Worktree Isolation · S19 MCP Plugin · S20 Comprehensive Agent

⬚ S14 Cron Scheduler — intentionally skipped (OS-level cron/Task Scheduler is more appropriate for a terminal tool)

Development

uv sync --extra dev
uv run pytest tests/           # 415 tests
uv run ruff check src/ tests/  # lint
uv run ruff format src/ tests/ # format

See docs/tasks.md for the full development history (P1–P33, 33 phases).

Publishing to PyPI

git tag v1.0.0
git push origin v1.0.0
# GitHub Actions auto-publishes via Trusted Publisher

First-time setup: register at pypi.org, add Trusted Publisher for ccxxxyy/mini-code-agentpublish.yml.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mini_code_agent-1.0.0.tar.gz (330.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mini_code_agent-1.0.0-py3-none-any.whl (136.4 kB view details)

Uploaded Python 3

File details

Details for the file mini_code_agent-1.0.0.tar.gz.

File metadata

  • Download URL: mini_code_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 330.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mini_code_agent-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5e91d8e3fc425499de055edc717744c506a029b3e1148493123c206c73921ac5
MD5 8f1e95fbad1da72e11e30d5584a72d3d
BLAKE2b-256 18ed538f7dcd048d36cac7af8651ecc26cc853420edc992da8aa463cb49c3367

See more details on using hashes here.

Provenance

The following attestation bundles were made for mini_code_agent-1.0.0.tar.gz:

Publisher: publish.yml on ccxxxyy/mini-code-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mini_code_agent-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mini_code_agent-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 136.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mini_code_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d11c58a18b4563af8701ca4eaa42a658d98f5129e53d74599680f379426f31d4
MD5 bc75998708d84f365ba7ac6954d9c50d
BLAKE2b-256 eadf9ba09d4ac891e54e34d006fb3d737460f5b9b797b1b8c860d51feab1128d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mini_code_agent-1.0.0-py3-none-any.whl:

Publisher: publish.yml on ccxxxyy/mini-code-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page