api2cli: Claude Turns Any API Into a CLI — Then Writes the Usage Manual for Itself
api2cli is a Claude Code Skill that turns any API into a working CLI tool, then generates a SKILL.md so that future Claude sessions can use the CLI directly without reading any code. Two layers of recursion: Claude turns the API into a CLI, then writes the manual explaining how to use that CLI.
The workflow is minimal: just tell Claude 'build me a CLI for the Resend API' and Claude automatically discovers all endpoints (supporting three methods: docs page parsing, live URL probing, or peek-api network captures), generates a Commander.js-based CLI, and outputs in dual mode — human-readable when run directly in a terminal, automatically switching to JSON format when piped, for easy AI Agent consumption.
The core value is reusability: the generated SKILL.md tells future Claude sessions all available commands and common workflows — generated once, usable forever. Any Claude Code session can pick it up directly without ever re-reading the API documentation.
Core Concept
api2cli solves a 'tool discoverability' problem: you have an API and want a Claude Agent to use it, but having Claude re-read the docs every time is too slow. With api2cli, you generate a CLI + Skill once, and all future sessions can call it directly.
Generated Outputs
1. Commander.js CLI
Features:
- **Dual-mode output**: Human-readable in terminal, auto-switches to JSON when piped
- **Self-documenting**: Running without arguments outputs all available commands
- **Full API client**: Built-in auth, pagination, retry (exponential backoff), rate limiting, caching
- **Agent-friendly errors**: Error messages include fix suggestions (next_actions)
Example (Resend email API):
# Run directly in terminal (human-readable)
$ npx tsx scripts/resend.ts domains list
ID Domain Status
re_abc123 example.com verified
# Piped (agent-readable)
$ npx tsx scripts/resend.ts domains list | cat
{
"ok": true,
"result": { "domains": [...] },
"next_actions": [
{ "command": "resend domains get re_abc123" }
]
}
2. SKILL.md
The generated SKILL.md is placed in `.claude/skills/{service}/` and includes:
- All available commands (with parameter descriptions)
- Common multi-step workflows
- Correct trigger phrases (so Claude auto-activates it)
- Auth configuration instructions
Endpoint Discovery Methods
| Method | Best For |
|--------|----------|
| Docs page parsing | Public APIs with documentation |
| Live URL probing | APIs where you have base URL + credentials |
| peek-api capture | Sites where you need to sniff network traffic for internal endpoints |
Installation
git clone https://github.com/alexknowshtml/api2cli.git
cp -r api2cli/skill/ /path/to/your/project/.claude/skills/api2cli/
Then in Claude Code:
Build me a CLI for the Resend API
Generate a CLI from this API docs page: https://docs.example.com/api
Use Cases
- **Automation toolchains**: Turn various SaaS APIs into tools Claude can call
- **Team sharing**: Generate a Skill once, everyone's Claude Code can use it
- **Internal APIs**: Use peek-api to discover company internal API endpoints, then generate a CLI
- **Testing & debugging**: Dual-mode output makes both manual testing and Agent calls convenient
Limitations
- Requires Claude Code to run (not a standalone tool)
- Generation quality depends on API documentation completeness
- Complex auth flows (OAuth 2.0, etc.) may require manual supplementation
In-Depth Analysis and Industry Outlook
From a broader perspective, this development reflects the accelerating trend of AI technology transitioning from laboratories to industrial applications. Industry analysts widely agree that 2026 will be a pivotal year for AI commercialization. On the technical front, large model inference efficiency continues to improve while deployment costs decline, enabling more SMEs to access advanced AI capabilities. On the market front, enterprise expectations for AI investment returns are shifting from long-term strategic value to short-term quantifiable gains.