api2cli: Let Claude Auto-Convert Any API into a CLI Tool and Skill
api2cli is a Claude Code skill that automatically converts any API into a working CLI tool and then generates a SKILL.md document—so future Claude sessions can use it without reading the code.
Just point it at API documentation pages, a live URL, or a peek-api network capture, and Claude will auto-discover all endpoints, generate a full Commander.js CLI (with dual-mode output: human-readable in terminal, JSON envelope when piped), and create a skill folder. It's essentially two layers of meta: AI wrapping an API into a CLI, then writing its own instruction manual.
The generated CLI is fully featured: authentication, pagination, retry with backoff, rate limiting, caching, with one subcommand per endpoint. Error handling is agent-friendly with fix suggestions. Endpoint discovery supports three methods: docs parsing, active probing, and peek-api network capture. The entire pipeline from discovery to generation to testing is fully automated—a true infrastructure-level project for the agent toolchain.
Overview
api2cli is a skill designed for Claude Code that automatically converts any API into a Commander.js CLI tool and generates accompanying SKILL.md documentation. You simply point Claude at an API entry point, and it handles the entire pipeline from endpoint discovery to CLI code generation to skill documentation.
Core Features
Three Endpoint Discovery Methods
- **Docs Parsing**: Point to public API documentation pages for automatic endpoint extraction
- **Active Probing**: Provide a base URL and credentials for Claude to actively probe available endpoints
- **peek-api Capture**: Use peek-api to monitor network traffic and discover hidden APIs from actual requests
Dual-Mode CLI Output
Generated CLIs feature intelligent output switching:
- **Terminal Mode**: Human-readable formatted table output
- **Pipe Mode**: Auto-detects piped environment, outputs JSON envelope with HATEOAS-style `next_actions` suggestions
Full-Featured API Client
- Authentication management (API Key, OAuth, etc.)
- Automatic pagination
- Exponential backoff retry
- Rate limiting
- Response caching
- Agent-friendly error handling with fix suggestions
Auto-Generated Skill
The generated `.claude/skills/{service}/SKILL.md` includes:
- All available commands with examples
- Common multi-step workflows
- Trigger phrases for automatic Claude activation
- Auth setup and agent usage documentation
Usage
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 these docs: https://docs.example.com/api"
- "Turn this peek-api capture into a CLI"
Real Example
Using Resend email API, Claude discovers 15 endpoints across 5 resource groups (emails, domains, api-keys, audiences, contacts), generates corresponding CLI subcommands, and creates complete skill documentation.
Design Philosophy
Born from the need to give AI agents tool access. Agents naturally excel at CLI usage, so this automates the API → CLI → Skill pipeline. Output patterns (JSON envelope, HATEOAS next_actions, self-documenting root commands, error fix suggestions) were inspired by Joel Hooks' agent-first CLI design.
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.