Skip to main content

Self-maintaining .claude/ runtime — LLM-powered doc review, project map, task queue, auto-fix, and project init

Project description

cmdop-claude

Self-maintaining .claude/ runtime for Claude Code. Keeps your project documentation accurate, your context lean, and your LLM session aware of what matters — automatically.

cmdop-claude dashboard

~$0.003 per full cycle (scan → review → fix → map) using DeepSeek V3.2 via SDKRouter.


What it does

Claude Code's .claude/ folder is powerful but static. cmdop-claude makes it live:

  • Documentation review — LLM finds stale docs, contradictions between docs and actual code, coverage gaps, and abandoned plans. Runs automatically once per day.
  • Project map — annotates directories with one-sentence descriptions. Cached by SHA256; only changed dirs cost tokens.
  • Task queue — review findings become structured tasks (T-001.md, T-002.md, ...). Top pending items injected into every prompt automatically.
  • Auto-fix — LLM generates targeted file edits for any task. Preview diff or apply directly.
  • Project init — bootstraps CLAUDE.md + rules from scratch for bare projects. Smart 3-phase pipeline: git context → filtered code snippets → cached tree summaries.
  • Plugin browser — searches Smithery + Official MCP registries (~1000 plugins), installs to ~/.claude.json.

Everything runs as Claude Code hooks. Zero manual steps after setup.


How it works

UserPromptSubmit hook
  └─ inject-tasks
      ├─ auto-scan if >24h since last review
      │   ├─ LLM reviews .claude/ docs, plans, deps, commits
      │   └─ creates/updates tasks from findings
      └─ injects top 3 pending tasks into context

PostToolUse hook (Write|Edit)
  └─ map-update (debounced 60s)
      ├─ scans changed directories
      ├─ SHA256 cache → skips unchanged dirs (0 tokens)
      └─ LLM annotates new/changed dirs only

sidecar_init (MCP tool / CLI)
  ├─ Phase 1: GitContextService — finds all .git repos, classifies own vs external
  │   └─ LLM + hard rules → own_top_dirs set
  ├─ Phase 2: smart snippets filtered to own dirs
  │   ├─ entry points, Makefiles, configs
  │   └─ external dirs (@archive, @vendor, submodules) excluded
  └─ Phase 3: TreeSummarizer with MerkleCache
      ├─ TOON format (~60% fewer tokens than JSON)
      ├─ Merkle hash per dir → skip LLM for unchanged
      └─ parallel LLM chunks (asyncio)

Install

pip install cmdop-claude

# With Streamlit dashboard
pip install cmdop-claude[ui]

Get your API key at sdkrouter.com (free tier available).


Quick Start

pip install cmdop-claude
cd your-project
python -m cmdop_claude.sidecar.hook setup

setup does everything in one shot:

  • Saves your SDKRouter API key to ~/.claude/cmdop.json (once for all projects)
  • Registers the MCP server globally in ~/.claude.json
  • Installs Claude Code hooks in .claude/settings.json
  • Configures plansDirectory: ".claude/plans"
  • Generates .claude/Makefile with convenience commands
  • Runs init if no CLAUDE.md found → generates docs via LLM

Uninstall

python -m cmdop_claude.sidecar.hook unregister

MCP Tools

Tool LLM Description
sidecar_scan yes Run documentation review
sidecar_review no Read current review
sidecar_status no Last run, pending items, token usage
sidecar_acknowledge no Suppress item for N days
sidecar_map yes Generate/update project map
sidecar_map_view no Read current map
sidecar_tasks no List tasks by status
sidecar_task_update no Update task status
sidecar_task_create no Create manual task
sidecar_fix yes Generate fix for a task (dry-run or apply)
sidecar_init yes Bootstrap .claude/ for bare projects
sidecar_activity no View recent action log

CLI

python -m cmdop_claude.sidecar.hook setup          # full setup (recommended)
python -m cmdop_claude.sidecar.hook register       # MCP + hooks + Makefile
python -m cmdop_claude.sidecar.hook unregister     # remove MCP from ~/.claude.json
python -m cmdop_claude.sidecar.hook scan           # manual review
python -m cmdop_claude.sidecar.hook status         # status JSON
python -m cmdop_claude.sidecar.hook map-update     # debounced map
python -m cmdop_claude.sidecar.hook inject-tasks   # auto-scan + pending tasks
python -m cmdop_claude.sidecar.hook fix <task_id> [--apply]
python -m cmdop_claude.sidecar.hook init           # bootstrap .claude/
python -m cmdop_claude.sidecar.hook acknowledge <id> [days]
python -m cmdop_claude.sidecar.hook activity [limit]

Python API

from cmdop_claude import Client

client = Client()

result = client.sidecar.generate_review()
fix    = client.sidecar.fix_task("T-001", apply=True)
init   = client.sidecar.init_project()
map_   = client.sidecar.generate_map()

plugins = client.plugins.search("slack", source="official")
client.plugins.install_plugin(plugins[0])

Streamlit Dashboard

make run              # http://localhost:8501
make -C .claude dashboard  # from project with generated Makefile

10 tabs: Health Auditor, Skill Studio, MCP Studio, Plugin Browser, Hooks Manager, Sidecar Monitor, Project Map, Task Queue, Settings & Security, Trigger Graph.

Plugin Browser searches Smithery + Official MCP registries (~1000 plugins) with background index caching. Supports stdio and streamable-http servers.

Health Auditor MCP Studio & Plugins
Plugin Browser Project Map
Task Queue Sidecar Monitor
Hooks Manager Skill Studio
Settings & Security Trigger Graph

Configuration

API Key

Read in this order:

  1. SDKROUTER_API_KEY env var
  2. ~/.claude/cmdop.jsonsdkrouterApiKey (written by setup)
  3. Falls back silently — LLM features skip, read-only tools still work
export SDKROUTER_API_KEY=your-key
# or
echo '{"sdkrouterApiKey": "your-key"}' > ~/.claude/cmdop.json

Environment Variables

Variable Default Description
SDKROUTER_API_KEY LLM backend key
CMDOP_CLAUDE_DIR_PATH .claude Path to .claude directory
CLAUDE_CP_SIDECAR_MODEL deepseek/deepseek-v3.2 Model for review/fix/map
CLAUDE_CP_SMITHERY_API_KEY Smithery registry key (optional)
CMDOP_DEBUG_MODE false Debug logging

Init uses Model.balanced(json=True) from SDKRouter (best model for structured output). Everything else uses DeepSeek V3.2 (cheap, fast).


File Layout

.claude/
├── CLAUDE.md                # project instructions (auto-generated or hand-written)
├── project-map.md           # directory annotations (auto-updated)
├── settings.json            # hooks + plansDirectory
├── Makefile                 # convenience commands
├── rules/*.md               # coding guidelines
├── plans/*.md               # Claude Code plans (project-local)
└── .sidecar/                # runtime state (git-ignored)
    ├── review.md            # latest review output
    ├── history/*.md         # past reviews
    ├── tasks/T-001.md       # task queue (YAML frontmatter + markdown)
    ├── map_cache.json       # SHA256 annotation cache
    ├── merkle_cache.json    # dir hash cache for init tree summarizer
    ├── git_context.json     # own vs external repo classification cache
    ├── plugins_cache.json   # plugin registry index cache
    ├── activity.jsonl       # action log (auto-rotates at 1000 lines)
    ├── usage.json           # daily token tracking
    └── suppressed.json      # acknowledged items

Architecture

src/cmdop_claude/
├── _config.py                  # Pydantic Settings (env vars)
├── _client.py                  # Client entry point (lazy service props)
├── models/
│   ├── base.py                 # CoreModel (strict Pydantic v2)
│   ├── git_context.py          # RepoInfo, GitContext, LLMRepoClassification
│   ├── sidecar.py              # Review, Fix, Init, Map, ActivityEntry
│   ├── project_map.py          # Map annotation models
│   ├── task.py                 # Task queue models
│   ├── mcp.py                  # MCPServerCommand, MCPServerURL, MCPConfig
│   └── plugin.py               # MCPPluginInfo, PluginCache
├── services/
│   ├── plugin_service.py       # Registry search, install, background indexing
│   ├── mcp_service.py          # MCP config read/write
│   └── sidecar_service/
│       ├── _base.py            # State, lock, scan, usage, activity
│       ├── _review.py          # LLM review → review.md
│       ├── _fix.py             # LLM fix for tasks
│       ├── _init.py            # 3-phase project init pipeline
│       ├── _tasks.py           # Task CRUD
│       ├── _mcp.py             # MCP registration + hooks + Makefile
│       └── _status.py          # Status + map access
└── sidecar/
    ├── server.py               # FastMCP server (12 tools)
    ├── hook.py                 # CLI (11 commands)
    ├── git_context.py          # GitContextService — own vs external repo classification
    ├── tree_summarizer.py      # TreeSummarizer — chunked parallel LLM dir analysis
    ├── toon.py                 # TOON serializer — token-efficient tree format
    ├── merkle_cache.py         # MerkleCache — SHA256 dir hashing, skips LLM for unchanged
    ├── mapper.py               # Project map generator
    ├── scanner.py              # .claude/ filesystem scanner
    ├── exclusions.py           # Junk filter + .gitignore integration
    ├── activity.py             # Activity logger (JSONL, auto-rotate)
    ├── cache.py                # SHA256 annotation cache for map
    ├── tasks.py                # Task queue manager
    └── prompts.py              # LLM prompt templates

Cost

Operation Tokens Cost
Documentation review ~1800 ~$0.0005
Fix a task ~500 ~$0.0001
Project init ~5000 ~$0.001
Map generation (45 dirs) ~5000 ~$0.001
Map incremental (cached dirs) 0 $0.00
Init (cached dirs via MerkleCache) 0 $0.00
Auto-scan (1×/day) ~1800 ~$0.0005
Read-only operations 0 $0.00

Full cycle: ~$0.003. Daily estimate: ~$0.001–0.003/day.


Testing

make test   # 364+ tests

License

MIT

Project details


Download files

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

Source Distribution

cmdop_claude-0.1.26.tar.gz (76.0 kB view details)

Uploaded Source

Built Distribution

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

cmdop_claude-0.1.26-py3-none-any.whl (94.5 kB view details)

Uploaded Python 3

File details

Details for the file cmdop_claude-0.1.26.tar.gz.

File metadata

  • Download URL: cmdop_claude-0.1.26.tar.gz
  • Upload date:
  • Size: 76.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for cmdop_claude-0.1.26.tar.gz
Algorithm Hash digest
SHA256 802978d61a5da88a8b969bf3a6b6624f564dc428bc2d2ff11c0d852e734a570a
MD5 c56f791e16a9ca3ef1e98bb91e7704db
BLAKE2b-256 fa61c2a19d147dcc65f962baef3df91822bc6f3108de562e2c93b282fb6834e3

See more details on using hashes here.

File details

Details for the file cmdop_claude-0.1.26-py3-none-any.whl.

File metadata

  • Download URL: cmdop_claude-0.1.26-py3-none-any.whl
  • Upload date:
  • Size: 94.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for cmdop_claude-0.1.26-py3-none-any.whl
Algorithm Hash digest
SHA256 730d9b6154d2bf1df38cba2fe8e803af96ba1bb35476d3209b3c036e4650c6cb
MD5 c7ed042d91e4f7eadafadab9c8fb0cb8
BLAKE2b-256 385738fa2b098f22e41af7f9722f85d77b4b2c7709b036d2da9a78054c2c427c

See more details on using hashes here.

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