← 返回 Skills 市场
melvynx

api2cli

作者 Melvyn · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
388
总下载
0
收藏
2
当前安装
2
版本数
在 OpenClaw 中安装
/install api2cli
功能描述
Generate or discover a CLI + AgentSkill for any REST API. Use when: user says 'create a CLI for X', 'wrap this API', 'search if a CLI exists', 'install an ex...
使用说明 (SKILL.md)

api2cli

Turn any REST API into a standardized, agent-ready CLI.

Always use npx api2cli to run commands. Always use --json when calling generated CLIs programmatically.

Prerequisites

bun --version || curl -fsSL https://bun.sh/install | bash

Workflow

Follow all steps in order — do not skip any.

1. Search the registry first

Before generating anything, check if a CLI already exists:

npx api2cli search \x3Cquery>

If the registry already has the CLI you need, install it instead of rebuilding it:

npx api2cli install \x3Cname>

See references/commands.md for filters like --type, --category, and --json.

2. Discover the API

Find the API docs or OpenAPI spec. Identify: base URL, auth type, auth header, all resources and endpoints.

3. Create the scaffold

npx api2cli create \x3Capp> --base-url \x3Curl> --auth-type bearer

See references/create.md for all flags and what gets generated.

4. Implement resources

Create ~/.cli/\x3Capp>-cli/src/resources/\x3Cresource>.ts for each API resource. Register in src/index.ts.

See references/resource-patterns.md for the CRUD template and library API.

5. Build, link, and test

npx api2cli bundle \x3Capp>
npx api2cli link \x3Capp>
\x3Capp>-cli --help
\x3Capp>-cli \x3Cresource> list --json

api2cli link adds ~/.local/bin to PATH automatically. No export PATH needed.

6. Finalize skill and README

This step is mandatory. The skill must become a real operating guide for another agent, not just a command list — no placeholders, no TODOs.

  1. Introspect the CLI: run \x3Capp>-cli --help, then \x3Cresource> --help and \x3Cresource> \x3Caction> --help for every resource and action
  2. Update the description: list all resource names and add domain-specific trigger phrases
  3. Set the category: replace {{CATEGORY}} with the correct value (e.g. social-media, email, devtools)
  4. Write the task-oriented sections: replace {{WHEN_TO_USE_HELP}}, {{CAPABILITIES_HELP}}, and {{USE_CASES_HELP}} with domain-specific guidance
  5. Build resource tables: for each resource, create a command table with every action and its real flags (from --help output)
  6. Add Quick Reference + Output Format: include --help commands and document the JSON envelope
  7. Remove all placeholders: no {{...}} or \x3C!-- TODO --> should remain
  8. Validate: run at least one command to confirm the skill's examples are accurate

See references/skill-generation.md for the full introspection workflow, format, quality checklist, and symlink instructions.

To also link skills for OpenClaw:

npx api2cli link \x3Capp> --openclaw

See references/openclaw.md for the one-prompt setup, ClawHub publishing, API key auto-detection, and custom --skills-path usage.

Also available on ClawHub: npx clawhub install api2cli

7. Publish (when user asks)

Before any publish target, run these pre-flight checks:

  1. Verify gh CLI is authenticated: run gh auth status. If not logged in, ask the user to run gh auth login first. Stop and wait.
  2. Check if the CLI is already on GitHub: run git remote get-url origin in the CLI directory.
    • If no remote exists → the CLI is not on GitHub yet. Automatically run the GitHub publish flow first (see below) before proceeding to npm or registry publish.
    • If a remote exists → already on GitHub, continue.

To GitHub

Push the CLI to a public GitHub repo.

See references/publish-to-github.md for pre-flight checks, repo creation, and push workflow.

To npm

Requires the CLI to be on GitHub first (for repository field in package.json). If not on GitHub, run the GitHub publish flow above first.

Publish the CLI to the npm registry so users can npm i -g \x3Cname> or npx \x3Cname>.

See references/publish-to-npm.md for auth, package.json validation, build, verify, and publish workflow. Also see references/package-checklist.md for the field-by-field package.json reference.

To ClawHub

Publish the generated skill to ClawHub so OpenClaw users can discover and install it.

  1. Auth: run npx clawhub login. If not authenticated, ask the user to complete login first. Stop and wait.
  2. Push the skill: run npx clawhub publish \x3Ccli-dir>/skills/\x3Capp>-cli --slug \x3Capp>-cli
  3. After publish, users can install with:
    npx clawhub install \x3Capp>-cli
    

See references/openclaw.md for the full OpenClaw setup workflow.

To Sundial Hub

Publish the generated skill to the Sundial Hub so any agent (Claude Code, Cursor, Codex, etc.) can install it.

  1. Auth: run npx sundial-hub auth status. If not authenticated, ask the user to run npx sundial-hub auth login first. Stop and wait.
  2. Push the skill: run npx sundial-hub push \x3Ccli-dir>/skills/\x3Capp>-cli --visibility public --categories coding
  3. After publish, users can install with:
    npx sundial-hub add \x3Csundial-username>/\x3Capp>-cli
    

To api2cli.dev registry

Requires the CLI to be on GitHub first. If not on GitHub, run the GitHub publish flow above first.

Register on api2cli.dev so others can install with npx api2cli install \x3Cname>.

See references/publish.md for the registry publish workflow.

Conventions

\x3Capp>-cli \x3Cresource> \x3Caction> [flags]
\x3Capp>-cli auth set|show|remove|test

--json returns: { "ok": true, "data": [...], "meta": { "total": 42 } }

Other flags: --format \x3Ctext|json|csv|yaml>, --verbose, --no-color, --no-header

Exit codes: 0 = success, 1 = API error, 2 = usage error

Tokens: ~/.config/tokens/\x3Capp>-cli.txt (chmod 600)

安全使用建议
This skill appears to do what it says (create, install, link, and publish CLIs), but its runtime instructions run high-impact shell commands, download and execute remote installers (bun.sh), clone and build third-party repos, manage token files, and symlink into other agent directories. Before using it: 1) Do not let any agent run the suggested curl | bash installer without first reviewing the script (prefer manual install from a verified source). 2) Require explicit human consent for cloning/building unknown GitHub repos and for any 'npm publish' or 'gh repo create' steps. 3) Inspect ~/.config/tokens/* and ~/.cli/* before and after running commands; back up any secrets. 4) If you want to limit blast radius, run the workflow in a disposable environment or container and avoid automatic 'tokens --show' or auto-detection features. 5) When publishing, follow interactive flows yourself (the docs say the agent should stop and wait for auth); never give the agent unattended access to your GitHub/npm/ClawHub credentials. If you want broader assurance, ask the author for a signed release or a repository you can inspect locally before building.
功能分析
Type: OpenClaw Skill Name: api2cli Version: 1.0.1 The api2cli bundle provides a framework for an AI agent to autonomously generate, build, and publish CLI tools, requiring broad 'shell', 'network', and 'filesystem' permissions. It employs high-risk patterns such as 'curl | bash' for environment setup (SKILL.md) and automates the management of API tokens stored in the filesystem (references/resource-patterns.md). While the documentation includes security-conscious 'pre-flight' checks and requires manual user intervention for npm publishing, the framework's deep integration with public registries and its ability to programmatically modify system PATHs and agent skill directories (references/openclaw.md) create a significant risk profile without clear evidence of malicious intent.
能力评估
Purpose & Capability
The name/description (api2cli) aligns with what the SKILL.md instructs: scaffold a CLI from an API, bundle/link it, and publish it. The declared capabilities (search, create, bundle, link, publish) are coherent with the files and references provided.
Instruction Scope
The instructions tell the agent to run networked installers (curl -fsSL https://bun.sh/install | bash), clone arbitrary GitHub repos, build/link code, read and write package.json and token files, and symlink SKILL.md into other agent directories (~/.openclaw, ~/.claude, ~/.cursor). They also reference 'API key auto-detection' and commands that list and reveal tokens (tokens --show). These actions go beyond simple 'generate a scaffold' and involve filesystem scanning, credential handling, and executing third-party code — all of which are plausible for the tool but are high-impact operations that an end user should explicitly approve and review step-by-step.
Install Mechanism
There is no formal install spec included (instruction-only), but the README explicitly recommends running a remote install script (bun.sh) via curl|bash. That pattern (downloading and piping a shell script to bash) is a common convenience but high risk because it executes remote code. The skill also advises running npm install/publish and running build steps that execute code from cloned repositories.
Credentials
The skill declares no required env vars or credentials, which matches the registry metadata. However, the instructions assume and instruct the agent to interact with credentialed tooling (gh, npm, clawhub, sundial-hub) and to manage token files at ~/.config/tokens/<app>-cli.txt. That behavior is reasonable for a CLI publisher, but token discovery and the ability to reveal tokens via commands (tokens --show) are sensitive and should be handled explicitly by the user.
Persistence & Privilege
always:false (good). Nonetheless, the workflow instructs creating persistent artifacts and symlinks into other agents' skill directories (e.g., ~/.openclaw/workspace/skills/), and performing git repo creation/push and npm publish flows. Writing into other agent directories and symlinking is coherent for integration, but it modifies other agents' state and could be surprising if done without explicit, local user approval.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install api2cli
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /api2cli 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
- Adds CLI registry search and install steps before generation; users are prompted to search for and install existing CLIs whenever possible. - Updates workflow to make registry discovery, search, and install the first required step. - Expands SKILL.md documentation with stricter introspection and finalization guidelines, emphasizing removal of all placeholders and complete operating instructions. - Clarifies and enhances references to command filters, resource tables, and publishing flows. - Improves support for OpenClaw and agent-ready skill documentation.
v1.0.0
Initial release of api2cli — generate a full-featured CLI and agent skill from any REST API. - Provides a guided workflow for API discovery, CLI scaffolding, resource implementation, building, testing, and publishing. - Supports publishing to GitHub, npm, ClawHub, Sundial Hub, and api2cli.dev registries, with built-in pre-flight checks. - Generated CLIs follow a standardized interface, support JSON output, and agent integration. - Automates common setup tasks, handles authentication, and manages skill/README templates. - Includes conventions for command structure, output formats, and token storage.
元数据
Slug api2cli
版本 1.0.1
许可证 MIT-0
累计安装 2
当前安装数 2
历史版本数 2
常见问题

api2cli 是什么?

Generate or discover a CLI + AgentSkill for any REST API. Use when: user says 'create a CLI for X', 'wrap this API', 'search if a CLI exists', 'install an ex... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 388 次。

如何安装 api2cli?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install api2cli」即可一键安装,无需额外配置。

api2cli 是免费的吗?

是的,api2cli 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

api2cli 支持哪些平台?

api2cli 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 api2cli?

由 Melvyn(@melvynx)开发并维护,当前版本 v1.0.1。

💬 留言讨论