Skip to content
Back to search

cli-printing-press

MarketplaceWorks with Claude CodeGitHub

Every API has a secret identity. This finds it, absorbs every feature from every competing tool, then builds the GOAT CLI — designed for AI agents first, with SQLite sync, offline search, and compound insight commands.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/mvanhorn/cli-printing-press with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/mvanhorn/cli-printing-press'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/mvanhorn-cli-printing-press/badge.svg)](/listings/mvanhorn-cli-printing-press)

HTML

<a href="/listings/mvanhorn-cli-printing-press"><img src="/api/listings/mvanhorn-cli-printing-press/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

You need both the **binary** and the **Printing Press skills**. The skills (`/printing-press <app>`) are the primary interface; they drive the binary behind the scenes.

The binary alone works (research, generation, verification, scoring) but skips the curated agent loop. The skills alone have nothing to call. Install both.

**Prerequisites:** [Go 1.26.6 or newer](https://go.dev/dl/), [Claude Code](https://claude.ai/code) or another `skills`-supported agent, and Node/npm for `npx`. The skills are tested with Claude Code; install for Codex with `--agent codex` when you want to try the same slash-command workflow there. **Use Claude Code for the best-tested experience.**

1. Install

curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash

The installer runs `go install` for the generator binary, then refreshes all Printing Press skills through `skills@latest add --skill '*'`. Restart or reload your agent session after it completes so the refreshed skills are loaded.

Use `--cli-only` or `--skills-only` when you only want one side:

curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --cli-only
curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --skills-only

Claude Code is the default install target. To install or refresh the skills for Codex instead, pass `--agent codex`:

curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --skills-only --agent codex
npx -y skills@latest list -g -a codex --json

See [docs/CODEX.md](docs/CODEX.md) for the Codex-specific notes.

Verify with `cli-printing-press --version`. If install fails, confirm Go 1.26.6 or newer is installed, Node/npm is installed for `npx`, and `$GOPATH/bin` is on your `PATH`.

Older releases installed a generator binary named `printing-press`. That legacy entrypoint still works for compatibility, but the canonical generator command is now `cli-printing-press` so the public library installer can own `printing-press list`, `printing-press search`, and `printing-press install`.

<details> <summary><b>Manual install</b></summary>

Install or update the binary:

go install github.com/mvanhorn/cli-printing-press/v4/cmd/cli-printing-press@latest

Use Vercel's [open-agent-skills](https://www.npmjs.com/package/skills) CLI to install the Printing Press skills from this repo into a supported agent. Claude Code is the default and tested path:

npx -y skills@latest add mvanhorn/cli-printing-press/skills --skill '*' -g -a claude-code -y

For Codex:

npx -y skills@latest add mvanhorn/cli-printing-press/skills --skill '*' -g -a codex -y
npx -y skills@latest list -g -a codex --json

To refresh the skills later without naming individual skills, rerun the installer in skills-only mode:

curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --skills-only

Restart or reload the target agent after refreshing skills so the new skill text is loaded.

</details>

Once installed, you can start Claude Code from any folder. Codex users should start a fresh Codex session after installing or refreshing skills.

<details> <summary><b>Developer path: load skills from a clone</b></summary>

Use this if you're editing the Printing Press itself and want local skill changes to take effect on the next session start.

git clone https://github.com/mvanhorn/cli-printing-press.git
cd cli-printing-press
claude --plugin-dir .          # load this repo's skills directly
claude --plugin-dir . -w       # ...in a new git worktree (parallel runs)

For a persistent local setup that survives restarts and also loads in background sessions, see [Local Plugin Development](docs/PLUGIN-DEV.md).

</details>

2. Start a printing session

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 31 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. {
  2. "name": "cli-printing-press",
  3. "owner": {
  4. "name": "mvanhorn"
  5. },
  6. "metadata": {
  7. "description": "Generate production Go CLIs from API descriptions or OpenAPI specs",
  8. "version": "2.0.0"
  9. },
  10. "plugins": [
  11. {
  12. "name": "cli-printing-press",
  13. "description": "Describe your API. Get a production CLI. Generates Go CLI tools from OpenAPI specs or natural language descriptions.",
  14. "author": {
  15. "name": "mvanhorn"
  16. },
  17. "repository": "mvanhorn/cli-printing-press",
  18. "tags": [
  19. "cli",
  20. "codegen",
  21. "openapi",
  22. "go",
  23. "api"
  24. ],
  25. "source": {
  26. "source": "github",
  27. "repo": "mvanhorn/cli-printing-press"
  28. }
  29. }
  30. ]
  31. }
README.md · README · 616 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # CLI Printing Press
  2. [![CI](https://github.com/mvanhorn/cli-printing-press/actions/workflows/lint.yml/badge.svg)](https://github.com/mvanhorn/cli-printing-press/actions/workflows/lint.yml)
  3. [![Golden](https://github.com/mvanhorn/cli-printing-press/actions/workflows/golden.yml/badge.svg)](https://github.com/mvanhorn/cli-printing-press/actions/workflows/golden.yml)
  4. [![Release](https://img.shields.io/github/v/release/mvanhorn/cli-printing-press?display_name=tag&sort=semver)](https://github.com/mvanhorn/cli-printing-press/releases)
  5. [![Go](https://img.shields.io/github/go-mod/go-version/mvanhorn/cli-printing-press)](go.mod)
  6. [![License](https://img.shields.io/github/license/mvanhorn/cli-printing-press)](LICENSE)
  7. Nothing is more valuable than time and money. In a world of AI agents, that's speed and token spend. A well-designed CLI is muscle memory for an agent: no hunting through docs, no wrong turns, no wasted tokens. We built the Printing Press to print the best CLIs in the world for agents.
  8. It reads the official API docs, studies every popular community CLI and MCP server, sniffs the web for the APIs nobody published (think Google Flights or Dominos), and applies the power-user playbook Peter Steinberger proved with [discrawl](https://github.com/steipete/discrawl) and [gogcli](https://github.com/steipete/gogcli) - local SQLite, compound commands, agent-native flags. It fuses all of that and prints a token-efficient Go CLI plus a Claude Code skill plus an MCP server for any API or any website.
  9. Three CLIs printed by the press, installable today:
  10. - ESPN (sniffed, no official API). _"Tonight's NBA playoff games with live score, series state, each team's leading scorer's stat line, and any injury or lineup news from the last 24 hours."_ Returns everything in one call.
  11. - flight-goat (Kayak nonstop search plus sniffed Google Flights). _"Non-stop flights over 8 hours from Seattle for 4 people, Dec 24 to Jan 1, cheapest first."_ Two sources stitched into one query.
  12. - linear-pp-cli (50ms against a local SQLite mirror). _"Every blocked issue whose blocker has been stuck for a week."_ Compound queries the API can't answer.
  13. Browse the full catalog of printed CLIs at [printingpress.dev](https://printingpress.dev) or in the [Printing Press Library](https://github.com/mvanhorn/printing-press-library), organized by category, most with full MCP servers.
  14. **Codex users:** see [docs/CODEX.md](docs/CODEX.md) to install the Printing Press skills with `--agent codex`, verify the install, and understand how that differs from `/printing-press <api> codex`.
  15. **Cursor users:** see [docs/CURSOR.md](docs/CURSOR.md) for how to install a printed CLI, attach the matching skill, handle auth, and choose CLI vs MCP when your repo does not already document a workflow.
  16. ## Install
  17. You need both the **binary** and the **Printing Press skills**. The skills (`/printing-press <app>`) are the primary interface; they drive the binary behind the scenes.
  18. The binary alone works (research, generation, verification, scoring) but skips the curated agent loop. The skills alone have nothing to call. Install both.
  19. **Prerequisites:** [Go 1.26.11 or newer](https://go.dev/dl/), [Claude Code](https://claude.ai/code) or another `skills`-supported agent, and Node/npm for `npx`. The skills are tested with Claude Code; install for Codex with `--agent codex` when you want to try the same slash-command workflow there. **Use Claude Code for the best-tested experience.**
  20. ### 1. Install
  21. ```bash
  22. curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash
  23. ```
  24. The installer runs `go install` for the generator binary, then refreshes all Printing Press skills through `skills@latest add --skill '*'`. Restart or reload your agent session after it completes so the refreshed skills are loaded.
  25. Use `--cli-only` or `--skills-only` when you only want one side:
  26. ```bash
  27. curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --cli-only
  28. curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --skills-only
  29. ```
  30. Claude Code is the default install target. To install or refresh the skills for Codex instead, pass `--agent codex`:
  31. ```bash
  32. curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --skills-only --agent codex
  33. npx -y skills@latest list -g -a codex --json
  34. ```
  35. See [docs/CODEX.md](docs/CODEX.md) for the Codex-specific notes.
  36. Verify with `cli-printing-press --version`. If install fails, confirm Go 1.26.11 or newer is installed, Node/npm is installed for `npx`, and `$GOPATH/bin` is on your `PATH`.
  37. Older releases installed a generator binary named `printing-press`. That legacy
  38. entrypoint still works for compatibility, but the canonical generator command is
  39. now `cli-printing-press` so the public library installer can own
  40. `printing-press list`, `printing-press search`, and `printing-press install`.
  41. <details>
  42. <summary><b>Manual install</b></summary>
  43. Install or update the binary:
  44. ```bash
  45. go install github.com/mvanhorn/cli-printing-press/v4/cmd/cli-printing-press@latest
  46. ```
  47. Use Vercel's [open-agent-skills](https://www.npmjs.com/package/skills) CLI to install the Printing Press skills from this repo into a supported agent. Claude Code is the default and tested path:
  48. ```bash
  49. npx -y skills@latest add mvanhorn/cli-printing-press/skills --skill '*' -g -a claude-code -y
  50. ```
  51. For Codex:
  52. ```bash
  53. npx -y skills@latest add mvanhorn/cli-printing-press/skills --skill '*' -g -a codex -y
  54. npx -y skills@latest list -g -a codex --json
  55. ```
  56. To refresh the skills later without naming individual skills, rerun the installer in skills-only mode:
  57. ```bash
  58. curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --skills-only
  59. ```
  60. Restart or reload the target agent after refreshing skills so the new skill text is loaded.
  61. </details>
  62. Once installed, you can start Claude Code from any folder. Codex users should start a fresh Codex session after installing or refreshing skills.
  63. <details>
  64. <summary><b>Developer path: load skills from a clone</b></summary>
  65. Use this if you're editing the Printing Press itself and want local skill changes to take effect on the next session start.
  66. ```bash
  67. git clone https://github.com/mvanhorn/cli-printing-press.git
  68. cd cli-printing-press
  69. claude --plugin-dir . # load this repo's skills directly
  70. claude --plugin-dir . -w # ...in a new git worktree (parallel runs)
  71. ```
  72. For a persistent local setup that survives restarts and also loads in background sessions, see [Local Plugin Development](docs/PLUGIN-DEV.md).
  73. </details>
  74. ### 2. Start a printing session
  75. ```bash
  76. claude
  77. ```
  78. Then inside Claude Code:
  79. ```text
  80. /printing-press <app-name>
  81. ```
  82. For example:
  83. ```text
  84. /printing-press Notion # Print a CLI for an API by name
  85. /printing-press https://postman.com/explore # ...or point at a website (no spec needed)
  86. /printing-press-reprint notion # Reprint an existing CLI under the latest machine
  87. ```
  88. `/printing-press` drives the `cli-printing-press` binary you installed — research, generation, scoring, and shipcheck all run through it. Two parts, one workflow.
  89. One command. Lean loop. Produces a Go CLI plus an MCP server that absorbs every feature from every competing tool, then transcends with compound use cases only possible with local data. REST, GraphQL, or browser-sniffed traffic. No OpenAPI spec required.
  90. Each run produces two binaries (`<api>-pp-cli` plus `<api>-pp-mcp`), research documents, verification proofs, and a Quality Score.
  91. <details>
  92. <summary><b>Where output goes</b></summary>
  93. By default, active and published output are separated:
  94. - Active managed runs work in `~/printing-press/.runstate/<scope>/runs/<run-id>/working/<api>-pp-cli`
  95. - Published CLIs go to `~/printing-press/library/<api>`
  96. - Archived manuscripts go to `~/printing-press/manuscripts/<api>/<run-id>/`
  97. - Manuscripts are split into `research/`, `proofs/`, `discovery/`, and `pipeline/`
  98. `<scope>` is derived from the current git checkout path, so parallel worktrees do not stomp on each other. If you pass `--output`, that overrides the generated CLI location for that command.
  99. </details>
  100. <details>
  101. <summary><b>Codex mode (60% fewer Opus tokens)</b></summary>
  102. ```bash
  103. /printing-press HubSpot codex # Offload code generation to Codex CLI
  104. /printing-press HubSpot # Standard Opus mode (default)
  105. ```
  106. When you add `codex`, Phase 3's code generation tasks are delegated to Codex CLI. Claude stays the brain (research, planning, scoring, review). Codex does the hands (writing Go code from scoped prompts). Same quality, 60% fewer Opus tokens. If Codex fails 3 times in a row, the press falls back to doing it locally, no manual intervention needed.
  107. </details>
  108. <details>
  109. <summary><b>Improve an existing CLI (Polish)</b></summary>
  110. Targeted fix-up. Diagnostics (dogfood, verify, scorecard, output review), fixes verify failures, removes dead code, cleans descriptions and READMEs, offers to publish. Auto-runs as Phase 5.5 of every generation; can also run standalone:
  111. ```bash
  112. /printing-press-polish notion
  113. ```
  114. </details>
  115. <details>
  116. <summary><b>Publish a CLI to the library</b></summary>
  117. When you're happy with a CLI, publish it to the library:
  118. ```bash
  119. /printing-press-publish linear # Validates, packages, creates PR
  120. ```
  121. </details>
  122. <details>
  123. <summary><b>Amend a published CLI from a dogfood session</b></summary>
  124. After dogfooding a published CLI in a Claude Code session, turn the friction you hit (missing flags, hand-rolled API payloads, silent-null returns) into a PR for the public library. Mines the active session transcript, scopes the patch with you, plans + executes the fix autonomously, scrubs PII, and opens a PR — two checkpoints (scope, PR draft):
  125. ```bash
  126. /printing-press-amend # auto-detect target CLI from session
  127. /printing-press-amend superhuman # explicit target
  128. ```
  129. </details>
  130. ## Why these CLIs win
  131. Most generators wrap endpoints and stop. Printing Press generates CLIs that understand the domain.
  132. Local-first data layer. High-gravity resources get domain-specific SQLite tables (not JSON blobs), FTS5 full-text search indexes, and incremental sync with cursor tracking. `sync` pulls data down. `search` finds it in milliseconds. `sql` lets power users query directly. All offline, all local.
  133. Machine-owned freshness. Store-backed CLIs can opt into a bounded pre-read refresh via `cache.enabled` so `--data-source auto` keeps the local store current without a manual `sync`. `--data-source local` and `--data-source live` give you full control.
  134. Compound commands no wrapper can do. Once data lives in SQLite, commands like `stale`, `health`, `bottleneck`, and `reconcile` become possible - they join across resources and analyze history. A stateless API wrapper literally cannot do this.
  135. Agent-native by default. Human-friendly tables when you're in a terminal. Auto-JSON when piped, no `--json` flag needed. `--compact` drops to high-gravity fields only (60-80% fewer tokens). Typed exit codes (`0`/`2`/`3`/`4`/`5`/`7`) let agents self-correct without parsing error text. `--dry-run` for safe exploration. Every flag exists because an AI agent will call it thousands of times a day.
  136. No spec? No problem. Don't have an OpenAPI spec? Point the press at a website. It launches a browser, captures traffic, reverse-engineers the API, and generates the spec for you. ESPN, Postman Explore, internal tools - if you can click through it, the press can build a CLI for it.
  137. Dual interface from one spec. Every API gets a Cobra CLI (`<api>-pp-cli`) and an MCP server (`<api>-pp-mcp`). Same client, same store, same auth. Shell agents use the CLI. IDE agents use MCP. Zero code duplication.
  138. Verified, not vibes. Four mechanical checks - scorecard, dogfood, proof-of-behavior, live API smoke test - catch hallucinated paths, dead flags, auth mismatches, and broken data pipelines before you ship.
  139. Credits its sources. Every generated README includes a Sources and Inspiration section that credits the ecosystem tools studied during research. We built on giants' shoulders and we say so.
  140. ## The non-obvious insight
  141. Every API has a secret identity. The data it exposes is useful for something its creators never designed for. The printing press finds that secret and builds a CLI around it.
  142. The Non-Obvious Insight (NOI) is a one-sentence reframe:
  143. ```
  144. "[API] isn't just [obvious thing]. It's [non-obvious thing].
  145. Every [data point] is a signal about [hidden truth]."
  146. ```
  147. | API | What they think it is | What it actually is |
  148. |-----|----------------------|---------------------|
  149. | Discord | A chat app | A searchable knowledge base. Every message thread is institutional memory. |
  150. | Linear | An issue tracker | A team behavior observatory. Every state change is a signal about how your team actually works vs. how they think they work. |
  151. | Stripe | A payment processor | A business health monitor. Every failed charge and churn event is a signal about product-market fit. |
  152. | GitHub | A code host | An engineering culture fingerprint. Every review turnaround and merge pattern is a signal about how your team ships. |
  153. | Notion | A doc editor | A knowledge decay detector. Every stale page and orphaned database is a signal about what your team has forgotten. |
  154. | HubSpot | A CRM | Your company's relationship memory. Every deal stage transition, email open, and meeting log is a signal about pipeline health and rep performance. |
  155. | Slack | Messaging | An organizational nervous system. Every response time and channel silence is a signal about team health. |
  156. | ESPN | Sports data | A betting intelligence terminal. Every injury report, lineup change, and odds movement is a signal about game outcomes. |
  157. The NOI is the creative DNA of every CLI the press generates. Phase 0 cannot complete without one. If the LLM can't write an NOI, the research wasn't deep enough.
  158. The printing press automates what Steinberger does intuitively: look at an API, see what power users actually do with it, and build the commands that matter. Then also wrap every endpoint for completeness.
  159. ## The thinking behind it
  160. ### Every endpoint. Every insight. One command.
  161. Discord's API has 300+ endpoints. Most generators stop there - wrap every endpoint, ship it, done. But [discrawl](https://github.com/steipete/discrawl) - Peter Steinberger's Discord tool - ignores most of them. It ships 11 commands: `sync`, `search`, `sql`, `tail`, `mentions`, `members`. 583 stars.
  162. Why does the 11-command tool win? Because Steinberger saw something Discord's own API designers didn't: conversations are institutional knowledge. Every message thread is a document that should be archived, indexed, and searched locally. Those 11 commands embody that insight. The 300 endpoint wrappers don't.
  163. Until now, you had to choose: breadth (wrap every endpoint) or depth (understand the user). The printing press eliminates that choice. It generates the full API surface AND matches every feature the top competitor has AND adds the discrawl-style intelligence layer AND an MCP server. One spec in. Everything out.
  164. ### Absorb and transcend
  165. The GOAT CLI isn't built by finding gaps. It's built by absorbing every good idea and compounding on top.
  166. Layer 1, absorb. Before generating, the ecosystem absorb gate catalogs every feature from every Claude Code plugin, MCP server, community skill, competing CLI, and automation script for your API. Every feature becomes a row in the absorb manifest, something our CLI must match AND beat with offline support, agent-native output, and SQLite persistence. The system even auto-suggests novel features it thinks are missing from the ecosystem before you approve the manifest.
  167. Layer 2, transcend. Once you have everything in SQLite, compound use cases emerge that no stateless tool can do. Velocity tracking requires historical cycle data. Churn risk requires joining charges + subscriptions. Bottleneck detection requires the full issue relationship graph. These are the Non-Obvious Insight commands, and they only work because Layer 1 put everything in a local database.
  168. The GOAT = everything everyone else does + everything nobody else thought of.
  169. ### The creativity ladder
  170. Most API CLIs stop at Rung 1. The printing press climbs to Rung 5.
  171. | Rung | What it is | Auto-generated? | Example |
  172. |------|-----------|-----------------|---------|
  173. | 1 | API wrapper commands | Yes (from spec) | `issue create --title "..."` |
  174. | 2 | Output formatting | Yes (always) | `--json`, `--select`, `--csv`, `--dry-run` |
  175. | 3 | Local persistence | Yes (conditional) | `sync`, `search`, `export`, `tail` |
  176. | 4 | Domain analytics | Yes (from archetype) | `stale --days 30`, `orphans`, `load` |
  177. | 5 | Behavioral insights | Yes (from archetype) | `health` (composite score), `similar` (duplicate detection) |
  178. Rung 3 is table stakes. Rung 4 is where discrawl lives. Rung 5 is where nobody else is yet.
  179. The press generates the API wrapper in Phase 2 (Rung 1-2). Then it generates the discrawl-style data layer and workflow commands in Phase 3 (Rung 3-5) from domain archetype templates. Both in one run.
  180. ### How we knew this was real
  181. When choosing between Peter Steinberger's [gogcli](https://github.com/steipete/gogcli) (6.5K+ stars, Go) and Google's official [Workspace CLI](https://github.com/googleworkspace/cli) (10K+ stars in a week, Rust), we ran [/last30days](https://github.com/mvanhorn/last30days-skill) - a recency research skill - across 34 X posts, 5 YouTube videos, and 10 web sources.
  182. The verdict: use gogcli. The newer, official tool with 10x the API coverage lost to the older third-party one. As one user put it: "my preference is 100% gogcli since I have my agent working a lot with Google Docs and sheets, and gogcli just makes him able to do what he needs to do."
  183. Breadth doesn't beat depth. Understanding the user beats understanding the API.
  184. ### Why CLIs plus MCP
  185. The NOI is the creative intelligence. The printing press generates both interfaces from one spec:
  186. - `<api>-pp-cli`. Cobra CLI for humans plus shell agents (Claude Code, Codex, Gemini CLI).
  187. - `<api>-pp-mcp`. MCP server for Claude Desktop, Cursor, Windsurf, Cline. Auto-discovered, no shell needed.
  188. Same `internal/client`, same `internal/store`, same auth. Two binaries, zero code duplication.
  189. CLIs win for agents. 100x fewer tokens than MCP tool definitions. LLMs were trained on shell interactions. Exit code 0 = done. `--json | jq` is a first-class composition pattern.
  190. MCP wins for IDE integration. Claude Desktop and Cursor discover tools automatically via MCP. No shell needed. The MCP server exposes the same operations as the CLI, including the data layer (sync, search, sql).
  191. ```
  192. One spec -> cli-printing-press generate -> <api>-pp-cli (cobra) + <api>-pp-mcp (MCP server)
  193. | |
  194. same internal/client, internal/store
  195. ```
  196. Every API that gets a CLI+MCP becomes instantly accessible to every AI coding tool. The printing press is the factory.
  197. ## How it works
  198. The fast path is a lean loop. Artifacts still matter, but only when they directly improve the next phase.
  199. ```
  200. Phase 0 Resolve + Reuse (1-3 min) Reuse research, detect tokens, resolve spec or URL
  201. Phase 1 Research Brief (5-10 min) API identity, competitors, data layer, product thesis
  202. Phase 1.5 Ecosystem Absorb Gate (5-10 min) Catalog every MCP/skill/CLI feature -> absorb manifest + novel suggestions
  203. Phase 1.7 Browser-Sniff Gate (2-5 min) Browser capture, HAR import, discovery provenance
  204. Phase 2 Generate (1-2 min) Go CLI + MCP server from spec with validation
  205. Phase 3 Build The GOAT (10-20 min) ALL absorbed features + transcendence commands
  206. Phase 4 Shipcheck (3-8 min) Dogfood + verify --fix + scorecard as one verification block
  207. Phase 5 Live Smoke (optional) (2-5 min) Read-only API smoke + data-flow check
  208. ```
  209. That Phase 0..5 table is a compression map. The skill's live IDs are the `phases/NN-*.md` filename stems (`10-generate`, `12-shipcheck`, `18-dogfood-testing`). Receipts and resume pointers use those stems.
  210. Three entry paths. Got an OpenAPI spec? Use `--spec`. Got a URL to a website with no docs? The browser-sniff gate launches a browser, captures traffic, and generates the spec. Got a HAR file from DevTools? Pass `--har`. The press handles all three.
  211. Published CLIs live in the Printing Press Library. The repo no longer carries a source catalog; new and updated CLIs should be published through the public-library workflow so the listing, skills mirror, and release metadata stay in one place.
  212. Discovery provenance. When the press sniffs a website, it archives everything - pages visited, endpoints discovered, response samples, rate limiting events, and `traffic-analysis.json` with protocol/auth/protection signals and discovery warnings - into a `discovery/` manuscript alongside the research and proofs. Full audit trail.
  213. Full pipeline contract. The fast path above compresses a longer 9-phase managed pipeline: preflight, research, scaffold, enrich, regenerate, review, agent-readiness, comparative, ship. Inputs, outputs, gates, and artifacts for each phase are documented in [docs/PIPELINE.md](docs/PIPELINE.md). Use it when you want to stop at any phase, resume later, re-run one step, or port the flow to another tool.
  214. <details>
  215. <summary><b>MCP spec surface (advanced config)</b></summary>
  216. The generator ships three opt-in knobs on the spec's `mcp:` block, aligned with Anthropic's [production-agent MCP guidance](https://www.anthropic.com/news/building-agents-that-reach-production-systems-with-mcp):
  217. ```yaml
  218. mcp:
  219. transport: [stdio, http] # remote-capable for cloud-hosted agents; default [stdio]
  220. addr: "127.0.0.1:7777" # loopback bind; ":7777" listens on every interface and requires TLS
  221. orchestration: code # "endpoint-mirror" (default), "intent", or "code"
  222. endpoint_tools: hidden # suppress raw endpoint tools when intents cover the surface
  223. intents: # compose multi-step tools declaratively
  224. - name: create_issue_from_thread
  225. description: "Create an issue from a Slack thread."
  226. params:
  227. - { name: thread_id, type: string, required: true, description: "slack thread id" }
  228. steps:
  229. - endpoint: messages.get_thread
  230. bind: { thread_id: "${input.thread_id}" }
  231. capture: thread
  232. - endpoint: issues.create
  233. bind: { title: "${thread.subject}", description: "${thread.body}" }
  234. capture: issue
  235. returns: issue
  236. ```
  237. Run `cli-printing-press mcp-audit` after changes to see which library CLIs would benefit from the new surface.
  238. </details>
  239. ## What gets generated
  240. Designed for AI agents. Every flag, every output format, every exit code is chosen because an agent will consume it. Human-friendly table output in the terminal. Auto-JSON when piped, no flag needed. `--compact` drops to high-gravity fields only (id, name, status, timestamps), 60-80% fewer tokens. Typed exit codes (`0`=success, `2`=usage, `3`=not found, `4`=auth, `5`=API, `7`=rate limited) let agents self-correct in one retry without parsing error text. `--dry-run` lets agents explore safely. Humans benefit from all of this too. Agent-native design is just good CLI design taken seriously.
  241. Agent-first flags (every command): `--json`, `--select`, `--dry-run`, `--stdin`, `--csv`, `--compact`, `--quiet`, `--yes`, `--no-input`, `--no-cache`, `--no-color`. Auto-JSON when piped (no `--json` needed). Typed exit codes as above.
  242. Actionable errors. Errors include the specific flag/arg that's wrong, the correct usage pattern, and the command path. Agents self-correct in one retry.
  243. Bounded output. List commands show "Showing N results. To narrow: add --limit, --json --select, or filter flags." Token-conscious `--compact` mode returns only high-gravity fields, 60-80% fewer tokens.
  244. Table stakes features (from the absorb gate). Every feature the top competitor has, classified and built before novel features. If schpet/linear-cli has `start` (git branch from issue), you get it. If 4ier/notion-cli has human-friendly filters, you get it. Anti-gaming rules prevent scorecard optimization over real features.
  245. Data layer (high-gravity entities). Domain-specific SQLite tables with proper columns (not JSON blobs), FTS5 full-text search, incremental sync with cursor tracking, `sql` command for raw queries, domain-specific `UpsertX()` and `SearchX()` methods.
  246. Workflow commands (from archetype): `stale`, `orphans`, `load`, etc.
  247. Insight commands (Rung 5): `health` (composite score), `similar` (duplicate detection), `trends`, `bottleneck`, `forecast`, `patterns`.
  248. Production-ready output. Command name normalization (`retrieve-a` -> `get`, `post` -> `create`, `patch` -> `update`); `.printing-press.json` provenance manifest; "Sources and Inspiration" section in each generated README; proxy-envelope support for APIs that wrap requests in a POST envelope; adaptive rate limiting on browser-sniffed APIs (start slow, ramp on success, back off on 429); minimum 1 test file per package; `.goreleaser.yaml` plus Homebrew formula plus GitHub Actions CI; REST or GraphQL specs both supported; MCP server auto-emitted at `cmd/api-mcp/main.go`; cursor-based pagination, batch SQLite transactions, tuned pragmas, `--since` incremental sync, and `--concurrency` parallel workers in every `sync` (discrawl-inspired).
  249. ### Domain archetypes
  250. The profiler classifies every API into a domain archetype and auto-generates the right workflow + insight commands:
  251. | Archetype | Detected by | Auto-generated commands |
  252. |-----------|------------|------------------------|
  253. | Project Management | issue/task/ticket resources, assignee fields, priority levels | `stale`, `orphans`, `load`, `health`, `similar` |
  254. | Communication | message/channel/thread resources, threading fields | `health`, `similar` |
  255. | Payments | charge/payment/invoice resources, amount/currency fields | `reconcile`, `revenue`, `health`, `similar` |
  256. | Infrastructure | server/deploy/instance resources | `health`, `similar` |
  257. | Content | document/page/block resources | `health`, `similar` |
  258. The archetype is detected automatically from the spec. The entity mapper figures out which resource is the "primary entity" (issues for PM, messages for comms, charges for payments) and wires the templates accordingly.
  259. ## Verification & quality
  260. Four mechanical checks before a CLI can ship: a two-tier scorecard, structural dogfood, proof of behavior, and (when an API key is present) a live read-only smoke test. No vibes, no self-assessment.
  261. Three benchmarks shape the scorecard, all must pass:
  262. 1. Architecture (discrawl benchmark). Does it have a real data layer: domain-specific SQLite, FTS5, incremental sync, workflow commands?
  263. 2. Quality (gogcli benchmark). Does the code have proper output modes, typed errors, agent-native flags, doctor, README with cookbook?
  264. 3. Features (competitor benchmark). Would a user of the top competitor switch to this CLI?
  265. Architecture without features is a toy. Features without architecture is a thin wrapper. Quality without either is polished nothing.
  266. ### Two-tier scorecard (100 points)
  267. Inspired by Peter Steinberger's [gogcli](https://github.com/steipete/gogcli). Two tiers, weighted 50/50. Grade A = 85+.
  268. Tier 1: infrastructure (50 points). Does the skeleton have the right patterns?
  269. | Dimension | What it checks |
  270. |-----------|---------------|
  271. | Output Modes | --json, --csv, --select, --quiet, --compact, auto-JSON when piped |
  272. | Auth | OAuth flow, format-aware headers (Bot/Bearer/Basic from spec) |
  273. | Error Handling | Typed exits, retry with backoff, actionable error messages |
  274. | Agent-Native | --json, --select, --dry-run, --stdin, --no-input, --compact, --yes |
  275. | + 5 more | Terminal UX, README, Doctor, Local Cache, Breadth |
  276. Tier 2: domain correctness (50 points). Does the code actually work?
  277. | Dimension | What it checks |
  278. |-----------|---------------|
  279. | Path Validity | Generated paths exist in the OpenAPI spec |
  280. | Auth Protocol | Auth format matches spec's securitySchemes |
  281. | Data Pipeline | Sync calls domain-specific UpsertX(), not generic Upsert() |
  282. | Sync Correctness | Real resources, nested paths, pagination, incremental cursors |
  283. | Type Fidelity | String IDs (not int), required params marked, quality descriptions |
  284. | Dead Code | No unwired flags, no uncalled functions, no ghost tables |
  285. Why two tiers? A scorecard that only checks syntax ("does this string exist in the file?") misses semantics ("does this code actually work?"). The two-tier system forces both breadth and depth.
  286. Anti-gaming rules prevent optimizing for score instead of features. Table stakes (features competitors have) are Priority 1. Scorecard optimization is Priority 4.
  287. ### Verification commands
  288. ```bash
  289. # Quality scorecard: two-tier scoring (infrastructure + domain correctness)
  290. cli-printing-press scorecard --dir ./my-pp-cli --spec ./openapi.json
  291. # Dogfood: catches dead flags, dead functions, auth mismatches, invalid paths
  292. cli-printing-press dogfood --dir ./my-pp-cli --spec ./openapi.json
  293. # Runtime verification: tests every command against real API or mock server
  294. cli-printing-press verify --dir ./my-pp-cli --spec ./openapi.json --api-key $TOKEN
  295. # Emboss audit: baseline snapshot for improvement cycle
  296. cli-printing-press emboss --dir ./my-pp-cli --spec ./openapi.json --audit-only
  297. ```
  298. ### Proof of behavior
  299. The scorecard checks structure. Proof of Behavior checks data flow: does `sync.go` actually call `UpsertMessage` on a table that `search.go` queries?
  300. Four behavioral proofs:
  301. - Path Proof. Every URL in generated commands exists in the OpenAPI spec.
  302. - Flag Proof. Every registered flag is referenced in at least one command.
  303. - Pipeline Proof. Every SQLite table has a WRITE path (sync) and READ path (search/query).
  304. - Auth Proof. Auth header format matches the spec's securitySchemes.
  305. If any proof fails, auto-remediation removes dead code and re-verifies. Hallucinated paths and auth mismatches are hard FAIL gates.
  306. ### Live API testing
  307. When you provide an API key at the start, Phase 5 runs read-only tests against the real API:
  308. ```
  309. LIVE API TEST RESULTS
  310. =====================
  311. Auth: PASS (200 OK on doctor)
  312. List: 3/3 passed (users, channels, guilds)
  313. Get: 1/1 passed (user abc123)
  314. Sync: PASS (5 pages synced, 12 blocks)
  315. Search: PASS (3 results for "a")
  316. Verdict: PASS - CLI works against real API
  317. ```
  318. Safety: GET only, --limit 1, 10s timeout, stops on 401. Never creates, posts, or deletes anything.
  319. ### Auth doctor
  320. `cli-printing-press auth doctor` scans every installed printed CLI's `tools-manifest.json` and reports whether its declared env vars are set, unset, or suspicious. Fingerprints show the first four characters of each set value, never the full token.
  321. ```bash
  322. cli-printing-press auth doctor
  323. cli-printing-press auth doctor --json
  324. ```
  325. Useful when an agent hits a 401 on a printed CLI: one command shows whether the token is missing, truncated, or shadowed by a stale value without having to inspect shell config. Offline, read-only, and exits 0 even when findings include "not set" or "suspicious" because this is diagnostic, not gating.
  326. ### Ship loop
  327. "Is this shippable?" triggers a fix cycle: identify top 3 issues, fix them, re-score. Max 3 iterations. No more dead-end assessments.
  328. ## Library
  329. Published CLIs live in the [Printing Press Library](https://github.com/mvanhorn/printing-press-library), organized by category, most with full MCP servers. Browse at [printingpress.dev](https://printingpress.dev).
  330. A small sample, see the [full catalog](https://github.com/mvanhorn/printing-press-library#catalog) for the rest:
  331. | CLI | Category | What it does |
  332. |-----|----------|--------------|
  333. | `espn-pp-cli` | Media and Entertainment | ESPN sports data: scores, stats, standings across 17 sports. |
  334. | `flightgoat-pp-cli` | Travel | Kayak nonstop search plus sniffed Google Flights, in one call. |
  335. | `linear-pp-cli` | Project Management | 50ms compound queries against a local Linear mirror. |
  336. | `kalshi-pp-cli` | Payments | Trade prediction markets from the terminal. |
  337. | `recipe-goat-pp-cli` | Food and Dining | Trust-aware ranking across 37 recipe sites. |
  338. Each newly published CLI ships a root `AGENTS.md` operating guide, a research manuscript, verification proofs, and a `.printing-press.json` provenance manifest.
  339. ## Troubleshooting
  340. **`/printing-press` slash command doesn't appear.** Restart or reload the agent session after installing the skills. For Claude Code, run `npx -y skills@latest list -g -a claude-code` to verify the install. For Codex, run `npx -y skills@latest list -g -a codex --json`. If you're developing from a clone in Claude Code, confirm `claude --plugin-dir .` was run from the cloned repo root or use the persistent local setup in [Local Plugin Development](docs/PLUGIN-DEV.md).
  341. **`cli-printing-press: command not found` after a successful `go install`.** `$GOPATH/bin` (default `~/go/bin`) isn't on your `PATH`. Add it to your shell profile.
  342. **Live API smoke test reports 401.** Token unset or stale. Run `cli-printing-press auth doctor` to see which env vars are missing or suspicious before reading shell config.
  343. **Browser-sniff captures no useful endpoints.** The site likely uses websockets, gRPC, or aggressive bot detection. Try a HAR export from DevTools (`/printing-press --har ./capture.har`) instead of the live browser flow.
  344. **Codex mode falls back to local generation.** Expected behavior after 3 consecutive Codex failures. Standard Opus mode takes over with no manual intervention.
  345. ## Limitations
  346. - **Technical capability is not legal permission.** Before generating a CLI for any service, review its Terms of Service. Many services explicitly prohibit automated access. Using this tool against such services may violate their terms or applicable law. You are responsible for ensuring your use is authorized.
  347. - **Requires Go 1.26.11 or newer and an agent that can load open-agent-skills.** Claude Code is the tested path; Codex installation is documented but may lag Claude Code behavior. No standalone distribution today; the slash command is the supported entry point for Claude Code.
  348. - **Generated CLIs are domain-shaped, not vendor-replacements.** A `<api>-pp-cli` covers the agent power-user surface, not every back-office knob a vendor's official CLI ships.
  349. - **Browser-sniff requires manual capture.** You point a browser at the site (or import a HAR); the press doesn't crawl autonomously.
  350. - **Live verify is read-only.** Phase 5 runs GET only and never mutates. Real write-path coverage lives in unit tests and the dogfood structural checks.
  351. - **Scoring is structural, not end-user QA.** A Grade A scorecard means the CLI follows the patterns; it doesn't replace using the CLI in anger for an afternoon.
  352. - **`regen-merge` is macOS+Linux only.** Windows isn't supported for the regen-merge subcommand today.
  353. ## FAQ
  354. **Why not Speakeasy, Fern, or openapi-generator?** Those wrap endpoints. We wrap endpoints AND generate the discrawl-style data layer (SQLite, FTS5, sync, compound commands) AND the MCP server AND the agent-native UX (typed exit codes, `--compact`, auto-JSON-when-piped). The output is shaped for an agent that will call it thousands of times a day.
  355. **Does it work without Claude?** The binary works standalone (research, generation, verification, scoring), and the skills can be installed for Codex with `--agent codex`. The curated agent loop is tested in Claude Code first, so bring your own review discipline if you use another harness.
  356. **Does it require an OpenAPI spec?** No. Three input modes: a spec (`--spec`), a HAR file (`--har`), or just a URL. The browser-sniff gate launches a browser, captures traffic, and reverse-engineers the spec for sites that don't publish one.
  357. **How fresh is the local SQLite cache?** Configurable. Without `cache.enabled`, you run `sync` manually. With `cache.enabled` and `--data-source auto`, the CLI runs a bounded pre-read refresh before serving local data. `--data-source local` skips refresh; `--data-source live` bypasses the cache entirely.
  358. **What does shipping a CLI cost in tokens?** Standard Opus mode runs end-to-end on Opus. Codex mode (`/printing-press <api> codex`) offloads Phase 3 code generation to Codex CLI for ~60% fewer Opus tokens. Both produce equivalent quality.
  359. **Can I run the verification tools on a CLI I built by hand?** Yes. `cli-printing-press scorecard`, `dogfood`, and `verify` accept any directory + spec. Tier 1 of the scorecard checks for agent-native patterns; Tier 2 checks paths/auth/data-flow against the spec.
  360. ## Contributing
  361. Bug reports, feature requests, and PRs are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a PR; it explains the PR template, AI / automation disclosure, and the repo boundary between the Printing Press and printed CLIs. [AGENTS.md](AGENTS.md) carries the full developer conventions, glossary, commit style, and verification rules. Report a vulnerability privately; see [SECURITY.md](SECURITY.md).
  362. ## Development
  363. <details>
  364. <summary><b>Build, test, lint, and hooks</b></summary>
  365. ```bash
  366. go build -o ./cli-printing-press ./cmd/cli-printing-press
  367. go test ./...
  368. go fmt ./...
  369. golangci-lint run ./...
  370. ```
  371. A pre-push lefthook hook runs `golangci-lint` on changed files; the same config (`.golangci.yml`) runs in CI.
  372. Install hooks with:
  373. ```bash
  374. brew install lefthook
  375. lefthook install --reset-hooks-path
  376. ```
  377. Use `--reset-hooks-path` so stale local `core.hooksPath` settings do not block hook sync. Avoid `lefthook install --force` unless intentionally overriding a custom hooks path.
  378. If you use the clone-based developer path above, `claude --plugin-dir .` loads `/printing-press` from your working copy, so local skill edits take effect on the next session start. For a restart-safe local plugin setup, see [Local Plugin Development](docs/PLUGIN-DEV.md). See [AGENTS.md](AGENTS.md) for full conventions, glossary, and release flow.
  379. </details>
  380. <details>
  381. <summary><b>Golden Output Harness</b></summary>
  382. Golden output checks compare deterministic, offline `printing-press` commands against committed stdout, stderr, exit-code, and selected artifact fixtures:
  383. ```bash
  384. scripts/golden.sh verify
  385. ```
  386. Use update mode only after an intentional behavior change:
  387. ```bash
  388. scripts/golden.sh update
  389. ```
  390. The harness rebuilds `./cli-printing-press`, writes actual outputs under `.gotmp/golden/actual`, and compares them to `testdata/golden/expected`. Cases live under `testdata/golden/cases/<case-name>/`; `command.txt` defines the offline command, and `artifacts.txt` lists behaviorally important generated files to compare. Normalization is intentionally narrow: machine-specific paths, deterministic JSON formatting, and known provenance fields like generated timestamps. CI runs this as a separate `Golden` workflow, not inside `go test ./...`.
  391. The generated-CLI golden uses `testdata/golden/fixtures/golden-api.yaml`, a purpose-built OpenAPI fixture for the Printing Press. Extend that fixture when the machine gains new deterministic generation capabilities that should be protected by artifact goldens. Update mode refuses dirty worktrees unless `GOLDEN_ALLOW_DIRTY=1` is set, so fixture churn stays intentional.
  392. </details>
  393. ## Credits
  394. - Peter Steinberger ([@steipete](https://github.com/steipete)). [discrawl](https://github.com/steipete/discrawl) and [gogcli](https://github.com/steipete/gogcli) set the bar. The quality scoring system is inspired by his work; discrawl's sync architecture directly influenced the printing press templates.
  395. - Trevin Chow ([@trevin](https://x.com/trevin)). [10 Principles for Agent Native CLIs](https://trevinsays.com/p/10-principles-for-agent-native-clis) shaped the agent-first template design. Co-creator shipping PRs daily.
  396. - Ramp ([@tryramp](https://github.com/ramp-public/ramp-cli)). Their agent-first CLI inspired auto-JSON piping, --no-input, and --compact output.
  397. - The community filers and contributors whose issues and PRs nudged the catalog forward.
  398. ## License
  399. MIT
scripts/install.sh · Bundled script · 465 lines · 3 findings marked
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. shopt -s lastpipe 2>/dev/null || true
  4. umask 022
  5. # CLI Printing Press installer
  6. #
  7. # One-line install:
  8. # curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 9 on GitHub
  9. #
  10. # Options:
  11. # --cli-only Install or update only the Go generator binary.
  12. # --skills-only Install or refresh only the Printing Press skills.
  13. # -a, --agent NAME Install skills for an agent supported by `skills`.
  14. # May be repeated. Defaults to claude-code.
  15. # --dry-run Print commands without executing them.
  16. # --quiet Suppress non-error output.
  17. # --no-gum Disable gum formatting even when gum is installed.
  18. # -h, --help Show help.
  19. readonly PROJECT_NAME="CLI Printing Press"
  20. readonly BINARY_NAME="cli-printing-press"
  21. readonly GO_MIN_VERSION="1.26.11"
  22. readonly GO_INSTALL_TARGET="github.com/mvanhorn/cli-printing-press/v4/cmd/cli-printing-press@latest"
  23. readonly SKILL_SOURCE="mvanhorn/cli-printing-press/skills"
  24. readonly SKILLS_PACKAGE="skills@latest"
  25. readonly DEFAULT_AGENT="claude-code"
  26. INSTALL_CLI=1
  27. INSTALL_SKILLS=1
  28. DRY_RUN=0
  29. QUIET=0
  30. NO_GUM=0
  31. AGENTS=()
  32. PROXY_ARGS=()
  33. TMP_DIR=""
  34. LOCK_DIR=""
  35. CLI_STATUS="skipped"
  36. SKILLS_STATUS="skipped"
  37. cleanup() {
  38. if [[ -n "${LOCK_DIR:-}" && -d "$LOCK_DIR" ]]; then
  39. rm -f "$LOCK_DIR/pid" 2>/dev/null || true
  40. rmdir "$LOCK_DIR" 2>/dev/null || true
  41. fi
  42. if [[ -n "${TMP_DIR:-}" && -d "$TMP_DIR" ]]; then
  43. rm -rf "$TMP_DIR"
  44. fi
  45. }
  46. trap cleanup EXIT
  47. usage() {
  48. cat <<'USAGE'
  49. CLI Printing Press installer
  50. Usage:
  51. bash scripts/install.sh [options]
  52. curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 58 on GitHub
  53. curl -fsSL https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/scripts/install.sh | bash -s -- --cli-only
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 59 on GitHub
  54. Options:
  55. --cli-only Install or update only the Go generator binary.
  56. --skills-only Install or refresh only the Printing Press skills.
  57. -a, --agent NAME Install skills for an agent supported by `skills`.
  58. May be repeated. Defaults to claude-code.
  59. --dry-run Print commands without executing them.
  60. --quiet Suppress non-error output.
  61. --no-gum Disable gum formatting even when gum is installed.
  62. -h, --help Show this help.
  63. USAGE
  64. }
  65. for arg in "$@"; do
  66. case "$arg" in
  67. --cli-only)
  68. INSTALL_SKILLS=0
  69. ;;
  70. --skills-only)
  71. INSTALL_CLI=0
  72. ;;
  73. --dry-run)
  74. DRY_RUN=1
  75. ;;
  76. --quiet)
  77. QUIET=1
  78. ;;
  79. --no-gum)
  80. NO_GUM=1
  81. ;;
  82. --agent=*)
  83. AGENTS+=("${arg#--agent=}")
  84. ;;
  85. -a=*)
  86. AGENTS+=("${arg#-a=}")
  87. ;;
  88. -h|--help)
  89. usage
  90. exit 0
  91. ;;
  92. *)
  93. # Handled below so "-a value" and "--agent value" can consume the next arg.
  94. ;;
  95. esac
  96. done
  97. # Re-parse options that consume a following value.
  98. if (($# > 0)); then
  99. while (($# > 0)); do
  100. case "$1" in
  101. -a|--agent)
  102. shift
  103. if (($# == 0)); then
  104. echo "error: --agent requires a value" >&2
  105. exit 1
  106. fi
  107. AGENTS+=("$1")
  108. ;;
  109. --cli-only|--skills-only|--dry-run|--quiet|--no-gum|-h|--help|--agent=*|-a=*)
  110. ;;
  111. *)
  112. echo "error: unknown option: $1" >&2
  113. exit 1
  114. ;;
  115. esac
  116. shift || true
  117. done
  118. fi
  119. if [[ "$INSTALL_CLI" -eq 0 && "$INSTALL_SKILLS" -eq 0 ]]; then
  120. echo "error: choose only one of --cli-only or --skills-only" >&2
  121. exit 1
  122. fi
  123. if [[ "${#AGENTS[@]}" -eq 0 ]]; then
  124. AGENTS=("$DEFAULT_AGENT")
  125. fi
  126. HAS_GUM=0
  127. if command -v gum >/dev/null 2>&1 && [[ -t 1 && "$NO_GUM" -eq 0 ]]; then
  128. HAS_GUM=1
  129. fi
  130. info() {
  131. [[ "$QUIET" -eq 1 ]] && return 0
  132. if [[ "$HAS_GUM" -eq 1 ]]; then
  133. gum style --foreground 39 "-> $*"
  134. else
  135. printf '\033[0;34m->\033[0m %s\n' "$*"
  136. fi
  137. }
  138. ok() {
  139. [[ "$QUIET" -eq 1 ]] && return 0
  140. if [[ "$HAS_GUM" -eq 1 ]]; then
  141. gum style --foreground 42 "✓ $*"
  142. else
  143. printf '\033[0;32m✓\033[0m %s\n' "$*"
  144. fi
  145. }
  146. warn() {
  147. [[ "$QUIET" -eq 1 ]] && return 0
  148. if [[ "$HAS_GUM" -eq 1 ]]; then
  149. gum style --foreground 214 "! $*"
  150. else
  151. printf '\033[1;33m!\033[0m %s\n' "$*"
  152. fi
  153. }
  154. err() {
  155. if [[ "$HAS_GUM" -eq 1 ]]; then
  156. gum style --foreground 196 "✗ $*" >&2
  157. else
  158. printf '\033[0;31m✗\033[0m %s\n' "$*" >&2
  159. fi
  160. }
  161. strip_ansi() {
  162. sed -E $'s/\x1B\\[[0-9;]*[A-Za-z]//g'
  163. }
  164. draw_box() {
  165. local color="$1"
  166. shift
  167. local lines=("$@")
  168. local width=0
  169. local line clean len
  170. for line in "${lines[@]}"; do
  171. clean="$(printf '%s' "$line" | strip_ansi)"
  172. len=${#clean}
  173. ((len > width)) && width=$len
  174. done
  175. ((width < 24)) && width=24
  176. [[ "$QUIET" -eq 1 ]] && return 0
  177. if [[ "$HAS_GUM" -eq 1 ]]; then
  178. printf '%s\n' "${lines[@]}" | gum style --border double --border-foreground "$color" --padding "0 1"
  179. return 0
  180. fi
  181. printf '╔'
  182. printf '═%.0s' $(seq 1 $((width + 2)))
  183. printf '╗\n'
  184. for line in "${lines[@]}"; do
  185. clean="$(printf '%s' "$line" | strip_ansi)"
  186. printf '║ %s%*s ║\n' "$line" $((width - ${#clean})) ''
  187. done
  188. printf '╚'
  189. printf '═%.0s' $(seq 1 $((width + 2)))
  190. printf '╝\n'
  191. }
  192. run_with_spinner() {
  193. local title="$1"
  194. shift
  195. if [[ "$DRY_RUN" -eq 1 ]]; then
  196. local quoted=()
  197. local arg
  198. for arg in "$@"; do
  199. printf -v arg '%q' "$arg"
  200. quoted+=("$arg")
  201. done
  202. info "[dry-run] ${quoted[*]}"
  203. return 0
  204. fi
  205. if [[ "$HAS_GUM" -eq 1 && "$QUIET" -eq 0 ]]; then
  206. gum spin --spinner dot --title "$title" -- "$@"
  207. else
  208. info "$title"
  209. "$@"
  210. fi
  211. }
  212. setup_proxy() {
  213. PROXY_ARGS=()
  214. if [[ -n "${HTTPS_PROXY:-}" ]]; then
  215. PROXY_ARGS=(--proxy "$HTTPS_PROXY")
  216. elif [[ -n "${HTTP_PROXY:-}" ]]; then
  217. PROXY_ARGS=(--proxy "$HTTP_PROXY")
  218. fi
  219. }
  220. detect_platform() {
  221. local os arch
  222. os="$(uname -s | tr '[:upper:]' '[:lower:]')"
  223. arch="$(uname -m)"
  224. case "$arch" in
  225. x86_64|amd64) arch="x86_64" ;;
  226. arm64|aarch64) arch="aarch64" ;;
  227. esac
  228. case "$os" in
  229. darwin|linux) ;;
  230. *)
  231. err "Unsupported OS: $os"
  232. exit 1
  233. ;;
  234. esac
  235. case "$arch" in
  236. x86_64|aarch64) ;;
  237. *)
  238. err "Unsupported architecture: $arch"
  239. exit 1
  240. ;;
  241. esac
  242. if [[ "$os" == "linux" ]] && grep -qi microsoft /proc/version 2>/dev/null; then
  243. warn "WSL detected; continuing with Linux install."
  244. fi
  245. }
  246. check_disk_space() {
  247. local path="${TMPDIR:-/tmp}"
  248. local available
  249. available="$(df -Pk "$path" | awk 'NR==2 {print $4}')"
  250. if [[ -n "$available" && "$available" -lt 10240 ]]; then
  251. err "At least 10MB of free space is required in $path."
  252. exit 1
  253. fi
  254. }
  255. check_write_permissions() {
  256. local probe
  257. probe="$(mktemp "${TMPDIR:-/tmp}/cli-printing-press-install.XXXXXX")"
  258. rm -f "$probe"
  259. }
  260. check_network() {
  261. if [[ "$DRY_RUN" -eq 1 ]]; then
  262. return 0
  263. fi
  264. if command -v curl >/dev/null 2>&1; then
  265. curl -fsSL --connect-timeout 5 ${PROXY_ARGS[@]+"${PROXY_ARGS[@]}"} https://github.com >/dev/null || {
  266. err "Network check failed: could not reach github.com."
  267. exit 1
  268. }
  269. if [[ "$INSTALL_SKILLS" -eq 1 ]]; then
  270. curl -fsSL --connect-timeout 5 ${PROXY_ARGS[@]+"${PROXY_ARGS[@]}"} https://registry.npmjs.org/skills >/dev/null || {
  271. err "Network check failed: could not reach registry.npmjs.org."
  272. exit 1
  273. }
  274. fi
  275. fi
  276. }
  277. acquire_lock() {
  278. local lock_base="${XDG_STATE_HOME:-$HOME/.local/state}/cli-printing-press"
  279. mkdir -p "$lock_base"
  280. LOCK_DIR="$lock_base/install.lock"
  281. if mkdir "$LOCK_DIR" 2>/dev/null; then
  282. printf '%s\n' "$$" > "$LOCK_DIR/pid"
  283. return 0
  284. fi
  285. if [[ -f "$LOCK_DIR/pid" ]]; then
  286. local pid
  287. pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
  288. if [[ -n "$pid" ]] && ! kill -0 "$pid" 2>/dev/null; then
  289. warn "Removing stale installer lock."
  290. rm -rf "$LOCK_DIR"
  291. mkdir "$LOCK_DIR"
  292. printf '%s\n' "$$" > "$LOCK_DIR/pid"
  293. return 0
  294. fi
  295. fi
  296. err "Another CLI Printing Press installer appears to be running."
  297. exit 1
  298. }
  299. parse_go_version() {
  300. sed -nE 's/^go version go([0-9]+(\.[0-9]+){1,2}).*/\1/p'
  301. }
  302. version_ge() {
  303. local left="$1"
  304. local right="$2"
  305. local IFS=.
  306. local -a l r
  307. read -r -a l <<< "$left"
  308. read -r -a r <<< "$right"
  309. local i lv rv
  310. for i in 0 1 2; do
  311. lv="${l[$i]:-0}"
  312. rv="${r[$i]:-0}"
  313. if ((10#$lv > 10#$rv)); then return 0; fi
  314. if ((10#$lv < 10#$rv)); then return 1; fi
  315. done
  316. return 0
  317. }
  318. check_go() {
  319. if ! command -v go >/dev/null 2>&1; then
  320. err "Go $GO_MIN_VERSION or newer is required."
  321. err "Install Go from https://go.dev/dl/, then re-run this installer."
  322. exit 1
  323. fi
  324. local version
  325. version="$(go version | parse_go_version)"
  326. if [[ -z "$version" ]]; then
  327. err "Could not determine the installed Go version. Ensure Go $GO_MIN_VERSION or newer is installed."
  328. exit 1
  329. fi
  330. if ! version_ge "$version" "$GO_MIN_VERSION"; then
  331. err "Go $GO_MIN_VERSION or newer is required; found Go $version."
  332. err "Install Go from https://go.dev/dl/, then re-run this installer."
  333. exit 1
  334. fi
  335. }
  336. check_node() {
  337. if ! command -v npm >/dev/null 2>&1 || ! command -v npx >/dev/null 2>&1; then
  338. err "Node/npm is required for skill installation."
  339. err "Install Node.js from https://nodejs.org/, then re-run this installer."
  340. exit 1
  341. fi
  342. }
  343. installed_cli_version() {
  344. if command -v "$BINARY_NAME" >/dev/null 2>&1; then
  345. "$BINARY_NAME" --version 2>/dev/null || true
  346. fi
  347. }
  348. install_cli() {
  349. local current
  350. current="$(installed_cli_version)"
  351. if [[ -n "$current" ]]; then
  352. info "Existing $BINARY_NAME detected: $current"
  353. fi
  354. run_with_spinner "Installing $BINARY_NAME with go install" go install "$GO_INSTALL_TARGET"
  355. if [[ "$DRY_RUN" -eq 1 ]]; then
  356. CLI_STATUS="planned"
  357. else
  358. CLI_STATUS="installed"
  359. ok "Installed $BINARY_NAME"
  360. fi
  361. }
  362. install_skills() {
  363. local cmd=(npx -y "$SKILLS_PACKAGE" add "$SKILL_SOURCE" --skill "*" -g -y)
  364. local agent
  365. for agent in "${AGENTS[@]}"; do
  366. cmd+=(-a "$agent")
  367. done
  368. run_with_spinner "Installing Printing Press skills" "${cmd[@]}"
  369. if [[ "$DRY_RUN" -eq 1 ]]; then
  370. SKILLS_STATUS="planned"
  371. else
  372. SKILLS_STATUS="installed"
  373. ok "Installed Printing Press skills for ${AGENTS[*]}"
  374. fi
  375. }
  376. preflight_checks() {
  377. info "Running preflight checks"
  378. detect_platform
  379. setup_proxy
  380. check_disk_space
  381. check_write_permissions
  382. check_network
  383. if [[ "$INSTALL_CLI" -eq 1 ]]; then
  384. check_go
  385. fi
  386. if [[ "$INSTALL_SKILLS" -eq 1 ]]; then
  387. check_node
  388. fi
  389. }
  390. print_header() {
  391. if [[ "$QUIET" -eq 1 ]]; then
  392. return 0
  393. fi
  394. if [[ "$HAS_GUM" -eq 1 ]]; then
  395. gum style \
  396. --border normal --border-foreground 39 \
  397. --padding "0 1" --margin "1 0" \
  398. "$(gum style --foreground 42 --bold "$PROJECT_NAME installer")" \
  399. "$(gum style --foreground 245 "Install the generator binary and Printing Press skills")"
  400. else
  401. printf '\033[1;32m%s installer\033[0m\n' "$PROJECT_NAME"
  402. printf '\033[0;90mInstall the generator binary and Printing Press skills\033[0m\n\n'
  403. fi
  404. }
  405. print_summary() {
  406. local lines=()
  407. lines+=("CLI: $CLI_STATUS")
  408. lines+=("Skills: $SKILLS_STATUS")
  409. if [[ "$INSTALL_SKILLS" -eq 1 ]]; then
  410. lines+=("Agents: ${AGENTS[*]}")
  411. lines+=("Restart or reload the target agent so refreshed skills are loaded.")
  412. fi
  413. draw_box 42 "${lines[@]}"
  414. }
  415. main() {
  416. TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/cli-printing-press-install.XXXXXX")"
  417. print_header
  418. acquire_lock
  419. preflight_checks
  420. if [[ "$INSTALL_CLI" -eq 1 ]]; then
  421. install_cli
  422. fi
  423. if [[ "$INSTALL_SKILLS" -eq 1 ]]; then
  424. install_skills
  425. fi
  426. print_summary
  427. }
  428. main "$@"

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.