claw-code-harness
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaw Code Harness
Claw Code Harness
Skill by ara.so — Daily 2026 Skills collection.
Claw Code is a clean-room Python (with Rust port in progress) rewrite of the Claude Code agent harness. It provides tooling to inspect the port manifest, enumerate subsystems, audit parity against an archived source, and query tool/command inventories — all via a CLI entrypoint and importable Python modules.
由ara.so开发的Skill — 属于2026年度Skill合集。
Claw Code是Claude Code Agent Harness的干净实现Python重写版本(Rust移植版本正在开发中)。它提供了用于检查移植清单、枚举子系统、对照归档源进行一致性审计、查询工具/命令清单的能力,所有功能都可以通过CLI入口点调用,也可作为Python模块导入使用。
Installation
安装
bash
undefinedbash
undefinedClone the repository
Clone the repository
git clone https://github.com/instructkr/claw-code.git
cd claw-code
git clone https://github.com/instructkr/claw-code.git
cd claw-code
Install dependencies (standard library only for core; extras for dev)
Install dependencies (standard library only for core; extras for dev)
pip install -r requirements.txt # if present, else no external deps required
pip install -r requirements.txt # if present, else no external deps required
Verify the workspace
Verify the workspace
python3 -m unittest discover -s tests -v
No PyPI package yet — use directly from source.
---python3 -m unittest discover -s tests -v
目前还没有发布PyPI包,请直接从源码安装使用。
---Repository Layout
仓库结构
.
├── src/
│ ├── __init__.py
│ ├── commands.py # Python-side command port metadata
│ ├── main.py # CLI entrypoint
│ ├── models.py # Dataclasses: Subsystem, Module, BacklogState
│ ├── port_manifest.py # Current Python workspace structure summary
│ ├── query_engine.py # Renders porting summary from active workspace
│ ├── task.py # Task primitives
│ └── tools.py # Python-side tool port metadata
└── tests/ # Unittest suite.
├── src/
│ ├── __init__.py
│ ├── commands.py # Python-side command port metadata
│ ├── main.py # CLI entrypoint
│ ├── models.py # Dataclasses: Subsystem, Module, BacklogState
│ ├── port_manifest.py # Current Python workspace structure summary
│ ├── query_engine.py # Renders porting summary from active workspace
│ ├── task.py # Task primitives
│ └── tools.py # Python-side tool port metadata
└── tests/ # Unittest suiteCLI Reference
CLI参考
All commands are invoked via .
python3 -m src.main <command>所有命令都通过 调用。
python3 -m src.main <command>summary
summarysummary
summaryRender the full Python porting summary.
bash
python3 -m src.main summary生成完整的Python移植进展汇总。
bash
python3 -m src.main summarymanifest
manifestmanifest
manifestPrint the current Python workspace manifest (file surface + subsystem names).
bash
python3 -m src.main manifest打印当前Python工作区清单(文件范围+子系统名称)。
bash
python3 -m src.main manifestsubsystems
subsystemssubsystems
subsystemsList known subsystems, with optional limit.
bash
python3 -m src.main subsystems
python3 -m src.main subsystems --limit 16列出已知子系统,支持可选的数量限制参数。
bash
python3 -m src.main subsystems
python3 -m src.main subsystems --limit 16commands
commandscommands
commandsInspect mirrored command inventory.
bash
python3 -m src.main commands
python3 -m src.main commands --limit 10查看已同步的命令清单。
bash
python3 -m src.main commands
python3 -m src.main commands --limit 10tools
toolstools
toolsInspect mirrored tool inventory.
bash
python3 -m src.main tools
python3 -m src.main tools --limit 10查看已同步的工具清单。
bash
python3 -m src.main tools
python3 -m src.main tools --limit 10parity-audit
parity-auditparity-audit
parity-auditRun parity audit against a locally present (gitignored) archived snapshot.
bash
python3 -m src.main parity-auditRequires the local archive to be present at its expected path (not tracked in git).
对照本地存在的(已加入gitignore的)归档快照运行一致性审计。
bash
python3 -m src.main parity-audit需要本地归档文件存在于预期路径(不会被Git追踪)。
Core Modules & API
核心模块与API
src/models.py
— Dataclasses
src/models.pysrc/models.py
— 数据类
src/models.pypython
from src.models import Subsystem, Module, BacklogStatepython
from src.models import Subsystem, Module, BacklogStateA subsystem groups related modules
A subsystem groups related modules
sub = Subsystem(name="tool-harness", modules=[], status="in-progress")
sub = Subsystem(name="tool-harness", modules=[], status="in-progress")
A module represents a single ported file
A module represents a single ported file
mod = Module(name="tools.py", ported=True, notes="tool metadata only")
mod = Module(name="tools.py", ported=True, notes="tool metadata only")
BacklogState tracks overall port progress
BacklogState tracks overall port progress
state = BacklogState(
total_subsystems=8,
ported=5,
backlog=3,
notes="runtime slices pending"
)
undefinedstate = BacklogState(
total_subsystems=8,
ported=5,
backlog=3,
notes="runtime slices pending"
)
undefinedsrc/tools.py
— Tool Port Metadata
src/tools.pysrc/tools.py
— 工具移植元数据
src/tools.pypython
from src.tools import get_tools, ToolMeta
tools: list[ToolMeta] = get_tools()
for t in tools[:5]:
print(t.name, t.ported, t.description)python
from src.tools import get_tools, ToolMeta
tools: list[ToolMeta] = get_tools()
for t in tools[:5]:
print(t.name, t.ported, t.description)src/commands.py
— Command Port Metadata
src/commands.pysrc/commands.py
— 命令移植元数据
src/commands.pypython
from src.commands import get_commands, CommandMeta
commands: list[CommandMeta] = get_commands()
for c in commands[:5]:
print(c.name, c.ported)python
from src.commands import get_commands, CommandMeta
commands: list[CommandMeta] = get_commands()
for c in commands[:5]:
print(c.name, c.ported)src/query_engine.py
— Porting Summary Renderer
src/query_engine.pysrc/query_engine.py
— 移植汇总渲染器
src/query_engine.pypython
from src.query_engine import render_summary
summary_text: str = render_summary()
print(summary_text)python
from src.query_engine import render_summary
summary_text: str = render_summary()
print(summary_text)src/port_manifest.py
— Manifest Access
src/port_manifest.pysrc/port_manifest.py
— 清单访问模块
src/port_manifest.pypython
from src.port_manifest import get_manifest, ManifestEntry
entries: list[ManifestEntry] = get_manifest()
for entry in entries:
print(entry.path, entry.status)python
from src.port_manifest import get_manifest, ManifestEntry
entries: list[ManifestEntry] = get_manifest()
for entry in entries:
print(entry.path, entry.status)Common Patterns
常用使用模式
Pattern 1: Check how many tools are ported
模式1:统计已完成移植的工具数量
python
from src.tools import get_tools
tools = get_tools()
ported = [t for t in tools if t.ported]
print(f"{len(ported)}/{len(tools)} tools ported")python
from src.tools import get_tools
tools = get_tools()
ported = [t for t in tools if t.ported]
print(f"{len(ported)}/{len(tools)} tools ported")Pattern 2: Find unported subsystems
模式2:查找未移植的子系统
python
from src.port_manifest import get_manifest
backlog = [e for e in get_manifest() if e.status != "ported"]
for entry in backlog:
print(f"BACKLOG: {entry.path}")python
from src.port_manifest import get_manifest
backlog = [e for e in get_manifest() if e.status != "ported"]
for entry in backlog:
print(f"BACKLOG: {entry.path}")Pattern 3: Programmatic summary pipeline
模式3:程序化生成汇总流水线
python
from src.query_engine import render_summary
from src.commands import get_commands
from src.tools import get_tools
print("=== Summary ===")
print(render_summary())
print("\n=== Commands ===")
for c in get_commands(limit=5):
print(f" {c.name}: ported={c.ported}")
print("\n=== Tools ===")
for t in get_tools(limit=5):
print(f" {t.name}: ported={t.ported}")python
from src.query_engine import render_summary
from src.commands import get_commands
from src.tools import get_tools
print("=== Summary ===")
print(render_summary())
print("\n=== Commands ===")
for c in get_commands(limit=5):
print(f" {c.name}: ported={c.ported}")
print("\n=== Tools ===")
for t in get_tools(limit=5):
print(f" {t.name}: ported={t.ported}")Pattern 4: Run tests before contributing
模式4:贡献代码前运行测试
bash
python3 -m unittest discover -s tests -vbash
python3 -m unittest discover -s tests -vPattern 5: Using as part of an OmX/agent workflow
模式5:在OmX/Agent工作流中使用
bash
undefinedbash
undefinedGenerate summary artifact for an agent to consume
Generate summary artifact for an agent to consume
python3 -m src.main summary > /tmp/claw_summary.txt
python3 -m src.main summary > /tmp/claw_summary.txt
Feed into another agent tool or diff against previous checkpoint
Feed into another agent tool or diff against previous checkpoint
diff /tmp/claw_summary_prev.txt /tmp/claw_summary.txt
---diff /tmp/claw_summary_prev.txt /tmp/claw_summary.txt
---Rust Port (In Progress)
Rust移植(开发中)
Switch to the Rust branch
Switch to the Rust branch
git fetch origin dev/rust
git checkout dev/rust
git fetch origin dev/rust
git checkout dev/rust
Build (requires Rust toolchain: https://rustup.rs)
Build (requires Rust toolchain: https://rustup.rs)
cargo build
cargo build
Run
Run
cargo run -- summary
> The Rust port aims for a faster, memory-safe harness runtime. It is **not yet merged** into main. Until then, use the Python implementation for all production workflows.
---cargo run -- summary
> Rust版本的目标是提供更快、内存安全的Harness运行时。目前**尚未合并**到主分支。在此之前,所有生产工作流请使用Python实现版本。
---Troubleshooting
故障排查
| Problem | Cause | Fix |
|---|---|---|
| Running from wrong directory | |
| Local snapshot not present | Place the archive at the expected local path (see |
| Tests fail with import errors | Missing | Ensure |
| Old checkout | |
| Rust build fails | Toolchain not installed | Run |
| 问题 | 原因 | 解决方法 |
|---|---|---|
| 运行命令的目录错误 | 切换到仓库根目录,再运行 |
| 本地不存在快照文件 | 将归档文件放到预期的本地路径(路径常量可查看 |
| 测试运行失败并提示导入错误 | 缺少 | 确保 |
| 本地代码版本过旧 | 执行 |
| Rust构建失败 | 未安装Rust工具链 | 运行 |
Key Design Notes for AI Agents
给AI Agent的核心设计说明
- No external runtime dependencies for the core Python modules — safe to run in sandboxed environments.
- is the single aggregation point — prefer it over calling individual modules when you need a full picture.
query_engine.py - dataclasses are the canonical data shapes; always import types from there, not inline dicts.
models.py - is read-only — it does not modify any tracked files.
parity-audit - The project is not affiliated with Anthropic and contains no proprietary Claude Code source.
- 核心Python模块无外部运行时依赖 — 可安全在沙箱环境中运行。
- 是唯一的聚合入口 — 当你需要获取完整信息时,优先使用它而不是调用单独的模块。
query_engine.py - 中的数据类是官方定义的数据结构;请始终从这里导入类型,不要使用内联字典。
models.py - 是只读的 — 不会修改任何被追踪的文件。
parity-audit - 本项目与Anthropic无关联,不包含任何Claude Code的专有源码。