cli-anything
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCLI-Anything Reference
CLI-Anything参考文档
Auto-generates production-ready, agent-controllable CLI interfaces for any GUI application with accessible source code. A 7-phase pipeline maps GUI actions to backend APIs and emits Click-based harnesses with output mode, interactive REPL, and pytest test suites.
--jsonSource: https://github.com/HKUDS/CLI-Anything
License: MIT | Python: 3.10+ | Tests: 1,508 passing across 11 apps
Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.
为任何拥有可访问源代码的GUI应用自动生成可投入生产、由Agent控制的CLI界面。一个7阶段流程会将GUI操作映射到后端API,并生成基于Click的封装工具,支持输出模式、交互式REPL以及pytest测试套件。
--json源码地址:https://github.com/HKUDS/CLI-Anything
许可证:MIT | Python版本要求:3.10+ | 测试情况:在11款应用上完成1508项测试且全部通过
自演进技能:该技能会随使用不断改进。如果说明有误、参数偏移或需要临时解决方案,请立即修改此文件,不要拖延。仅针对真实可复现的问题进行更新。
Installation
安装方法
Method 1: Claude Code Marketplace (recommended)
方法1:Claude Code Marketplace(推荐)
/plugin marketplace add HKUDS/CLI-Anything
/plugin install cli-anything/plugin marketplace add HKUDS/CLI-Anything
/plugin install cli-anythingMethod 2: Manual Claude Code
方法2:手动安装到Claude Code
bash
git clone https://github.com/HKUDS/CLI-Anything.git
cp -r CLI-Anything/cli-anything-plugin ~/.claude/plugins/cli-anythingbash
git clone https://github.com/HKUDS/CLI-Anything.git
cp -r CLI-Anything/cli-anything-plugin ~/.claude/plugins/cli-anythingReload in Claude Code:
在Claude Code中重新加载:
/reload-plugins
undefined/reload-plugins
undefinedMethod 3: OpenCode — global
方法3:OpenCode — 全局安装
bash
git clone https://github.com/HKUDS/CLI-Anything.git
cp CLI-Anything/opencode-commands/*.md ~/.config/opencode/commands/
cp CLI-Anything/cli-anything-plugin/HARNESS.md ~/.config/opencode/commands/bash
git clone https://github.com/HKUDS/CLI-Anything.git
cp CLI-Anything/opencode-commands/*.md ~/.config/opencode/commands/
cp CLI-Anything/cli-anything-plugin/HARNESS.md ~/.config/opencode/commands/Method 4: OpenCode — project-level
方法4:OpenCode — 项目级安装
bash
cp CLI-Anything/opencode-commands/*.md .opencode/commands/
cp CLI-Anything/cli-anything-plugin/HARNESS.md .opencode/commands/bash
cp CLI-Anything/opencode-commands/*.md .opencode/commands/
cp CLI-Anything/cli-anything-plugin/HARNESS.md .opencode/commands/Generating a New CLI Harness
生成新的CLI封装工具
bash
undefinedbash
undefinedFrom local source path
从本地源码路径生成
/cli-anything ./gimp
/cli-anything ./gimp
From GitHub URL (auto-cloned)
从GitHub URL生成(自动克隆)
/cli-anything https://github.com/blender/blender
/cli-anything https://github.com/blender/blender
Claude Code variant (plugin command)
Claude Code插件命令版本
/cli-anything ./inkscape
/cli-anything ./inkscape
OpenCode variant
OpenCode版本
/cli-anything ./libreoffice
---/cli-anything ./libreoffice
---All Commands
所有命令
| Command | Platform | Purpose |
|---|---|---|
| Claude Code | Build full 7-phase harness |
| Claude Code | Expand with gap analysis |
| Claude Code | Run tests + update TEST.md |
| Claude Code | Verify HARNESS.md standards |
| Claude Code | Discover installed CLI-Anything tools |
| OpenCode | Build harness |
| OpenCode | Refine harness |
| OpenCode | Run tests |
| OpenCode | Validate standards |
| OpenCode | List installed tools |
| 命令 | 平台 | 用途 |
|---|---|---|
| Claude Code | 构建完整的7阶段封装工具 |
| Claude Code | 通过差距分析扩展功能 |
| Claude Code | 运行测试并更新TEST.md文件 |
| Claude Code | 验证HARNESS.md标准规范 |
| Claude Code | 发现已安装的CLI-Anything工具 |
| OpenCode | 构建封装工具 |
| OpenCode | 优化封装工具 |
| OpenCode | 运行测试 |
| OpenCode | 验证标准规范 |
| OpenCode | 列出已安装的工具 |
Refinement with Focus
指定方向的优化
bash
undefinedbash
undefinedBroad gap analysis
全面差距分析
/cli-anything:refine ./gimp
/cli-anything:refine ./gimp
Targeted domain expansion
针对性领域扩展
/cli-anything:refine ./gimp "batch processing and filters"
/cli-anything:refine ./blender "rendering pipeline and animations"
/cli-anything:refine ./libreoffice "spreadsheet formulas and macros"
---/cli-anything:refine ./gimp "批量处理与滤镜"
/cli-anything:refine ./blender "渲染流程与动画"
/cli-anything:refine ./libreoffice "电子表格公式与宏"
---Installing a Generated CLI
安装生成的CLI
bash
cd <software>/agent-harness
pip install -e .bash
cd <software>/agent-harness
pip install -e .Verify PATH entry created
验证PATH路径已配置
which cli-anything-gimp
cli-anything-gimp --help
---which cli-anything-gimp
cli-anything-gimp --help
---Using Generated CLIs
使用生成的CLI
All generated CLIs share a consistent interface pattern.
所有生成的CLI都遵循一致的接口模式。
GIMP Example
GIMP示例
bash
undefinedbash
undefinedHelp
查看帮助
cli-anything-gimp --help
cli-anything-gimp --help
Create project
创建项目
cli-anything-gimp project new --width 1920 --height 1080 -o poster.json
cli-anything-gimp project new --width 1920 --height 1080 -o poster.json
Machine-readable JSON output (for agent consumption)
机器可读JSON输出(供Agent使用)
cli-anything-gimp --json layer add -n "Background" --type solid --color "#1a1a2e"
cli-anything-gimp --json layer add -n "Background" --type solid --color "#1a1a2e"
Interactive REPL
交互式REPL
cli-anything-gimp
cli-anything-gimp
Stateful workflow with --project flag
使用--project标记的有状态工作流
cli-anything-gimp --project poster.json layer add -n "Logo" --type group
cli-anything-gimp --project poster.json export render output.png --format png
undefinedcli-anything-gimp --project poster.json layer add -n "Logo" --type group
cli-anything-gimp --project poster.json export render output.png --format png
undefinedLibreOffice Example
LibreOffice示例
bash
undefinedbash
undefinedNew document
新建文档
cli-anything-libreoffice document new -o report.json --type writer
cli-anything-libreoffice document new -o report.json --type writer
Populate document
填充文档内容
cli-anything-libreoffice --project report.json writer add-heading -t "Q1 Report" --level 1
cli-anything-libreoffice --project report.json writer add-table --rows 4 --cols 3
cli-anything-libreoffice --project report.json writer add-heading -t "Q1报告" --level 1
cli-anything-libreoffice --project report.json writer add-table --rows 4 --cols 3
Export
导出
cli-anything-libreoffice --project report.json export render output.pdf -p pdf --overwrite
cli-anything-libreoffice --project report.json export render output.pdf -p pdf --overwrite
JSON output
JSON输出
cli-anything-libreoffice --json document info --project report.json
undefinedcli-anything-libreoffice --json document info --project report.json
undefinedBlender Example
Blender示例
bash
cli-anything-blender scene new -o scene.json
cli-anything-blender --project scene.json object add --type mesh --mesh-type CUBE
cli-anything-blender --project scene.json render image output.png --engine CYCLES
cli-anything-blender --json scene info --project scene.jsonbash
cli-anything-blender scene new -o scene.json
cli-anything-blender --project scene.json object add --type mesh --mesh-type CUBE
cli-anything-blender --project scene.json render image output.png --engine CYCLES
cli-anything-blender --json scene info --project scene.jsonInkscape Example
Inkscape示例
bash
cli-anything-inkscape document new --width 800 --height 600 -o design.json
cli-anything-inkscape --project design.json shape add rect --x 10 --y 10 --w 200 --h 100
cli-anything-inkscape --project design.json export render output.svg
cli-anything-inkscape --json document info --project design.jsonbash
cli-anything-inkscape document new --width 800 --height 600 -o design.json
cli-anything-inkscape --project design.json shape add rect --x 10 --y 10 --w 200 --h 100
cli-anything-inkscape --project design.json export render output.svg
cli-anything-inkscape --json document info --project design.jsonOutput Modes
输出模式
Every command supports two output modes:
| Mode | Usage | Audience |
|---|---|---|
| Human-readable (default) | | Terminal / humans |
| Machine-readable JSON | | AI agents, scripts |
The flag is always the first argument, before any subcommands.
--json每个命令都支持两种输出模式:
| 模式 | 使用方式 | 受众 |
|---|---|---|
| 人类可读模式(默认) | | 终端用户 / 人类 |
| 机器可读JSON模式 | | AI Agent、脚本 |
--jsonInteractive REPL
交互式REPL
Enter by running the CLI with no subcommands:
bash
cli-anything-gimp
cli-anything-blender
cli-anything-libreofficeREPL features:
- 50-level undo/redo stack
- Persistent command history
- ANSI 256-color output (software-specific accent colors)
- Table rendering, progress indicators
- All subcommands available interactively
运行不带任何子命令的CLI即可进入:
bash
cli-anything-gimp
cli-anything-blender
cli-anything-libreofficeREPL特性:
- 50级撤销/重做栈
- 持久化命令历史
- ANSI 256色输出(软件专属强调色)
- 表格渲染、进度指示器
- 所有子命令均可在交互式环境中使用
Running Tests
运行测试
bash
undefinedbash
undefinedStandard pytest run
标准pytest运行
cd <software>/agent-harness
python3 -m pytest cli_anything/<software>/tests/ -v
cd <software>/agent-harness
python3 -m pytest cli_anything/<software>/tests/ -v
Validate the installed binary is invoked (not just the module)
验证调用的是已安装的二进制文件(而非仅模块)
CLI_ANYTHING_FORCE_INSTALLED=1 python3 -m pytest cli_anything/<software>/tests/ -v -s
CLI_ANYTHING_FORCE_INSTALLED=1 python3 -m pytest cli_anything/<software>/tests/ -v -s
Coverage
覆盖率测试
python3 -m pytest cli_anything/<software>/tests/ --cov=cli_anything/<software>
python3 -m pytest cli_anything/<software>/tests/ --cov=cli_anything/<software>
Per-software examples
各软件示例
cd gimp/agent-harness && python3 -m pytest cli_anything/gimp/tests/ -v
cd blender/agent-harness && python3 -m pytest cli_anything/blender/tests/ -v
cd libreoffice/agent-harness && python3 -m pytest cli_anything/libreoffice/tests/ -v
---cd gimp/agent-harness && python3 -m pytest cli_anything/gimp/tests/ -v
cd blender/agent-harness && python3 -m pytest cli_anything/blender/tests/ -v
cd libreoffice/agent-harness && python3 -m pytest cli_anything/libreoffice/tests/ -v
---Environment Variables
环境变量
| Variable | Purpose |
|---|---|
| Forces tests to use the real installed binary (validates |
| 变量 | 用途 |
|---|---|
| 强制测试使用真实安装的二进制文件(验证 |
Supported Applications (11 total, 1,508 tests)
支持的应用(共11款,1508项测试)
| Application | Category | Entry Point |
|---|---|---|
| GIMP | Creative (raster) | |
| Blender | Creative (3D) | |
| Inkscape | Creative (vector) | |
| Audacity | Media (audio) | |
| LibreOffice | Productivity | |
| OBS Studio | Media (streaming) | |
| Kdenlive | Media (video) | |
| Shotcut | Media (video) | |
| Zoom | Communication | |
| Draw.io | Diagramming | |
| AnyGen | AI Content | |
| 应用程序 | 分类 | 入口命令 |
|---|---|---|
| GIMP | 创意工具(光栅图) | |
| Blender | 创意工具(3D) | |
| Inkscape | 创意工具(矢量图) | |
| Audacity | 媒体工具(音频) | |
| LibreOffice | 生产力工具 | |
| OBS Studio | 媒体工具(流媒体) | |
| Kdenlive | 媒体工具(视频) | |
| Shotcut | 媒体工具(视频) | |
| Zoom | 通讯工具 | |
| Draw.io | 图表工具 | |
| AnyGen | AI内容生成 | |
The 7-Phase Pipeline (HARNESS.md)
7阶段流程(HARNESS.md)
What triggers under the hood:
/cli-anything| Phase | Name | What happens |
|---|---|---|
| 1 | Source Acquisition | Accept local path or GitHub URL; clone if needed |
| 2 | Codebase Analysis | Map GUI actions → backend APIs; inventory existing CLI tools; document data model |
| 3 | CLI Architecture Design | Choose interaction model (stateful REPL + subcommand); define command groups; plan |
| 4 | Implementation | Build Click-based CLI with |
| 5 | Test Planning | Write |
| 6 | Test Implementation | Unit tests (synthetic data) + E2E tests (real software output) + subprocess tests |
| 7 | PyPI Publishing | |
Fundamental Rule: The CLI MUST delegate rendering to the real software — never reimplement functionality in Python. The target software is a hard dependency.
/cli-anything| 阶段 | 名称 | 执行内容 |
|---|---|---|
| 1 | 源码获取 | 接受本地路径或GitHub URL;需要时自动克隆 |
| 2 | 代码库分析 | 映射GUI操作→后端API;盘点现有CLI工具;记录数据模型 |
| 3 | CLI架构设计 | 选择交互模型(有状态REPL + 子命令);定义命令组;规划 |
| 4 | 实现 | 构建基于Click的CLI,使用 |
| 5 | 测试规划 | 在编写代码前先编写 |
| 6 | 测试实现 | 单元测试(合成数据)+ 端到端测试(真实软件输出)+ 子进程测试 |
| 7 | PyPI发布 | 配置 |
核心规则:CLI必须将渲染任务委托给真实软件——绝不能在Python中重新实现功能。目标软件是硬依赖。
Generated Harness Structure
生成的封装工具结构
Each generated CLI follows this layout (PEP 420 namespace packages):
<software>/agent-harness/
├── setup.py # find_namespace_packages(), entry_points
├── <SOFTWARE>.md # Software-specific SOP
└── cli_anything/ # NO __init__.py (namespace package)
└── <software>/
├── __init__.py
├── __main__.py
├── <software>_cli.py # Main Click entry point
├── core/ # Domain modules (project, session, export, ...)
├── utils/
│ └── repl_skin.py # Shared REPL UI (copied from plugin)
└── tests/
├── TEST.md # Test inventory (written in phase 5)
├── test_core.py # Unit tests
└── test_full_e2e.py # E2E + subprocess testsWhy namespace packages: has no , enabling multiple separately-installed CLIs to coexist under the same namespace without conflict.
cli_anything/__init__.pycli_anything.*每个生成的CLI都遵循此布局(PEP 420命名空间包):
<software>/agent-harness/
├── setup.py # 配置find_namespace_packages()和entry_points
├── <SOFTWARE>.md # 软件专属操作手册
└── cli_anything/ # 无__init__.py(命名空间包)
└── <software>/
├── __init__.py
├── __main__.py
├── <software>_cli.py # 主Click入口
├── core/ # 领域模块(项目、会话、导出等)
├── utils/
│ └── repl_skin.py # 共享REPL UI(从插件复制)
└── tests/
├── TEST.md # 测试清单(第5阶段编写)
├── test_core.py # 单元测试
└── test_full_e2e.py # 端到端测试+子进程测试为什么使用命名空间包:没有,允许多个独立安装的CLI共存于同一命名空间下,避免冲突。
cli_anything/__init__.pycli_anything.*Output Verification Standards
输出验证标准
Tests verify real output using magic bytes and content analysis:
| Output Type | Verification |
|---|---|
| |
| OOXML (.docx, .xlsx) | ZIP structure validation |
| CSV | Data row count + column check |
| Images | Pillow pixel value analysis |
| Audio | RMS level check (non-silent) |
测试通过魔术字节和内容分析验证真实输出:
| 输出类型 | 验证方式 |
|---|---|
检查 | |
| OOXML(.docx, .xlsx) | ZIP结构验证 |
| CSV | 数据行数检查 + 列校验 |
| 图片 | Pillow像素值分析 |
| 音频 | RMS电平检查(非静音) |
Prerequisites Checklist
前置条件检查清单
Before running :
/cli-anything <path>- Python 3.10+ installed
- Target software installed (hard dependency — it will be called for rendering)
- Source code accessible (local path or public GitHub URL)
- available (installed via
click>=8.0.0)pip install -e . - ,
Pillow>=10.0.0availableprompt-toolkit>=3.0.0 - available for running tests
pytest
运行前请确认:
/cli-anything <path>- 已安装Python 3.10+
- 已安装目标软件(硬依赖——渲染时会调用它)
- 可访问源代码(本地路径或公开GitHub URL)
- 可用(通过
click>=8.0.0安装)pip install -e . - 可用、
Pillow>=10.0.0prompt-toolkit>=3.0.0 - 可用运行测试
pytest
Key Files Reference
关键文件参考
| File | Purpose |
|---|---|
| Complete methodology document (30K chars) |
| Quick start guide |
| Shared REPL UI class (18K, ANSI 256-color) |
| |
| |
| |
| |
| |
| 文件 | 用途 |
|---|---|
| 完整方法文档(3万字) |
| 快速入门指南 |
| 共享REPL UI类(1.8万行,ANSI 256色) |
| |
| |
| |
| |
| |
Post-Execution Reflection
执行后反思
After this skill completes, check before closing:
- Did the command succeed? — If not, fix the instruction or error table that caused the failure.
- Did parameters or output change? — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
- Was a workaround needed? — If you had to improvise (different flags, extra steps), update this SKILL.md so the next invocation doesn't need the same workaround.
Only update if the issue is real and reproducible — not speculative.
完成此技能操作后,关闭前请检查:
- 命令是否成功? —— 如果失败,请修正导致失败的说明或错误表。
- 参数或输出是否有变化? —— 如果底层工具的接口发生偏移,请更新使用示例和参数表以匹配。
- 是否需要临时解决方案? —— 如果必须临时变通(使用不同标记、额外步骤),请更新此SKILL.md,避免下次调用时需要相同的变通方法。
仅针对真实可复现的问题进行更新——不要基于推测修改。