@complexthings/superpowers-agent 8.4.1 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.agents/skills/caveman/SKILL.md +49 -0
  2. package/.agents/skills/diagnose/SKILL.md +117 -0
  3. package/.agents/skills/diagnose/scripts/hitl-loop.template.sh +41 -0
  4. package/.agents/skills/grill-with-docs/ADR-FORMAT.md +47 -0
  5. package/.agents/skills/grill-with-docs/CONTEXT-FORMAT.md +63 -0
  6. package/.agents/skills/grill-with-docs/SKILL.md +90 -0
  7. package/.agents/skills/handoff/SKILL.md +15 -0
  8. package/.agents/skills/improve-codebase-architecture/DEEPENING.md +37 -0
  9. package/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  10. package/.agents/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -0
  11. package/.agents/skills/improve-codebase-architecture/LANGUAGE.md +53 -0
  12. package/.agents/skills/improve-codebase-architecture/SKILL.md +81 -0
  13. package/.agents/skills/karpathy-guidelines/SKILL.md +75 -0
  14. package/.agents/skills/prototype/LOGIC.md +79 -0
  15. package/.agents/skills/prototype/SKILL.md +30 -0
  16. package/.agents/skills/prototype/UI.md +112 -0
  17. package/.agents/skills/review/SKILL.md +78 -0
  18. package/.agents/skills/setup-matt-pocock-skills/SKILL.md +125 -0
  19. package/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
  20. package/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +22 -0
  21. package/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +23 -0
  22. package/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +19 -0
  23. package/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
  24. package/.agents/skills/tdd/SKILL.md +109 -0
  25. package/.agents/skills/tdd/deep-modules.md +33 -0
  26. package/.agents/skills/tdd/interface-design.md +31 -0
  27. package/.agents/skills/tdd/mocking.md +59 -0
  28. package/.agents/skills/tdd/refactoring.md +10 -0
  29. package/.agents/skills/tdd/tests.md +61 -0
  30. package/.agents/skills/to-issues/SKILL.md +83 -0
  31. package/.agents/skills/to-prd/SKILL.md +76 -0
  32. package/.agents/skills/triage/AGENT-BRIEF.md +168 -0
  33. package/.agents/skills/triage/OUT-OF-SCOPE.md +101 -0
  34. package/.agents/skills/triage/SKILL.md +103 -0
  35. package/.agents/skills/ubiquitous-language/SKILL.md +93 -0
  36. package/.agents/skills/zoom-out/SKILL.md +7 -0
  37. package/.agents/superpowers-agent +120 -140
  38. package/.github/copilot-instructions.md +3 -0
  39. package/.github/workflows/main.yaml +1 -1
  40. package/AGENTS.md +97 -0
  41. package/README.md +32 -94
  42. package/package.json +3 -5
  43. package/skills/collaboration/leveraging-cli-tools/SKILL.md +48 -101
  44. package/skills/meta/create-agents-md/SKILL.md +182 -0
  45. package/skills/meta/create-agents-md/skill.json +9 -0
  46. package/skills/meta/writing-prompts/SKILL.md +64 -287
  47. package/skills/meta/writing-prompts/references/platforms.md +114 -0
@@ -0,0 +1,3 @@
1
+ <!-- SUPERPOWERS_-_INSTRUCTIONS_START -->
2
+ ${content}
3
+ <!-- SUPERPOWERS_-_INSTRUCTIONS_END -->
@@ -30,4 +30,4 @@ jobs:
30
30
  - name: Publish to npm
31
31
  env:
32
32
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
33
- run: npm publish --access public
33
+ run: npm publish --access public
package/AGENTS.md CHANGED
@@ -58,3 +58,100 @@ Skills encode proven techniques that prevent mistakes. Not using them means repe
58
58
 
59
59
  <!-- SUPERPOWERS_SKILLS_END -->
60
60
 
61
+ ## What This Project Is
62
+
63
+ **Superpowers Agent** is a CLI (`superpowers-agent`, alias `superpowers`) that manages reusable markdown-based "skills" for AI coding assistants. It delivers skills to Claude, GitHub Copilot, Cursor, Gemini, OpenCode, and Codex. Skills live in `skills/` (this repo) and `.agents/skills/`, and bootstrap symlinks them into each assistant's config directory. Published to npm as `@complexthings/superpowers-agent`.
64
+
65
+ ## Build & Development
66
+
67
+ The CLI source lives in `.agents/` and is built with **Bun** (`packageManager: bun@1.3.8`). Run scripts from the `.agents/` directory:
68
+
69
+ ```bash
70
+ cd .agents
71
+ bun run build # Build minified ESM bundle → .agents/superpowers-agent
72
+ bun run watch # Build in watch mode
73
+ bun run dev # Run CLI from source (bun src/cli.js)
74
+ bun run dev:link # Symlink the `superpowers-agent` bin to the dev source
75
+ bun run production:link # Symlink the bin to the built bundle
76
+ ```
77
+
78
+ The build (`.agents/build.js`) uses the `Bun.build` API, so it must run under **bun**, not node. Output is `.agents/superpowers-agent` — a polyglot shebang script that execs `bun` if present, otherwise `node`.
79
+
80
+ The CLI has **no runtime dependencies** (pure Node.js/Bun built-ins). The only dev dependency is `husky`. Node engines: `^20 || ^22 || ^24`.
81
+
82
+ ## Testing
83
+
84
+ There is **no automated test runner** and no `test` script. Verification is manual: run the CLI commands directly, or drive the saved prompt scenarios in `.agents/prompts/`. State this plainly rather than inventing a test command.
85
+
86
+ ## Architecture
87
+
88
+ ### Source (`.agents/src/`)
89
+
90
+ | Layer | Files | Responsibility |
91
+ |-------|-------|---------------|
92
+ | CLI entry | `cli.js` | Command dispatch table |
93
+ | Commands | `commands/bootstrap.js`, `update.js`, `simple-commands.js` | Command implementations |
94
+ | Core | `core/config.js`, `paths.js`, `platform-detection.js`, `git.js` | Config, path resolution, platform detection, git helpers |
95
+ | Skills | `skills/finder.js`, `locator.js`, `installer.js`, `executor.js`, `parser.js` | Skill discovery, install, execution pipeline |
96
+ | Agents | `agents/installer.js`, `agents/platforms.js` | Install agent definitions (`.github/agents/*.agent.md`, `.opencode/agents/*.md`) into platform dirs |
97
+ | Integrations | `integrations/claude.js`, `codex.js`, `copilot.js`, `cursor.js`, `gemini.js`, `opencode.js` | Per-platform symlink/config setup |
98
+ | Utils | `utils/symlinks.js`, `frontmatter.js`, `output.js`, `file-ops.js` | Shared helpers |
99
+
100
+ ### Skill Discovery Priority (highest → lowest)
101
+
102
+ 1. `.agents/skills/` — project-level
103
+ 2. `~/.agents/skills/` — personal cross-project
104
+ 3. `~/.agents/superpowers/skills/` — bundled community skills
105
+
106
+ ### CLI Commands
107
+
108
+ From `.agents/src/cli.js` dispatch table:
109
+
110
+ - **Core:** `bootstrap [--no-update] [--force]`, `version`, `check-updates`, `update [--no-reinstall]`
111
+ - **Config:** `config-get`, `config-set <key> <value>`
112
+ - **Skills:** `setup-skills`, `find-skills [pattern]`, `use-skill <name>`, `execute <name>`, `dir <name>`, `path <name>`, `get-helpers <skill> <search-term>`
113
+ - **Install/manage skills:** `add <url-or-path|@alias> [path]`, `add-repository <git-url> [--as=@alias]`, `list-repositories`, `pull <url-or-path|@alias>`, `rm <url-or-path|@alias>`
114
+ - **Integrations:** `install-cursor-hooks`, `install-aliases`
115
+
116
+ ### Key Flows
117
+
118
+ - **`bootstrap`** → detects installed AI platforms → symlinks skills into each platform's skills dir → writes platform config files
119
+ - **`find-skills [pattern]`** → searches all three skill tiers → returns name/path/description
120
+ - **`execute <skill-name>`** → locates skill → outputs SKILL.md content for the agent to follow
121
+ - **`add <url-or-path|@alias>`** → clones a git repo or copies a local path → installs skills into `~/.agents/superpowers/skills/`
122
+ - **`update`** → checks the npm registry for a newer version → reports if an update is available
123
+
124
+ ### Skill Structure
125
+
126
+ Each skill is a directory with a `SKILL.md` file:
127
+
128
+ ```
129
+ skills/
130
+ └── <category>/
131
+ └── <skill-name>/
132
+ ├── SKILL.md # Frontmatter (name, description) + instructions
133
+ ├── scripts/ # Optional support scripts
134
+ └── resources/ # Optional templates/data
135
+ ```
136
+
137
+ `SKILL.md` frontmatter fields: `name`, `description`, and optional `metadata` (e.g. `version`). The set of bundled skills and their lockfile state are tracked in `skill.json` and `skills-lock.json` at the repo root.
138
+
139
+ ## Versioning & Publishing
140
+
141
+ The `.husky/pre-commit` hook keeps the root `package.json` and `.agents/package.json` versions in sync: on commit it picks the higher of the two, writes both, refreshes lockfiles, rebuilds the bundle (`cd .agents && bun install && bun run build`), and stages the affected files. Don't hand-edit one version without the other.
142
+
143
+ The package is published to npm as `@complexthings/superpowers-agent` (registry auth via the `COMPLEX_THINGS_NPM_TOKEN` in `.npmrc`). The current version is whatever `package.json` reports — do not hardcode it elsewhere.
144
+
145
+ ## Agent skills
146
+
147
+ ### Issue tracker
148
+
149
+ Issues and PRDs are tracked as GitHub issues on `complexthings/superpowers`, managed via the `gh` CLI. See `docs/agents/issue-tracker.md`.
150
+
151
+ ### Triage labels
152
+
153
+ The five canonical triage roles use their default label strings (`needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`). See `docs/agents/triage-labels.md`.
154
+
155
+ ### Domain docs
156
+
157
+ Single-context layout — one `CONTEXT.md` + `docs/adr/` at the repo root (created lazily). See `docs/agents/domain.md`.
package/README.md CHANGED
@@ -2,10 +2,19 @@
2
2
 
3
3
  A comprehensive skills library of proven techniques, patterns, and workflows for AI coding assistants.
4
4
 
5
- **This is a fork and extension of Jesse Vincent's incredible [Superpowers for Claude Code](https://github.com/obra/superpowers).** Jesse's groundbreaking work and [his amazing blog post](https://blog.fsck.com/2025/10/09/superpowers/) introduced the concept of systematic, reusable skills for AI agents. This fork extends that vision to support agent-agnostic workflows across GitHub Copilot, Cursor, Gemini, and other AI coding assistants.
5
+ **This is a fork and extension of Jesse Vincent's incredible [Superpowers for Claude Code](https://github.com/obra/superpowers).** Jesse's groundbreaking work and [his amazing blog post](https://blog.fsck.com/2025/10/09/superpowers/) introduced the concept of systematic, reusable skills for AI agents. This fork extends that vision to support agent-agnostic workflows across GitHub Copilot, Claude Code, and OpenCode.
6
6
 
7
7
  ## What's New
8
8
 
9
+ **v9.0.0 (May 28, 2026):**
10
+
11
+ - **Claude persona installation** — `.claude/agents/<name>.md` personas now install into `~/.claude/agents/` via `add`/`pull` (previously silently skipped)
12
+ - ⚠️ **No more `postinstall`** — the npm `postinstall` script was removed for supply-chain hardening. Fresh installs now require a **one-time manual** `superpowers-agent bootstrap`; `superpowers-agent update` self-runs bootstrap thereafter
13
+ - ⚠️ **Removed Cursor, Codex & Gemini support** — supported platforms are now **GitHub Copilot, Claude Code, and OpenCode** only. Integration modules, detection, the `install-cursor-hooks` command, and `GEMINI.md` generation were removed
14
+ - ⚠️ **Skills live only in `~/.agents/skills`** — per-platform skill symlinking has been removed. A one-time `skill.json`-gated cleaner runs during `bootstrap` to scrub deprecated symlink directories (including legacy Cursor/Codex/Gemini) without touching agent personas
15
+ - **Fixed `copilot-instructions.md`** — `setup-skills` now correctly creates and idempotently updates `.github/copilot-instructions.md`
16
+ - **`bun test` harness** — added a Bun test runner, smoke test, and `test` script following the `.agents/tests/<feature>.test.js` convention
17
+
9
18
  **v8.4.0 (April 6, 2026):**
10
19
 
11
20
  - **`superpowers-agent rm` command** — new CLI command for removing installed skills and agents from your system
@@ -77,7 +86,7 @@ A comprehensive skills library of proven techniques, patterns, and workflows for
77
86
  - **Utility Commands** - `find-skills` to discover available skills, `execute` to load them
78
87
 
79
88
  Plus:
80
- - **Universal Prompts** - Work across Claude, GitHub Copilot, Cursor, Gemini, and other AI assistants
89
+ - **Universal Skills** - Work across GitHub Copilot, Claude Code, and OpenCode
81
90
  - **Automatic Integration** - Skills activate automatically when relevant
82
91
  - **Consistent Workflows** - Systematic approaches to common engineering tasks
83
92
 
@@ -85,13 +94,15 @@ Plus:
85
94
 
86
95
  ## Quick Install (Recommended)
87
96
 
88
- Install Superpowers globally with one command:
97
+ Install Superpowers globally and run the required one-time bootstrap step:
89
98
 
90
99
  ```bash
91
100
  npm install -g @complexthings/superpowers-agent
92
101
  superpowers-agent bootstrap
93
102
  ```
94
103
 
104
+ > **Note:** `superpowers-agent bootstrap` is a **required** one-time step after every fresh install. It is no longer run automatically by npm's `postinstall` hook — you must run it manually. Subsequent `superpowers-agent update` calls will run bootstrap for you automatically.
105
+
95
106
  ## Migration to Superpower Agent `^8.0.0`
96
107
 
97
108
  ```bash
@@ -273,90 +284,28 @@ superpowers-agent add https://github.com/example/agents-repo.git
273
284
  superpowers-agent pull @my-agents
274
285
  ```
275
286
 
276
- ### Skill Symlinks for IDE Integration
277
-
278
- Superpowers automatically creates symlinks to make skills available to all major AI coding assistants in their native skill directories.
279
-
280
- **How it works:**
281
-
282
- When you run `superpowers-agent bootstrap` or `superpowers-agent setup-skills`:
283
-
284
- 1. **Global symlinks** (via `bootstrap`) sync skills to user-level directories:
285
- - `~/.claude/skills/superpowers` -> `~/.agents/superpowers/skills/`
286
- - `~/.copilot/skills/superpowers` -> `~/.agents/superpowers/skills/`
287
- - `~/.config/opencode/skill/superpowers` -> `~/.agents/superpowers/skills/`
288
- - `~/.cursor/skills/superpowers` -> `~/.agents/superpowers/skills/`
289
- - `~/.gemini/skills/superpowers` -> `~/.agents/superpowers/skills/`
290
- - `~/.codex/skills/superpowers` -> `~/.agents/superpowers/skills/`
291
-
292
- 2. **Project symlinks** (via `setup-skills`) sync project skills to agent directories:
293
- - `.claude/skills` -> `.agents/skills`
294
- - `.github/skills` -> `.agents/skills`
295
- - `.opencode/skill` -> `.agents/skills`
296
- - `.cursor/skills` -> `.agents/skills`
297
- - `.gemini/skills` -> `.agents/skills`
298
- - `.codex/skills` -> `.agents/skills`
287
+ ### Skill Storage
299
288
 
300
- 3. **Personal skills** (installed via `superpowers-agent add`) are symlinked individually to all platforms.
289
+ As of v9.0.0, Superpowers no longer creates per-platform skill symlinks. Skills live in just two canonical locations and the supported agents discover them there directly:
301
290
 
302
- **Behavior:**
303
- - Symlinks are only created if the parent directory exists
304
- - Use `--force` flag to create parent directories: `superpowers-agent bootstrap --force`
305
- - Use `--force-<agent>` flags to re-install only specific agent integrations (e.g. `--force-copilot`, `--force-cursor`, `--force-claude`)
306
- - Symlinks are tracked in `~/.agents/config.json` for management
291
+ - **Global skills** — bundled Superpowers skills in `~/.agents/superpowers/skills/` and personal skills in `~/.agents/skills/`
292
+ - **Project skills** `.agents/skills/` inside a project (created/managed by `setup-skills`)
307
293
 
308
- **Windows Notes:**
294
+ **Stale symlink cleanup:**
309
295
 
310
- On Windows, symlinks require either:
311
- - Developer Mode enabled (Settings > Update & Security > For developers)
312
- - Running as administrator
313
-
314
- If symlink creation fails on Windows, you'll see a warning with instructions.
315
-
316
- **Configuration:**
317
- ```json
318
- // ~/.agents/config.json
319
- {
320
- "symlinks": {
321
- "claude": {
322
- "superpowers": "~/.claude/skills/superpowers",
323
- "skills": ["~/.claude/skills/my-skill"]
324
- },
325
- "copilot": {
326
- "superpowers": "~/.copilot/skills/superpowers",
327
- "skills": []
328
- },
329
- "opencode": {
330
- "superpowers": "~/.config/opencode/skill/superpowers",
331
- "skills": []
332
- },
333
- "cursor": {
334
- "superpowers": "~/.cursor/skills/superpowers",
335
- "skills": []
336
- },
337
- "gemini": {
338
- "superpowers": "~/.gemini/skills/superpowers",
339
- "skills": []
340
- },
341
- "codex": {
342
- "superpowers": "~/.codex/skills/superpowers",
343
- "skills": []
344
- }
345
- }
346
- }
347
- ```
296
+ A one-time, `skill.json`-gated cleaner runs during `superpowers-agent bootstrap`. It scrubs deprecated per-platform skill symlink directories left behind by older versions — including legacy Cursor, Codex, and Gemini directories — without touching agent personas in `~/.claude/agents/` or the supported platforms.
348
297
 
349
- ## Slash Commands & Skill Priority
298
+ ## Skill Priority
350
299
 
351
- Superpowers delivers skills as symlinks into each agent's native skill directory. Each agent discovers and loads skills using its native skill tool no separate prompt/command files are installed.
300
+ Each supported agent discovers and loads skills using its native skill tool. No separate prompt/command files are installed.
352
301
 
353
302
  **Skill priority pipeline (first match wins):**
354
- 1. `./skills/` or `.agents/skills/` inside the workspace (project-specific overrides)
303
+ 1. `.agents/skills/` inside the workspace (project-specific overrides)
355
304
  2. `.claude/skills/` inside the repo if present (repo-wide Claude overrides)
356
305
  3. Personal skills in `~/.agents/skills/` (user-level customizations)
357
306
  4. Bundled Superpowers skills in `~/.agents/superpowers/skills/` (system defaults)
358
307
 
359
- When any agent invokes a skill — no matter which tool it originates from — the CLI enforces the ordering above. Add a `brainstorming` skill under `./skills/` and every tool immediately picks it up without modifying any prompt files.
308
+ When any agent invokes a skill — no matter which supported tool it originates from — the CLI enforces the ordering above. Add a `brainstorming` skill under `.agents/skills/` and every supported tool immediately picks it up.
360
309
 
361
310
  ### OpenCode
362
311
 
@@ -364,22 +313,11 @@ Skills are available via OpenCode's native `skill` tool. The `.opencode/plugins/
364
313
 
365
314
  ### GitHub Copilot
366
315
 
367
- Skills are available via the native skill tool.
368
-
369
- ### Cursor
370
-
371
- Skills are available via the native skill tool.
372
- ### Gemini
373
-
374
- Skills are available via the native skill tool.
316
+ Skills are available via the native skill tool.
375
317
 
376
318
  ### Claude Code
377
319
 
378
- Skills are available via the native skill tool.
379
-
380
- ### Codex
381
-
382
- Skills are available via the native skill tool.
320
+ Skills are available via the native skill tool. Claude agent personas defined in `.claude/agents/<name>.md` are installed into `~/.claude/agents/` via `add`/`pull`.
383
321
 
384
322
  ## What's Inside
385
323
 
@@ -450,7 +388,7 @@ The `tests/` directory contains agent-agnostic test scripts for validating skill
450
388
  ./tests/skill-triggering/run-all.sh
451
389
 
452
390
  # Configure for your agent
453
- export AGENT_CLI="opencode" # or "claude", "cursor", etc.
391
+ export AGENT_CLI="opencode" # or "claude", "copilot", etc.
454
392
  ./tests/skill-triggering/run-test.sh prompts/test-name.txt
455
393
  ```
456
394
 
@@ -609,7 +547,7 @@ superpowers-agent add @baici
609
547
  1. **Bootstrap Process** - Installs agent integrations and syncs skill symlinks globally
610
548
  2. **Skill Discovery** - Finds skills across system, personal, and project locations
611
549
  3. **Priority Resolution** - Project skills override personal skills override system skills
612
- 4. **Universal Integration** - Works with OpenCode, GitHub Copilot, Cursor, Gemini, and other AI assistants
550
+ 4. **Universal Integration** - Works with GitHub Copilot, Claude Code, and OpenCode
613
551
 
614
552
  **For OpenCode:**
615
553
  1. **Plugin System** - The `.opencode/plugins/superpowers-agent.js` plugin injects bootstrap context dynamically at session start
@@ -667,11 +605,11 @@ Use `--force-<agent>` flags to target individual agents without running the full
667
605
  # Re-install only GitHub Copilot integration
668
606
  superpowers-agent bootstrap --force-copilot
669
607
 
670
- # Re-install Copilot and Gemini together
671
- superpowers-agent bootstrap --force-copilot --force-gemini
608
+ # Re-install Copilot and Claude together
609
+ superpowers-agent bootstrap --force-copilot --force-claude
672
610
  ```
673
611
 
674
- Supported flags: `--force-copilot`, `--force-cursor`, `--force-codex`, `--force-gemini`, `--force-claude`, `--force-opencode`
612
+ Supported flags: `--force-copilot`, `--force-claude`, `--force-opencode`
675
613
 
676
614
  > When `--force-<agent>` flags are used, universal alias installation and `AGENTS.md` platform generation are skipped. Skill symlink sync still runs. If the agent's directory does not exist (e.g. `~/.copilot`), it will be created automatically.
677
615
 
@@ -725,7 +663,7 @@ This project builds on [Jesse Vincent's Superpowers for Claude Code](https://git
725
663
  - OpenCode plugin architecture pattern
726
664
  - Test infrastructure for skill validation
727
665
 
728
- This fork extends that vision to support agent-agnostic workflows across multiple AI coding assistants including GitHub Copilot, Cursor, Gemini, OpenCode, and Codex.
666
+ This fork extends that vision to support agent-agnostic workflows across GitHub Copilot, Claude Code, and OpenCode.
729
667
 
730
668
  ## License
731
669
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@complexthings/superpowers-agent",
3
- "version": "8.4.1",
3
+ "version": "9.0.1",
4
4
  "description": "Superpowers agent CLI — skills system for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,9 +25,7 @@
25
25
  "engines": {
26
26
  "node": "^20 || ^22 || ^24"
27
27
  },
28
- "scripts": {
29
- "postinstall": "node .agents/superpowers-agent bootstrap --no-update 2>/dev/null || true"
30
- },
28
+ "scripts": {},
31
29
  "author": {
32
30
  "name": "Greg Harvell",
33
31
  "email": "greg.harvell@complexthings.com",
@@ -35,7 +33,7 @@
35
33
  },
36
34
  "repository": {
37
35
  "type": "git",
38
- "url": "https://github.com/complexthings/superpowers.git"
36
+ "url": "git+https://github.com/complexthings/superpowers.git"
39
37
  },
40
38
  "bugs": {
41
39
  "url": "https://github.com/complexthings/superpowers/issues"
@@ -1,132 +1,79 @@
1
1
  ---
2
2
  name: leveraging-cli-tools
3
- description: Use when performing code searches, JSON parsing, file viewing, or file finding tasks - ensures agents verify and use high-performance CLI tools (rg, jq, fd, bat, ast-grep) instead of slower standard tools, reducing token costs and latency by 5-50x
3
+ description: Use when performing code searches, JSON/YAML parsing, file finding, structural refactors, or data wrangling - ensures agents reach for high-performance CLI tools (rg, jq, fd, yq, ast-grep, gh, sd) over slower standard tools like grep/find/sed, cutting token cost and latency 5-50x. Check availability and offer to install a tool when a relevant task arises.
4
4
  ---
5
5
 
6
6
  # Leveraging CLI Tools
7
7
 
8
- ## Core Principle
8
+ ## Purpose
9
9
 
10
- **High-performance CLI tools reduce costs, latency, and cognitive load by 5-50x.**
10
+ Reach for high-performance CLI tools over slower standard tools. The leverage is filtering and transforming with the right tool **before reading**, so tokens and time go to the answer, not the search. On a large tree `rg` is 10-50x faster than `grep` and returns far less noise; across a session that compounds into hours and tens of thousands of tokens saved.
11
11
 
12
- Modern tools have massive RL optimization in frontier models - use them.
12
+ ## When a relevant task arises
13
13
 
14
- ## Tool Availability Protocol
14
+ 1. Pick the right tool from the table below.
15
+ 2. Confirm it's installed before relying on it — e.g. `command -v rg`.
16
+ 3. If it's missing, name the tool and its payoff and **offer** to install it — don't install silently. Adapt the command to the user's package manager/OS (the table shows `brew`; substitute `apt install`, `dnf install`, `pacman -S`, `cargo install`, etc.). If they decline, fall back to the standard tool and move on.
15
17
 
16
- **Session start (silent check, cache result):**
18
+ Check only the tools the current task needs — no upfront session-wide scan.
17
19
 
18
- ```bash
19
- command -v rg jq fd bat gh >/dev/null 2>&1 && echo "ready" || echo "missing"
20
- ```
21
-
22
- **If tools missing:** Offer installation when relevant task appears.
23
- **If tools ready:** Use optimal workflows throughout session.
24
-
25
- ## Tool Selection
26
-
27
- | Task | Use | Instead of | Speedup |
28
- |------|-----|-----------|---------|
29
- | Search code | **rg** | grep | 10-50x |
30
- | Parse JSON | **jq** | awk/sed | 5-20x |
31
- | Find files | **fd** | find | 5-10x |
32
- | View code | **bat** | cat | Better UX |
33
- | Transform code | **ast-grep** | sed | 3-10x |
34
- | GitHub ops | **gh** | curl+API | 2-5x |
35
- | Interactive select | **fzf** | manual | 10-100x |
36
-
37
- ## Quick Reference
38
-
39
- ### Code Search: rg
40
- ```bash
41
- rg "AuthError" --type typescript # 10-50x faster than grep, respects .gitignore
42
- ```
20
+ ## Tools
43
21
 
44
- ### JSON Parse: jq
45
- ```bash
46
- jq '.results[] | select(.status=="error") | .error.code' api.json | sort -u
47
- ```
48
-
49
- ### Find Files: fd
50
- ```bash
51
- fd "\.test\.ts$" # 5-10x faster than find, parallel traversal
52
- ```
22
+ | Rating | Tool | Replaces | Why | Install |
23
+ |:------:|------|----------|-----|---------|
24
+ | 10 | `rg` (ripgrep) | `grep`, `grep -r`, `ack` | Code/text search. Respects `.gitignore`, 10-50x faster than `grep` — the highest-leverage tool; filter before reading. | `brew install ripgrep` |
25
+ | 10 | `jq` | `grep`/`sed`/`awk` on JSON | JSON query/transform. Turns API responses and config into exactly the fields you need; the pipe target for JSON. | `brew install jq` |
26
+ | 9 | `fd` | `find` | File finding. Faster, saner syntax, parallel traversal, `.gitignore`-aware. | `brew install fd` |
27
+ | 8 | `yq` | `grep`/`sed`/`awk` on YAML | `jq` for YAML/TOML/XML. Reads CI files, `docker-compose`, k8s manifests, frontmatter. | `brew install yq` |
28
+ | 8 | `ast-grep` (`sg`) | `sed`/`grep` for refactors | Structural search/rewrite by AST, not regex. Safe codebase-wide refactors that `sed` would mangle. | `brew install ast-grep` |
29
+ | 8 | `gh` | `curl` + GitHub API + tokens | GitHub from the shell — PRs, issues, CI, API. No hand-rolled `curl` + token juggling. | `brew install gh` |
30
+ | 7 | `sd` | `sed -i`, `perl -pe` | Find/replace. Literal-string-safe, no regex-escaping footguns. | `brew install sd` |
31
+ | 6 | `dasel` | `jq`+`yq`+`xq` (mixed formats) | Query *and modify* JSON/YAML/TOML/XML/CSV through one selector. Use when format is mixed or unknown. | `brew install dasel` |
32
+ | 6 | `htmlq` | `grep`/`sed` on HTML | `jq` for HTML — CSS-selector extraction from fetched pages. | `brew install htmlq` |
33
+ | 6 | `miller` (`mlr`) | `awk`/`cut`/`join`/`sort` on CSV/TSV | `awk`/`cut`/`join`/`sort` for CSV/TSV/JSON with *named* fields — no brittle column counting. | `brew install miller` |
34
+ | 5 | `qsv` | `awk`/`cut`/`sort -u` on CSV, `csvkit` | High-perf CSV toolkit (maintained `xsv` successor). Stats, slice, join, dedup on big CSVs. | `brew install qsv` |
35
+ | 5 | `hyperfine` | `time`, `for`-loop timing | Statistical benchmarking with warmups. Real before/after numbers, not `time` guesses. | `brew install hyperfine` |
36
+ | 5 | `tokei` | `wc -l`, `find … \| wc`, `cloc` | Instant LOC/language breakdown. Orient in an unfamiliar repo before exploring. | `brew install tokei` |
37
+ | 5 | `fzf` (`-f`) | manual fuzzy filtering | Non-interactive `-f`/`--filter` mode: fuzzy-rank a candidate list piped from `fd`/`rg`. | `brew install fzf` |
38
+ | 4 | `watchexec` | `while`+`sleep`, `entr` | Run a command on file change. Useful in build/test loops; non-interactive unlike most watchers. | `brew install watchexec` |
53
39
 
54
- ### View Code: bat
55
- ```bash
56
- bat src/auth.ts # Syntax highlighting, Git integration, line numbers
57
- ```
40
+ ## Core workflows
58
41
 
59
- ### Code Transform: ast-grep
42
+ **Filter before reading** — find the matches, then read only those.
60
43
  ```bash
61
- sg --pattern 'console.log($$$ARGS)' --rewrite 'logger.debug($$$ARGS)'
44
+ rg -l "password.*hash" src/auth/ --type ts | xargs rg "TODO"
62
45
  ```
63
46
 
64
- ## Installation Protocol
65
-
66
- **If tool missing when needed:**
67
-
68
- 1. Explain impact: "Using rg is 10-50x faster, reducing token costs"
69
- 2. Install automatically for core tools (rg, jq, fd, bat, gh): `brew install ripgrep jq fd bat gh` (macOS) or equivalent
70
- 3. Ask before installing: ast-grep, httpie, fzf
71
-
72
- **No exceptions:** If tool unavailable and user declines install, explain performance cost but use fallback.
73
-
74
- ## Key Workflows
75
-
76
- ### Filter Before Reading
47
+ **Compose tools** — search, parse, dedup in one pass.
77
48
  ```bash
78
- # DON'T: Read all files blindly
79
- # DO: Filter first, read matches only
80
- rg "password.*hash" src/auth/ --type ts -l | xargs bat
49
+ rg -l '"error"' logs/ --type json | xargs jq -r 'select(.level=="error") | .code' | sort -u
81
50
  ```
82
51
 
83
- Under fatigue: filtering first reduces cognitive load.
84
-
85
- ### Compose Tools
52
+ **Structural rewrite, not regex** refactor by AST so syntax can't trip you.
86
53
  ```bash
87
- rg "error.code" logs/ -o | jq -r . | sort -u # Search + parse + dedup
54
+ sg --pattern 'console.log($$$A)' --rewrite 'logger.debug($$$A)' --lang ts
88
55
  ```
89
56
 
90
- ## Performance Impact
91
-
92
- | Task | grep/find/cat | rg/fd/bat | Savings |
93
- |------|---------------|-----------|---------|
94
- | Search 50k files | 45s | 0.8s | 56x, ~40k tokens |
95
- | Parse 10MB JSON | 12s (awk) | 2s (jq) | 6x, ~15k tokens |
96
- | Find in monorepo | 8s | 1s | 8x, ~10k tokens |
57
+ In Claude Code the `Grep` and `Glob` tools are themselves built on ripgrep — prefer them for in-context searches, and reach for the CLI tools when you need piping, transforms, or rewrites.
97
58
 
98
- ## Red Flags
59
+ ## Red flags
99
60
 
100
- - Manually parsing JSON with awk/sed/grep (use jq)
101
- - Reading files without filtering first (use rg to filter)
102
- - Not checking tool availability at session start
103
- - Using bash grep when Grep tool exists (use Grep tool)
61
+ - Parsing JSON/YAML with `awk`/`sed`/`grep` instead of `jq`/`yq`.
62
+ - Reading files before filtering them with `rg`.
63
+ - Hand-rolling `curl` against the GitHub API instead of `gh`.
64
+ - Regex codemods with `sed` where `ast-grep` is structurally safe.
104
65
 
105
- ## Common Rationalizations
66
+ ## Common rationalizations
106
67
 
107
68
  | Excuse | Reality |
108
69
  |--------|---------|
109
- | "grep works fine" | 50x slower, burns 40k tokens on 50k files |
110
- | "I don't know if they have jq" | Check once, install takes 30s, saves hours |
111
- | "Not worth setup overhead" | One install = 10-100x speedup on ALL future tasks |
112
- | "User didn't ask for optimization" | Faster task completion IS better completion |
113
-
114
- ## When NOT to Use
115
-
116
- **Skip when:**
117
- - Small dataset (< 100 files, < 1MB) AND one-off task
118
- - User explicitly declines install
119
- - Teaching context where standard tools are the goal
120
-
121
- **Use when:**
122
- - Codebase search (always)
123
- - JSON operations (always)
124
- - Time pressure, large datasets, repeated operations
125
-
126
- ## Summary
127
-
128
- **Protocol: Check → Use → Combine**
70
+ | "grep works fine" | On a big tree it's 10-50x slower and floods context with noise `rg` would have filtered out. |
71
+ | "I don't know if they have jq" | One `command -v jq` answers it; install is seconds and pays back across the whole session. |
72
+ | "Not worth the setup" | One install = a speedup on every future task, not just this one. |
73
+ | "User didn't ask for optimization" | Faster, lower-noise completion *is* better completion. |
129
74
 
130
- Session start: Silent availability check. Task appears: Use optimal tool or install. Complex tasks: Compose tools.
75
+ ## When NOT to use
131
76
 
132
- **Not using available tools burns resources.**
77
+ - A tiny one-off (a handful of files, well under a megabyte) where the standard tool is already at hand.
78
+ - The user declined the install — note the cost once, then use the fallback.
79
+ - A teaching context where the standard tool is the point.