跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 kwcode-local-coding-agent

Kwcode 本地编码代理

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.

214 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

官方 description 用英文写明「Kwcode 本地编码代理」做什么。中文介绍不改写这段原文,能力边界以文件结构与下方原文为准。

何时用

官方 description 未单独写出 Use when。按规范,代理会在用户任务与这段 description 的关键词匹配时激活本技能。

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:KWCode Local Coding Agent、Installation、Standard install、China mirror (faster in mainland)、Optional: Cross-Encoder search reranking、Quick Start。 其中含规范建议的小节:输入输出示例。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

KWCode Local Coding AgentInstallationStandard installChina mirror (faster in mainland)Optional: Cross-Encoder search rerankingQuick StartLaunch interactive REPLConfigurationConnect to a local inference engine (Ollama example)Inside kwcode REPL or as a slash command:Connect to a cloud API (no local GPU needed)Environment variable approach

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
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.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「kwcode-local-coding-agent」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-78e9c74a86ef3f06-Kwcode-%E6%9C%AC%E5%9C%B0%E7%BC%96%E7%A0%81%E4%BB%A3%E7%90%86.html
请存为 .cursor/skills/kwcode-local-coding-agent/SKILL.md 或 .claude/skills/kwcode-local-coding-agent/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/reason-machines/trending-skills' --list

npx skills add 'https://github.com/reason-machines/trending-skills' --skill 'kwcode-local-coding-agent'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- 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 ``` > ``` ``` > 修复登录验证失败的问题 > write a FastAPI login endpoint with JWT auth > refactor calculate_price into smaller functions ``` ### Planning & safety ``` > /plan ``` 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 # 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 [model] # set default endpoint > /api add # add named endpoint > /api use # 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 # 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_.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.

相关技能

Agent 工作流

技能创建者Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

克劳德胡布Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

团队指挥Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

超级力量Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…