DM-Code-Agent CLI
A local Python coding agent that writes every step to a log you can analyze, replay and resume.
- 152 ★ on the repository
- Last commit
- MIT
Broad access
Why this level
- The agent reads and writes files in the working folder and runs tests, linters and commands with no sandbox.
- Connected MCP tools can act on your behalf, and API keys sit in the local `.env` file.
Install
Manual install
git clone https://github.com/hwfengcs/DM-Code-Agent.git && cd DM-Code-Agent
uv sync --frozen --extra devThen `cp .env.example .env` and an API key for at least one provider. `pip install -e ".[dev]"` works instead of `uv`.
Access and checks
How we reviewBroad accessThe tool can change data, run commands or handle secrets.
- The agent reads and writes files in the working folder and runs tests, linters and commands with no sandbox.
- Connected MCP tools can act on your behalf, and API keys sit in the local `.env` file.
This is third-party code. Review the repository files before installing.
What it does
DM-Code-Agent is a terminal coding agent built on a single ReAct loop. It reads and edits files in the working folder, runs tests and linters, connects tools over MCP and writes every plan step, tool call and result into an append-only session log. The log is a tree: each entry has an id and a parent, and context compaction adds a new entry without erasing the originals. So `dm-agent-trace` shows how a session went, diagnoses a failure, compares two runs and reruns from a chosen step (`fork`). DeepSeek, OpenAI, Claude and Gemini models work, and `dm-agent-web` opens a browser console for auditing and launching tasks.
Who it is for. Developers and agent researchers who want to trace from a log what an agent did in a repository and rerun it.
Good fit when
- The agent fixes a bug and the result is checked against the full step log.
- Two runs gave different results and you need the step where they diverged.
- Agent behavior is tested without an API key: the scripted client and the eval run offline.
- Custom tools, guard hooks or a provider are added in a single `.py` file and the core stays untouched.
- An interrupted task resumes from a checkpoint with `--resume`.
Not a fit when
- You want a ready plugin for Claude Code or Cursor: DM-Code-Agent runs as a standalone terminal program.
- You do not want to set up a Python environment and an API key for at least one provider.
- You need container isolation: the project works in a local folder and uses no sandbox.
Example request
Fix the retry boundary in `retry.py`, run the tests and save the log to `sessions/fix.jsonl`.Limitations
Python 3.10 or newer and an API key for at least one provider (DeepSeek, OpenAI, Claude or Gemini) in the `.env` file are required. Installation runs from a repository clone with `uv sync --frozen --extra dev` or `pip install -e ".[dev]"`; there is no registry package. The agent works locally without a sandbox: it edits files and runs commands in the working folder itself, and blocking dangerous commands is done with a `before_tool_call` hook, as in `examples/block_dangerous_shell.py`. Project extensions load after explicit trust. The main documentation and development logs are in Chinese and the English README is a separate file. The license is MIT.
How to disable. Delete the cloned folder and the virtual environment and remove the API keys from `.env`. Session logs sit wherever `--trace` pointed, so delete them by hand.
FAQ
How do I install DM-Code-Agent?
Clone the repository, run `uv sync --frozen --extra dev` (or `pip install -e ".[dev]"`) and copy `.env.example` to `.env` with an API key. Then run `dm-agent "task"`.
Can I try it without an API key?
Yes. Tests and deterministic evals run offline: `python -m pytest` and `python -m dm_agent.evals.cli --variant full --task direct_finish`. `dm-agent-web --read-only` opens saved sessions and needs no key either.
How do I analyze a failed run?
Run `dm-agent-trace analyze sessions/fix.jsonl`: it shows the failure stage, whether replanning happened and whether verification was skipped. `view` prints the step flow, `diff` compares two runs and `fork --at <id>` reruns from a chosen entry.
Which models are supported?
DeepSeek, OpenAI, Claude and Gemini. Put the key of the provider you use into `.env`; a custom provider is added through an extension.
How do I add my own tool?
Write a `.py` file with a `setup(api)` function and put it in the extensions directory. The `register_tool`, `register_skill`, `register_provider` and `on` methods add tools, skills, providers and one of six interceptable hooks.
Discussion
No questions or reviews yet.
Related
CLI toolsA teaching terminal coding agent in Python, built as a "nanoGPT for agents": read it, take it apart and fork it
An open coding agent for the terminal, browser and desktop that works with models from OpenAI and Claude to Ollama
A terminal coding agent in one Rust binary that reads code, edits files and runs tests with any model of your choice.
PaiCLI Python is a terminal AI agent with ReAct and planning, an MCP client, memory, pre-edit snapshots and a Runtime API.
Daintree runs Claude Code, Codex and other agent CLIs in parallel and exposes control of them through a local MCP server
pydantic-deepagents
pydantic-deepagents (pydantic-deep)
An open-source terminal AI assistant and Python framework with a Docker sandbox, agent tools and subagents
Comparison with similar tools
Cards that share the main search query, and how they differ.
| Tool | Official | Repository stars | Main difference |
|---|---|---|---|
| DM-Code-Agent (this card) | no | 152 | |
| Aider | no | 50,089 | pair programming with git auto-commits; DM-Code-Agent keeps a tree log with analysis, comparison and replay of sessions |
| OpenCode | no | 226,389 | an open agent with build and plan modes; DM-Code-Agent focuses on run auditing and extensions without touching the core |
README in short
Guard mechanisms are on by default: read-before-edit checks, atomic writes with backups and checkpoints. Experimental modules are off and enabled by flags. The project reports 554 tests and its own 30-task benchmark, and 21 of 50 SWE-bench Verified tasks solved.