skill/SKILL.md
Generate a working CLI from any API, then wrap it in a Claude Code skill. Point it at API docs, a live URL, or a peek-api capture and get a dual-mode Commander.js CLI (human + agent output) plus a ready-to-use skill folder. Use when user wants to wrap an API in a CLI, generate a CLI from API docs, turn an API into a command-line tool, scaffold a CLI from discovered endpoints, or create a skill for an API.
npx skillsauth add alexknowshtml/api2cli api2cliInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate a working Node.js CLI from any API, then wrap it in a Claude Code skill. Discovers endpoints, scaffolds a dual-mode Commander.js CLI with a full-featured API client, and creates a skill folder so Claude knows how to use it.
Ask the user:
Determine which discovery paths to use based on what they provide:
| Input | Discovery Path |
|-------|---------------|
| Docs URL (e.g., https://docs.stripe.com/api) | Docs parsing + active probing |
| Base URL (e.g., https://api.example.com/v1) | Active probing |
| peek-api capture dir (e.g., ./peek-api-linkedin/) | Read existing catalog |
| Live website URL | Suggest running peek-api first, then active probing |
Also ask:
Use all applicable discovery paths. Combine results into a single catalog.
/.well-known/openapi.json, /.well-known/openapi.yaml/openapi.json, /openapi.yaml, /swagger.json, /swagger.yaml/api-docs, /docs, /api/docs/graphql (with introspection query)OPTIONS on the base URL and common resource paths/api/v1/, /api/v2/, /v1/, /v2/GET /resources, GET /resources/:id, POST /resources, etc.X-RateLimit-*, Retry-After)next, cursor, page, offset)See references/discovery-strategies.md for detailed probing patterns.
endpoints.json, auth.json, CAPTURE.mdauth.jsonIf peek-api is not installed or no capture exists, tell the user:
To capture endpoints from a live site, install peek-api:
git clone https://github.com/alexknowshtml/peek-api
cd peek-api && npm install
node bin/cli.js https://example.com
Normalize all discovered endpoints into this format:
interface EndpointCatalog {
service: string; // e.g., "stripe", "nexudus"
baseUrl: string;
auth: {
type: 'api-key' | 'bearer' | 'cookies' | 'oauth' | 'none';
headerName?: string; // e.g., "Authorization", "X-API-Key"
envVar: string; // e.g., "STRIPE_API_KEY"
};
pagination?: {
style: 'cursor' | 'offset' | 'page' | 'link-header';
paramName: string; // e.g., "starting_after", "offset", "page"
responseField: string; // e.g., "has_more", "next", "next_page_url"
};
rateLimit?: {
requests: number;
window: string; // e.g., "1m", "1h"
};
resources: ResourceGroup[];
}
interface ResourceGroup {
name: string; // e.g., "customers", "invoices"
description: string;
endpoints: Endpoint[];
}
interface Endpoint {
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
path: string; // e.g., "/v1/customers/:id"
description: string;
parameters: Parameter[];
requestBody?: object; // JSON schema or example
responseExample?: object;
}
interface Parameter {
name: string;
in: 'path' | 'query' | 'header';
required: boolean;
type: string;
description: string;
}
Present the catalog to the user for review before generating:
Found 24 endpoints across 5 resources:
customers (6 endpoints): list, get, create, update, delete, search
invoices (5 endpoints): list, get, create, send, void
...
Ready to generate the CLI?
Generate a dual-mode CLI using Commander.js. The CLI auto-detects human vs agent output via process.stdout.isTTY.
In-project scaffold:
scripts/
{service}.ts # Entry point with shebang
{service}/
lib/
client.ts # API client (auth, pagination, retry, caching)
envelope.ts # Agent JSON envelope helpers
commands/
{resource}.ts # One file per resource group
Standalone project:
{service}-cli/
package.json
tsconfig.json
bin/
{service}.ts # Entry point with shebang
src/
lib/
client.ts
envelope.ts
commands/
{resource}.ts
See these references for the patterns to apply during generation:
references/api-client-template.md -- API client class with pagination, retry, rate limiting, cachingreferences/agent-first-patterns.md -- JSON envelope, HATEOAS next_actions, context-safe output, error fix suggestionsreferences/commander-patterns.md -- Commander.js subcommands, global options, interactive prompts, colored outputEntry point ({service}.ts):
#!/usr/bin/env npx tsx--json (force JSON output), --verbose, --config <path>API client (lib/client.ts):
catalog.auth.envVar)Envelope helpers (lib/envelope.ts):
const isAgent = !process.stdout.isTTY;
function respond(command: string, result: any, nextActions: Action[] = []) {
if (isAgent) {
console.log(JSON.stringify({ ok: true, command, result, next_actions: nextActions }));
} else {
return result; // caller handles human rendering
}
}
function respondError(command: string, message: string, code: string, fix: string, nextActions: Action[] = []) {
if (isAgent) {
console.log(JSON.stringify({ ok: false, command, error: { message, code }, fix, next_actions: nextActions }));
} else {
console.error(`Error: ${message}`);
console.error(`Fix: ${fix}`);
}
process.exit(1);
}
Command files (commands/{resource}.ts):
mycli customers list, mycli customers get <id>list commands: support --limit, --offset/--cursor, --status (if filterable)get commands: take ID as argumentcreate/update commands: accept --data <json> or individual --field flagsnext_actions for agent modefix suggestionsStandalone project extras:
package.json with commander, tsx as dependencies, bin field pointing to entrytsconfig.json for TypeScript.env.example with the required env varAfter generating the CLI:
Create a Claude Code skill folder that teaches Claude how to use the generated CLI. This is the final step -- it turns the CLI into something any Claude session can pick up and use without reading the code.
.claude/skills/{service}/
SKILL.md # Skill instructions
Generate a SKILL.md with this structure:
---
name: {service}
description: Interact with the {Service} API via CLI. Use when user wants to
{list of actions based on discovered resources, e.g., "list customers,
create invoices, check order status"}. Commands: {service} {resource} {action}.
---
# {Service} CLI
CLI wrapper for the {Service} API.
## Setup
Set the `{SERVICE_ENV_VAR}` environment variable:
\`\`\`bash
export {SERVICE_ENV_VAR}=your-api-key-here
\`\`\`
## Commands
{For each resource group, list commands with examples:}
### {Resource}
\`\`\`bash
# List {resources}
npx tsx {path/to/cli}.ts {resource} list
# Get a specific {resource}
npx tsx {path/to/cli}.ts {resource} get <id>
# Create a {resource}
npx tsx {path/to/cli}.ts {resource} create --field value
\`\`\`
## Common Workflows
{Generate 2-3 practical workflows combining multiple commands:}
### Example: {Workflow name}
\`\`\`bash
# Step 1: Find the customer
npx tsx {path/to/cli}.ts customers list --status=active
# Step 2: Get their invoices
npx tsx {path/to/cli}.ts invoices list --customer-id=abc123
\`\`\`
## Agent Usage
When piped, all commands return JSON with `next_actions`:
\`\`\`bash
npx tsx {path/to/cli}.ts {resource} list | cat
\`\`\`
--help. Focus on what Claude needs to know that it can't infer.After generating both the CLI and the skill:
CLI generated at {cli_path}
Skill generated at .claude/skills/{service}/SKILL.md
To use the CLI directly:
npx tsx {cli_path} # See all commands
npx tsx {cli_path} customers list # List customers
Claude will now automatically use this skill when you ask about {service}.
references/discovery-strategies.md -- Detailed probing patterns, well-known paths, GraphQL introspection, response parsingreferences/api-client-template.md -- Full API client class with pagination, retry, rate limiting, cachingreferences/agent-first-patterns.md -- Agent JSON envelope, HATEOAS, context-safe output, error handlingreferences/commander-patterns.md -- Commander.js subcommands, nested commands, interactive prompts, colored output, config files, testingtools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.