@spardutti/claude-skills 2.22.0 → 2.23.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
@@ -100,8 +100,8 @@ Portable slash commands installed to `.claude/commands/`. Some orchestrate paral
100
100
 
101
101
  | Command | What it does |
102
102
  |---------|--------------|
103
- | `/ship` | Unified delivery pipeline — gate → commit → PR → merge → release. The gate is the one enforcement moment: it checks the diff's file lengths, audits it against the skills installed in the project, and mutation-tests the changed lines to prove the tests would catch a break — **fixing what it finds** rather than handing you a list. `--force` skips it. No argument steps through interactively; `/ship pr` runs through PR creation; `/ship release` runs the full pipeline |
104
- | `/discover` | Find the right problem before deciding what to build — diverges first: names competing interpretations of what you said, stress-tests the framing with a blind critic subagent, then converges on a mental model. Run before `/preplan` |
103
+ | `/ship` | Unified delivery pipeline — commit → gate → PR → merge → release. The gate is the one enforcement moment: it checks the diff's file lengths, audits it against the skills installed in the project, and mutation-tests the changed lines to prove the tests would catch a break — **fixing what it finds** rather than handing you a list. It runs before the **PR**, not before every commit: its scope is the whole branch, so gating each commit re-mutated every file the branch had ever touched. `--force` skips it. No argument steps through interactively; `/ship pr` runs through PR creation; `/ship release` runs the full pipeline |
104
+ | `/discover` | Find the right problem before deciding what to build — diverges first: generates competing framings through blind subagents under forced constraints, stress-tests the winner with a blind critic, and refuses to converge until every open question is answered or deferred. Run before `/preplan` |
105
105
  | `/preplan` | Resolve a fuzzy feature idea into concrete decisions — 6 fixed phases, one question at a time, ends with a decision log. Run before `/plan-feature` |
106
106
  | `/plan-feature` | Integration-first feature planning — 3 parallel subagents scan for reusable code, patterns, and touch points before producing a short plan |
107
107
  | `/refactor` | Detect size / complexity / duplication / coupling issues via 4 parallel subagents, then refactor |
package/bin/cli.mjs CHANGED
@@ -8,7 +8,13 @@ import { dirname, join } from "node:path";
8
8
  import { fetchSkills, fetchCommands, fetchAgents } from "../lib/github.mjs";
9
9
  import { promptSkillSelection, promptCommandSelection, promptRemoval } from "../lib/prompt.mjs";
10
10
  import { installSkills, installCommands, installRequiredAgents } from "../lib/install.mjs";
11
- import { setupHook, detectStack, writeGauntletConf } from "../lib/setup-hook.mjs";
11
+ import {
12
+ setupHook,
13
+ detectStack,
14
+ writeGauntletConf,
15
+ autoModeRuleStatus,
16
+ writeAutoModeRule,
17
+ } from "../lib/setup-hook.mjs";
12
18
  import { makeLocalSource, reportToolNeeds } from "../lib/local.mjs";
13
19
  import { scaffoldStryker } from "../lib/scaffold-stryker.mjs";
14
20
  import { setupClaudeMd } from "../lib/setup-claude-md.mjs";
@@ -173,6 +179,39 @@ async function main() {
173
179
  await setupHook();
174
180
  await setupClaudeMd();
175
181
 
182
+ // In auto mode the classifier denies the gate's ack, and it only reads
183
+ // autoMode.allow from the user's own ~/.claude/settings.json. Without this
184
+ // the gate cannot be satisfied at all, and the session cannot fix it
185
+ // either — an agent editing permission settings is denied by the same
186
+ // classifier. The installer is the only thing here running as the user.
187
+ const autoModeStatus = await autoModeRuleStatus();
188
+ if (autoModeStatus === "unreadable") {
189
+ console.log();
190
+ console.log(` ${chalk.yellow("!")} ${chalk.dim("~/.claude/settings.json is not valid JSON — skipping the auto mode rule.")}`);
191
+ } else if (autoModeStatus !== "current") {
192
+ console.log();
193
+ console.log(chalk.dim(" Auto mode's classifier denies the gate's acknowledgement files, and"));
194
+ console.log(chalk.dim(" clearing that needs a rule in your own ~/.claude/settings.json. Claude"));
195
+ console.log(chalk.dim(" cannot add it — editing permission settings is denied to agents too."));
196
+ const addRule = await confirm({
197
+ message:
198
+ autoModeStatus === "stale"
199
+ ? "Update the auto mode allow rule in ~/.claude/settings.json? (Recommended)"
200
+ : "Add an auto mode allow rule to ~/.claude/settings.json? (Recommended)",
201
+ default: true,
202
+ });
203
+ if (addRule) {
204
+ try {
205
+ const written = await writeAutoModeRule();
206
+ console.log(` Settings updated: ${written}`);
207
+ } catch (err) {
208
+ console.log(` ${chalk.yellow("!")} ${chalk.dim(err.message)}`);
209
+ }
210
+ } else {
211
+ console.log(` ${chalk.dim("Skipped. In auto mode the gate will block until you add it via /permissions.")}`);
212
+ }
213
+ }
214
+
176
215
  // Report what the gauntlet will actually run, so a silent no-op is visible.
177
216
  // This asks the installed hook itself — never a second copy of its logic.
178
217
  const gates = await detectStack(CWD);
@@ -23,13 +23,50 @@ const CONFIG = {
23
23
  tempDirName: ".stryker-tmp",
24
24
  };
25
25
 
26
+ // Bumped whenever IGNORER changes. A project scaffolded before a rule existed
27
+ // has no other way to learn about it, and the file is generated, not authored —
28
+ // so a missing marker means overwrite, not keep.
29
+ const IGNORER_VERSION = "v2";
30
+
31
+ // Exported and then serialised into the generated ignorer below, rather than
32
+ // written twice. A copy in the template and a copy under test would agree with
33
+ // each other and disagree with the shipped file.
34
+ export function inDataTable(path) {
35
+ let found = false;
36
+ for (let p = path; p; p = p.parentPath) {
37
+ if (p.isFunction()) return false;
38
+ if (!found && p.isVariableDeclarator()) {
39
+ const init = p.node.init;
40
+ if (!init) return false;
41
+ if (init.type !== "ArrayExpression" && init.type !== "ObjectExpression") return false;
42
+ found = true;
43
+ }
44
+ }
45
+ return found;
46
+ }
47
+
26
48
  // .mjs, not .js: an app without "type": "module" in its package.json cannot
27
49
  // load ESM from a .js file, and the plugin is ESM.
28
- const IGNORER = `// Ignore by WHERE the mutant sits, not by what kind it is. Disabling the
50
+ const IGNORER = `// Generated by @spardutti/claude-skills — ignorer ${IGNORER_VERSION}. Edits are
51
+ // overwritten when the rules change.
52
+ //
53
+ // Ignore by WHERE the mutant sits, not by what kind it is. Disabling the
29
54
  // StringLiteral mutator globally would also stop mutating labels, keys and
30
55
  // separators — strings whose value is behaviour.
31
56
  import { PluginKind, declareValuePlugin } from "@stryker-mutator/api/plugin";
32
57
 
58
+ // A string in a module-level array or object literal is copy: a heading, a
59
+ // label, a term row. Mutating it produces 'Pizzas' -> 'Stryker was here!',
60
+ // which can only be killed by asserting the table against a copy of itself —
61
+ // the tautology the testing skill exists to stop. One table of 11 headings and
62
+ // 16 rows produced 57 such survivors and a fifteen-minute gate.
63
+ //
64
+ // Any function between the string and the top disqualifies it: that is code
65
+ // building a value, not a table of content. A non-string mutant in the same
66
+ // table is left alone, because a number or a flag in a config object is
67
+ // behaviour even when it sits in data.
68
+ ${inDataTable.toString()}
69
+
33
70
  export const strykerPlugins = [
34
71
  declareValuePlugin(PluginKind.Ignore, "tailwind-classnames", {
35
72
  shouldIgnore(path) {
@@ -37,6 +74,8 @@ export const strykerPlugins = [
37
74
  return "styling, not behaviour";
38
75
  if (path.find((p) => p.isCallExpression() && p.node.callee.name === "cn"))
39
76
  return "styling, not behaviour";
77
+ if (path.isStringLiteral() && inDataTable(path))
78
+ return "copy in a data table, not behaviour";
40
79
  },
41
80
  }),
42
81
  ];
@@ -102,12 +141,24 @@ export async function scaffoldStryker(projectDir, rel) {
102
141
  wrote.push(`${at}stryker.config.json`);
103
142
  }
104
143
 
144
+ // Testing the fresh install here would have missed the whole point: a project
145
+ // that already had the v1 ignorer would have kept it forever and never gained
146
+ // the data-table rule, which is the rule this release exists for.
105
147
  const ignorerPath = join(dir, "stryker-classname-ignorer.mjs");
106
- if (await exists(ignorerPath)) {
148
+ let existingIgnorer = null;
149
+ try {
150
+ existingIgnorer = await readFile(ignorerPath, "utf-8");
151
+ } catch {
152
+ // not scaffolded yet
153
+ }
154
+ if (existingIgnorer === null) {
155
+ await writeFile(ignorerPath, IGNORER);
156
+ wrote.push(`${at}stryker-classname-ignorer.mjs`);
157
+ } else if (existingIgnorer.includes(`ignorer ${IGNORER_VERSION}`)) {
107
158
  kept.push(`${at}stryker-classname-ignorer.mjs`);
108
159
  } else {
109
160
  await writeFile(ignorerPath, IGNORER);
110
- wrote.push(`${at}stryker-classname-ignorer.mjs`);
161
+ patched.push(`${at}stryker-classname-ignorer.mjs`);
111
162
  }
112
163
 
113
164
  // A crashed run leaves a full second copy of the project behind, so this one
@@ -1,6 +1,7 @@
1
1
  import { mkdir, writeFile, readFile, chmod, unlink } from "node:fs/promises";
2
2
  import { join, resolve, dirname } from "node:path";
3
3
  import { spawn } from "node:child_process";
4
+ import { homedir } from "node:os";
4
5
 
5
6
  // PreToolUse gate on Write|Edit|MultiEdit. Blocks the tool call unless
6
7
  // a per-session marker file exists at /tmp/claude-skill-gate-<SESSION_ID>.
@@ -52,6 +53,9 @@ if [ "$TOOL" != "Bash" ]; then
52
53
  # The structured tools name their target outright.
53
54
  TARGET=$(printf '%s' "$INPUT" | grep -o '"file_path":[[:space:]]*"[^"]*"' | head -1 | sed 's/.*:[[:space:]]*"//; s/"$//')
54
55
  case "$TARGET" in
56
+ # The settings file that configures the escape hatch cannot sit behind the
57
+ # gate, or a denied ack has no way to be un-denied.
58
+ */.claude/settings.json|*/.claude/settings.local.json) exit 0 ;;
55
59
  *.*) printf '%s' "$TARGET" | grep -qiE "\.($PROSE_EXT)$" && exit 0 ;;
56
60
  esac
57
61
  fi
@@ -61,6 +65,7 @@ if [ "$TOOL" = "Bash" ]; then
61
65
  # Never gate the command that clears the gate, or this deadlocks.
62
66
  case "$CMD" in
63
67
  *claude-skill-gate-*|*claude-skill-acked-*|*claude-skill-loaded-*) exit 0 ;;
68
+ *.claude/settings.json*|*.claude/settings.local.json*) exit 0 ;;
64
69
  esac
65
70
 
66
71
  # /dev/null redirects are not file writes; drop them before looking for one.
@@ -155,6 +160,9 @@ if [ "$TOOL" != "Bash" ]; then
155
160
  # The structured tools name their target outright.
156
161
  TARGET=$(printf '%s' "$INPUT" | grep -o '"file_path":[[:space:]]*"[^"]*"' | head -1 | sed 's/.*:[[:space:]]*"//; s/"$//')
157
162
  case "$TARGET" in
163
+ # The settings file that configures the escape hatch cannot sit behind the
164
+ # gate, or a denied ack has no way to be un-denied.
165
+ */.claude/settings.json|*/.claude/settings.local.json) exit 0 ;;
158
166
  *.*) printf '%s' "$TARGET" | grep -qiE "\.($PROSE_EXT)$" && exit 0 ;;
159
167
  esac
160
168
  fi
@@ -162,6 +170,7 @@ if [ "$TOOL" = "Bash" ]; then
162
170
  CMD=$(printf '%s' "$INPUT" | grep -o '"command":[[:space:]]*"[^"]*"' | head -1 | sed 's/.*:[[:space:]]*"//; s/"$//')
163
171
  case "$CMD" in
164
172
  *claude-skill-gate-*|*claude-skill-acked-*|*claude-skill-loaded-*) exit 0 ;;
173
+ *.claude/settings.json*|*.claude/settings.local.json*) exit 0 ;;
165
174
  esac
166
175
 
167
176
  # A command that names a prose file and no code file is writing prose.
@@ -235,15 +244,20 @@ Before this Write/Edit, you must:
235
244
  One ack per skill per session. After acking, retry the Write/Edit.
236
245
 
237
246
  If that Bash call is denied by the auto mode classifier, STOP. Do not ask your
238
- user to run it for you, and do not look for another route to create the files.
239
- Both are what the classifier is there to stop, and asking a human to run a
240
- command you were just denied makes them the tool that performs it. Report this
241
- to them instead and let them decide:
247
+ user to run it for you, do not look for another route to create the files, and
248
+ do not try to add the allow rule yourself — an agent editing permission settings
249
+ is denied by the same classifier, so that attempt fails too and costs a round
250
+ trip that ends in the same place. All three are what the classifier is there to
251
+ stop, and asking a human to run a command you were just denied makes them the
252
+ tool that performs it. Report this to them instead and let them decide:
242
253
 
243
254
  Auto mode's built-in Auto-Mode Bypass rule counts a hook's ack file as working
244
255
  around the permission system. It is a soft rule, so an allow entry clears it.
245
- It has to go in ~/.claude/settings.json — the classifier does not read a
246
- project's .claude/settings.json — or in /permissions, Auto mode tab. Keep the
256
+ The user has to add it — you cannot. The shortest route is for them to re-run
257
+ npx @spardutti/claude-skills and accept the auto mode prompt, which writes it.
258
+ Otherwise /permissions, Auto mode tab. Editing the file by hand works too, and
259
+ it has to be ~/.claude/settings.json — the classifier does not read a
260
+ project's .claude/settings.json. Keep the
247
261
  \\\$defaults line or every built-in allow rule is discarded:
248
262
 
249
263
  \\"autoMode\\": { \\"allow\\": [ \\"\\\$defaults\\",
@@ -1035,7 +1049,7 @@ exit $STATUS
1035
1049
  // PreToolUse on Bash: refuses git commit/push without a ship-gate receipt.
1036
1050
  // Canonical source: scripts/ship-gate-hook.sh.
1037
1051
  const SHIP_GATE_HOOK_SCRIPT = `#!/usr/bin/env bash
1038
- # ship-gate-hook.sh — PreToolUse on Bash. Refuses \`git commit\` and \`git push\`
1052
+ # ship-gate-hook.sh — PreToolUse on Bash. Refuses the commands that publish work
1039
1053
  # unless ship-gate.sh has left a receipt for exactly these changes.
1040
1054
  #
1041
1055
  # A gate written as an instruction is a gate an agent can decide is not worth the
@@ -1046,21 +1060,38 @@ const SHIP_GATE_HOOK_SCRIPT = `#!/usr/bin/env bash
1046
1060
  # The receipt key covers everything about to ship, so it survives \`git commit\`
1047
1061
  # and still matches at push time, and it changes the moment any file is edited —
1048
1062
  # a fix has to be re-gated instead of riding on the previous verdict.
1063
+ #
1064
+ # It gated \`git commit\` and \`git push\` until 2.23.0, and that was the wrong
1065
+ # moment. The gate's scope is merge-base..HEAD — the whole branch, because the
1066
+ # whole branch is what a PR ships — so a branch touching 46 files re-mutated all
1067
+ # 46 on every commit. Fifteen minutes, twenty times, for one branch. Neither a
1068
+ # commit nor a push to a feature branch publishes anything, so neither is gated
1069
+ # now: the cost is paid once, at the point work actually ships.
1049
1070
 
1050
1071
  INPUT=$(cat)
1051
1072
 
1052
1073
  CMD=$(printf '%s' "$INPUT" | grep -o '"command"[[:space:]]*:[[:space:]]*"[^"]*"' \\
1053
1074
  | head -1 | sed 's/.*:[[:space:]]*"//; s/"$//')
1054
1075
 
1055
- # Only the two commands that publish work. Everything else passes untouched.
1076
+ PROJECT_DIR="\${CLAUDE_PROJECT_DIR:-$PWD}"
1077
+ cd "$PROJECT_DIR" 2>/dev/null || exit 0
1078
+
1079
+ # Opening or merging a PR publishes. So does pushing while standing on a
1080
+ # protected branch — that is a direct ship with no PR in front of it. The branch
1081
+ # is read from git rather than parsed out of the command, because \`git push\` with
1082
+ # no arguments names no branch at all.
1056
1083
  case "$CMD" in
1057
- *"git commit"*|*"git push"*) ;;
1084
+ *"gh pr create"*|*"gh pr merge"*) ;;
1085
+ *"git push"*)
1086
+ BRANCH=$(git branch --show-current 2>/dev/null)
1087
+ case "$BRANCH" in
1088
+ main|master|develop|development|dev) ;;
1089
+ *) exit 0 ;;
1090
+ esac
1091
+ ;;
1058
1092
  *) exit 0 ;;
1059
1093
  esac
1060
1094
 
1061
- PROJECT_DIR="\${CLAUDE_PROJECT_DIR:-$PWD}"
1062
- cd "$PROJECT_DIR" 2>/dev/null || exit 0
1063
-
1064
1095
  GATE="$PROJECT_DIR/.claude/hooks/ship-gate.sh"
1065
1096
  [ -x "$GATE" ] || exit 0
1066
1097
  git rev-parse --git-dir >/dev/null 2>&1 || exit 0
@@ -1414,3 +1445,81 @@ export async function setupHook(targetDir = process.cwd()) {
1414
1445
  console.log(` Hook installed: .claude/hooks/${SHIP_GATE_HOOK_FILENAME}`);
1415
1446
  console.log(` Settings updated: .claude/settings.json`);
1416
1447
  }
1448
+
1449
+ // The project-level permissions.allow written above does not clear auto mode.
1450
+ // The classifier reads autoMode.allow, and only from the user's own
1451
+ // ~/.claude/settings.json — it deliberately ignores a project's settings so a
1452
+ // cloned repo cannot loosen it. So the gate's ack was denied, and the remedy the
1453
+ // deny message named could not be applied by the agent either: the classifier
1454
+ // refuses an agent editing permission settings by any route. That left a
1455
+ // deadlock nothing in the session could break. The installer can, because npx
1456
+ // runs as the user, not as an agent — but only ever behind an explicit prompt,
1457
+ // since this is the user's global file.
1458
+ export const AUTO_MODE_RULE =
1459
+ "Touching marker files under /tmp/claude-skill-gate-*, /tmp/claude-skill-acked-* " +
1460
+ "and /tmp/claude-skill-loaded-* is allowed: they are acknowledgement files for the " +
1461
+ "user's own PreToolUse skill gates. Creating one satisfies a workflow gate the user " +
1462
+ "installed, grants no permission and executes no code, and is a false positive for " +
1463
+ "Auto-Mode Bypass.";
1464
+
1465
+ // Any entry naming a marker path is ours, whatever wording it shipped with. An
1466
+ // upgrade must correct that entry rather than add a second one beside it —
1467
+ // a fresh-install test would never see the difference.
1468
+ const AUTO_MODE_RULE_MARK = "/tmp/claude-skill-acked-";
1469
+
1470
+ function globalSettingsPath(homeDir) {
1471
+ return join(homeDir ?? homedir(), ".claude", "settings.json");
1472
+ }
1473
+
1474
+ async function readGlobalSettings(homeDir) {
1475
+ try {
1476
+ return JSON.parse(await readFile(globalSettingsPath(homeDir), "utf-8"));
1477
+ } catch {
1478
+ return null;
1479
+ }
1480
+ }
1481
+
1482
+ // "current" — the rule is present and matches. "stale" — an older wording is
1483
+ // there. "missing" — nothing of ours. "unreadable" — the file exists but does
1484
+ // not parse, so we must not rewrite it.
1485
+ export async function autoModeRuleStatus(homeDir) {
1486
+ let raw;
1487
+ try {
1488
+ raw = await readFile(globalSettingsPath(homeDir), "utf-8");
1489
+ } catch {
1490
+ return "missing";
1491
+ }
1492
+ let settings;
1493
+ try {
1494
+ settings = JSON.parse(raw);
1495
+ } catch {
1496
+ return "unreadable";
1497
+ }
1498
+ const allow = settings?.autoMode?.allow;
1499
+ if (!Array.isArray(allow)) return "missing";
1500
+ if (allow.includes(AUTO_MODE_RULE)) return "current";
1501
+ if (allow.some((r) => typeof r === "string" && r.includes(AUTO_MODE_RULE_MARK))) return "stale";
1502
+ return "missing";
1503
+ }
1504
+
1505
+ // Writes the rule into ~/.claude/settings.json, keeping "$defaults" first —
1506
+ // dropping it discards every built-in allow. Everything else in the file is
1507
+ // preserved. Refuses an unparseable file rather than replacing it.
1508
+ export async function writeAutoModeRule(homeDir) {
1509
+ if ((await autoModeRuleStatus(homeDir)) === "unreadable") {
1510
+ throw new Error(`${globalSettingsPath(homeDir)} is not valid JSON — fix it, then re-run.`);
1511
+ }
1512
+ const settings = (await readGlobalSettings(homeDir)) ?? {};
1513
+ if (!settings.autoMode || typeof settings.autoMode !== "object") settings.autoMode = {};
1514
+ const existing = Array.isArray(settings.autoMode.allow) ? settings.autoMode.allow : [];
1515
+
1516
+ const kept = existing.filter(
1517
+ (r) => r !== "$defaults" && !(typeof r === "string" && r.includes(AUTO_MODE_RULE_MARK)),
1518
+ );
1519
+ settings.autoMode.allow = ["$defaults", ...kept, AUTO_MODE_RULE];
1520
+
1521
+ const path = globalSettingsPath(homeDir);
1522
+ await mkdir(dirname(path), { recursive: true });
1523
+ await writeFile(path, JSON.stringify(settings, null, 2) + "\n", { mode: 0o600 });
1524
+ return path;
1525
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spardutti/claude-skills",
3
- "version": "2.22.0",
3
+ "version": "2.23.0",
4
4
  "description": "CLI to install Claude Code skills from the claude-skills collection",
5
5
  "type": "module",
6
6
  "repository": {