@schalkneethling/toolkit 0.7.2 → 1.0.0

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.
package/README.md CHANGED
@@ -1,15 +1,11 @@
1
1
  # claude-toolkit
2
2
 
3
- CLI for managing [Claude Code](https://claude.com/claude-code) hooks, skills, commands, and collections across projects. Hooks are copied into a project's `.claude/` directory; skills are copied into `.claude-toolkit/skills/` and symlinked into wherever Claude Code expects to find them; commands are copied into `.claude/commands/`; collections install any combination of those resources from a bundled root config.
3
+ CLI for managing [Claude Code](https://claude.com/claude-code) hooks, skills, and collections across projects. Hooks are copied into a project's `.claude/` directory; skills are copied into `.claude-toolkit/skills/` and symlinked into wherever Claude Code expects to find them; collections install any combination of those resources from a bundled root config.
4
4
 
5
5
  ## Repo layout
6
6
 
7
7
  ```plaintext
8
8
  .
9
- ├── commands/ # Claude Code custom slash commands (*.md)
10
- │ ├── rpm-start.md
11
- │ ├── rpm-advance.md
12
- │ └── ...
13
9
  ├── config.json # bundled collection definitions
14
10
  ├── hooks/
15
11
  │ ├── auto-approve-safe-commands/
@@ -33,7 +29,7 @@ CLI for managing [Claude Code](https://claude.com/claude-code) hooks, skills, co
33
29
  - Node.js 22+
34
30
  - `tsx` (installed as a devDependency)
35
31
 
36
- From inside a consuming project, run the CLI with `tsx /path/to/claude-toolkit/cli/index.ts <command>`, or link it as `toolkit` on your `PATH`.
32
+ From inside a consuming project, run the CLI with `tsx /path/to/claude-toolkit/src/index.ts <command>`, or link it as `toolkit` on your `PATH`.
37
33
 
38
34
  ## Commands
39
35
 
@@ -49,17 +45,9 @@ Copies `skills/<name>/` into `<project>/.claude-toolkit/skills/<name>/` and crea
49
45
  toolkit add skill css-shared-first --link .claude/skills --link docs/skills
50
46
  ```
51
47
 
52
- ### `toolkit add command <name>`
53
-
54
- Copies `commands/<name>.md` into `<project>/.claude/commands/<name>.md`. Records the source hash in `.claude/toolkit-manifest.json`.
55
-
56
- ```
57
- toolkit add command rpm-start
58
- ```
59
-
60
48
  ### `toolkit add collections <name>`
61
49
 
62
- Reads the root `config.json`, resolves the named collection, and installs each referenced hook, skill, and command using the same underlying logic as the individual `add` commands.
50
+ Reads the root `config.json`, resolves the named collection, and installs each referenced hook and skill using the same underlying logic as the individual `add` commands.
63
51
 
64
52
  ```bash
65
53
  toolkit add collections web
@@ -73,9 +61,9 @@ For every entry in `.claude/toolkit-manifest.json`, compares the current source
73
61
  - If the installed file was modified locally (its hash differs from the one recorded in the manifest), warns and skips unless `--force` is passed.
74
62
  - Silent if everything is current.
75
63
 
76
- ### `toolkit list hook` / `toolkit list skill` / `toolkit list command`
64
+ ### `toolkit list hook` / `toolkit list skill`
77
65
 
78
- Lists available hooks, skills, or commands shipped by this repo, with the current source hash.
66
+ Lists available hooks or skills shipped by this repo, with the current source hash.
79
67
 
80
68
  ### `toolkit list collections`
81
69
 
@@ -109,13 +97,12 @@ Collections are defined in the repo root `config.json` as an array:
109
97
  ```
110
98
 
111
99
  - `name` must be unique.
112
- - `items` may contain `skill`, `hook`, or `command` entries.
113
- - `src` must point to a top-level entry under `skills/`, `hooks/`, or `commands/`.
114
- - Plural `type` values such as `commands` are also accepted for compatibility.
100
+ - `items` may contain `skill` or `hook` entries.
101
+ - `src` must point to a top-level entry under `skills/` or `hooks/`.
102
+ - Plural `type` values such as `skills` are also accepted for compatibility.
115
103
 
116
104
  ## Versioning
117
105
 
118
- - Each command is hashed over its `.md` file only.
119
106
  - Each hook is hashed over `hook.mjs` only (not the README or `settings-fragment.json`).
120
107
  - Each skill is hashed over every file in the skill directory (sorted by path).
121
108
  - SHA-256, truncated to the first 7 hex characters.
@@ -126,12 +113,6 @@ The CLI writes `<project>/.claude/toolkit-manifest.json`:
126
113
 
127
114
  ```json
128
115
  {
129
- "commands": {
130
- "rpm-start": {
131
- "hash": "b8e2a1f",
132
- "installedAt": "2026-04-18"
133
- }
134
- },
135
116
  "hooks": {
136
117
  "block-dangerous-commands": {
137
118
  "hash": "a3f9c2d",
package/dist/index.mjs CHANGED
@@ -7,23 +7,20 @@ import { fileURLToPath } from "node:url";
7
7
  import { parseArgs } from "node:util";
8
8
  //#region src/index.ts
9
9
  /**
10
- * toolkit — personal CLI for managing Claude Code hooks, skills, and commands.
10
+ * toolkit — personal CLI for managing Claude Code hooks and skills.
11
11
  *
12
12
  * Commands:
13
13
  * toolkit add hook <name>
14
14
  * toolkit add skill <name> [--link <target>...]
15
- * toolkit add command <name>
16
15
  * toolkit add collections <name>
17
16
  * toolkit update [--force]
18
17
  * toolkit list hook
19
18
  * toolkit list skill
20
- * toolkit list command
21
19
  * toolkit list collections
22
20
  */
23
21
  const TOOLKIT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
24
22
  const HOOKS_SRC = join(TOOLKIT_ROOT, "hooks");
25
23
  const SKILLS_SRC = join(TOOLKIT_ROOT, "skills");
26
- const COMMANDS_SRC = join(TOOLKIT_ROOT, "commands");
27
24
  const CONFIG_PATH = join(TOOLKIT_ROOT, "config.json");
28
25
  const PROJECT_ROOT = process.cwd();
29
26
  const CLAUDE_DIR = join(PROJECT_ROOT, ".claude");
@@ -37,20 +34,17 @@ function shortHash(content) {
37
34
  }
38
35
  function readManifest() {
39
36
  if (!existsSync(MANIFEST_PATH)) return {
40
- commands: {},
41
37
  hooks: {},
42
38
  skills: {}
43
39
  };
44
40
  try {
45
41
  const parsed = JSON.parse(readFileSync(MANIFEST_PATH, "utf8"));
46
42
  return {
47
- commands: parsed.commands ?? {},
48
43
  hooks: parsed.hooks ?? {},
49
44
  skills: parsed.skills ?? {}
50
45
  };
51
46
  } catch {
52
47
  return {
53
- commands: {},
54
48
  hooks: {},
55
49
  skills: {}
56
50
  };
@@ -72,9 +66,6 @@ function deepMerge(target, source) {
72
66
  }
73
67
  return source;
74
68
  }
75
- function hashCommandSource(name) {
76
- return shortHash(readFileSync(join(COMMANDS_SRC, `${name}.md`)));
77
- }
78
69
  function hashHookSource(name) {
79
70
  return shortHash(readFileSync(join(HOOKS_SRC, name, "hook.mjs")));
80
71
  }
@@ -131,7 +122,6 @@ function sanitizeName(name, kind) {
131
122
  return name;
132
123
  }
133
124
  function normalizeCollectionItemType(type, collectionName) {
134
- if (type === "command" || type === "commands") return "command";
135
125
  if (type === "hook" || type === "hooks") return "hook";
136
126
  if (type === "skill" || type === "skills") return "skill";
137
127
  throw new Error(`Collection "${collectionName}" has unsupported item type "${type}"`);
@@ -142,10 +132,6 @@ function resolveSourcePath(src, kind, collectionName) {
142
132
  return sourcePath;
143
133
  }
144
134
  function inferItemNameFromSource(type, sourcePath, collectionName) {
145
- if (type === "command") {
146
- if (dirname(sourcePath) !== COMMANDS_SRC || !sourcePath.startsWith(COMMANDS_SRC + sep) || !sourcePath.endsWith(".md")) throw new Error(`Collection "${collectionName}" command source must point to a markdown file directly under commands/: ${relative(TOOLKIT_ROOT, sourcePath)}`);
147
- return basename(sourcePath, ".md");
148
- }
149
135
  const expectedRoot = type === "hook" ? HOOKS_SRC : SKILLS_SRC;
150
136
  if (dirname(sourcePath) !== expectedRoot || !sourcePath.startsWith(expectedRoot + sep)) throw new Error(`Collection "${collectionName}" ${type} source must point to a top-level entry under ${relative(TOOLKIT_ROOT, expectedRoot)}/: ${relative(TOOLKIT_ROOT, sourcePath)}`);
151
137
  return basename(sourcePath);
@@ -200,31 +186,6 @@ function resolveCollection(name) {
200
186
  }
201
187
  return [...deduped.values()];
202
188
  }
203
- function installCommand(name, src) {
204
- if (!existsSync(src)) {
205
- console.error(`Command not found: ${name}`);
206
- process.exit(1);
207
- }
208
- const commandsDir = join(CLAUDE_DIR, "commands");
209
- mkdirSync(commandsDir, { recursive: true });
210
- const dest = resolve(commandsDir, `${name}.md`);
211
- if (!dest.startsWith(commandsDir + sep)) {
212
- console.error("Invalid command name");
213
- process.exit(1);
214
- }
215
- writeFileSync(dest, readFileSync(src));
216
- const manifest = readManifest();
217
- manifest.commands[name] = {
218
- hash: hashCommandSource(name),
219
- installedAt: today()
220
- };
221
- writeManifest(manifest);
222
- console.log(`Installed command: ${name} → ${relative(PROJECT_ROOT, dest)}`);
223
- }
224
- function addCommand(name) {
225
- name = sanitizeName(name, "command");
226
- installCommand(name, join(COMMANDS_SRC, `${name}.md`));
227
- }
228
189
  function installHook(name, srcDir) {
229
190
  if (!existsSync(srcDir)) {
230
191
  console.error(`Hook not found: ${name}`);
@@ -298,11 +259,6 @@ function addCollection(name) {
298
259
  if (!existsSync(item.sourcePath)) throw new Error(`Collection "${item.collection}" references missing ${item.type} source: ${relative(TOOLKIT_ROOT, item.sourcePath)}`);
299
260
  const itemStats = statSync(item.sourcePath);
300
261
  const actualKind = itemStats.isFile() ? "file" : itemStats.isDirectory() ? "directory" : "other";
301
- if (item.type === "command") {
302
- if (!itemStats.isFile()) throw new Error(`Collection "${item.collection}" expected command source "${item.sourcePath}" to be a file, found ${actualKind}`);
303
- installCommand(item.sourceName, item.sourcePath);
304
- continue;
305
- }
306
262
  if (item.type === "hook") {
307
263
  if (!itemStats.isDirectory()) throw new Error(`Collection "${item.collection}" expected hook source "${item.sourcePath}" to be a directory, found ${actualKind}`);
308
264
  installHook(item.sourceName, item.sourcePath);
@@ -368,36 +324,9 @@ async function update(force) {
368
324
  linkedTo: entry.linkedTo
369
325
  };
370
326
  }
371
- for (const [name, entry] of Object.entries(manifest.commands)) {
372
- const src = join(COMMANDS_SRC, `${name}.md`);
373
- if (!existsSync(src)) continue;
374
- const sourceHash = hashCommandSource(name);
375
- if (sourceHash === entry.hash) continue;
376
- changed = true;
377
- console.log(`\n~ command: ${name} (${entry.hash} → ${sourceHash})`);
378
- if (!(force || await confirm(`Update command "${name}"?`))) continue;
379
- writeFileSync(join(CLAUDE_DIR, "commands", `${name}.md`), readFileSync(src));
380
- manifest.commands[name] = {
381
- hash: sourceHash,
382
- installedAt: today()
383
- };
384
- }
385
327
  if (changed) writeManifest(manifest);
386
328
  }
387
329
  function list(kind) {
388
- if (kind === "command") {
389
- if (!existsSync(COMMANDS_SRC)) {
390
- console.log("(no commands available)");
391
- return;
392
- }
393
- const files = readdirSync(COMMANDS_SRC).filter((f) => f.endsWith(".md")).map((f) => f.replace(/\.md$/, ""));
394
- if (files.length === 0) {
395
- console.log("(no commands available)");
396
- return;
397
- }
398
- for (const name of files) console.log(`${name} ${hashCommandSource(name)}`);
399
- return;
400
- }
401
330
  const dir = kind === "hook" ? HOOKS_SRC : SKILLS_SRC;
402
331
  if (!existsSync(dir)) {
403
332
  console.log(`(no ${kind}s available)`);
@@ -425,12 +354,10 @@ function usage() {
425
354
  console.error(`Usage:
426
355
  toolkit add hook <name>
427
356
  toolkit add skill <name> [--link <target>]...
428
- toolkit add command <name>
429
357
  toolkit add collections <name>
430
358
  toolkit update [--force]
431
359
  toolkit list hook
432
360
  toolkit list skill
433
- toolkit list command
434
361
  toolkit list collections`);
435
362
  process.exit(1);
436
363
  }
@@ -460,11 +387,6 @@ async function main() {
460
387
  addSkill(name, links ? links : []);
461
388
  return;
462
389
  }
463
- if (command === "add" && resource === "command") {
464
- if (!name) usage();
465
- addCommand(name);
466
- return;
467
- }
468
390
  if (command === "add" && (resource === "collection" || resource === "collections")) {
469
391
  if (!name) usage();
470
392
  addCollection(name);
@@ -474,7 +396,7 @@ async function main() {
474
396
  await update(force);
475
397
  return;
476
398
  }
477
- if (command === "list" && (resource === "hook" || resource === "skill" || resource === "command")) {
399
+ if (command === "list" && (resource === "hook" || resource === "skill")) {
478
400
  list(resource);
479
401
  return;
480
402
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * toolkit — personal CLI for managing Claude Code hooks, skills, and commands.\n *\n * Commands:\n * toolkit add hook <name>\n * toolkit add skill <name> [--link <target>...]\n * toolkit add command <name>\n * toolkit add collections <name>\n * toolkit update [--force]\n * toolkit list hook\n * toolkit list skill\n * toolkit list command\n * toolkit list collections\n */\n\nimport { createHash } from \"node:crypto\";\nimport {\n cpSync,\n existsSync,\n lstatSync,\n mkdirSync,\n readFileSync,\n readdirSync,\n statSync,\n symlinkSync,\n unlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { createInterface } from \"node:readline/promises\";\nimport { basename, dirname, join, relative, resolve, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgs } from \"node:util\";\n\nconst TOOLKIT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\nconst HOOKS_SRC = join(TOOLKIT_ROOT, \"hooks\");\nconst SKILLS_SRC = join(TOOLKIT_ROOT, \"skills\");\nconst COMMANDS_SRC = join(TOOLKIT_ROOT, \"commands\");\nconst CONFIG_PATH = join(TOOLKIT_ROOT, \"config.json\");\n\nconst PROJECT_ROOT = process.cwd();\nconst CLAUDE_DIR = join(PROJECT_ROOT, \".claude\");\nconst TOOLKIT_DIR = join(PROJECT_ROOT, \".claude-toolkit\");\nconst MANIFEST_PATH = join(CLAUDE_DIR, \"toolkit-manifest.json\");\n\ntype HookEntry = { hash: string; installedAt: string };\ntype SkillEntry = { hash: string; installedAt: string; linkedTo: string[] };\ntype CommandEntry = { hash: string; installedAt: string };\ntype Manifest = {\n commands: Record<string, CommandEntry>;\n hooks: Record<string, HookEntry>;\n skills: Record<string, SkillEntry>;\n};\ntype CollectionItemKind = \"command\" | \"hook\" | \"skill\";\ntype CollectionItemConfig = {\n type: CollectionItemKind | `${CollectionItemKind}s`;\n src: string;\n};\ntype CollectionConfig = {\n name: string;\n items: CollectionItemConfig[];\n};\ntype ResolvedCollectionItem = {\n collection: string;\n sourcePath: string;\n sourceName: string;\n type: CollectionItemKind;\n};\n\n// ---------- helpers ----------\n\nfunction today(): string {\n return new Date().toISOString().slice(0, 10);\n}\n\nfunction shortHash(content: string | Buffer): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").slice(0, 7);\n}\n\nfunction readManifest(): Manifest {\n if (!existsSync(MANIFEST_PATH)) {\n return { commands: {}, hooks: {}, skills: {} };\n }\n\n try {\n const parsed = JSON.parse(readFileSync(MANIFEST_PATH, \"utf8\")) as Partial<Manifest>;\n return {\n commands: parsed.commands ?? {},\n hooks: parsed.hooks ?? {},\n skills: parsed.skills ?? {},\n };\n } catch {\n return { commands: {}, hooks: {}, skills: {} };\n }\n}\n\nfunction writeManifest(m: Manifest): void {\n mkdirSync(CLAUDE_DIR, { recursive: true });\n writeFileSync(MANIFEST_PATH, JSON.stringify(m, null, 2) + \"\\n\");\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction deepMerge<T>(target: T, source: T): T {\n if (Array.isArray(target) && Array.isArray(source)) {\n return [...target, ...source] as T;\n }\n if (isPlainObject(target) && isPlainObject(source)) {\n const out: Record<string, unknown> = { ...target };\n for (const [k, v] of Object.entries(source)) {\n out[k] = k in out ? deepMerge(out[k], v) : v;\n }\n return out as T;\n }\n return source;\n}\n\nfunction hashCommandSource(name: string): string {\n const p = join(COMMANDS_SRC, `${name}.md`);\n return shortHash(readFileSync(p));\n}\n\nfunction hashHookSource(name: string): string {\n const p = join(HOOKS_SRC, name, \"hook.mjs\");\n return shortHash(readFileSync(p));\n}\n\nfunction hashSkillSource(name: string): string {\n const dir = join(SKILLS_SRC, name);\n const files = collectFiles(dir).sort();\n const h = createHash(\"sha256\");\n for (const f of files) {\n h.update(relative(dir, f));\n h.update(\"\\0\");\n h.update(readFileSync(f));\n h.update(\"\\0\");\n }\n return h.digest(\"hex\").slice(0, 7);\n}\n\nfunction collectFiles(dir: string): string[] {\n const out: string[] = [];\n if (!existsSync(dir)) {\n return out;\n }\n\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name === \".gitkeep\") {\n continue;\n }\n\n const full = join(dir, entry.name);\n if (entry.isDirectory()) {\n out.push(...collectFiles(full));\n } else if (entry.isFile()) {\n out.push(full);\n }\n }\n return out;\n}\n\nasync function confirm(question: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const answer = (await rl.question(`${question} [y/N] `)).trim().toLowerCase();\n rl.close();\n return answer === \"y\" || answer === \"yes\";\n}\n\nfunction diffLines(oldStr: string, newStr: string): string {\n const a = oldStr.split(\"\\n\");\n const b = newStr.split(\"\\n\");\n const out: string[] = [];\n const max = Math.max(a.length, b.length);\n for (let i = 0; i < max; i++) {\n if (a[i] === b[i]) {\n continue;\n }\n\n if (a[i] !== undefined) {\n out.push(`- ${a[i]}`);\n }\n\n if (b[i] !== undefined) {\n out.push(`+ ${b[i]}`);\n }\n }\n return out.join(\"\\n\");\n}\n\n// ---------- commands ----------\n\nfunction sanitizeName(name: string, kind: string): string {\n name = basename(name);\n if (!name) {\n console.error(`Invalid ${kind} name`);\n process.exit(1);\n }\n return name;\n}\n\nfunction normalizeCollectionItemType(\n type: CollectionItemConfig[\"type\"],\n collectionName: string,\n): CollectionItemKind {\n if (type === \"command\" || type === \"commands\") {\n return \"command\";\n }\n if (type === \"hook\" || type === \"hooks\") {\n return \"hook\";\n }\n if (type === \"skill\" || type === \"skills\") {\n return \"skill\";\n }\n\n throw new Error(`Collection \"${collectionName}\" has unsupported item type \"${type}\"`);\n}\n\nfunction resolveSourcePath(src: string, kind: string, collectionName: string): string {\n const sourcePath = resolve(TOOLKIT_ROOT, src);\n if (!sourcePath.startsWith(TOOLKIT_ROOT + sep)) {\n throw new Error(\n `Collection \"${collectionName}\" ${kind} source must stay within the toolkit root: ${src}`,\n );\n }\n return sourcePath;\n}\n\nfunction inferItemNameFromSource(\n type: CollectionItemKind,\n sourcePath: string,\n collectionName: string,\n): string {\n if (type === \"command\") {\n if (\n dirname(sourcePath) !== COMMANDS_SRC ||\n !sourcePath.startsWith(COMMANDS_SRC + sep) ||\n !sourcePath.endsWith(\".md\")\n ) {\n throw new Error(\n `Collection \"${collectionName}\" command source must point to a markdown file directly under commands/: ${relative(TOOLKIT_ROOT, sourcePath)}`,\n );\n }\n return basename(sourcePath, \".md\");\n }\n\n const expectedRoot = type === \"hook\" ? HOOKS_SRC : SKILLS_SRC;\n if (dirname(sourcePath) !== expectedRoot || !sourcePath.startsWith(expectedRoot + sep)) {\n throw new Error(\n `Collection \"${collectionName}\" ${type} source must point to a top-level entry under ${relative(TOOLKIT_ROOT, expectedRoot)}/: ${relative(TOOLKIT_ROOT, sourcePath)}`,\n );\n }\n\n return basename(sourcePath);\n}\n\nfunction readCollectionsConfig(): CollectionConfig[] {\n if (!existsSync(CONFIG_PATH)) {\n throw new Error(`Collections config not found: ${relative(TOOLKIT_ROOT, CONFIG_PATH)}`);\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(CONFIG_PATH, \"utf8\"));\n } catch (error) {\n throw new Error(\n `Invalid collections config in ${relative(TOOLKIT_ROOT, CONFIG_PATH)}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n if (!Array.isArray(parsed)) {\n throw new Error(\"Collections config must be an array\");\n }\n\n const names = new Set<string>();\n return parsed.map((entry, index) => {\n if (!isPlainObject(entry)) {\n throw new Error(`Collection at index ${index} must be an object`);\n }\n\n const { name, items } = entry;\n if (typeof name !== \"string\" || name.trim().length === 0) {\n throw new Error(`Collection at index ${index} must have a non-empty name`);\n }\n if (names.has(name)) {\n throw new Error(`Duplicate collection name: ${name}`);\n }\n names.add(name);\n\n if (!Array.isArray(items)) {\n throw new Error(`Collection \"${name}\" must have an items array`);\n }\n\n const validatedItems = items.map((item, itemIndex) => {\n if (!isPlainObject(item)) {\n throw new Error(`Collection \"${name}\" item at index ${itemIndex} must be an object`);\n }\n if (typeof item.type !== \"string\" || item.type.trim().length === 0) {\n throw new Error(\n `Collection \"${name}\" item at index ${itemIndex} must have a non-empty type`,\n );\n }\n if (typeof item.src !== \"string\" || item.src.trim().length === 0) {\n throw new Error(\n `Collection \"${name}\" item at index ${itemIndex} must have a non-empty src`,\n );\n }\n\n return {\n type: item.type as CollectionItemConfig[\"type\"],\n src: item.src,\n };\n });\n\n return {\n name,\n items: validatedItems,\n };\n });\n}\n\nfunction resolveCollection(name: string): ResolvedCollectionItem[] {\n const collectionName = sanitizeName(name, \"collection\");\n const collections = readCollectionsConfig();\n const collection = collections.find((entry) => entry.name === collectionName);\n\n if (!collection) {\n throw new Error(`Collection not found: ${collectionName}`);\n }\n\n const deduped = new Map<string, ResolvedCollectionItem>();\n\n for (const item of collection.items) {\n const type = normalizeCollectionItemType(item.type, collection.name);\n const sourcePath = resolveSourcePath(item.src, type, collection.name);\n const sourceName = inferItemNameFromSource(type, sourcePath, collection.name);\n const key = `${type}:${sourceName}`;\n\n if (!deduped.has(key)) {\n deduped.set(key, {\n collection: collection.name,\n sourcePath,\n sourceName,\n type,\n });\n }\n }\n\n return [...deduped.values()];\n}\n\nfunction installCommand(name: string, src: string): void {\n if (!existsSync(src)) {\n console.error(`Command not found: ${name}`);\n process.exit(1);\n }\n\n const commandsDir = join(CLAUDE_DIR, \"commands\");\n mkdirSync(commandsDir, { recursive: true });\n const dest = resolve(commandsDir, `${name}.md`);\n if (!dest.startsWith(commandsDir + sep)) {\n console.error(\"Invalid command name\");\n process.exit(1);\n }\n writeFileSync(dest, readFileSync(src));\n\n const manifest = readManifest();\n manifest.commands[name] = {\n hash: hashCommandSource(name),\n installedAt: today(),\n };\n writeManifest(manifest);\n\n console.log(`Installed command: ${name} → ${relative(PROJECT_ROOT, dest)}`);\n}\n\nfunction addCommand(name: string): void {\n name = sanitizeName(name, \"command\");\n installCommand(name, join(COMMANDS_SRC, `${name}.md`));\n}\n\nfunction installHook(name: string, srcDir: string): void {\n if (!existsSync(srcDir)) {\n console.error(`Hook not found: ${name}`);\n process.exit(1);\n }\n\n const hookSrc = join(srcDir, \"hook.mjs\");\n const fragmentPath = join(srcDir, \"settings-fragment.json\");\n\n const hooksDir = join(CLAUDE_DIR, \"hooks\");\n mkdirSync(hooksDir, { recursive: true });\n const destHook = resolve(hooksDir, `${name}.mjs`);\n if (!destHook.startsWith(hooksDir + sep)) {\n console.error(\"Invalid hook name\");\n process.exit(1);\n }\n writeFileSync(destHook, readFileSync(hookSrc));\n\n if (existsSync(fragmentPath)) {\n const fragment = JSON.parse(readFileSync(fragmentPath, \"utf8\"));\n const settingsPath = join(CLAUDE_DIR, \"settings.json\");\n const current = existsSync(settingsPath) ? JSON.parse(readFileSync(settingsPath, \"utf8\")) : {};\n const merged = deepMerge(current, fragment);\n writeFileSync(settingsPath, JSON.stringify(merged, null, 2) + \"\\n\");\n }\n\n const manifest = readManifest();\n manifest.hooks[name] = { hash: hashHookSource(name), installedAt: today() };\n writeManifest(manifest);\n\n console.log(`Installed hook: ${name} → ${relative(PROJECT_ROOT, destHook)}`);\n}\n\nfunction addHook(name: string): void {\n name = sanitizeName(name, \"hook\");\n installHook(name, join(HOOKS_SRC, name));\n}\n\nfunction installSkill(name: string, srcDir: string, links: string[]): void {\n if (!existsSync(srcDir) || !statSync(srcDir).isDirectory()) {\n console.error(`Skill not found: ${name}`);\n process.exit(1);\n }\n\n const destDir = resolve(TOOLKIT_DIR, \"skills\", name);\n if (!destDir.startsWith(join(TOOLKIT_DIR, \"skills\") + sep)) {\n console.error(\"Invalid skill name\");\n process.exit(1);\n }\n mkdirSync(dirname(destDir), { recursive: true });\n cpSync(srcDir, destDir, { recursive: true });\n\n const resolvedLinks = links.length > 0 ? links : [join(\".claude\", \"skills\")];\n for (const link of resolvedLinks) {\n const linkDir = resolve(PROJECT_ROOT, link);\n mkdirSync(linkDir, { recursive: true });\n\n const linkPath = join(linkDir, name);\n if (existsSync(linkPath) || lstatExists(linkPath)) {\n unlinkSync(linkPath);\n }\n\n const relTarget = relative(linkDir, destDir);\n symlinkSync(relTarget, linkPath, \"dir\");\n }\n\n const manifest = readManifest();\n manifest.skills[name] = {\n hash: hashSkillSource(name),\n installedAt: today(),\n linkedTo: resolvedLinks,\n };\n writeManifest(manifest);\n\n console.log(`Installed skill: ${name} → ${relative(PROJECT_ROOT, destDir)}`);\n for (const l of resolvedLinks) {\n console.log(` linked: ${join(l, name)}`);\n }\n}\n\nfunction addSkill(name: string, links: string[]): void {\n name = sanitizeName(name, \"skill\");\n installSkill(name, join(SKILLS_SRC, name), links);\n}\n\nfunction addCollection(name: string): void {\n const items = resolveCollection(name);\n for (const item of items) {\n if (!existsSync(item.sourcePath)) {\n throw new Error(\n `Collection \"${item.collection}\" references missing ${item.type} source: ${relative(TOOLKIT_ROOT, item.sourcePath)}`,\n );\n }\n\n const itemStats = statSync(item.sourcePath);\n const actualKind = itemStats.isFile()\n ? \"file\"\n : itemStats.isDirectory()\n ? \"directory\"\n : \"other\";\n\n if (item.type === \"command\") {\n if (!itemStats.isFile()) {\n throw new Error(\n `Collection \"${item.collection}\" expected command source \"${item.sourcePath}\" to be a file, found ${actualKind}`,\n );\n }\n installCommand(item.sourceName, item.sourcePath);\n continue;\n }\n\n if (item.type === \"hook\") {\n if (!itemStats.isDirectory()) {\n throw new Error(\n `Collection \"${item.collection}\" expected hook source \"${item.sourcePath}\" to be a directory, found ${actualKind}`,\n );\n }\n installHook(item.sourceName, item.sourcePath);\n continue;\n }\n\n if (!itemStats.isDirectory()) {\n throw new Error(\n `Collection \"${item.collection}\" expected skill source \"${item.sourcePath}\" to be a directory, found ${actualKind}`,\n );\n }\n installSkill(item.sourceName, item.sourcePath, []);\n }\n}\n\nfunction lstatExists(p: string): boolean {\n try {\n lstatSync(p);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function update(force: boolean): Promise<void> {\n const manifest = readManifest();\n let changed = false;\n\n for (const [name, entry] of Object.entries(manifest.hooks)) {\n const srcDir = join(HOOKS_SRC, name);\n if (!existsSync(srcDir)) {\n continue;\n }\n\n const sourceHash = hashHookSource(name);\n const installedPath = join(CLAUDE_DIR, \"hooks\", `${name}.mjs`);\n const installedHash = existsSync(installedPath) ? shortHash(readFileSync(installedPath)) : null;\n\n const sourceChanged = sourceHash !== entry.hash;\n const locallyModified = installedHash !== null && installedHash !== entry.hash;\n\n if (!sourceChanged && !locallyModified) {\n continue;\n }\n\n changed = true;\n\n if (locallyModified && !force) {\n console.warn(\n `! hook \"${name}\" was modified locally (installed=${installedHash}, manifest=${entry.hash}). Use --force to overwrite.`,\n );\n continue;\n }\n\n if (sourceChanged) {\n const oldSrc = existsSync(installedPath) ? readFileSync(installedPath, \"utf8\") : \"\";\n const newSrc = readFileSync(join(srcDir, \"hook.mjs\"), \"utf8\");\n console.log(`\\n~ hook: ${name} (${entry.hash} → ${sourceHash})`);\n console.log(diffLines(oldSrc, newSrc));\n const ok = force || (await confirm(`Update hook \"${name}\"?`));\n\n if (!ok) {\n continue;\n }\n\n writeFileSync(installedPath, newSrc);\n manifest.hooks[name] = { hash: sourceHash, installedAt: today() };\n }\n }\n\n for (const [name, entry] of Object.entries(manifest.skills)) {\n const srcDir = join(SKILLS_SRC, name);\n if (!existsSync(srcDir)) {\n continue;\n }\n\n const sourceHash = hashSkillSource(name);\n if (sourceHash === entry.hash) {\n continue;\n }\n\n changed = true;\n console.log(`\\n~ skill: ${name} (${entry.hash} → ${sourceHash})`);\n const ok = force || (await confirm(`Update skill \"${name}\"?`));\n if (!ok) {\n continue;\n }\n\n const destDir = join(TOOLKIT_DIR, \"skills\", name);\n cpSync(srcDir, destDir, { recursive: true, force: true });\n manifest.skills[name] = {\n hash: sourceHash,\n installedAt: today(),\n linkedTo: entry.linkedTo,\n };\n }\n\n for (const [name, entry] of Object.entries(manifest.commands)) {\n const src = join(COMMANDS_SRC, `${name}.md`);\n if (!existsSync(src)) {\n continue;\n }\n\n const sourceHash = hashCommandSource(name);\n if (sourceHash === entry.hash) {\n continue;\n }\n\n changed = true;\n console.log(`\\n~ command: ${name} (${entry.hash} → ${sourceHash})`);\n const ok = force || (await confirm(`Update command \"${name}\"?`));\n if (!ok) {\n continue;\n }\n\n const dest = join(CLAUDE_DIR, \"commands\", `${name}.md`);\n writeFileSync(dest, readFileSync(src));\n manifest.commands[name] = { hash: sourceHash, installedAt: today() };\n }\n\n if (changed) {\n writeManifest(manifest);\n }\n}\n\nfunction list(kind: \"hook\" | \"skill\" | \"command\"): void {\n if (kind === \"command\") {\n if (!existsSync(COMMANDS_SRC)) {\n console.log(\"(no commands available)\");\n return;\n }\n const files = readdirSync(COMMANDS_SRC)\n .filter((f) => f.endsWith(\".md\"))\n .map((f) => f.replace(/\\.md$/, \"\"));\n if (files.length === 0) {\n console.log(\"(no commands available)\");\n return;\n }\n for (const name of files) {\n console.log(`${name} ${hashCommandSource(name)}`);\n }\n return;\n }\n\n const dir = kind === \"hook\" ? HOOKS_SRC : SKILLS_SRC;\n if (!existsSync(dir)) {\n console.log(`(no ${kind}s available)`);\n return;\n }\n const entries = readdirSync(dir, { withFileTypes: true })\n .filter((e) => e.isDirectory() || (kind === \"skill\" && e.isSymbolicLink()))\n .map((e) => e.name);\n\n if (entries.length === 0) {\n console.log(`(no ${kind}s available)`);\n return;\n }\n\n for (const name of entries) {\n const hash = kind === \"hook\" ? hashHookSource(name) : hashSkillSource(name);\n console.log(`${name} ${hash}`);\n }\n}\n\nfunction listCollections(): void {\n const collections = readCollectionsConfig();\n if (collections.length === 0) {\n console.log(\"(no collections available)\");\n return;\n }\n\n for (const collection of collections) {\n console.log(`${collection.name} ${collection.items.length} item(s)`);\n }\n}\n\n// ---------- argv ----------\n\nfunction usage(): never {\n console.error(\n `Usage:\n toolkit add hook <name>\n toolkit add skill <name> [--link <target>]...\n toolkit add command <name>\n toolkit add collections <name>\n toolkit update [--force]\n toolkit list hook\n toolkit list skill\n toolkit list command\n toolkit list collections`,\n );\n process.exit(1);\n}\n\nasync function main(): Promise<void> {\n const { values, positionals } = parseArgs({\n options: {\n force: {\n default: false,\n type: \"boolean\",\n },\n links: {\n multiple: true,\n type: \"string\",\n },\n },\n allowPositionals: true,\n });\n\n const { force, links } = values;\n const [command, resource, name] = positionals;\n\n if (command === \"add\" && resource === \"hook\") {\n if (!name) {\n usage();\n }\n\n addHook(name);\n return;\n }\n\n if (command === \"add\" && resource === \"skill\") {\n if (!name) {\n usage();\n }\n\n addSkill(name, links ? links : []);\n return;\n }\n\n if (command === \"add\" && resource === \"command\") {\n if (!name) {\n usage();\n }\n\n addCommand(name);\n return;\n }\n\n if (command === \"add\" && (resource === \"collection\" || resource === \"collections\")) {\n if (!name) {\n usage();\n }\n\n addCollection(name);\n return;\n }\n\n if (command === \"update\") {\n await update(force);\n return;\n }\n\n if (\n command === \"list\" &&\n (resource === \"hook\" || resource === \"skill\" || resource === \"command\")\n ) {\n list(resource as \"hook\" | \"skill\" | \"command\");\n return;\n }\n\n if (command === \"list\" && (resource === \"collection\" || resource === \"collections\")) {\n listCollections();\n return;\n }\n\n usage();\n}\n\nmain().catch((err) => {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAe,QAAQ,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE,KAAK;AAC3E,MAAM,YAAY,KAAK,cAAc,QAAQ;AAC7C,MAAM,aAAa,KAAK,cAAc,SAAS;AAC/C,MAAM,eAAe,KAAK,cAAc,WAAW;AACnD,MAAM,cAAc,KAAK,cAAc,cAAc;AAErD,MAAM,eAAe,QAAQ,KAAK;AAClC,MAAM,aAAa,KAAK,cAAc,UAAU;AAChD,MAAM,cAAc,KAAK,cAAc,kBAAkB;AACzD,MAAM,gBAAgB,KAAK,YAAY,wBAAwB;AA4B/D,SAAS,QAAgB;CACvB,wBAAO,IAAI,MAAM,EAAC,aAAa,CAAC,MAAM,GAAG,GAAG;;AAG9C,SAAS,UAAU,SAAkC;CACnD,OAAO,WAAW,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,MAAM,GAAG,EAAE;;AAGvE,SAAS,eAAyB;CAChC,IAAI,CAAC,WAAW,cAAc,EAC5B,OAAO;EAAE,UAAU,EAAE;EAAE,OAAO,EAAE;EAAE,QAAQ,EAAE;EAAE;CAGhD,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,aAAa,eAAe,OAAO,CAAC;EAC9D,OAAO;GACL,UAAU,OAAO,YAAY,EAAE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QAAe;CACtB,QAAQ,MACN;;;;;;;;;4BAUD;CACD,QAAQ,KAAK,EAAE;;AAGjB,eAAe,OAAsB;CACnC,MAAM,EAAE,QAAQ,gBAAgB,UAAU;EACxC,SAAS;GACP,OAAO;IACL,SAAS;IACT,MAAM;IACP;GACD,OAAO;IACL,UAAU;IACV,MAAM;IACP;GACF;EACD,kBAAkB;EACnB,CAAC;CAEF,MAAM,EAAE,OAAO,UAAU;CACzB,MAAM,CAAC,SAAS,UAAU,QAAQ;CAElC,IAAI,YAAY,SAAS,aAAa,QAAQ;EAC5C,IAAI,CAAC,MACH,OAAO;EAGT,QAAQ,KAAK;EACb;;CAGF,IAAI,YAAY,SAAS,aAAa,SAAS;EAC7C,IAAI,CAAC,MACH,OAAO;EAGT,SAAS,MAAM,QAAQ,QAAQ,EAAE,CAAC;EAClC;;CAGF,IAAI,YAAY,SAAS,aAAa,WAAW;EAC/C,IAAI,CAAC,MACH,OAAO;EAGT,WAAW,KAAK;EAChB;;CAGF,IAAI,YAAY,UAAU,aAAa,gBAAgB,aAAa,gBAAgB;EAClF,IAAI,CAAC,MACH,OAAO;EAGT,cAAc,KAAK;EACnB;;CAGF,IAAI,YAAY,UAAU;EACxB,MAAM,OAAO,MAAM;EACnB;;CAGF,IACE,YAAY,WACX,aAAa,UAAU,aAAa,WAAW,aAAa,YAC7D;EACA,KAAK,SAAyC;EAC9C;;CAGF,IAAI,YAAY,WAAW,aAAa,gBAAgB,aAAa,gBAAgB;EACnF,iBAAiB;EACjB;;CAGF,OAAO;;AAGT,MAAM,CAAC,OAAO,QAAQ;CACpB,QAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC;CAC/D,QAAQ,KAAK,EAAE;EACf"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * toolkit — personal CLI for managing Claude Code hooks and skills.\n *\n * Commands:\n * toolkit add hook <name>\n * toolkit add skill <name> [--link <target>...]\n * toolkit add collections <name>\n * toolkit update [--force]\n * toolkit list hook\n * toolkit list skill\n * toolkit list collections\n */\n\nimport { createHash } from \"node:crypto\";\nimport {\n cpSync,\n existsSync,\n lstatSync,\n mkdirSync,\n readFileSync,\n readdirSync,\n statSync,\n symlinkSync,\n unlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { createInterface } from \"node:readline/promises\";\nimport { basename, dirname, join, relative, resolve, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgs } from \"node:util\";\n\nconst TOOLKIT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\nconst HOOKS_SRC = join(TOOLKIT_ROOT, \"hooks\");\nconst SKILLS_SRC = join(TOOLKIT_ROOT, \"skills\");\nconst CONFIG_PATH = join(TOOLKIT_ROOT, \"config.json\");\n\nconst PROJECT_ROOT = process.cwd();\nconst CLAUDE_DIR = join(PROJECT_ROOT, \".claude\");\nconst TOOLKIT_DIR = join(PROJECT_ROOT, \".claude-toolkit\");\nconst MANIFEST_PATH = join(CLAUDE_DIR, \"toolkit-manifest.json\");\n\ntype HookEntry = { hash: string; installedAt: string };\ntype SkillEntry = { hash: string; installedAt: string; linkedTo: string[] };\ntype Manifest = {\n hooks: Record<string, HookEntry>;\n skills: Record<string, SkillEntry>;\n};\ntype CollectionItemKind = \"hook\" | \"skill\";\ntype CollectionItemConfig = {\n type: CollectionItemKind | `${CollectionItemKind}s`;\n src: string;\n};\ntype CollectionConfig = {\n name: string;\n items: CollectionItemConfig[];\n};\ntype ResolvedCollectionItem = {\n collection: string;\n sourcePath: string;\n sourceName: string;\n type: CollectionItemKind;\n};\n\n// ---------- helpers ----------\n\nfunction today(): string {\n return new Date().toISOString().slice(0, 10);\n}\n\nfunction shortHash(content: string | Buffer): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").slice(0, 7);\n}\n\nfunction readManifest(): Manifest {\n if (!existsSync(MANIFEST_PATH)) {\n return { hooks: {}, skills: {} };\n }\n\n try {\n const parsed = JSON.parse(readFileSync(MANIFEST_PATH, \"utf8\")) as Partial<Manifest>;\n return {\n hooks: parsed.hooks ?? {},\n skills: parsed.skills ?? {},\n };\n } catch {\n return { hooks: {}, skills: {} };\n }\n}\n\nfunction writeManifest(m: Manifest): void {\n mkdirSync(CLAUDE_DIR, { recursive: true });\n writeFileSync(MANIFEST_PATH, JSON.stringify(m, null, 2) + \"\\n\");\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction deepMerge<T>(target: T, source: T): T {\n if (Array.isArray(target) && Array.isArray(source)) {\n return [...target, ...source] as T;\n }\n if (isPlainObject(target) && isPlainObject(source)) {\n const out: Record<string, unknown> = { ...target };\n for (const [k, v] of Object.entries(source)) {\n out[k] = k in out ? deepMerge(out[k], v) : v;\n }\n return out as T;\n }\n return source;\n}\n\nfunction hashHookSource(name: string): string {\n const p = join(HOOKS_SRC, name, \"hook.mjs\");\n return shortHash(readFileSync(p));\n}\n\nfunction hashSkillSource(name: string): string {\n const dir = join(SKILLS_SRC, name);\n const files = collectFiles(dir).sort();\n const h = createHash(\"sha256\");\n for (const f of files) {\n h.update(relative(dir, f));\n h.update(\"\\0\");\n h.update(readFileSync(f));\n h.update(\"\\0\");\n }\n return h.digest(\"hex\").slice(0, 7);\n}\n\nfunction collectFiles(dir: string): string[] {\n const out: string[] = [];\n if (!existsSync(dir)) {\n return out;\n }\n\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name === \".gitkeep\") {\n continue;\n }\n\n const full = join(dir, entry.name);\n if (entry.isDirectory()) {\n out.push(...collectFiles(full));\n } else if (entry.isFile()) {\n out.push(full);\n }\n }\n return out;\n}\n\nasync function confirm(question: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const answer = (await rl.question(`${question} [y/N] `)).trim().toLowerCase();\n rl.close();\n return answer === \"y\" || answer === \"yes\";\n}\n\nfunction diffLines(oldStr: string, newStr: string): string {\n const a = oldStr.split(\"\\n\");\n const b = newStr.split(\"\\n\");\n const out: string[] = [];\n const max = Math.max(a.length, b.length);\n for (let i = 0; i < max; i++) {\n if (a[i] === b[i]) {\n continue;\n }\n\n if (a[i] !== undefined) {\n out.push(`- ${a[i]}`);\n }\n\n if (b[i] !== undefined) {\n out.push(`+ ${b[i]}`);\n }\n }\n return out.join(\"\\n\");\n}\n\n// ---------- resources ----------\n\nfunction sanitizeName(name: string, kind: string): string {\n name = basename(name);\n if (!name) {\n console.error(`Invalid ${kind} name`);\n process.exit(1);\n }\n return name;\n}\n\nfunction normalizeCollectionItemType(\n type: CollectionItemConfig[\"type\"],\n collectionName: string,\n): CollectionItemKind {\n if (type === \"hook\" || type === \"hooks\") {\n return \"hook\";\n }\n if (type === \"skill\" || type === \"skills\") {\n return \"skill\";\n }\n\n throw new Error(`Collection \"${collectionName}\" has unsupported item type \"${type}\"`);\n}\n\nfunction resolveSourcePath(src: string, kind: string, collectionName: string): string {\n const sourcePath = resolve(TOOLKIT_ROOT, src);\n if (!sourcePath.startsWith(TOOLKIT_ROOT + sep)) {\n throw new Error(\n `Collection \"${collectionName}\" ${kind} source must stay within the toolkit root: ${src}`,\n );\n }\n return sourcePath;\n}\n\nfunction inferItemNameFromSource(\n type: CollectionItemKind,\n sourcePath: string,\n collectionName: string,\n): string {\n const expectedRoot = type === \"hook\" ? HOOKS_SRC : SKILLS_SRC;\n if (dirname(sourcePath) !== expectedRoot || !sourcePath.startsWith(expectedRoot + sep)) {\n throw new Error(\n `Collection \"${collectionName}\" ${type} source must point to a top-level entry under ${relative(TOOLKIT_ROOT, expectedRoot)}/: ${relative(TOOLKIT_ROOT, sourcePath)}`,\n );\n }\n\n return basename(sourcePath);\n}\n\nfunction readCollectionsConfig(): CollectionConfig[] {\n if (!existsSync(CONFIG_PATH)) {\n throw new Error(`Collections config not found: ${relative(TOOLKIT_ROOT, CONFIG_PATH)}`);\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(CONFIG_PATH, \"utf8\"));\n } catch (error) {\n throw new Error(\n `Invalid collections config in ${relative(TOOLKIT_ROOT, CONFIG_PATH)}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n if (!Array.isArray(parsed)) {\n throw new Error(\"Collections config must be an array\");\n }\n\n const names = new Set<string>();\n return parsed.map((entry, index) => {\n if (!isPlainObject(entry)) {\n throw new Error(`Collection at index ${index} must be an object`);\n }\n\n const { name, items } = entry;\n if (typeof name !== \"string\" || name.trim().length === 0) {\n throw new Error(`Collection at index ${index} must have a non-empty name`);\n }\n if (names.has(name)) {\n throw new Error(`Duplicate collection name: ${name}`);\n }\n names.add(name);\n\n if (!Array.isArray(items)) {\n throw new Error(`Collection \"${name}\" must have an items array`);\n }\n\n const validatedItems = items.map((item, itemIndex) => {\n if (!isPlainObject(item)) {\n throw new Error(`Collection \"${name}\" item at index ${itemIndex} must be an object`);\n }\n if (typeof item.type !== \"string\" || item.type.trim().length === 0) {\n throw new Error(\n `Collection \"${name}\" item at index ${itemIndex} must have a non-empty type`,\n );\n }\n if (typeof item.src !== \"string\" || item.src.trim().length === 0) {\n throw new Error(\n `Collection \"${name}\" item at index ${itemIndex} must have a non-empty src`,\n );\n }\n\n return {\n type: item.type as CollectionItemConfig[\"type\"],\n src: item.src,\n };\n });\n\n return {\n name,\n items: validatedItems,\n };\n });\n}\n\nfunction resolveCollection(name: string): ResolvedCollectionItem[] {\n const collectionName = sanitizeName(name, \"collection\");\n const collections = readCollectionsConfig();\n const collection = collections.find((entry) => entry.name === collectionName);\n\n if (!collection) {\n throw new Error(`Collection not found: ${collectionName}`);\n }\n\n const deduped = new Map<string, ResolvedCollectionItem>();\n\n for (const item of collection.items) {\n const type = normalizeCollectionItemType(item.type, collection.name);\n const sourcePath = resolveSourcePath(item.src, type, collection.name);\n const sourceName = inferItemNameFromSource(type, sourcePath, collection.name);\n const key = `${type}:${sourceName}`;\n\n if (!deduped.has(key)) {\n deduped.set(key, {\n collection: collection.name,\n sourcePath,\n sourceName,\n type,\n });\n }\n }\n\n return [...deduped.values()];\n}\n\nfunction installHook(name: string, srcDir: string): void {\n if (!existsSync(srcDir)) {\n console.error(`Hook not found: ${name}`);\n process.exit(1);\n }\n\n const hookSrc = join(srcDir, \"hook.mjs\");\n const fragmentPath = join(srcDir, \"settings-fragment.json\");\n\n const hooksDir = join(CLAUDE_DIR, \"hooks\");\n mkdirSync(hooksDir, { recursive: true });\n const destHook = resolve(hooksDir, `${name}.mjs`);\n if (!destHook.startsWith(hooksDir + sep)) {\n console.error(\"Invalid hook name\");\n process.exit(1);\n }\n writeFileSync(destHook, readFileSync(hookSrc));\n\n if (existsSync(fragmentPath)) {\n const fragment = JSON.parse(readFileSync(fragmentPath, \"utf8\"));\n const settingsPath = join(CLAUDE_DIR, \"settings.json\");\n const current = existsSync(settingsPath) ? JSON.parse(readFileSync(settingsPath, \"utf8\")) : {};\n const merged = deepMerge(current, fragment);\n writeFileSync(settingsPath, JSON.stringify(merged, null, 2) + \"\\n\");\n }\n\n const manifest = readManifest();\n manifest.hooks[name] = { hash: hashHookSource(name), installedAt: today() };\n writeManifest(manifest);\n\n console.log(`Installed hook: ${name} → ${relative(PROJECT_ROOT, destHook)}`);\n}\n\nfunction addHook(name: string): void {\n name = sanitizeName(name, \"hook\");\n installHook(name, join(HOOKS_SRC, name));\n}\n\nfunction installSkill(name: string, srcDir: string, links: string[]): void {\n if (!existsSync(srcDir) || !statSync(srcDir).isDirectory()) {\n console.error(`Skill not found: ${name}`);\n process.exit(1);\n }\n\n const destDir = resolve(TOOLKIT_DIR, \"skills\", name);\n if (!destDir.startsWith(join(TOOLKIT_DIR, \"skills\") + sep)) {\n console.error(\"Invalid skill name\");\n process.exit(1);\n }\n mkdirSync(dirname(destDir), { recursive: true });\n cpSync(srcDir, destDir, { recursive: true });\n\n const resolvedLinks = links.length > 0 ? links : [join(\".claude\", \"skills\")];\n for (const link of resolvedLinks) {\n const linkDir = resolve(PROJECT_ROOT, link);\n mkdirSync(linkDir, { recursive: true });\n\n const linkPath = join(linkDir, name);\n if (existsSync(linkPath) || lstatExists(linkPath)) {\n unlinkSync(linkPath);\n }\n\n const relTarget = relative(linkDir, destDir);\n symlinkSync(relTarget, linkPath, \"dir\");\n }\n\n const manifest = readManifest();\n manifest.skills[name] = {\n hash: hashSkillSource(name),\n installedAt: today(),\n linkedTo: resolvedLinks,\n };\n writeManifest(manifest);\n\n console.log(`Installed skill: ${name} → ${relative(PROJECT_ROOT, destDir)}`);\n for (const l of resolvedLinks) {\n console.log(` linked: ${join(l, name)}`);\n }\n}\n\nfunction addSkill(name: string, links: string[]): void {\n name = sanitizeName(name, \"skill\");\n installSkill(name, join(SKILLS_SRC, name), links);\n}\n\nfunction addCollection(name: string): void {\n const items = resolveCollection(name);\n for (const item of items) {\n if (!existsSync(item.sourcePath)) {\n throw new Error(\n `Collection \"${item.collection}\" references missing ${item.type} source: ${relative(TOOLKIT_ROOT, item.sourcePath)}`,\n );\n }\n\n const itemStats = statSync(item.sourcePath);\n const actualKind = itemStats.isFile()\n ? \"file\"\n : itemStats.isDirectory()\n ? \"directory\"\n : \"other\";\n\n if (item.type === \"hook\") {\n if (!itemStats.isDirectory()) {\n throw new Error(\n `Collection \"${item.collection}\" expected hook source \"${item.sourcePath}\" to be a directory, found ${actualKind}`,\n );\n }\n installHook(item.sourceName, item.sourcePath);\n continue;\n }\n\n if (!itemStats.isDirectory()) {\n throw new Error(\n `Collection \"${item.collection}\" expected skill source \"${item.sourcePath}\" to be a directory, found ${actualKind}`,\n );\n }\n installSkill(item.sourceName, item.sourcePath, []);\n }\n}\n\nfunction lstatExists(p: string): boolean {\n try {\n lstatSync(p);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function update(force: boolean): Promise<void> {\n const manifest = readManifest();\n let changed = false;\n\n for (const [name, entry] of Object.entries(manifest.hooks)) {\n const srcDir = join(HOOKS_SRC, name);\n if (!existsSync(srcDir)) {\n continue;\n }\n\n const sourceHash = hashHookSource(name);\n const installedPath = join(CLAUDE_DIR, \"hooks\", `${name}.mjs`);\n const installedHash = existsSync(installedPath) ? shortHash(readFileSync(installedPath)) : null;\n\n const sourceChanged = sourceHash !== entry.hash;\n const locallyModified = installedHash !== null && installedHash !== entry.hash;\n\n if (!sourceChanged && !locallyModified) {\n continue;\n }\n\n changed = true;\n\n if (locallyModified && !force) {\n console.warn(\n `! hook \"${name}\" was modified locally (installed=${installedHash}, manifest=${entry.hash}). Use --force to overwrite.`,\n );\n continue;\n }\n\n if (sourceChanged) {\n const oldSrc = existsSync(installedPath) ? readFileSync(installedPath, \"utf8\") : \"\";\n const newSrc = readFileSync(join(srcDir, \"hook.mjs\"), \"utf8\");\n console.log(`\\n~ hook: ${name} (${entry.hash} → ${sourceHash})`);\n console.log(diffLines(oldSrc, newSrc));\n const ok = force || (await confirm(`Update hook \"${name}\"?`));\n\n if (!ok) {\n continue;\n }\n\n writeFileSync(installedPath, newSrc);\n manifest.hooks[name] = { hash: sourceHash, installedAt: today() };\n }\n }\n\n for (const [name, entry] of Object.entries(manifest.skills)) {\n const srcDir = join(SKILLS_SRC, name);\n if (!existsSync(srcDir)) {\n continue;\n }\n\n const sourceHash = hashSkillSource(name);\n if (sourceHash === entry.hash) {\n continue;\n }\n\n changed = true;\n console.log(`\\n~ skill: ${name} (${entry.hash} → ${sourceHash})`);\n const ok = force || (await confirm(`Update skill \"${name}\"?`));\n if (!ok) {\n continue;\n }\n\n const destDir = join(TOOLKIT_DIR, \"skills\", name);\n cpSync(srcDir, destDir, { recursive: true, force: true });\n manifest.skills[name] = {\n hash: sourceHash,\n installedAt: today(),\n linkedTo: entry.linkedTo,\n };\n }\n\n if (changed) {\n writeManifest(manifest);\n }\n}\n\nfunction list(kind: \"hook\" | \"skill\"): void {\n const dir = kind === \"hook\" ? HOOKS_SRC : SKILLS_SRC;\n if (!existsSync(dir)) {\n console.log(`(no ${kind}s available)`);\n return;\n }\n const entries = readdirSync(dir, { withFileTypes: true })\n .filter((e) => e.isDirectory() || (kind === \"skill\" && e.isSymbolicLink()))\n .map((e) => e.name);\n\n if (entries.length === 0) {\n console.log(`(no ${kind}s available)`);\n return;\n }\n\n for (const name of entries) {\n const hash = kind === \"hook\" ? hashHookSource(name) : hashSkillSource(name);\n console.log(`${name} ${hash}`);\n }\n}\n\nfunction listCollections(): void {\n const collections = readCollectionsConfig();\n if (collections.length === 0) {\n console.log(\"(no collections available)\");\n return;\n }\n\n for (const collection of collections) {\n console.log(`${collection.name} ${collection.items.length} item(s)`);\n }\n}\n\n// ---------- argv ----------\n\nfunction usage(): never {\n console.error(\n `Usage:\n toolkit add hook <name>\n toolkit add skill <name> [--link <target>]...\n toolkit add collections <name>\n toolkit update [--force]\n toolkit list hook\n toolkit list skill\n toolkit list collections`,\n );\n process.exit(1);\n}\n\nasync function main(): Promise<void> {\n const { values, positionals } = parseArgs({\n options: {\n force: {\n default: false,\n type: \"boolean\",\n },\n links: {\n multiple: true,\n type: \"string\",\n },\n },\n allowPositionals: true,\n });\n\n const { force, links } = values;\n const [command, resource, name] = positionals;\n\n if (command === \"add\" && resource === \"hook\") {\n if (!name) {\n usage();\n }\n\n addHook(name);\n return;\n }\n\n if (command === \"add\" && resource === \"skill\") {\n if (!name) {\n usage();\n }\n\n addSkill(name, links ? links : []);\n return;\n }\n\n if (command === \"add\" && (resource === \"collection\" || resource === \"collections\")) {\n if (!name) {\n usage();\n }\n\n addCollection(name);\n return;\n }\n\n if (command === \"update\") {\n await update(force);\n return;\n }\n\n if (command === \"list\" && (resource === \"hook\" || resource === \"skill\")) {\n list(resource as \"hook\" | \"skill\");\n return;\n }\n\n if (command === \"list\" && (resource === \"collection\" || resource === \"collections\")) {\n listCollections();\n return;\n }\n\n usage();\n}\n\nmain().catch((err) => {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,eAAe,QAAQ,QAAQ,cAAc,OAAO,KAAK,IAAI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AEF,MAAM,EAAE,OAAO,UAAU;CACzB,MAAM,CAAC,SAAS,UAAU,QAAQ;CAElC,IAAI,YAAY,SAAS,aAAa,QAAQ;EAC5C,IAAI,CAAC,MACH,OAAO;EAGT,QAAQ,KAAK;EACb;;CAGF,IAAI,YAAY,SAAS,aAAa,SAAS;EAC7C,IAAI,CAAC,MACH,OAAO;EAGT,SAAS,MAAM,QAAQ,QAAQ,EAAE,CAAC;EAClC;;CAGF,IAAI,YAAY,UAAU,aAAa,gBAAgB,aAAa,gBAAgB;EAClF,IAAI,CAAC,MACH,OAAO;EAGT,cAAc,KAAK;EACnB;;CAGF,IAAI,YAAY,UAAU;EACxB,MAAM,OAAO,MAAM;EACnB;;CAGF,IAAI,YAAY,WAAW,aAAa,UAAU,aAAa,UAAU;EACvE,KAAK,SAA6B;EAClC;;CAGF,IAAI,YAAY,WAAW,aAAa,gBAAgB,aAAa,gBAAgB;EACnF,iBAAiB;EACjB;;CAGF,OAAO;;AAGT,MAAM,CAAC,OAAO,QAAQ;CACpB,QAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC;CAC/D,QAAQ,KAAK,EAAE;EACf"}
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@schalkneethling/toolkit",
3
- "version": "0.7.2",
3
+ "version": "1.0.0",
4
4
  "description": "CLI for managing Claude Code hooks and skills across projects.",
5
5
  "license": "MIT",
6
6
  "bin": {
7
7
  "toolkit": "./dist/index.mjs"
8
8
  },
9
9
  "files": [
10
- "commands",
11
10
  "config.json",
12
11
  "dist",
13
12
  "hooks",
@@ -20,14 +19,16 @@
20
19
  "publishConfig": {
21
20
  "access": "public"
22
21
  },
22
+ "scripts": {
23
+ "toolkit": "tsx src/index.ts",
24
+ "prepare": "vp pack && vp run build:hooks",
25
+ "build:hooks": "tsc --project tsconfig.hooks.json"
26
+ },
23
27
  "devDependencies": {
24
28
  "@types/node": "^25.6.0",
25
29
  "tsx": "^4.21.0",
26
30
  "typescript": "^6.0.2",
27
31
  "vite-plus": "^0.1.18"
28
32
  },
29
- "scripts": {
30
- "toolkit": "tsx src/index.ts",
31
- "build:hooks": "tsc --project tsconfig.hooks.json"
32
- }
33
- }
33
+ "packageManager": "pnpm@11.1.1"
34
+ }
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: code-review
3
+ description: Review code changes for correctness, security, performance, accessibility, maintainability, tests, dependencies, design-system adherence, and localization. Use when the user asks for a code review, PR review, review of local changes, risk assessment, code quality feedback, or actionable findings before merge.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Code Review
8
+
9
+ Review code to catch issues the original engineer may have missed and to improve the codebase without creating unnecessary friction. Prioritize real risks over style noise.
10
+
11
+ ## Review Workflow
12
+
13
+ 1. Determine the review scope:
14
+ - Inspect `git status`, the relevant diff, and any user-specified files or PR context.
15
+ - Preserve unrelated user changes. Do not modify code unless the user asks for fixes.
16
+ - Identify whether the change is frontend, backend, library, CLI, infrastructure, docs, or mixed.
17
+ 2. Check project context before judging:
18
+ - Frameworks and languages.
19
+ - Test tooling and CI coverage.
20
+ - Linting, formatting, type checking, and build scripts.
21
+ - Dependency management and lockfiles.
22
+ - Accessibility, localization, and design-system tooling when UI code is involved.
23
+ 3. Review the change for material issues:
24
+ - Correctness: broken behavior, edge cases, data loss, error handling, and regressions.
25
+ - Security: injection risks, unsafe auth, secret handling, dependency risk, and permission scope.
26
+ - Performance and resources: unnecessary CPU, memory, network use, leaks, race conditions, deadlocks, async coordination, and missing back-pressure or throttling.
27
+ - Accessibility: semantic HTML, labels, keyboard support, focus management, ARIA misuse, and contrast.
28
+ - Maintainability: naming, structure, type safety, readability, duplication, and fit with local patterns.
29
+ - Tests and docs: missing coverage for new behavior, insufficient regression tests, and stale public docs.
30
+ - Dependencies: added packages, bundle/runtime impact, maintenance state, security posture, and whether built-in or existing project utilities would be enough.
31
+ - Design systems and branding: token usage, component reuse, theme consistency, and justified deviations.
32
+ - Localization: hard-coded UI strings, date/number formatting, translation keys, and future translation workflow.
33
+ 4. Produce review feedback:
34
+ - Lead with findings, ordered by severity.
35
+ - Include file and line references for repo-local issues.
36
+ - Explain impact and give a concrete fix.
37
+ - Group repeated instances when one root cause explains them.
38
+ - Mark non-blocking refactors as follow-up suggestions, not merge blockers.
39
+ - If no issues are found, say so clearly and mention any residual test or tooling gaps.
40
+
41
+ ## Setup Deficiencies
42
+
43
+ If essential review infrastructure is missing, call it out early before deep findings:
44
+
45
+ - No runnable tests or tests absent from CI.
46
+ - No linting, formatting, type checking, or build validation for the changed area.
47
+ - Missing lockfile or unpinned dependencies.
48
+ - No dependency or supply-chain scanning for publishable/server code.
49
+ - No accessibility checks for UI-heavy changes.
50
+ - No i18n framework or translation process for localized UI.
51
+ - Missing design-system tokens/components when the project clearly depends on them.
52
+
53
+ When a setup deficiency would make the review noisy or unreliable, report the deficiency as the primary finding and then provide only the highest-confidence code findings.
54
+
55
+ ## Feedback Standards
56
+
57
+ - Be direct, specific, and respectful. Focus on code and impact, never the author.
58
+ - Avoid nitpicks that an existing formatter or linter should handle.
59
+ - Prefer established local helpers, components, patterns, and style systems over new abstractions.
60
+ - Flag redundant implementations when the project already has an equivalent helper, component, CSS pattern, or service.
61
+ - Challenge clever but opaque code. Prefer readable control flow and well-named helpers.
62
+ - Encourage comments only for non-obvious decisions, tradeoffs, constraints, or nuanced behavior. Discourage comments that restate the code.
63
+ - Include positive feedback after findings when something is genuinely strong, such as clean tests, simple abstractions, or thoughtful design.
64
+
65
+ ## Severity Guide
66
+
67
+ - `P0`: Must fix immediately. Security exploit, data loss, severe outage, or merge-blocking broken core behavior.
68
+ - `P1`: Should fix before merge. Likely bug, serious regression, accessibility blocker, unsafe dependency/auth pattern, or missing critical test.
69
+ - `P2`: Important but may be follow-up. Maintainability issue, incomplete edge coverage, performance concern, duplicate implementation, or design-system drift.
70
+ - `P3`: Optional improvement. Clarity, small refactor, documentation polish, or non-blocking suggestion.
71
+
72
+ ## Output Shape
73
+
74
+ Use this order for review responses:
75
+
76
+ 1. Findings, ordered by severity, with `file:line`.
77
+ 2. Open questions or assumptions.
78
+ 3. Brief positive notes, if useful.
79
+ 4. Validation performed or not performed.
80
+
81
+ Keep summaries short. The findings are the review.
@@ -0,0 +1,6 @@
1
+ interface:
2
+ display_name: "Code Review"
3
+ short_description: "Review code changes for risk and quality."
4
+ default_prompt: "Use $code-review to review my current changes and prioritize actionable findings."
5
+ policy:
6
+ allow_implicit_invocation: false
@@ -1,12 +1,13 @@
1
1
  ---
2
2
  name: npm-package-publishing
3
3
  description: >
4
- Apply best practices when publishing npm packages, including secure CI/CD workflows, trusted
5
- publishing via OIDC, GitHub repository hardening, and supply-chain attack prevention. Use this
6
- skill whenever the user asks about publishing an npm package, setting up a publish workflow,
7
- configuring GitHub Actions for release automation, managing npm tokens or secrets, setting up
8
- changesets, or auditing an existing publishing pipeline for security. Also trigger when the user
9
- mentions publint, OIDC trusted publishing, release automation, or package versioning workflows.
4
+ Audit and improve the security posture of npm package publishing: account security, npm trusted
5
+ publishing strategy, GitHub repository hardening, token removal, release governance, dependency
6
+ update policy, provenance, and supply-chain risk. Use when the user asks about npm publishing best
7
+ practices, publishing security, OIDC/trusted publishing strategy, npm token hygiene, release
8
+ automation posture, Changesets versus changelog strategies, publint, provenance, or auditing an
9
+ existing publishing pipeline. For writing or debugging the concrete GitHub Actions publish
10
+ workflow file, use the npm-trusted-publishing-github-workflow skill instead.
10
11
  ---
11
12
 
12
13
  # npm Package Publishing — Best Practices
@@ -14,8 +15,66 @@ description: >
14
15
  Based on the [e18e publishing guide](https://e18e.dev/docs/publishing.html). Reference it for
15
16
  the canonical source; this skill distils the actionable steps.
16
17
 
17
- > **Package manager note.** All examples in this skill use `npm` to match the e18e source
18
- > material, but nothing here is npm-specific. Always use whichever package manager the project
18
+ ## Agent Workflow
19
+
20
+ 1. Inspect the repository before recommending changes:
21
+ - `package.json`
22
+ - lockfiles and `packageManager`
23
+ - `.npmrc`, `.yarnrc.yml`, `.github/workflows/*`
24
+ - release tooling such as Changesets, changelogithub, semantic-release, or release-it
25
+ - existing npm/GitHub tokens or `NODE_AUTH_TOKEN` usage in workflows
26
+ 2. Classify the request:
27
+ - **Audit**: report risks by severity, with file and line references where possible.
28
+ - **Implementation**: make scoped repository changes, then run relevant validation.
29
+ - **Strategy**: explain tradeoffs and identify user-only settings.
30
+ 3. Separate agent-doable work from user-only UI work. Do not claim account, npmjs.com, or GitHub
31
+ settings are configured unless verified by authenticated tool/API access.
32
+ 4. For concrete GitHub Actions publish workflow creation or CI failure debugging, hand off to the
33
+ `npm-trusted-publishing-github-workflow` skill.
34
+
35
+ ## Freshness Rule
36
+
37
+ Before changing trusted publishing requirements, supported CI providers, npm CLI minimums, Node.js
38
+ minimums, provenance behavior, or GitHub release/security settings, verify the current official npm
39
+ and GitHub documentation when browsing is available. These requirements change over time.
40
+
41
+ ## Responsibility Split
42
+
43
+ Agent can usually:
44
+
45
+ - Edit `.github/workflows/*`.
46
+ - Add or update repository package-manager config such as `.npmrc` or `.yarnrc.yml`.
47
+ - Remove `NODE_AUTH_TOKEN` usage from publish steps when trusted publishing is used.
48
+ If private dependencies require registry auth during install, keep that token scoped to read-only
49
+ install steps only.
50
+ - Add Dependabot/Renovate config.
51
+ - Run `publint`, workflow linting, tests, package builds, and other local validation.
52
+ - Report exact user steps for npm/GitHub settings.
53
+
54
+ User or authenticated UI/API access required:
55
+
56
+ - Enable npm/GitHub 2FA.
57
+ - Configure npm trusted publisher settings on npmjs.com.
58
+ - Set package publishing access to require 2FA and disallow tokens.
59
+ - Enable GitHub repository/org Actions restrictions.
60
+ - Configure branch/tag rulesets and immutable releases.
61
+ - Remove repository/org secrets when the agent lacks GitHub settings access.
62
+
63
+ ## Non-Negotiables
64
+
65
+ - Do not add `NODE_AUTH_TOKEN` to publish steps when trusted publishing is available.
66
+ Use OIDC for publishing; if private dependencies require install auth, use a read-only token only
67
+ for the install step.
68
+ - Do not store npm publish tokens in GitHub Actions secrets for OIDC-capable publishing.
69
+ - Do not run install lifecycle scripts in release workflows unless the user explicitly accepts the
70
+ risk.
71
+ - Do not show tag-pinned actions as compliant with SHA pinning; resolve actions to full commit SHAs.
72
+ - Do not say npm/GitHub account settings are complete unless they were actually checked.
73
+ - Do not use self-hosted runners for npm trusted publishing unless official npm docs currently
74
+ support them.
75
+
76
+ > **Package manager note.** The example install and configuration commands in this skill use `npm`
77
+ > to match the e18e source material, but should be adapted to whichever package manager the project
19
78
  > already uses — `pnpm`, `yarn`, `bun`, etc. Adapt commands accordingly:
20
79
  >
21
80
  > | npm | pnpm | yarn |
@@ -27,6 +86,10 @@ the canonical source; this skill distils the actionable steps.
27
86
  > Detect the project's package manager by checking for a lockfile (`pnpm-lock.yaml`,
28
87
  > `yarn.lock`, `bun.lockb`) or a `packageManager` field in `package.json` before
29
88
  > generating any commands or workflow steps.
89
+ >
90
+ > Section 2.2's trusted-publishing requirement is npm-specific: the publish step must run with a
91
+ > supported Node.js version and npm CLI version even when the rest of the workflow uses another
92
+ > package manager.
30
93
 
31
94
  ---
32
95
 
@@ -92,7 +155,8 @@ ever touches the repository.
92
155
  ### 2.2 · npm CLI version requirement
93
156
 
94
157
  The publish step **must** use npm CLI ≥ 11.5.1 for automatic OIDC trusted publishing.
95
- Node.js 24 bundles npm 11.5.1; with older CI images, add a step before publishing:
158
+ Node.js 22.14.0 or newer can use trusted publishing when the workflow installs npm CLI 11.5.1 or
159
+ newer before publishing:
96
160
 
97
161
  ```yaml
98
162
  - run: npm i -g npm
@@ -277,6 +341,24 @@ all other security recommendations in this document regardless.
277
341
 
278
342
  ---
279
343
 
344
+ ## Audit Output Format
345
+
346
+ For audits, lead with findings:
347
+
348
+ - **P0/P1/P2/P3** severity.
349
+ - File and line when repo-local.
350
+ - Risk.
351
+ - Recommended fix.
352
+ - Whether the agent can implement it now or the user must configure it externally.
353
+
354
+ Then include:
355
+
356
+ - Validation run.
357
+ - Remaining user-only checklist.
358
+ - Suggested next change.
359
+
360
+ ---
361
+
280
362
  ## Quick Reference Checklist
281
363
 
282
364
  Use this when setting up a new package or auditing an existing one.
@@ -299,7 +381,7 @@ Use this when setting up a new package or auditing an existing one.
299
381
 
300
382
  - [ ] OIDC trusted publisher configured on npmjs.com
301
383
  - [ ] "Require 2FA, disallow tokens" enabled on npm
302
- - [ ] Publish step uses Node.js 24.8.0
384
+ - [ ] Publish step uses npm CLI ≥ 11.5.1 and a Node.js version supported by official npm docs
303
385
  - [ ] GitHub environment (`publish`) configured with branch restrictions
304
386
 
305
387
  ### Workflow hygiene
@@ -0,0 +1,3 @@
1
+ display_name: npm Publishing Security
2
+ short_description: Audit and improve secure npm package publishing workflows.
3
+ default_prompt: Audit this package's npm publishing setup and recommend secure trusted publishing, token, workflow, and release hardening improvements.
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: refined-plan-mode
3
+ description: Use this skill when the user asks to plan, review, revise, continue, checkpoint, handoff, reset, or execute work using Refined Plan Mode. Also use it for legacy /rpm:start, /rpm:advance, /rpm:review, /rpm:feedback, /rpm:checkpoint, and /rpm:handoff prompts.
4
+ ---
5
+
1
6
  # Refined Plan Mode
2
7
 
3
8
  Use this skill when the user asks to plan, review, revise, continue, checkpoint, handoff, reset, or execute work using Refined Plan Mode.
@@ -24,7 +29,99 @@ Users can ask for checkpoint, handoff, or reset in natural language:
24
29
 
25
30
  - For a checkpoint, report the current version, latest plan path, feedback status, approval status, and recommended next action.
26
31
  - For a handoff, summarize the goal, current plan, feedback status, approval status, important assumptions, unresolved decisions, and recommended next action.
27
- - For a reset, empty only `.plan-review` while keeping the `.plan-review` directory itself. Do not remove source files or any other workspace files.
32
+ - For a reset, first require explicit confirmation by asking the user to type `RESET` or by accepting an explicit `--force` request. After confirmation, empty only the contents of `.plan-review` while keeping the `.plan-review` directory itself. Do not remove source files or any other workspace files.
33
+
34
+ ## Task Modes
35
+
36
+ Treat these legacy `/rpm:*` prompts as natural-language requests for this skill:
37
+
38
+ ### `/rpm:start`
39
+
40
+ Start a plan review loop for the user's current task.
41
+
42
+ 1. Inspect the repository enough to understand the task and relevant constraints.
43
+ 2. Ask only blocking clarification questions. If reasonable assumptions are available, state them in the plan instead of stopping.
44
+ 3. Create `.plan-review/plans/plan-v1.md` with the complete plan.
45
+ 4. Create or update `.plan-review/.current-version` with `v1`.
46
+ 5. Reply with a concise summary and tell the user the plan is ready for review in Refined Plan Mode.
47
+
48
+ Do not implement the plan yet unless the user explicitly asks you to proceed without review.
49
+
50
+ ### `/rpm:advance`
51
+
52
+ Continue the loop from the current state.
53
+
54
+ 1. Inspect `.plan-review/.current-version`, `.plan-review/approved-plan.md`, available plan files, and available feedback files.
55
+ 2. If an approved plan exists, execute that plan.
56
+ 3. If feedback exists for the current plan version, incorporate it into the next plan version.
57
+ 4. If there is a current plan but no feedback or approval, remind the user that the plan is awaiting review.
58
+ 5. If no plan exists, start with `/rpm:start` behavior.
59
+
60
+ Keep the response focused on the next state transition.
61
+
62
+ ### `/rpm:review`
63
+
64
+ Audit the latest plan before the user reviews it.
65
+
66
+ 1. Read the current plan version.
67
+ 2. Review the plan for missing context, vague steps, untested assumptions, risky sequencing, and weak validation.
68
+ 3. If improvements are needed, write a revised next version and update `.plan-review/.current-version`.
69
+ 4. If the plan is already review-ready, leave files unchanged.
70
+ 5. Reply with either the new plan version written or a short explanation that the current plan is ready for review.
71
+
72
+ This mode reviews plan quality. It does not implement the plan.
73
+
74
+ ### `/rpm:feedback`
75
+
76
+ Incorporate submitted feedback into the next plan version.
77
+
78
+ 1. Read `.plan-review/.current-version` to find the current version.
79
+ 2. Read `.plan-review/feedback/plan-vN-feedback.json` for that version.
80
+ 3. Read `.plan-review/plans/plan-vN.md`.
81
+ 4. Address every feedback item in a revised plan, adding a `Feedback Addressed` section that maps comments to changes made.
82
+ 5. Write the revision to `.plan-review/plans/plan-vN+1.md`.
83
+ 6. Update `.plan-review/.current-version` to the new version.
84
+ 7. Reply with a short note naming the feedback file read and the new plan file written.
85
+
86
+ If the feedback file is missing, report the exact path expected and stop.
87
+
88
+ ### `/rpm:checkpoint`
89
+
90
+ Summarize the current review-loop state.
91
+
92
+ Report:
93
+
94
+ - Current plan version from `.plan-review/.current-version`, if present.
95
+ - Latest plan file path.
96
+ - Whether feedback exists for the current version.
97
+ - Whether `.plan-review/approved-plan.md` exists.
98
+ - The recommended next action.
99
+
100
+ Do not modify files unless the user also asks you to advance or revise the plan.
101
+
102
+ ### `/rpm:handoff`
103
+
104
+ Prepare a compact continuation summary for another agent or a future session.
105
+
106
+ Include:
107
+
108
+ - Goal.
109
+ - Current plan version and file path.
110
+ - Feedback status.
111
+ - Approval status.
112
+ - Important assumptions or unresolved decisions.
113
+ - Recommended next action.
114
+
115
+ Prefer reading the current plan and feedback files directly instead of relying on chat history.
116
+
117
+ ### Reset
118
+
119
+ Reset the review-loop state only after explicit confirmation:
120
+
121
+ 1. If the user did not provide an explicit `--force` request, ask them to type `RESET`.
122
+ 2. Proceed only when the user confirms exactly.
123
+ 3. Empty the contents of `.plan-review`, preserving the `.plan-review` directory itself.
124
+ 4. Do not remove source files or any workspace files outside `.plan-review`.
28
125
 
29
126
  ## File Convention
30
127
 
@@ -1,13 +0,0 @@
1
- # /rpm:advance
2
-
3
- Use the Refined Plan Mode skill to continue the loop from the current state.
4
-
5
- Steps:
6
-
7
- 1. Inspect `.plan-review/.current-version`, `.plan-review/approved-plan.md`, available plan files, and available feedback files.
8
- 2. If an approved plan exists, execute that plan.
9
- 3. If feedback exists for the current plan version, incorporate it into the next plan version.
10
- 4. If there is a current plan but no feedback or approval, remind the user that the plan is awaiting review.
11
- 5. If no plan exists, start with `/rpm:start` behavior.
12
-
13
- Keep the response focused on the next state transition.
@@ -1,13 +0,0 @@
1
- # /rpm:checkpoint
2
-
3
- Use the Refined Plan Mode skill to summarize the current review-loop state.
4
-
5
- Report:
6
-
7
- - Current plan version from `.plan-review/.current-version`, if present.
8
- - Latest plan file path.
9
- - Whether feedback exists for the current version.
10
- - Whether `.plan-review/approved-plan.md` exists.
11
- - The recommended next action.
12
-
13
- Do not modify files unless the user also asks you to advance or revise the plan.
@@ -1,15 +0,0 @@
1
- # /rpm:feedback
2
-
3
- Use the Refined Plan Mode skill to incorporate submitted feedback into the next plan version.
4
-
5
- Steps:
6
-
7
- 1. Read `.plan-review/.current-version` to find the current version.
8
- 2. Read `.plan-review/feedback/plan-vN-feedback.json` for that version.
9
- 3. Read `.plan-review/plans/plan-vN.md`.
10
- 4. Address every feedback item in a revised plan, adding a "Feedback Addressed" section that maps comments to changes made.
11
- 5. Write the revision to `.plan-review/plans/plan-vN+1.md`.
12
- 6. Update `.plan-review/.current-version` to the new version.
13
- 7. Reply with a short note naming the feedback file read and the new plan file written.
14
-
15
- If the feedback file is missing, report the exact path expected and stop.
@@ -1,14 +0,0 @@
1
- # /rpm:handoff
2
-
3
- Use the Refined Plan Mode skill to prepare a compact continuation summary for another agent or a future session.
4
-
5
- Include:
6
-
7
- - Goal.
8
- - Current plan version and file path.
9
- - Feedback status.
10
- - Approval status.
11
- - Important assumptions or unresolved decisions.
12
- - Recommended next command or action.
13
-
14
- Prefer reading the current plan and feedback files directly instead of relying on chat history.
@@ -1,13 +0,0 @@
1
- # /rpm:review
2
-
3
- Use the Refined Plan Mode skill to audit the latest plan before the user reviews it.
4
-
5
- Steps:
6
-
7
- 1. Read the current plan version.
8
- 2. Review the plan for missing context, vague steps, untested assumptions, risky sequencing, and weak validation.
9
- 3. If improvements are needed, write a revised next version and update `.plan-review/.current-version`.
10
- 4. If the plan is already review-ready, leave files unchanged.
11
- 5. Reply with either the new plan version written or a short explanation that the current plan is ready for review.
12
-
13
- This command reviews plan quality. It does not implement the plan.
@@ -1,13 +0,0 @@
1
- # /rpm:start
2
-
3
- Use the Refined Plan Mode skill to start a plan review loop for the user's current task.
4
-
5
- Steps:
6
-
7
- 1. Inspect the repository enough to understand the task and relevant constraints.
8
- 2. Ask only blocking clarification questions. If reasonable assumptions are available, state them in the plan instead of stopping.
9
- 3. Create `.plan-review/plans/plan-v1.md` with the complete plan.
10
- 4. Create or update `.plan-review/.current-version` with `v1`.
11
- 5. Reply with a concise summary and tell the user the plan is ready for review in Refined Plan Mode.
12
-
13
- Do not implement the plan yet unless the user explicitly asks you to proceed without review.