Runs a CLI coding agent for local open-source models (8B-30B) with deterministic expert pipelines, BM25+AST code search, and runtime debugging, fully offline.
Ships in aradotso-trending-skills-37. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Skill by ara.so — Daily 2026 Skills collection.
KWCode is a CLI coding agent designed specifically for local open-source models (8B–30B parameters). Unlike cloud-first agents (Claude Code, Cursor), KWCode uses a deterministic expert pipeline where the LLM only classifies and generates — all routing, validation, and decision-making is handled by deterministic code. This lets small models succeed where they would otherwise hallucinate or loop.
# Standard install
pip install kwcode
# China mirror (faster in mainland)
pip install kwcode -i https://pypi.tuna.tsinghua.edu.cn/simple
# Optional: Cross-Encoder search reranking
pip install "kwcode[rerank]"
Requirements: Python 3.10+, any OpenAI-compatible API (local or cloud).
# Launch interactive REPL
kwcode
On first launch, KWCode runs a setup wizard to configure your model connection.
# Inside kwcode REPL or as a slash command:
/api default http://localhost:11434/v1 ollama qwen3:8b
/api default https://api.deepseek.com $DEEPSEEK_API_KEY deepseek-coder
/api default https://api.siliconflow.cn/v1 $SILICONFLOW_API_KEY Qwen/Qwen3-8B
export KWCODE_API_BASE=http://localhost:11434/v1
export KWCODE_API_KEY=ollama
export KWCODE_MODEL=qwen3:8b
kwcode
| VRAM | Model |
|---|---|
| 4 GB | gemma3:4b |
| 8 GB | qwen3:8b |
| 16 GB | qwen3:14b |
| 24 GB+ | qwen3:30b-a3b |
All commands are entered inside the kwcode REPL (> prompt).
> <natural language task description>
> 修复登录验证失败的问题
> write a FastAPI login endpoint with JWT auth
> refactor calculate_price into smaller functions
> /plan <task description>
Shows execution steps and risk level (High / Medium / Low) before touching any file. Requires confirmation.
> /checkpoint
Manually snapshot current project state. KWCode also auto-snapshots before each task.
> /rollback
Restore to the last checkpoint if a task goes wrong.
> /multi task1 ; task2 ; task3 # all parallel
> /multi task1 -> task2 -> task3 # serial chain
> /multi # interactive builder
Interactive multi-task example:
> /multi
+ add docstring to function `add` (parallel)
+ add docstring to function `sub` (parallel)
+ >write tests for the modified code (serial, depends on above two)
# Install SearXNG (requires Docker Desktop running)
kwcode setup-search
> /search <query> # explicit search inside REPL
Without Docker, KWCode falls back to DuckDuckGo automatically.
kwcode stats # CLI command (outside REPL)
Shows tasks completed, estimated time saved, and flywheel expert promotions.
> /api list # show configured endpoints
> /api default <base_url> <key> [model] # set default endpoint
> /api add <name> <base_url> <key> # add named endpoint
> /api use <name> # switch active endpoint
KWCode looks for these files in your project root and injects them as context:
| File | Purpose |
|---|---|
KWCODE.md | Project-level rules, conventions, coding standards. Injected per task type. |
PROJECT.md | Auto-maintained project summary (Layer 1 memory). |
EXPERT.md | Domain expert knowledge accumulated by the flywheel (Layer 2). |
PATTERN.md | Recurring code patterns learned from your project (Layer 3). |
REFLECTION.md | Structured log of past failures and lessons (auto-updated). |
KWCODE.md# Project Rules
## bugfix
- Always run `pytest tests/` after any fix
- Never modify migration files directly
## codegen
- Use `async def` for all new route handlers
- Import order: stdlib → third-party → local
## general
- Line length: 88 (black default)
- All new functions must have type hints
Every user input flows through five deterministic stages:
Input
└─► Gate — classifies task, routes to skill, matches domain knowledge
└─► Locator — BM25 keyword recall + AST call-graph expansion (no LLM)
└─► Generator — generates only the changed diff, injects SKILL.md
└─► Verifier — syntax check + pytest (deterministic)
└─► Debugger — sys.settrace captures live variable values
└─► Reviewer — LLM checks intent vs actual change
The LLM is only called at Generator and Reviewer stages. Everything else is deterministic Python.
# KWCode detects "bug", "fix", "error", "失败" → routes to BugFix expert
# Inside REPL:
# > fix the KeyError in user_service.py when email is missing
KWCode will:
user_service.py + trace call graph for hidden dependenciespytest automaticallysys.settrace and retry> generate pytest tests for the PaymentProcessor class
KWCode injects the TestGen SKILL.md, locates PaymentProcessor via AST, generates tests, and verifies they pass.
from kwcode import KWCodeAgent
agent = KWCodeAgent(
api_base="http://localhost:11434/v1",
api_key="ollama",
model="qwen3:8b",
project_dir="/path/to/your/project",
)
result = agent.run("fix the login validation bug")
print(result.status) # "success" | "failed" | "rolled_back"
print(result.files_changed) # list of modified file paths
print(result.patch) # unified diff string
from kwcode import KWCodeAgent, TaskGraph
agent = KWCodeAgent(model="qwen3:14b", project_dir=".")
graph = TaskGraph()
t1 = graph.add("add type hints to utils.py")
t2 = graph.add("add type hints to models.py")
t3 = graph.add("write tests for typed functions", depends_on=[t1, t2])
results = agent.run_graph(graph)
for task_id, result in results.items():
print(f"{task_id}: {result.status}")
When Verifier fails, KWCode does not repeat the same attempt:
| Attempt | Strategy |
|---|---|
| 1st | Normal task description sent to Generator |
| 2nd | Error message + sys.settrace runtime variable dump injected; LLM reflects on why attempt 1 failed |
| 3rd | Minimal-change constraint enforced; Debug Subagent provides full pytest --tb=long trace |
After 3 failures, task is marked failed and rolled back to checkpoint.
/api default <your_base_url> <key> <model> # re-confirm model name matches server
Check that your local inference engine is running:
curl http://localhost:11434/v1/models # Ollama
curl http://localhost:8080/v1/models # llama.cpp / LM Studio
BM25 needs indexed content. If your project is new:
> /index # force re-index project files
If the file uses an unusual extension, add it to KWCODE.md:
## index
- include: ["*.pyx", "*.pxd", "*.proto"]
> /config verifier.test_cmd "python -m pytest tests/ -x"
Or set in KWCODE.md:
## verifier
- test_cmd: python -m pytest tests/ -x --tb=short
# Install local SearXNG (requires Docker)
kwcode setup-search
# Verify it's running
curl http://localhost:8080/search?q=test&format=json
KWCode auto-compresses context when it approaches the limit, but you can tune aggressiveness:
> /config context.compression_ratio 0.6 # keep 60% of mid-conversation history
> /config locator.max_files 3 # limit files sent to Generator
Promotion requires: ≥5 successes of the same task type → backtest pass rate ≥ baseline → 10-run A/B test with >10% improvement. Check flywheel status:
kwcode stats --flywheel
KWCode ships with 15 built-in domain skills injected at Generator stage:
| Skill | Triggers |
|---|---|
BugFix | fix, bug, error, crash, 修复 |
FastAPI | fastapi, route, endpoint, async |
TestGen | test, pytest, unittest, 测试 |
API | api, rest, http, request |
DeepSeekAPI | deepseek, r1, v3 |
Docstring | docstring, document, 注释 |
MyBatis | mybatis, mapper, xml, sql |
Office | excel, word, ppt, spreadsheet |
Refactor | refactor, clean, extract, 重构 |
SpringBoot | spring, springboot, java |
SQLOpt | sql, query, optimize, index |
TypeHint | type hint, annotation, mypy |
UniApp | uniapp, vue, miniprogram |
Custom skills can be added by placing a SKILL_<name>.md file in your project root or ~/.kwcode/skills/.
~/.kwcode/stats.db (SQLite, local only).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/aradotso-trending-skills-37:kwcode-local-coding-agentfrom aradotso-trending-skills-37
aradotso-trending-skills-37@cascade-ai-ml-agents-misc-1 is listed by joshuarweaver/cascade-ai-ml-agents-misc-1 — review the source before installing
npx claudepluginhub joshuarweaver/cascade-ai-ml-agents-misc-1 --plugin aradotso-trending-skills-37496 skills in this plugin
/3dsvg-interactive-reactTurn SVGs into interactive React 3D components using the 3dsvg library and visual editor/724-office-ai-agentSelf-evolving AI agent system with 26 tools, three-layer memory, MCP plugins, and 24/7 self-repair in pure Python./acgti-anime-persona-quizACG Type Indicator — MBTI-inspired anime character persona quiz built with Vue 3, TypeScript, and ViteOther plugins' skills for the same job