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.
- Discovers endpoints from API docs pages, live probing, or peek-api network captures
- Builds an endpoint catalog with auth, pagination, and rate limit info
- 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)
- Generates a skill -- a SKILL.md that teaches Claude how to use the CLI, with commands, examples, and common workflows
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.
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/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:
- Ask what API and how to access it
- Discover endpoints (parses docs, probes live endpoints, reads peek-api captures)
- Show you the endpoint catalog for review
- Generate the CLI -- you choose: scaffold into your project or standalone
- Test that it works
- Generate a skill folder so Claude can use the CLI in future sessions
A CLI -- Commander.js with:
- Dual-mode output -- human-readable in terminal, JSON with
next_actionswhen 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
fixsuggestions
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
| Method | Best For |
|---|---|
| Docs parsing | Public APIs with documentation pages |
| Active probing | APIs where you have a base URL and credentials |
| peek-api capture | Sites where you need to sniff network traffic to find endpoints |
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
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.
- peek-api -- Discover internal APIs from any website by monitoring network traffic
MIT