Agent skill

Api2cli

by alexknowshtml in alexknowshtml/api2cli

Generate a working CLI from any API, then wrap it in a Claude Code skill.

MITAuto-check passedBackend & APIs

Install Api2cli

skills CLI
$ npx skills add alexknowshtml/api2cli --skill api2cli -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install alexknowshtml/api2cli api2cli --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/alexknowshtml/api2cli.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skill .claude/skills/api2cli && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
api2cli
GitHub stars
455
Token cost
~2.9k tokens
SKILL.md length
913 words
Files
5 (incl. references)
Skills in repo
1
Repo updated
First seen
Licence
MIT

At a glance

Generate a working CLI from any API, then wrap it in a Claude Code skill.

  • Works in 6 steps: Identify the API → Discover Endpoints → Build Endpoint Catalog → …
  • User wants to wrap an API in a CLI
  • SKILL.md covers Workflow, Step 1: Identify the API, Step 2: Discover Endpoints and Step 3: Build Endpoint Catalog, plus 4 more sections
  • Calls npx, git and npm; reaches docs.stripe.com and github.com; needs STRIPE_API_KEY

What it does

Api2cli is an agent skill from alexknowshtml/api2cli. 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.

Its SKILL.md is about 2.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `references/agent-first-patterns.md`, `references/api-client-template.md` and `references/commander-patterns.md`).

It sits in Backend & APIs, covering Technical documentation, Skill authoring and OpenAPI specifications. It works with OpenAPI, Node.js and TypeScript. The repository describes itself as: Audience-aware CLI patterns for Node.js + Commander.js. Build CLIs for humans, AI agents, or both. The licence is MIT.

When your agent uses it

  • 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

Example prompts

  • “/api2cli”

Requirements

  • Node.js
  • A credential in STRIPE_API_KEY

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Identify the API
  2. Discover Endpoints
  3. Build Endpoint Catalog
  4. Generate CLI
  5. Verify
  6. Generate Skill

What it can do on your machine

Read from SKILL.md and the folder at commit fde6f88. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npx
    • git
    • npm
    • node
    • claude

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • docs.stripe.com
    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • STRIPE_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Api2cli loads about 2.9k tokens when it runs, and up to ~7.3k if it reads all its reference files. Until then it costs about 104 tokens; SKILL.md has 913 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~104
When it runs · the whole SKILL.md, loaded when a task matches
~2.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from alexknowshtml/api2cli at commit fde6f88, republished under its MIT licence (© alexknowshtml). 913 words, ~2,944 tokens.

Download SKILL.mdSave it as .claude/skills/api2cli/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
api2cli
description
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.

api2cli

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.

Workflow

  1. Identify the API -- user provides a docs URL, a live API base URL, or a peek-api capture
  2. Discover endpoints -- parse docs, probe the API, or read a peek-api catalog
  3. Build endpoint catalog -- normalize all discovered endpoints into a standard format
  4. Generate CLI -- scaffold Commander.js CLI from the catalog
  5. User chooses destination -- scaffold into current project or create standalone project
  6. Generate skill -- create a SKILL.md that teaches Claude how to use the generated CLI

Step 1: Identify the API

Ask the user:

  • "What API do you want to wrap? Share a docs URL, a base URL, or point me at a peek-api capture."

Determine which discovery paths to use based on what they provide:

InputDiscovery 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 URLSuggest running peek-api first, then active probing

Also ask:

  • "What auth does this API use?" (API key, Bearer token, cookies, OAuth, none)
  • "Do you want this CLI in your current project or as a standalone project?"

Step 2: Discover Endpoints

Use all applicable discovery paths. Combine results into a single catalog.

Path A: Docs Parsing
  1. Fetch the docs URL with WebFetch
  2. Extract endpoint information: method, path, description, parameters, request/response examples
  3. Look for pagination patterns, auth requirements, rate limit info
  4. Follow links to sub-pages for individual endpoint docs if the main page is an index
Path B: Active Probing
  1. Check well-known paths for API specs:
    • /.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)
  2. Try OPTIONS on the base URL and common resource paths
  3. Probe common REST patterns: /api/v1/, /api/v2/, /v1/, /v2/
  4. For each discovered resource, try standard CRUD: GET /resources, GET /resources/:id, POST /resources, etc.
  5. Parse response shapes to understand data models
  6. Check response headers for rate limit info (X-RateLimit-*, Retry-After)
  7. Check for pagination patterns in responses (next, cursor, page, offset)

See references/discovery-strategies.md for detailed probing patterns.

Path C: peek-api Capture
  1. Read the capture directory: endpoints.json, auth.json, CAPTURE.md
  2. Parse endpoints into the standard catalog format
  3. Extract auth headers and cookies from auth.json

If 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

Step 3: Build Endpoint Catalog

Normalize all discovered endpoints into this format:

typescript
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?

Step 4: Generate CLI

Generate a dual-mode CLI using Commander.js. The CLI auto-detects human vs agent output via process.stdout.isTTY.

File Structure

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
Code Generation Patterns

See these references for the patterns to apply during generation:

  • references/api-client-template.md -- API client class with pagination, retry, rate limiting, caching
  • references/agent-first-patterns.md -- JSON envelope, HATEOAS next_actions, context-safe output, error fix suggestions
  • references/commander-patterns.md -- Commander.js subcommands, global options, interactive prompts, colored output
Show full SKILL.md (403 more words)Show less
Key Generation Rules

Entry point ({service}.ts):

  • Shebang: #!/usr/bin/env npx tsx
  • Self-documenting root command (no args → prints full command tree as JSON)
  • Global options: --json (force JSON output), --verbose, --config <path>

API client (lib/client.ts):

  • Constructor takes base URL + auth config
  • Auth from env var (name based on catalog.auth.envVar)
  • Built-in pagination matching the API's pattern
  • Retry with exponential backoff for 5xx and 429 errors
  • Rate limiting based on discovered limits
  • Optional response caching

Envelope helpers (lib/envelope.ts):

typescript
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):

  • One file per resource group
  • Each endpoint becomes a subcommand: mycli customers list, mycli customers get <id>
  • list commands: support --limit, --offset/--cursor, --status (if filterable)
  • get commands: take ID as argument
  • create/update commands: accept --data <json> or individual --field flags
  • Every command includes contextual next_actions for agent mode
  • Errors include fix suggestions

Standalone project extras:

  • package.json with commander, tsx as dependencies, bin field pointing to entry
  • tsconfig.json for TypeScript
  • .env.example with the required env var

Step 5: Verify

After generating the CLI:

  1. Verify it runs: Execute with no args, confirm the self-documenting root works
  2. Test one endpoint: Pick a simple GET endpoint, run it, verify output
  3. Move on to Step 6 to wrap the CLI in a skill

Step 6: Generate Skill

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.

Skill Structure
.claude/skills/{service}/
  SKILL.md                    # Skill instructions
SKILL.md Template

Generate a SKILL.md with this structure:

markdown
---
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
\`\`\`
Key Rules for Skill Generation
  1. Description is critical -- include specific trigger phrases and list the actions the CLI supports. This is what Claude reads to decide when to use the skill.
  2. Include real command examples -- use the actual CLI path and real subcommand names from the generated CLI.
  3. Generate practical workflows -- combine multiple commands into realistic multi-step scenarios based on how the API's resources relate to each other.
  4. Keep it lean -- the skill should be a quick reference, not a restatement of --help. Focus on what Claude needs to know that it can't infer.
Tell the User

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}.

Reference Files

  • references/discovery-strategies.md -- Detailed probing patterns, well-known paths, GraphQL introspection, response parsing
  • references/api-client-template.md -- Full API client class with pagination, retry, rate limiting, caching
  • references/agent-first-patterns.md -- Agent JSON envelope, HATEOAS, context-safe output, error handling
  • references/commander-patterns.md -- Commander.js subcommands, nested commands, interactive prompts, colored output, config files, testing

© alexknowshtml, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (references) in skill of alexknowshtml/api2cli.

  • SKILL.md
  • references/agent-first-patterns.md
  • references/api-client-template.md
  • references/commander-patterns.md
  • references/discovery-strategies.md

Open the folder on GitHubat commit fde6f88

Compare with similar skills

Api2cli next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Api2cli compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Api2cli this skillalexknowshtml/api2cli455—~2.9kAutomated safety check: PassMIT
Code Documenterzebbern/claude-code-guide4.7k—~1kAutomated safety check: PassMIT
Spiceflowremorses/spiceflow167—~1.9kAutomated safety check: PassMIT
Code DocumenterJeffallan/claude-skills12k—~1.5kAutomated safety check: PassMIT
Generating Documentationancoleman/ai-design-components526—~3kAutomated safety check: PassMIT
CLI Creatorhuangruiteng/CS-Notes4k2 repos~2.7kAutomated safety check: PassApache-2.0

Similar skills

  • Code Documenter

    zebbern/claude-code-guide

    A skill your agent uses when adding docstrings, creating API documentation, or building documentation sites.

    4.7k GitHub stars~1k tokensUpdated today
    Backend & APIsAuto-check passed
  • Spiceflow

    remorses/spiceflow

    Spiceflow is a super simple, fast, and type-safe API and React Server Components framework for TypeScript.

    167 GitHub stars~1.9k tokensUpdated 2 days ago
    Backend & APIsAuto-check passed
  • Code Documenter

    Jeffallan/claude-skills

    Generates and validates docstrings, OpenAPI specs, JSDoc annotations and user guides, running every code example through a real compiler or linter before reporting coverage.

    12k GitHub stars~1.5k tokensUpdated 5 days ago
    DevelopmentAuto-check passed
  • Generating Documentation

    ancoleman/ai-design-components

    Generate comprehensive technical documentation including API docs (OpenAPI/Swagger), code documentation (TypeDoc/Sphinx), documentation sites (Docusaurus/MkDocs), Architecture Decision Records…

    526 GitHub stars~3k tokensUpdated 10 mo ago
    DevelopmentAuto-check passed
  • CLI Creator

    huangruiteng/CS-Notes

    Build a composable CLI for Codex from API docs, an OpenAPI spec, existing curl examples, an SDK, a web app, an admin tool, or a local script.

    4k GitHub starsUsed in 2 repos~2.7k tokens
    Backend & APIsAuto-check passed
  • Create, validate and maintain OpenAPI 3.1 specs for REST APIs, whether designed first or generated from existing code, and use them for docs and client SDKs.

    40k GitHub starsUsed in 9 repos~511 tokens
    Backend & APIsAuto-check passed

Questions about Api2cli

What does Api2cli do?

Generate a working CLI from any API, then wrap it in a Claude Code skill. Api2cli is an agent skill from alexknowshtml/api2cli. Generate a working CLI from any API, then wrap it in a Claude Code skill.

When should I use Api2cli?

Api2cli fits situations like: 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.

How do I install Api2cli in Claude Code?

Run `npx skills add alexknowshtml/api2cli --skill api2cli -a claude-code`. Or copy the skill folder (skill in alexknowshtml/api2cli) into .claude/skills/api2cli in your project. Claude Code loads it when a task matches its description.

How do I install Api2cli in Codex?

Run `npx skills add alexknowshtml/api2cli --skill api2cli -a codex`. Or copy the skill folder (skill in alexknowshtml/api2cli) into .agents/skills/api2cli in your project. Codex loads it when a task matches its description.

Can I use Api2cli in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add alexknowshtml/api2cli --skill api2cli -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/api2cli, .gemini/skills/api2cli, .github/skills/api2cli and .opencode/skills/api2cli in your project.

What does Api2cli need to run?

Going by SKILL.md and its folder, Api2cli needs the command-line tools its instructions call (npx, git, npm, node and claude) and credentials named STRIPE_API_KEY. Our summary lists: Node.js; A credential in STRIPE_API_KEY.

Does Api2cli access the network?

SKILL.md names 2 domains. In commands or code: docs.stripe.com and github.com; the agent is likely to contact these when it follows the instructions. This is read from the text; nothing was executed.

Is Api2cli safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Api2cli use?

Api2cli is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Api2cli use?

About 2.9k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.4k tokens, read only when the agent opens those files.

What are the alternatives to Api2cli?

Skills that share tags, products or a category with Api2cli: Code Documenter (zebbern/claude-code-guide, 4.7k stars), Spiceflow (remorses/spiceflow, 167 stars), Code Documenter (Jeffallan/claude-skills, 12k stars) and Generating Documentation (ancoleman/ai-design-components, 526 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Api2cli?

alexknowshtml (a GitHub user) maintains it in alexknowshtml/api2cli, which has 455 GitHub stars. The repository was last updated on February 20, 2026.

Source: alexknowshtml/api2cli on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.