Install
$ agentstack add mcp-kkkhs-clawdcode β scanned Β· β verified β works with Claude Code, Cursor, and more.
Security review
β PassedNo issues found. Passed automated security review. Β· v0.1.0 How review works β
- β Prompt-injection patterns
- β Secret / credential exfiltration
- β Dangerous shell & filesystem operations
- β Untrusted network calls
- β Known-malicious package signatures
What it can access
- β Network access No
- β Filesystem access No
- β Shell / process execution No
- β Environment & secrets Used
- β Dynamic code execution No
From automated source analysis of v0.1.0. βUsedβ means the capability is present in the source β more access means more to trust, not that itβs unsafe.
About
ClawdCode
An AI-Powered CLI Coding Agent
Inspired by Claude Code β read, write, and execute code directly in your terminal.
Features β’ Installation β’ Quick Start β’ Architecture β’ Documentation
β¨ Features
π€ Intelligent Agent
- Agentic Loop: LLM + System Prompt + Context + Tools
- Streaming output with real-time response
- Thinking process with auto-collapse/expand
- Tool call display with compact dim-styled logs
- AbortController-based Ctrl+C interruption
π οΈ Built-in Tools (7)
- Read / Write / Edit β file operations with diff preview
- Glob / Grep β fast code search and pattern matching
- Bash β shell execution with permission control
- MCP β external tool integration via Model Context Protocol
π Security & Permissions
- 4 permission modes:
default/autoEdit/yolo/plan - 7-stage execution pipeline with safety checks
- Inline permission prompt above input area
- Sensitive file detection (
.env, credentials, etc.) - Deny stops agent immediately β no continued thinking
π¨ Terminal UI
- Ink (React for CLI) β declarative interactive UI
- Markdown rendering with 140+ language syntax highlighting
- 5 built-in themes with auto dark/light detection
- Theme persistence across sessions
- Code block file paths and
/copyclipboard support
π§© Extensions
- Slash Commands β
/help,/compact,/model,/theme, ... - Custom Commands β Markdown files as commands, zero code
- Skills β pluggable agent capabilities via
SKILL.md - Hooks β 11 lifecycle events with pre/post shell scripts
π¦ State & Context
- Zustand store with fine-grained subscriptions
- Token counting and auto-compaction
- Session persistence and resume (
--continue) - Command history with arrow key navigation
- MCP Registry for external tool servers
π₯ Installation
# npm
npm install -g clawdcode
# pnpm
pnpm add -g clawdcode
# bun (recommended)
bun add -g clawdcode
π Quick Start
1. Configure API Key
# Interactive setup
clawdcode --init
# Or set environment variable
export OPENAI_API_KEY=sk-your-api-key
# Or use other OpenAI-compatible providers
export OPENAI_BASE_URL=https://api.deepseek.com
export OPENAI_API_KEY=sk-your-deepseek-key
2. Start Coding
# Interactive mode
clawdcode
# With initial message
clawdcode "analyze this project structure"
# With specific model
clawdcode --model gpt-4o
# Resume previous session
clawdcode --continue
3. Slash Commands
/help Show all commands
/clear Clear conversation
/compact Compress context (save tokens)
/model Switch model interactively
/theme Switch theme (dark/light/ocean/forest/sunset)
/status Show session info
/copy Copy code block to clipboard (/copy list)
/thinking Toggle thinking block expand/collapse
/mcp MCP server status
/hooks List active hooks
/skills List loaded skills
ποΈ Architecture
Coding Agent = LLM + System Prompt + Context + Tools
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLI Entry (yargs) β
β β β
β Agent Loop ββββββββββββββββββββββββββββββββ β
β ββ Build Context (messages + tools) β β
β ββ Call LLM (streaming) β β
β ββ Parse Response β β
β β ββ text β render to UI β β
β β ββ tool_calls β Execution Pipeline β β
β β ββ 1. Discovery β β
β β ββ 2. Permission β β
β β ββ 3. Pre-Hooks β β
β β ββ 4. Confirmation (UI) β β
β β ββ 5. Execute β β
β β ββ 6. Post-Hooks β β
β β ββ 7. Format β β
β ββ Inject Results βββββββββββββββββββββββ β
β β
β Store (Zustand) β β UI (Ink/React) β β Theme Manager β
β Context Manager β β Token Counter β β Compaction β
β MCP Registry β β External Tool Servers β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Custom Commands
Create project-specific commands in .clawdcode/commands/ (shareable via Git):
.clawdcode/commands/review.md
---
description: Code review for current changes
---
Review the current Git changes.
## Changes
!`git diff --stat HEAD~1`
## Requirements
1. Summarize what changed
2. Point out potential issues
3. Suggest improvements
.clawdcode/commands/test.md
---
description: Run tests and analyze failures
argument-hint: [test file or pattern]
allowed-tools:
- Bash(npm:*)
- Read
---
Run tests: $ARGUMENTS
If any test fails, analyze the cause and suggest fixes.
Then use them:
/review # Code review
/test src/utils # Run specific tests
Dynamic Content Syntax
| Syntax | Description | Example | |--------|-------------|---------| | $ARGUMENTS | All arguments | /cmd foo bar β foo bar | | $1, $2 | Positional args | /greet Alice β $1=Alice | | ` !cmd | Bash embed | !git branch | | @path | File reference | @package.json` |
βοΈ Configuration
ClawdCode supports multiple configuration methods (in priority order):
- CLI arguments β
--api-key,--base-url,--model - Environment variables β
OPENAI_API_KEY,OPENAI_BASE_URL - Project config β
./.clawdcode/config.json - User config β
~/.clawdcode/config.json
Config File Example
{
"default": {
"apiKey": "sk-your-api-key",
"baseURL": "https://api.openai.com/v1",
"model": "gpt-4o"
},
"ui": {
"theme": "dark"
},
"permissions": {
"allow": ["Bash(npm:*)", "Bash(git:*)"],
"deny": ["Bash(rm -rf:*)"]
},
"mcpServers": {
"filesystem": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
}
Permission Modes
| Mode | Read | Write | Execute | Description | |------|:----:|:-----:|:-------:|-------------| | default | β
| β | β | Ask for write/execute | | autoEdit | β
| β
| β | Auto-approve writes | | yolo | β
| β
| β
| Full auto mode | | plan | β
| β | β | Read-only analysis |
clawdcode --permission yolo "fix all lint errors automatically"
Permission Rules
{
"permissions": {
"allow": [
"Read(**/*.ts)",
"Bash(npm:*)",
"Bash(git:*)"
],
"deny": [
"Bash(rm -rf:*)",
"Write(/etc/*)"
]
}
}
Rule format: ToolName(pattern)
- Exact:
Bash(npm test) - Prefix:
Bash(npm:*)β matchesnpm install,npm test, etc. - Glob:
Read(**/*.ts)β matches all TypeScript files
Hooks
Add lifecycle hooks in .clawdcode/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": ["echo 'About to run shell command: $TOOL_INPUT'"]
}
],
"PostToolUse": [
{
"matcher": "Write",
"hooks": ["npx prettier --write $FILE_PATH"]
}
],
"Notification": [
{
"matcher": "",
"hooks": ["terminal-notifier -message '$NOTIFICATION_MESSAGE'"]
}
]
}
}
11 hook events: PreToolUse, PostToolUse, Stop, UserPromptSubmit, Notification, etc.
π» CLI Options
Usage: clawdcode [options] [message]
Options:
--api-key, -k OpenAI API key
--base-url, -b OpenAI API base URL
--model, -m Model to use (default: gpt-4o)
--permission, -p Permission mode (default/autoEdit/yolo/plan)
--theme, -t Color theme (dark/light/ocean/forest/sunset)
--continue, -c Resume previous session
--debug, -d Enable debug mode
--init Create default config file
--help, -h Show help
--version, -v Show version
π§ Tech Stack
| Technology | Role | |:-----------|:-----| | TypeScript | Type safety, strict mode | | Bun | Build & runtime | | Ink | React for CLI β declarative terminal UI | | Zustand | Lightweight state management | | OpenAI SDK | Compatible with OpenAI / DeepSeek / local models | | Zod | Runtime parameter validation | | MCP | Model Context Protocol for external tools | | lowlight | 140+ language syntax highlighting |
π Documentation
> π Complete Tutorial β 17 Chapters β Build an AI CLI Coding Agent from scratch
| Part | Chapters | Topics | |:-----|:---------|:-------| | Getting Started | 01 - 03 | Coding Agent overview, project setup, CLI entry | | Core Architecture | 04 - 07 | Agent core, system prompt, tool system, execution pipeline | | System Integration | 08 - 12 | Context management, UI system, MCP protocol, state management, command history | | Extensions | 13 - 17 | Slash commands, interactive commands, streaming & themes, skills, hooks |
π‘ Examples
# Analyze project structure
clawdcode "analyze this project's architecture"
# Fix TypeScript errors
clawdcode "fix all TypeScript type errors"
# Code review (read-only mode)
clawdcode --permission plan "review the recent code changes"
# Full auto mode
clawdcode --permission yolo "format all files with prettier"
# Use DeepSeek
clawdcode --base-url https://api.deepseek.com --model deepseek-chat "refactor this function"
π Development
# Clone
git clone https://github.com/kkkhs/ClawdCode.git
cd ClawdCode
# Install
bun install
# Dev
bun run dev
# Build
bun run build
# Type check
bun run typecheck
π€ Contributing
Contributions welcome. Please submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
π License
[MIT](LICENSE) Β© 2024-present
Built with β€οΈ by kkkhs
Source & license
This open-source MCP server is cataloged on AgentStack and links to its original source β we do not rehost the code.
- Author: kkkhs
- Source: kkkhs/ClawdCode
- License: MIT
- Homepage: https://kkkhs.github.io/ClawdCode/
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet β be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.