DM Code
Agentic AI coding assistant for your terminal — powered by Annihilator
██████╗ ███╗ ███╗ ██████╗ ██████╗ ██████╗ ███████╗
██╔══██╗████╗ ████║ ██╔════╝██╔═══██╗██╔══██╗██╔════╝
██║ ██║██╔████╔██║ ██║ ██║ ██║██║ ██║█████╗
██║ ██║██║╚██╔╝██║ ██║ ██║ ██║██║ ██║██╔══╝
██████╔╝██║ ╚═╝ ██║ ╚██████╗╚██████╔╝██████╔╝███████╗
╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝
DM Code is a free, open-source Claude Code alternative that runs from your terminal on macOS, Linux, and Windows. Choose your engine from 11 free models across 4 providers — Anthropic, Google, Groq, and Mistral — and switch between them at any time.
Quick Install
git clone https://github.com/Dipendu27/dm-code.git
cd dm-code
npm install
npm linkNote:
npm linkregistersdmcode,dm,dm-code, andannihilatoras global commands. On macOS/Linux you can also run:npm install -g dm-code
That's it. Now type dmcode from any directory on any device:
dmcode # start interactive session
dm # shorthand — also works
dm-code # also works
annihilator # also worksFirst-time setup
dmcode setup # guided model + API key configurationHow to Update
Already have DM Code installed? Pull the latest and re-link:
cd dm-code
git pull
npm install
npm linkCheck your version:
dmcode --versionChangelog
v1.3.4 — Latest
Bug Fixes
- Google API Compatibility: Updated Google Gemini model endpoints from
gemini-2.0-flash-thinking-exptogemini-2.5-proandgemini-3.5-flashto resolve a404 Not FoundAPI breakage caused by Google deprecating experimental endpoints.
v1.3.3
Major Features
- IDE Diff Viewer: DM Code now automatically opens a side-by-side diff in your IDE (VS Code or Cursor) whenever it modifies a file using the
edit_fileorwrite_filetools. - Backend Thought Blocks: Added native terminal rendering for
<think>blocks. When models like DeepSeek R1 or Gemini Thinking emit thought processes, they are now neatly formatted in a dimmed▶ Backend thoughtblock in real-time.
v1.3.2
Major Features
- New input validation layer prevents directory traversal & injection attacks
- Enhanced error handling with retry logic, exponential backoff, and timeouts
- Structured logging system with DEBUG support for diagnostics
- New utility modules:
validation.js,errors.js,logger.js
Security Improvements
- Path traversal prevention for all file operations
- Improved command injection pattern detection
- Better dangerous command classification with explanations
Performance & Reliability
- Configurable request timeouts (60s default)
- Exponential backoff with jitter for retries (capped at 30s)
- Optimized streaming response parsing
- Better session cleanup and MCP schema management
v1.1.2
Critical Bug Fixes
- Fixed Anthropic model IDs —
claude-haiku-3-5→claude-haiku-4-5,claude-sonnet-4-5→claude-sonnet-4-6(previous IDs caused "model not found" API errors) - Updated Claude Sonnet 4.6 context window from 200K → 1M tokens (matches Anthropic docs)
- Updated global
MAX_CONTEXT_TOKENSceiling to 1M to match largest supported model - Added
DEBUG=1env var support for diagnosing silent errors in session/memory persistence
v1.1.1
Ctrl+C Interrupt Fix
- Ctrl+C now always works — even while the AI is processing or streaming
- Fixed on Windows: readline is no longer paused, so SIGINT stays alive on all platforms
- Added process-level SIGINT fallback for Windows terminal edge cases
- Abort signal now passed to API calls for instant network cancellation
- Fixed double "Goodbye!" message on exit (debounced duplicate SIGINT handlers)
v1.1.0
Exit & Interrupt Fixes
exit,quit, andqnow work directly — no need to type/exit- Double
Ctrl+Cnow reliably exits the app (fixed race condition)
Animated Thinking Spinner
- New braille-animated spinner with fun rotating status messages while the AI is processing
- Shows elapsed time so you always know something is happening
- Messages cycle through: "Cooking up a response…", "Diving deep into the code…", "Weaving some magic…" and more
v1.0.1
- Initial streaming support across all 4 providers
/savecommand for session export- Automatic rate-limit fallback across providers
- Session persistence and restore
- Context window auto-compaction
v1.0.0
- Initial release with 11 free models across 4 providers
- 12 built-in tools (read, write, edit, run, search, etc.)
- Interactive model picker and API key management
Free Models Available
| # | Model | Provider | Tier | Speed | Best For |
|---|---|---|---|---|---|
| 1 | Claude Haiku 4.5 ✦ | Anthropic | FREE* | Fastest | Quick tasks, fast iteration |
| 2 | Claude Sonnet 4.6 | Anthropic | FREE* | Fast | Complex refactoring, architecture (1M ctx) |
| 3 | Gemini 2.0 Flash ✦ | FREE | Fastest | Large codebases, 1M token context | |
| 4 | Gemini 2.0 Flash Thinking | FREE | Medium | Hard algorithms, deep reasoning | |
| 5 | Gemini 1.5 Flash | FREE | Very Fast | Lightweight tasks, large file reads | |
| 6 | Llama 3.3 70B ✦ | Groq | FREE | Ultra-fast | General coding, open-source quality |
| 7 | Llama 3.1 8B Instant | Groq | FREE | Instant | Scripts, one-liners, rapid output |
| 8 | Mixtral 8x7B | Groq | FREE | Very Fast | Code generation, multilingual |
| 9 | DeepSeek R1 70B | Groq | FREE | Fast | Math, algorithms, problem-solving |
| 10 | Mistral Small | Mistral | FREE* | Fast | Privacy-focused, EU projects |
| 11 | Codestral | Mistral | FREE* | Fast | Code-only, fill-in-the-middle |
FREE = permanently unlimited free
FREE* = free with monthly quota (generous for personal use)
✦ = recommended picks
Requirements
| Item | Requirement |
|---|---|
| OS | macOS, Linux, or Windows |
| Node.js | v20 or later |
| API key | At least one free key from any provider below |
Installation
Option 1: npm global install (recommended)
npm install -g dm-code
dmcode setupWorks on macOS, Linux, and Windows. The dmcode command becomes available system-wide immediately.
Option 2: Platform-specific installers
macOS / Linux
git clone https://github.com/Dipendu27/dm-code.git
cd dm-code
bash install.shThe script auto-detects your OS and package manager (Homebrew, apt, dnf, yum, pacman), installs Node.js if needed, links dmcode globally, and walks you through API key setup.
Windows (PowerShell)
git clone https://github.com/Dipendu27/dm-code.git
cd dm-code
.\install.ps1
The script checks Node.js, installs dependencies, links dmcode globally, and walks you through API key setup.
Option 3: Manual install (developers)
git clone https://github.com/Dipendu27/dm-code.git
cd dm-code
npm install
npm link # makes dmcode available system-wide
dmcode setup # guided model + key setupGetting Free API Keys
You only need one key to get started. All are free with no credit card required.
Google AI Studio (recommended — truly unlimited free)
- Go to https://aistudio.google.com/app/apikey
- Sign in with your Google account → Create API Key
- Run:
dmcode keys set google YOUR_KEY
Groq (fastest inference, truly free)
- Go to https://console.groq.com/keys
- Sign up → Create Key
- Run:
dmcode keys set groq YOUR_KEY
Anthropic (Claude models)
- Go to https://console.anthropic.com
- Sign up → API Keys → Create Key
- Run:
dmcode keys set anthropic YOUR_KEY
Mistral
- Go to https://console.mistral.ai/api-keys
- Sign up → Create Key
- Run:
dmcode keys set mistral YOUR_KEY
Usage
Start interactive session
dmcodeOn first run, the interactive model picker appears — choose your engine and paste your API key. Every subsequent run starts immediately.
Switch your engine at any time
# Interactive picker (beautifully formatted table):
dmcode model
# Or from inside the REPL:
/model
# Or override for a single session:
dmcode --model gemini-2.0-flash "refactor my auth module"
# Or by model ID:
dmcode --model llama-3.3-70b-versatile "write unit tests for utils.py"List all models
dmcode modelsManage API keys
dmcode keys # show status of all keys
dmcode keys set google AIzaSy... # save a key
dmcode keys set groq gsk_...
dmcode keys clear groq # remove a keySlash Commands (inside the REPL)
| Command | Description |
|---|---|
/model |
Open the interactive model picker |
/models |
Quick list of all models with current marker |
/keys |
Show API key status for all providers |
/keys set PROVIDER KEY |
Save an API key |
/help |
Show all commands |
/clear |
Clear screen and reset conversation |
/reset |
Reset conversation history only |
/config |
View configuration |
/approve-all |
Toggle auto-approve for tool calls |
/verbose |
Toggle verbose tool output |
/memory |
Show session memory |
/cwd |
Show current working directory |
/cd <path> |
Change working directory |
/resume <id> |
Restore a previous session by its session ID (shown at startup) |
/save |
Export session to Markdown file |
/save <filename> |
Export session to a specific filename or path |
/exit |
Exit DM Code |
Tools Available to Annihilator
| Tool | What it does |
|---|---|
read_file |
Read file contents (with optional line range) |
write_file |
Create or overwrite a file |
edit_file |
Surgical string replacement in a file |
run_command |
Execute shell commands |
list_files |
List directory contents with glob patterns |
search_files |
Regex / string search across files |
create_directory |
Create directories recursively |
delete_file |
Delete files or directories |
move_file |
Move or rename files |
web_fetch |
Fetch and read a URL |
memory_read |
Read from session memory |
memory_write |
Write to session memory |
Project Structure
dm-code/
├── bin/
│ └── dm.js ← CLI entry point
├── src/
│ ├── repl.js ← Main REPL orchestrator
│ ├── agent/
│ │ ├── loop.js ← Agentic loop (multi-provider)
│ │ ├── providers.js ← Anthropic / Google / Groq / Mistral clients
│ │ ├── session.js ← Session persistence ✨ new in v1.3
│ │ └── mcp-manager.js ← MCP schema management ✨ new in v1.3
│ ├── tools/
│ │ └── executor.js ← All 12 tool implementations
│ ├── ui/
│ │ ├── renderer.js ← Terminal UI (Claude Code visual style)
│ │ ├── input.js ← Readline REPL handler
│ │ └── model-picker.js ← Interactive model selection UI
│ ├── config/
│ │ ├── constants.js ← MODELS registry, theme, system prompt
│ │ └── settings.js ← Persistent config (per-provider API keys)
│ └── utils/ ← Shared utilities ✨ new in v1.3
│ ├── validation.js ← Input validation & security checks
│ ├── errors.js ← Custom error types & handling
│ └── logger.js ← Structured logging
├── test-smoke.mjs ← Smoke tests for session + MCP ✨ new in v1.3
├── install.sh ← macOS / Linux installer
├── install.ps1 ← Windows PowerShell installer
├── CHANGELOG.md ← Version history
├── .npmignore ← npm publish exclusions
├── .env.example ← Environment variable template
├── package.json
└── README.md
Session Persistence
DM Code automatically saves every session with a unique ID shown at startup:
ℹ Session ID: 3eb85a0c (use /resume <id> to restore)
To restore a previous session:
/resume 3eb85a0c
Sessions persist your conversation history and working directory across restarts. They are stored locally in your config directory and are never sent to any server.
CLI Reference
dmcode # start interactive REPL
dmcode "your prompt" # single prompt, non-interactive
dmcode --model <id> "prompt" # override engine for this run
dmcode --cwd /path/to/project # set working directory
dmcode --auto-approve # skip all confirmation prompts
dmcode --verbose # show full tool output
dmcode models # list all 11 free models
dmcode model # interactive model picker
dmcode keys # show API key status
dmcode keys set PROVIDER KEY # save an API key
dmcode keys clear PROVIDER # remove a key
dmcode config # show all settings
dmcode setup # guided first-time setup
dmcode version # detailed version infoNote:
dm,dm-code, andannihilatorare aliases — all work identically.
Environment Variables
export ANTHROPIC_API_KEY="sk-ant-..."
export GOOGLE_API_KEY="AIzaSy..."
export GROQ_API_KEY="gsk_..."
export MISTRAL_API_KEY="..."
export DM_MODEL="gemini-2.0-flash" # default engine override
export DEBUG=1 # enable debug logging
export DEBUG=verbose # extra verbose debug outputEnvironment variables always take priority over saved config.
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Enter |
Send message |
↑ / ↓ |
Navigate input history |
Ctrl+C |
Cancel current operation |
Ctrl+C (twice) |
Exit |
Troubleshooting
dmcode: command not found
# Re-link globally:
npm install -g dm-code
# Or from the project directory:
cd dm-code && npm link
# Windows: You may need to restart your terminal after installNo API key error
dmcode keys set google AIzaSy... # fastest to get, truly free
dmcode keys # verify statusNode.js too old
# macOS:
brew upgrade node
# Linux (Debian/Ubuntu):
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
# Windows:
winget upgrade OpenJS.NodeJS.LTS
# nvm (any platform):
nvm install 22 && nvm use 22Model not responding
Try a different provider — if Groq is rate-limiting, switch to Google:
dmcode model # interactive pickerEnable Debug Logging
For diagnostic information, run with DEBUG enabled:
DEBUG=1 dmcodeOr for very verbose logging:
DEBUG=verbose dmcodePublishing to npm
For maintainers:
npm login
npm publish --access publicUsers can then install globally with npm install -g dm-code.
Security & Privacy
- File Operations: All file paths are validated to prevent directory traversal
- Command Execution: Dangerous commands are flagged and require confirmation
- API Keys: Keys are stored in OS config and never logged
- Sessions: Session files are stored in
~/.dmcode/sessions(local machine only) - No Telemetry: DM Code collects no usage data
License
MIT — free to use, modify, and distribute.
Built by Dipendu Mukherjee.
Inspired by Claude Code by Anthropic.