Sandbox
@alexknowshtml/api2cli

Claude Code skill for API-to-CLI generation

api2cli is a Claude Code skill that turns an API into a working CLI and then wraps that CLI in a skill. It discovers endpoints from docs, probing, or peek-api captures, generates a dual-mode Commander.js interface, and writes a SKILL.md Claude can load later.

451 stars18 forksUpdated 7mo ago
Who it's for

Builders who use Claude Code and want an API wrapped into a reusable CLI workflow.

What it delivers

You can turn an API into a CLI Claude can keep using without re-reading the code.

What it does

Endpoint discovery

Finds endpoints from API docs, live probing, or peek-api network captures.

Endpoint catalog generation

Builds a catalog with auth, pagination, and rate limit details.

Dual-mode CLI output

Shows human-readable tables in the terminal and JSON with `next_actions` when piped.

Companion skill generation

Writes a service-specific `SKILL.md` with commands, examples, and workflows.

API client scaffolding

Generates a full API client with auth, pagination, retries, rate limiting, and caching.

How to get it

  1. 1Copy the skill/ folder into your Claude Code project
    # Clone this repo
    git clone https://github.com/alexknowshtml/api2cli.git
    
    # Copy the skill into your project
    cp -r api2cli/skill/ /path/to/your/project/.claude/skills/api2cli/
  2. 2In Claude Code, tell Claude what API you want to wrap
    "Build me a CLI for the Resend API"
    "Generate a CLI from these docs: https://docs.example.com/api"
    "Turn this peek-api capture into a CLI"

README

api2cli

A Claude Code skill that turns any API into a working CLI, then wraps that CLI in a skill. Point it at API docs, a live URL, or a peek-api capture and get a dual-mode Commander.js CLI plus a ready-to-use Claude Code skill -- so any future Claude session can pick it up and use it without reading the code.

Requires Claude Code -- this is a skill, not a standalone tool. Claude handles the discovery, generation, and wiring.

What It Does

  1. Discovers endpoints from API docs pages, live probing, or peek-api network captures
  2. Builds an endpoint catalog with auth, pagination, and rate limit info
  3. Generates a CLI with one subcommand per endpoint, a full-featured API client, and dual-mode output (human-readable in terminal, JSON envelope when piped)
  4. Generates a skill -- a SKILL.md that teaches Claude how to use the CLI, with commands, examples, and common workflows

Example: Resend API

Here's what it looks like when you point api2cli at the Resend email API.

You say:

Build me a CLI for the Resend API. Here are the docs: https://resend.com/docs/api-reference

Claude discovers 15 endpoints across 5 resources:

Found 15 endpoints across 5 resources:
  emails (3 endpoints): send, get, batch
  domains (4 endpoints): list, get, create, delete
  api-keys (3 endpoints): list, create, delete
  audiences (3 endpoints): list, get, create
  contacts (2 endpoints): list, create

Ready to generate the CLI?

Claude generates a CLI at scripts/resend.ts:

# See all commands
$ npx tsx scripts/resend.ts
{
  "ok": true,
  "command": "resend",
  "result": {
    "description": "Resend email API CLI",
    "commands": [
      { "command": "resend emails send", "description": "Send an email" },
      { "command": "resend emails get <id>", "description": "Get email by ID" },
      { "command": "resend domains list", "description": "List all domains" },
      ...
    ]
  }
}

# Send an email
$ npx tsx scripts/resend.ts emails send \
    --to user@example.com \
    --subject "Hello" \
    --html "<p>Hi there</p>"

# List domains (human-readable in terminal)
$ npx tsx scripts/resend.ts domains list
ID          Domain              Status
re_abc123   example.com         verified
re_def456   staging.example.com pending

# Same command piped to an agent (auto-detects, returns JSON)
$ npx tsx scripts/resend.ts domains list | cat
{
  "ok": true,
  "command": "resend domains list",
  "result": { "domains": [...], "count": 2 },
  "next_actions": [
    { "command": "resend domains get re_abc123", "description": "View domain details" },
    { "command": "resend emails send --from noreply@example.com", "description": "Send from verified domain" }
  ]
}

Claude also generates a skill at .claude/skills/resend/SKILL.md:

---
name: resend
description: Interact with the Resend email API via CLI. Use when user wants to
  send emails, manage domains, create API keys, manage audiences and contacts.
  Commands: resend emails send, resend domains list, resend contacts create.
---

# Resend CLI

## Setup
export RESEND_API_KEY=re_your_key_here

## Commands
### emails send --to <email> --subject <text> --html <html>
### domains list | get <id> | create --name <domain>
### contacts list --audience-id <id> | create --email <email>
...

From here, any Claude session in your project can send emails, manage domains, and work with contacts -- without knowing anything about the Resend API.

Install

Copy the skill/ folder into your Claude Code project:

# Clone this repo
git clone https://github.com/alexknowshtml/api2cli.git

# Copy the skill into your project
cp -r api2cli/skill/ /path/to/your/project/.claude/skills/api2cli/

Usage

In Claude Code, tell Claude what API you want to wrap:

"Build me a CLI for the Resend API"
"Generate a CLI from these docs: https://docs.example.com/api"
"Turn this peek-api capture into a CLI"

Claude will:

  1. Ask what API and how to access it
  2. Discover endpoints (parses docs, probes live endpoints, reads peek-api captures)
  3. Show you the endpoint catalog for review
  4. Generate the CLI -- you choose: scaffold into your project or standalone
  5. Test that it works
  6. Generate a skill folder so Claude can use the CLI in future sessions

What Gets Generated

A CLI -- Commander.js with:

  • Dual-mode output -- human-readable in terminal, JSON with next_actions when piped
  • Self-documenting root -- run with no args to see all commands
  • Full API client -- auth, pagination, retry with backoff, rate limiting, caching
  • One subcommand per endpoint -- mycli customers list, mycli customers get <id>
  • Error handling -- agent-friendly errors with fix suggestions

A skill -- a .claude/skills/{service}/SKILL.md that:

  • Lists all available commands with examples
  • Includes common multi-step workflows
  • Has the right trigger phrases so Claude auto-activates when relevant
  • Documents auth setup and agent usage

Discovery Methods

MethodBest For
Docs parsingPublic APIs with documentation pages
Active probingAPIs where you have a base URL and credentials
peek-api captureSites where you need to sniff network traffic to find endpoints

What's Inside

skill/
  SKILL.md                                # Main skill instructions
  references/
    discovery-strategies.md               # Endpoint discovery patterns and probing techniques
    api-client-template.md                # API client with pagination, retry, rate limiting, caching
    agent-first-patterns.md               # Agent JSON envelope, HATEOAS, context-safe output
    commander-patterns.md                 # Commander.js advanced patterns

Credits

This came from a pattern of wanting to give my AI agent access to apps and discovering it loved working with CLIs. I wanted an easy way to turn any API into a CLI, then wrap that CLI in a skill. The audience routing (human-first, agent-first, dual-mode), the API discovery pipeline (peek-api, docs parsing, active probing), and the generation approach all came from that.

The agent-side output patterns -- JSON envelope, HATEOAS-style next_actions, self-documenting root commands, and fix suggestions on errors -- were inspired by Joel Hooks' agent-first CLI design.

Related

  • peek-api -- Discover internal APIs from any website by monitoring network traffic

License

MIT

Files in the repo

Repository payload4 top-level entries
  • skill
  • .gitignore
  • LICENSE
  • README.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More skills

obra/
superpowers

An agentic skills framework & software development methodology that works.

285k
1 add

Turn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local deterministic AST parsing, every edge explained, no vector store.

117k
1 add
Vincentwei1021/
anything2explainer

Topic in, narrated explainer video out. A Claude Code / Codex skill that turns any topic into a black-canvas motion-graphics explainer video with TTS voiceover, subtitles and a chapter progress bar. Chinese or English; every frame drawn in code with Remotion.

666

Open-source AI job search: scan job portals, evaluate listings into a structured A-H report with a global 1-5 score, tailor your CV, track applications — runs locally in your AI coding CLI (Claude Code, Codex, OpenCode, Antigravity…)

71k