cli-to-js-api-wrapper — Claude Code skill: CLI into a JS API
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.
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a claude-codeWhat cli-to-js-api-wrapper 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.
What it helps with
- 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 for the agent
- Wrap
gitwith cli-to-js and callgit.status() - Build a typed wrapper for
npmand parsenpm outdated --json - Check the flags with
$validatebefore running the command
How to install cli-to-js-api-wrapper
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a claude-code2Manually: put the files in place
~/.claude/skills/cli-to-js-api-wrapper/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/cli-to-js-api-wrapper/
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a codex2Manually: put the files in place
.agents/skills/cli-to-js-api-wrapper/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a cursor2Manually: put the files in place
.cursor/skills/cli-to-js-api-wrapper/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install reason-machines/trending-skills cli-to-js-api-wrapper2Manually: put the files in place
.github/skills/cli-to-js-api-wrapper/SKILL.md1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a gemini-cli2Platform CLI
gemini skills install https://github.com/reason-machines/trending-skills --path skills/cli-to-js-api-wrapperManually: put the files in place
.devin/skills/cli-to-js-api-wrapper/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about cli-to-js-api-wrapper
How do I install cli-to-js-api-wrapper in Claude Code?
Run npx skills add reason-machines/trending-skills --skill cli-to-js-api-wrapper -a claude-code. The skill file lands at ~/.claude/skills/cli-to-js-api-wrapper/SKILL.md.
What does cli-to-js-api-wrapper do?
It shows how to use the cli-to-js library to expose a command line tool as a typed JavaScript/TypeScript API, with subcommands as methods and flags as options.
What do I need for this skill to work?
Node.js and the cli-to-js package, installed with npm install cli-to-js. The wrapper works against binaries that are already available on your system.