Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Kwcode Local Coding Agent

ASecurity

KWCode (天工开物) — a CLI coding agent optimized for local open-source models (8B-30B), featuring deterministic expert pipelines, BM25+AST code location, runtime debugging, and a self-improving flywheel — all running fully offline.

81 stars
0 votes
0 copies
0 views
Added 9/19/2026
ai-agentspythongojavabashsqlvuefastapispringdockerdebugging

Works with

claude codecursorcliapi

Security Analysis

A92/100
mediumUses curl or wget to download content
mediumInstalls packages at runtime which could introduce malicious dependencies

Scanned 9/19/2026

Install to Claude Code

$npx -y skills add reason-machines/trending-skills --skill kwcode-local-coding-agent --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kwcode Local Coding Agent?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Kwcode Local Coding Agent
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/reason-machines-kwcode-local-coding-agent/badge)](https://www.skillsdirectory.com/skills/reason-machines-kwcode-local-coding-agent)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: kwcode-local-coding-agent
description: KWCode (天工开物) — a CLI coding agent optimized for local open-source models (8B-30B), featuring deterministic expert pipelines, BM25+AST code location, runtime debugging, and a self-improving flywheel — all running fully offline.
triggers:
  - set up kwcode for my local model
  - use kwcode to fix a bug in my project
  - run kwcode with deepseek or qwen
  - configure kwcode api endpoint
  - use kwcode multi-task mode
  - install kwcode search enhancement
  - understand kwcode expert pipeline
  - troubleshoot kwcode not finding files
---

# KWCode Local Coding Agent

> Skill by [ara.so](https://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.

---

## Installation

```bash
# 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).

---

## Quick Start

```bash
# Launch interactive REPL
kwcode
```

On first launch, KWCode runs a setup wizard to configure your model connection.

---

## Configuration

### Connect to a local inference engine (Ollama example)

```bash
# Inside kwcode REPL or as a slash command:
/api default http://localhost:11434/v1 ollama qwen3:8b
```

### Connect to a cloud API (no local GPU needed)

```bash
/api default https://api.deepseek.com $DEEPSEEK_API_KEY deepseek-coder
/api default https://api.siliconflow.cn/v1 $SILICONFLOW_API_KEY Qwen/Qwen3-8B
```

### Environment variable approach

```bash
export KWCODE_API_BASE=http://localhost:11434/v1
export KWCODE_API_KEY=ollama
export KWCODE_MODEL=qwen3:8b
kwcode
```

### Recommended models by VRAM

| VRAM | Model |
|------|-------|
| 4 GB | `gemma3:4b` |
| 8 GB | `qwen3:8b` |
| 16 GB | `qwen3:14b` |
| 24 GB+ | `qwen3:30b-a3b` |

---

## Key Commands

All commands are entered inside the `kwcode` REPL (`>`  prompt).

### Core task commands

```
> <natural language task description>
```
```
> 修复登录验证失败的问题
> write a FastAPI login endpoint with JWT auth
> refactor calculate_price into smaller functions
```

### Planning & safety

```
> /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-task orchestration (DAG)

```
> /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)
```

### Search enhancement

```bash
# Install SearXNG (requires Docker Desktop running)
kwcode setup-search
```

```
> /search <query>       # explicit search inside REPL
```

Without Docker, KWCode falls back to DuckDuckGo automatically.

### Statistics & flywheel

```bash
kwcode stats            # CLI command (outside REPL)
```

Shows tasks completed, estimated time saved, and flywheel expert promotions.

### API management

```
> /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
```

---

## Project Configuration Files

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). |

### Example `KWCODE.md`

```markdown
# 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
```

---

## How the Expert Pipeline Works

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.

---

## Code Examples

### Trigger a bugfix task

```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:
1. BM25-locate `user_service.py` + trace call graph for hidden dependencies
2. Generate a minimal patch (only changed lines)
3. Run `pytest` automatically
4. If failing: inject runtime variable values via `sys.settrace` and retry

### Trigger a test generation task

```
> generate pytest tests for the PaymentProcessor class
```

KWCode injects the `TestGen` SKILL.md, locates `PaymentProcessor` via AST, generates tests, and verifies they pass.

### Use the Python API (programmatic access)

```python
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
```

### Multi-task via Python API

```python
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}")
```

---

## Three-Stage Retry Logic

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.

---

## Troubleshooting

### Model returns garbled output or loops

```
/api default <your_base_url> <key> <model>   # re-confirm model name matches server
```

Check that your local inference engine is running:
```bash
curl http://localhost:11434/v1/models        # Ollama
curl http://localhost:8080/v1/models         # llama.cpp / LM Studio
```

### KWCode can't find the right file

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`:
```markdown
## index
- include: ["*.pyx", "*.pxd", "*.proto"]
```

### pytest not found / tests not running

```
> /config verifier.test_cmd "python -m pytest tests/ -x"
```

Or set in `KWCODE.md`:
```markdown
## verifier
- test_cmd: python -m pytest tests/ -x --tb=short
```

### Search not working (DuckDuckGo blocked)

```bash
# Install local SearXNG (requires Docker)
kwcode setup-search

# Verify it's running
curl http://localhost:8080/search?q=test&format=json
```

### Context window overflow with large projects

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
```

### Flywheel expert not promoting

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
```

---

## Skill Domains (SKILL.md Library)

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/`.

---

## Data & Privacy

- **All processing is local.** No code, file contents, or task descriptions leave your machine.
- Model inference: your local engine or your chosen cloud API endpoint only.
- Search: SearXNG self-hosted (recommended) or DuckDuckGo (queries only, no code).
- Statistics: stored in `~/.kwcode/stats.db` (SQLite, local only).
- Reflection/memory files: written to your project directory, fully under your control.

Attribution

reason-machinesreason-machines
View sourceMore from reason-machines →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.

1023331 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

686011 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3331 votes

catchup

Recovers prior coding-agent session context by running `catchup <agent> --since-compact`, which extracts a clean summary of a previous Codex, Claude Code, Antigravity, OpenCode, or Pi Agent session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", or asks to recover/summarize a previous session before continuing. Do NOT use for the current conversation, git history, or any non-agent log.

611 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →