cli-anything

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

CLI-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
--json
output mode, interactive REPL, and pytest test suites.
Source: 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的封装工具,支持
--json
输出模式、交互式REPL以及pytest测试套件。
源码地址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-anything

Method 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-anything
bash
git clone https://github.com/HKUDS/CLI-Anything.git
cp -r CLI-Anything/cli-anything-plugin ~/.claude/plugins/cli-anything

Reload in Claude Code:

在Claude Code中重新加载:

/reload-plugins
undefined
/reload-plugins
undefined

Method 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
undefined
bash
undefined

From local source path

从本地源码路径生成

/cli-anything ./gimp
/cli-anything ./gimp

From GitHub URL (auto-cloned)

从GitHub URL生成(自动克隆)

Claude Code variant (plugin command)

Claude Code插件命令版本

/cli-anything ./inkscape
/cli-anything ./inkscape

OpenCode variant

OpenCode版本

/cli-anything ./libreoffice

---
/cli-anything ./libreoffice

---

All Commands

所有命令

CommandPlatformPurpose
/cli-anything <path-or-url>
Claude CodeBuild full 7-phase harness
/cli-anything:refine <path> [focus]
Claude CodeExpand with gap analysis
/cli-anything:test <path-or-url>
Claude CodeRun tests + update TEST.md
/cli-anything:validate <path-or-url>
Claude CodeVerify HARNESS.md standards
/cli-anything:list [--path dir] [--depth n] [--json]
Claude CodeDiscover installed CLI-Anything tools
/cli-anything ./gimp
OpenCodeBuild harness
/cli-anything-refine ./gimp
OpenCodeRefine harness
/cli-anything-test ./gimp
OpenCodeRun tests
/cli-anything-validate ./gimp
OpenCodeValidate standards
/cli-anything-list
OpenCodeList installed tools
命令平台用途
/cli-anything <path-or-url>
Claude Code构建完整的7阶段封装工具
/cli-anything:refine <path> [focus]
Claude Code通过差距分析扩展功能
/cli-anything:test <path-or-url>
Claude Code运行测试并更新TEST.md文件
/cli-anything:validate <path-or-url>
Claude Code验证HARNESS.md标准规范
/cli-anything:list [--path dir] [--depth n] [--json]
Claude Code发现已安装的CLI-Anything工具
/cli-anything ./gimp
OpenCode构建封装工具
/cli-anything-refine ./gimp
OpenCode优化封装工具
/cli-anything-test ./gimp
OpenCode运行测试
/cli-anything-validate ./gimp
OpenCode验证标准规范
/cli-anything-list
OpenCode列出已安装的工具

Refinement with Focus

指定方向的优化

bash
undefined
bash
undefined

Broad 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
undefined
bash
undefined

Help

查看帮助

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
undefined
cli-anything-gimp --project poster.json layer add -n "Logo" --type group cli-anything-gimp --project poster.json export render output.png --format png
undefined

LibreOffice Example

LibreOffice示例

bash
undefined
bash
undefined

New 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
undefined
cli-anything-libreoffice --json document info --project report.json
undefined

Blender 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.json
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.json

Inkscape 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.json

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

Output Modes

输出模式

Every command supports two output modes:
ModeUsageAudience
Human-readable (default)
cli-anything-gimp layer add ...
Terminal / humans
Machine-readable JSON
cli-anything-gimp --json layer add ...
AI agents, scripts
The
--json
flag is always the first argument, before any subcommands.

每个命令都支持两种输出模式:
模式使用方式受众
人类可读模式(默认)
cli-anything-gimp layer add ...
终端用户 / 人类
机器可读JSON模式
cli-anything-gimp --json layer add ...
AI Agent、脚本
--json
标记始终是第一个参数,位于所有子命令之前。

Interactive REPL

交互式REPL

Enter by running the CLI with no subcommands:
bash
cli-anything-gimp
cli-anything-blender
cli-anything-libreoffice
REPL 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-libreoffice
REPL特性:
  • 50级撤销/重做栈
  • 持久化命令历史
  • ANSI 256色输出(软件专属强调色)
  • 表格渲染、进度指示器
  • 所有子命令均可在交互式环境中使用

Running Tests

运行测试

bash
undefined
bash
undefined

Standard 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

环境变量

VariablePurpose
CLI_ANYTHING_FORCE_INSTALLED=1
Forces tests to use the real installed binary (validates
which cli-anything-<software>
resolves correctly, not just module import)

变量用途
CLI_ANYTHING_FORCE_INSTALLED=1
强制测试使用真实安装的二进制文件(验证
which cli-anything-<software>
能正确解析,而非仅模块导入)

Supported Applications (11 total, 1,508 tests)

支持的应用(共11款,1508项测试)

ApplicationCategoryEntry Point
GIMPCreative (raster)
cli-anything-gimp
BlenderCreative (3D)
cli-anything-blender
InkscapeCreative (vector)
cli-anything-inkscape
AudacityMedia (audio)
cli-anything-audacity
LibreOfficeProductivity
cli-anything-libreoffice
OBS StudioMedia (streaming)
cli-anything-obs-studio
KdenliveMedia (video)
cli-anything-kdenlive
ShotcutMedia (video)
cli-anything-shotcut
ZoomCommunication
cli-anything-zoom
Draw.ioDiagramming
cli-anything-drawio
AnyGenAI Content
cli-anything-anygen

应用程序分类入口命令
GIMP创意工具(光栅图)
cli-anything-gimp
Blender创意工具(3D)
cli-anything-blender
Inkscape创意工具(矢量图)
cli-anything-inkscape
Audacity媒体工具(音频)
cli-anything-audacity
LibreOffice生产力工具
cli-anything-libreoffice
OBS Studio媒体工具(流媒体)
cli-anything-obs-studio
Kdenlive媒体工具(视频)
cli-anything-kdenlive
Shotcut媒体工具(视频)
cli-anything-shotcut
Zoom通讯工具
cli-anything-zoom
Draw.io图表工具
cli-anything-drawio
AnyGenAI内容生成
cli-anything-anygen

The 7-Phase Pipeline (HARNESS.md)

7阶段流程(HARNESS.md)

What
/cli-anything
triggers under the hood:
PhaseNameWhat happens
1Source AcquisitionAccept local path or GitHub URL; clone if needed
2Codebase AnalysisMap GUI actions → backend APIs; inventory existing CLI tools; document data model
3CLI Architecture DesignChoose interaction model (stateful REPL + subcommand); define command groups; plan
--json
output
4ImplementationBuild Click-based CLI with
cli_anything.<software>
namespace; implement REPL via shared
ReplSkin
5Test PlanningWrite
TEST.md
with planned test inventory before code
6Test ImplementationUnit tests (synthetic data) + E2E tests (real software output) + subprocess tests
7PyPI Publishing
setup.py
with
find_namespace_packages()
; console_scripts entry points
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工具;记录数据模型
3CLI架构设计选择交互模型(有状态REPL + 子命令);定义命令组;规划
--json
输出模式
4实现构建基于Click的CLI,使用
cli_anything.<software>
命名空间;通过共享
ReplSkin
实现REPL
5测试规划在编写代码前先编写
TEST.md
,规划测试清单
6测试实现单元测试(合成数据)+ 端到端测试(真实软件输出)+ 子进程测试
7PyPI发布配置
setup.py
使用
find_namespace_packages()
;设置console_scripts入口点
核心规则: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 tests
Why namespace packages:
cli_anything/
has no
__init__.py
, enabling multiple separately-installed CLIs to coexist under the same
cli_anything.*
namespace without conflict.

每个生成的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_anything/
没有
__init__.py
,允许多个独立安装的CLI共存于同一
cli_anything.*
命名空间下,避免冲突。

Output Verification Standards

输出验证标准

Tests verify real output using magic bytes and content analysis:
Output TypeVerification
PDF
%PDF-
magic bytes + non-zero size
OOXML (.docx, .xlsx)ZIP structure validation
CSVData row count + column check
ImagesPillow pixel value analysis
AudioRMS level check (non-silent)

测试通过魔术字节和内容分析验证真实输出:
输出类型验证方式
PDF检查
%PDF-
魔术字节 + 非零文件大小
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)
  • click>=8.0.0
    available (installed via
    pip install -e .
    )
  • Pillow>=10.0.0
    ,
    prompt-toolkit>=3.0.0
    available
  • pytest
    available for running tests

运行
/cli-anything <path>
前请确认:
  • 已安装Python 3.10+
  • 已安装目标软件(硬依赖——渲染时会调用它)
  • 可访问源代码(本地路径或公开GitHub URL)
  • 可用
    click>=8.0.0
    (通过
    pip install -e .
    安装)
  • 可用
    Pillow>=10.0.0
    prompt-toolkit>=3.0.0
  • 可用
    pytest
    运行测试

Key Files Reference

关键文件参考

FilePurpose
cli-anything-plugin/HARNESS.md
Complete methodology document (30K chars)
cli-anything-plugin/QUICKSTART.md
Quick start guide
cli-anything-plugin/repl_skin.py
Shared REPL UI class (18K, ANSI 256-color)
cli-anything-plugin/commands/cli-anything.md
/cli-anything
slash command definition
cli-anything-plugin/commands/refine.md
/cli-anything:refine
command
cli-anything-plugin/commands/test.md
/cli-anything:test
command
cli-anything-plugin/commands/validate.md
/cli-anything:validate
command
cli-anything-plugin/commands/list.md
/cli-anything:list
command
文件用途
cli-anything-plugin/HARNESS.md
完整方法文档(3万字)
cli-anything-plugin/QUICKSTART.md
快速入门指南
cli-anything-plugin/repl_skin.py
共享REPL UI类(1.8万行,ANSI 256色)
cli-anything-plugin/commands/cli-anything.md
/cli-anything
斜杠命令定义
cli-anything-plugin/commands/refine.md
/cli-anything:refine
命令
cli-anything-plugin/commands/test.md
/cli-anything:test
命令
cli-anything-plugin/commands/validate.md
/cli-anything:validate
command
cli-anything-plugin/commands/list.md
/cli-anything:list
命令

Post-Execution Reflection

执行后反思

After this skill completes, check before closing:
  1. Did the command succeed? — If not, fix the instruction or error table that caused the failure.
  2. Did parameters or output change? — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
  3. 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.
完成此技能操作后,关闭前请检查:
  1. 命令是否成功? —— 如果失败,请修正导致失败的说明或错误表。
  2. 参数或输出是否有变化? —— 如果底层工具的接口发生偏移,请更新使用示例和参数表以匹配。
  3. 是否需要临时解决方案? —— 如果必须临时变通(使用不同标记、额外步骤),请更新此SKILL.md,避免下次调用时需要相同的变通方法。
仅针对真实可复现的问题进行更新——不要基于推测修改。