# cli-to-js-api-wrapper

A skill that walks through wrapping a command line tool in a typed JavaScript/TypeScript API with the cli-to-js package. Useful when an agent should call commands as methods, not shell strings.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 439 installs · ★ 88
- Author: reason-machines
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/reason-machines/trending-skills/tree/HEAD/skills/cli-to-js-api-wrapper/SKILL.md
- Updated: 2026-10-09
- HTML: https://affpapa.org/en/nevibecode/skills/cli-to-js-api-wrapper

## What it does

The skill covers the `cli-to-js` package. It runs a binary's `--help`, turns that output into a schema, and hands back a Proxy where each subcommand is a method and each flag is an option. Positional arguments go under the `_` key, and camelCase keys are rewritten to kebab-case flags, so `{ dryRun: true }` becomes `--dry-run`.

TypeScript generics get their own section: you declare the subcommands and their options once and keep autocomplete plus type errors on later calls. Validation is the part worth reading twice. `$validate` reports flags the binary does not have and suggests near matches, which matters in agent loops where a made-up flag would otherwise reach the shell. Output helpers include `.text()`, `.lines()` and `.json<T>()`, and there is streaming through callbacks or `$spawn`, plus `$command` for building the command string without running it.

You need Node.js and the package itself: `npm install cli-to-js`. The wrapper only reaches binaries already present on the machine — `convertCliToJs("git")` installs nothing. Tools whose `--help` is a wall of unstructured text are a poor fit; for those you feed the help string to `fromHelpText` yourself.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/cli-to-js-api-wrapper/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/cli-to-js-api-wrapper/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/cli-to-js-api-wrapper/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/cli-to-js-api-wrapper/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install reason-machines/trending-skills cli-to-js-api-wrapper
```

2. **Manually: put the files in place**
- File: `.github/skills/cli-to-js-api-wrapper/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/reason-machines/trending-skills --path skills/cli-to-js-api-wrapper
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/cli-to-js-api-wrapper/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/reason-machines/trending-skills/tree/HEAD/skills/cli-to-js-api-wrapper/SKILL.md

## When to use it
- call a command line tool from Node.js without joining shell strings
- get autocomplete and type checking for CLI flags
- catch a mistyped flag name before the process starts
- turn command output into a string array or parsed JSON
- stream a long build and stop it on a matching line

## Example prompts
- Wrap `git` with cli-to-js and call `git.status()`
- Build a typed wrapper for `npm` and parse `npm outdated --json`
- Check the flags with `$validate` before running the command

## Similar
- [setup-matt-pocock-skills](https://affpapa.org/en/nevibecode/skills/setup-matt-pocock-skills.md) — skill · 1052851 installs
- [ask-matt](https://affpapa.org/en/nevibecode/skills/ask-matt.md) — skill · 766587 installs
- [to-tickets](https://affpapa.org/en/nevibecode/skills/to-tickets.md) — skill · 711230 installs
- [writing-plans](https://affpapa.org/en/nevibecode/skills/writing-plans.md) — skill · 282859 installs
- [caveman-review](https://affpapa.org/en/nevibecode/skills/caveman-review.md) — skill · 411800 installs
- [caveman-compress](https://affpapa.org/en/nevibecode/skills/caveman-compress.md) — skill · 411500 installs

From the same set: [reason-machines/trending-skills](https://affpapa.org/en/nevibecode/by/reason-machines/trending-skills.md) — 139 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
