Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ClaudeSkills.test.ts

1,227 lines47.5 KB

1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { assert, it } from "@effect/vitest";
3import * as Effect from "effect/Effect";
4import * as FileSystem from "effect/FileSystem";
5import * as Path from "effect/Path";
6import * as HostProcess from "@t3tools/shared/HostProcess";
7​
8import { discoverClaudeSkills as discoverSkills } from "./ClaudeSkills.ts";
9import { planClaudeSkillDispatch } from "./ClaudeSkillDispatch.ts";
10​
11// Windows makes the managed directory fixture-controlled without reading host policy or skills.
12const discoverClaudeSkills = (
13 ...[config, cwd, environment = {}]: Parameters<typeof discoverSkills>
14) =>
15 discoverSkills(config, cwd, environment).pipe(
16 Effect.provideService(HostProcess.Platform, "win32"),
17 );
18​
19const writeSkill = Effect.fn(function* (
20 skillsDir: string,
21 directoryName: string,
22 contents: string,
23) {
24 const fs = yield* FileSystem.FileSystem;
25 const path = yield* Path.Path;
26 const skillDir = path.join(skillsDir, directoryName);
27 yield* fs.makeDirectory(skillDir, { recursive: true });
28 yield* fs.writeFileString(path.join(skillDir, "SKILL.md"), contents);
29});
30​
31it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {
32 it.effect("discovers enabled plugin skills with manifest names and ignores skill overrides", () =>
33 Effect.gen(function* () {
34 const fs = yield* FileSystem.FileSystem;
35 const path = yield* Path.Path;
36 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
37 const configDir = path.join(tempDir, "claude-home");
38 const plugin = path.join(configDir, "plugins", "cache", "shop", "plugin", "1.0.0");
39 const disabled = path.join(configDir, "plugins", "disabled");
40 yield* writeSkill(path.join(disabled, "skills"), "hidden", "# Hidden");
41 yield* writeSkill(path.join(plugin, "skills"), "plain", "# Plain");
42 yield* writeSkill(
43 path.join(plugin, "engineering"),
44 "review",
45 "---\nname: review-alias\ndescription: Review changes.\ndisable-model-invocation: true\nuser-invocable: false\n---\n",
46 );
47 yield* fs.makeDirectory(path.join(plugin, ".claude-plugin"), { recursive: true });
48 yield* fs.writeFileString(
49 path.join(plugin, ".claude-plugin", "plugin.json"),
50 '{"name":"manifest-plugin","skills":["./engineering/review"]}',
51 );
52 yield* fs.writeFileString(
53 path.join(configDir, "plugins", "installed_plugins.json"),
54 JSON.stringify({
55 plugins: {
56 "plugin@shop": [{ scope: "user", installPath: plugin }],
57 "disabled@shop": [{ scope: "user", installPath: disabled }],
58 "unconfigured@shop": [{ scope: "user", installPath: disabled }],
59 },
60 }),
61 );
62 yield* fs.writeFileString(
63 path.join(configDir, "settings.json"),
64 '{"enabledPlugins":{"plugin@shop":true,"disabled@shop":false,"uninstalled@shop":true,"other@shop":["^1.0.0"]},"skillOverrides":{"manifest-plugin:plain":"off"}}',
65 );
66​
67 const skills = yield* discoverClaudeSkills({ homePath: configDir });
68 assert.deepEqual(skills, [
69 {
70 name: "manifest-plugin:plain",
71 path: path.join(plugin, "skills", "plain", "SKILL.md"),
72 enabled: true,
73 scope: "user",
74 },
75 {
76 name: "manifest-plugin:review-alias",
77 path: path.join(plugin, "engineering", "review", "SKILL.md"),
78 enabled: true,
79 scope: "user",
80 description: "Review changes.",
81 userInvocationOnly: true,
82 userInvocable: false,
83 },
84 ]);
85 }),
86 );
87​
88 it.effect("merges plugin enablement and selects installs in native registry order", () =>
89 Effect.gen(function* () {
90 const fs = yield* FileSystem.FileSystem;
91 const path = yield* Path.Path;
92 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
93 const configDir = path.join(tempDir, "claude-home");
94 const workspace = path.join(tempDir, "workspace");
95 const nestedWorkspace = path.join(workspace, "packages", "app");
96 const aliasedWorkspace = path.join(tempDir, "aliased-workspace");
97 const userInstall = path.join(configDir, "plugins", "user");
98 const projectInstall = path.join(configDir, "plugins", "project");
99 const localInstall = path.join(configDir, "plugins", "local");
100 const managedInstall = path.join(configDir, "plugins", "managed");
101 yield* fs.makeDirectory(path.join(workspace, ".git"), { recursive: true });
102 yield* fs.makeDirectory(nestedWorkspace, { recursive: true });
103 yield* fs.symlink(workspace, aliasedWorkspace);
104 for (const install of [userInstall, projectInstall, localInstall, managedInstall]) {
105 yield* writeSkill(path.join(install, "skills"), "review", "# Review");
106 }
107 yield* fs.writeFileString(
108 path.join(configDir, "plugins", "installed_plugins.json"),
109 JSON.stringify({
110 plugins: {
111 "plugin@shop": [
112 { scope: "project", projectPath: aliasedWorkspace, installPath: localInstall },
113 { scope: "project", projectPath: workspace, installPath: projectInstall },
114 { scope: "user", installPath: userInstall },
115 { scope: "managed", installPath: managedInstall },
116 ],
117 "local@shop": [
118 { scope: "local", projectPath: workspace, installPath: localInstall },
119 { scope: "project", projectPath: workspace, installPath: projectInstall },
120 { scope: "managed", installPath: path.join(configDir, "plugins", "missing") },
121 { scope: "managed", installPath: managedInstall },
122 { scope: "user", installPath: userInstall },
123 ],
124 },
125 }),
126 );
127 yield* fs.writeFileString(
128 path.join(configDir, "settings.json"),
129 '{"enabledPlugins":{"plugin@shop":true,"local@shop":false}}',
130 );
131 yield* fs.makeDirectory(path.join(workspace, ".claude"), { recursive: true });
132 yield* fs.writeFileString(
133 path.join(workspace, ".claude", "settings.json"),
134 '{"enabledPlugins":{"plugin@shop":false,"local@shop":true,"other@shop":["^1.0.0"]}}',
135 );
136 const projectSettings = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
137 assert.deepEqual(
138 projectSettings.map((skill) => [skill.name, skill.scope, skill.path]),
139 [["local:review", "project", path.join(localInstall, "skills", "review", "SKILL.md")]],
140 );
141 assert.deepEqual(
142 (yield* discoverClaudeSkills({ homePath: configDir }, nestedWorkspace)).map((skill) => [
143 skill.name,
144 skill.scope,
145 skill.path,
146 ]),
147 [["plugin:review", "project", path.join(projectInstall, "skills", "review", "SKILL.md")]],
148 );
149 yield* fs.writeFileString(
150 path.join(workspace, ".claude", "settings.local.json"),
151 '{"enabledPlugins":{"plugin@shop":true,"local@shop":false},"skillOverrides":{"invalid":"bogus"}}',
152 );
153 assert.deepEqual(
154 yield* discoverClaudeSkills({ homePath: configDir }, workspace),
155 projectSettings,
156 );
157 yield* fs.writeFileString(
158 path.join(workspace, ".claude", "settings.local.json"),
159 '{"enabledPlugins":{"plugin@shop":true,"local@shop":true}}',
160 );
161 const localSettings = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
162 assert.deepEqual(
163 localSettings.map((skill) => [skill.name, skill.scope, skill.path]),
164 [
165 ["local:review", "project", path.join(localInstall, "skills", "review", "SKILL.md")],
166 ["plugin:review", "project", path.join(projectInstall, "skills", "review", "SKILL.md")],
167 ],
168 );
169 assert.deepEqual(
170 yield* discoverClaudeSkills({ homePath: configDir }, nestedWorkspace),
171 localSettings,
172 );
173 assert.deepEqual(
174 yield* discoverClaudeSkills({ homePath: configDir }, aliasedWorkspace),
175 localSettings,
176 );
177 yield* fs.writeFileString(
178 path.join(workspace, ".claude", "settings.local.json"),
179 '{"enabledPlugins":{"local@shop":["^1.0.0"]}}',
180 );
181 assert.deepEqual(yield* discoverClaudeSkills({ homePath: configDir }, workspace), []);
182 yield* fs.writeFileString(
183 path.join(configDir, "settings.json"),
184 '{"enabledPlugins":{"plugin@shop":true,"local@shop":true}}',
185 );
186 const separateRepository = path.join(workspace, "separate");
187 yield* fs.makeDirectory(path.join(separateRepository, ".git"), { recursive: true });
188 for (const cwd of [undefined, path.join(tempDir, "elsewhere"), separateRepository]) {
189 const elsewhere = yield* discoverClaudeSkills({ homePath: configDir }, cwd);
190 assert.deepEqual(
191 elsewhere.map((skill) => [skill.name, skill.scope, skill.path]),
192 [
193 ["local:review", "user", path.join(managedInstall, "skills", "review", "SKILL.md")],
194 ["plugin:review", "user", path.join(userInstall, "skills", "review", "SKILL.md")],
195 ],
196 );
197 }
198 const worktree = path.join(tempDir, "worktree");
199 const worktreeGitDirectory = path.join(workspace, ".git", "worktrees", "fixture");
200 yield* fs.makeDirectory(worktree);
201 yield* fs.makeDirectory(worktreeGitDirectory, { recursive: true });
202 yield* fs.writeFileString(path.join(worktree, ".git"), `gitdir: ${worktreeGitDirectory}\n`);
203 yield* fs.writeFileString(path.join(worktreeGitDirectory, "commondir"), "../..\n");
204 yield* fs.writeFileString(
205 path.join(worktreeGitDirectory, "gitdir"),
206 path.join(worktree, ".git"),
207 );
208 assert.deepEqual(
209 yield* discoverClaudeSkills({ homePath: configDir }, worktree),
210 localSettings,
211 );
212 const linkedWorktree = path.join(tempDir, "linked-worktree");
213 yield* fs.symlink(worktree, linkedWorktree);
214 assert.deepEqual(
215 yield* discoverClaudeSkills({ homePath: configDir }, linkedWorktree),
216 localSettings,
217 );
218 }),
219 );
220​
221 it.effect("resolves each install record's project repository once per discovery", () =>
222 Effect.gen(function* () {
223 const fs = yield* FileSystem.FileSystem;
224 const path = yield* Path.Path;
225 // Real path: macOS temp dirs sit behind a /var -> /private/var symlink.
226 const tempDir = yield* fs.realPath(
227 yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" }),
228 );
229 const configDir = path.join(tempDir, "claude-home");
230 const workspace = path.join(tempDir, "workspace");
231 const otherProject = path.join(tempDir, "other", "packages", "app");
232 const sameRepoProject = path.join(workspace, "packages", "app");
233 yield* fs.makeDirectory(path.join(workspace, ".git"), { recursive: true });
234 yield* fs.makeDirectory(path.join(tempDir, "other", ".git"), { recursive: true });
235 yield* fs.makeDirectory(otherProject, { recursive: true });
236 yield* fs.makeDirectory(sameRepoProject, { recursive: true });
237 const elsewhereInstall = path.join(configDir, "plugins", "elsewhere");
238 const sameRepoInstall = path.join(configDir, "plugins", "same-repo");
239 yield* writeSkill(path.join(elsewhereInstall, "skills"), "elsewhere", "# Elsewhere");
240 yield* writeSkill(path.join(sameRepoInstall, "skills"), "same-repo", "# Same repo");
241 const records = Array.from({ length: 4 }, () => ({
242 scope: "project",
243 projectPath: otherProject,
244 installPath: elsewhereInstall,
245 }));
246 const plugins = ["a@shop", "b@shop", "c@shop"];
247 yield* fs.writeFileString(
248 path.join(configDir, "plugins", "installed_plugins.json"),
249 JSON.stringify({
250 plugins: {
251 ...Object.fromEntries(plugins.map((key) => [key, records])),
252 "d@shop": [
253 { scope: "project", projectPath: sameRepoProject, installPath: sameRepoInstall },
254 ],
255 },
256 }),
257 );
258 yield* fs.writeFileString(
259 path.join(configDir, "settings.json"),
260 JSON.stringify({
261 enabledPlugins: Object.fromEntries([...plugins, "d@shop"].map((key) => [key, true])),
262 }),
263 );
264​
265 const probed: Array<string> = [];
266 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace).pipe(
267 Effect.provideService(FileSystem.FileSystem, {
268 ...fs,
269 exists: (target) => {
270 probed.push(target);
271 return fs.exists(target);
272 },
273 }),
274 );
275 assert.strictEqual(
276 probed.filter((target) => target === path.join(otherProject, ".git")).length,
277 1,
278 );
279 assert.deepEqual(
280 skills.map((skill) => skill.name),
281 ["d:same-repo"],
282 );
283 }),
284 );
285​
286 it.effect("publishes and dispatches canonical plugin folder names regardless of aliases", () =>
287 Effect.gen(function* () {
288 const fs = yield* FileSystem.FileSystem;
289 const path = yield* Path.Path;
290 const configDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
291 const plugin = path.join(configDir, "plugins", "installed");
292 yield* writeSkill(path.join(plugin, "skills"), "review", "---\nname: review-alias\n---\n");
293 yield* writeSkill(path.join(plugin, "skills"), "alias", "---\nname: dot.alias\n---\n");
294 yield* fs.writeFileString(
295 path.join(configDir, "plugins", "installed_plugins.json"),
296 JSON.stringify({ plugins: { "plugin@shop": [{ scope: "user", installPath: plugin }] } }),
297 );
298 yield* fs.writeFileString(
299 path.join(configDir, "settings.json"),
300 '{"enabledPlugins":{"plugin@shop":true}}',
301 );
302​
303 const skills = yield* discoverClaudeSkills({ homePath: configDir });
304 assert.deepEqual(
305 planClaudeSkillDispatch(
306 "$plugin:alias focus on auth",
307 new Map(skills.map((skill) => [skill.name, skill])),
308 ),
309 {
310 leadingText: undefined,
311 commandText: "/plugin:alias focus on auth",
312 },
313 );
314 assert.deepEqual(
315 skills.map((skill) => skill.name),
316 ["plugin:alias", "plugin:review"],
317 );
318 }),
319 );
320​
321 it.effect("uses the native cache root, root-skill fallback and manifest path boundaries", () =>
322 Effect.gen(function* () {
323 const fs = yield* FileSystem.FileSystem;
324 const path = yield* Path.Path;
325 const workspace = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
326 const configDir = path.join(workspace, "config");
327 const pluginsDir = path.join(workspace, "plugin-cache");
328 const plugin = path.join(pluginsDir, "installed");
329 const outside = path.join(workspace, "outside");
330 yield* writeSkill(pluginsDir, "installed", "---\nname: plugin:root.alias\n---\n");
331 yield* fs.makeDirectory(configDir);
332 yield* fs.writeFileString(
333 path.join(configDir, "settings.json"),
334 '{"enabledPlugins":{"plugin@shop":true}}',
335 );
336 yield* fs.writeFileString(
337 path.join(pluginsDir, "installed_plugins.json"),
338 JSON.stringify({ plugins: { "plugin@shop": [{ scope: "user", installPath: plugin }] } }),
339 );
340 const environment = { CLAUDE_CODE_PLUGIN_CACHE_DIR: "plugin-cache" };
341 assert.deepEqual(
342 (yield* discoverClaudeSkills({ homePath: configDir }, workspace, environment)).map(
343 (skill) => skill.name,
344 ),
345 ["plugin:root-alias"],
346 );
347​
348 yield* writeSkill(path.join(plugin, "skills"), "plain", "# Plain");
349 yield* writeSkill(plugin, "custom", "---\nname: custom.review\n---\n");
350 yield* writeSkill(outside, "escaped", "# Outside");
351 yield* fs.symlink(outside, path.join(plugin, "escape"));
352 yield* fs.makeDirectory(path.join(plugin, ".claude-plugin"));
353 yield* fs.writeFileString(
354 path.join(plugin, ".claude-plugin", "plugin.json"),
355 '{"skills":["./custom","./escape","../../outside"]}',
356 );
357 assert.deepEqual(
358 (yield* discoverClaudeSkills({ homePath: configDir }, workspace, environment)).map(
359 (skill) => skill.name,
360 ),
361 ["plugin:custom-review", "plugin:plain"],
362 );
363 }),
364 );
365​
366 it.effect("discovers skills from the current account's claude.ai synced plugins", () =>
367 Effect.gen(function* () {
368 const fs = yield* FileSystem.FileSystem;
369 const path = yield* Path.Path;
370 const configDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
371 const synced = path.join(configDir, "plugins", "synced");
372 const organization = "11111111-2222-4333-8444-555555555555";
373 const writeBucket = Effect.fn(function* (account: string, skillSuffix = "") {
374 const bucket = path.join(synced, `${organization}_${account}`);
375 const plugins = [
376 {
377 pluginId: "plugin_01pstack",
378 name: "pstack",
379 directory: "pstack",
380 skill: "poteto-mode",
381 },
382 {
383 pluginId: "plugin_01design",
384 name: "0f6a7c9e-1111-4222-8333-444444444444",
385 generation: 2,
386 directory: "0f6a7c9e-1111-4222-8333-444444444444~g2",
387 prefix: "design",
388 skill: "design-critique",
389 },
390 ];
391 for (const plugin of plugins) {
392 const pluginDir = path.join(bucket, plugin.directory);
393 yield* writeSkill(path.join(pluginDir, "skills"), plugin.skill + skillSuffix, "# Synced");
394 yield* fs.makeDirectory(path.join(pluginDir, ".claude-plugin"));
395 yield* fs.writeFileString(
396 path.join(pluginDir, ".claude-plugin", "plugin.json"),
397 JSON.stringify({ name: plugin.prefix ?? plugin.name }),
398 );
399 }
400 yield* fs.writeFileString(
401 path.join(bucket, "manifest.json"),
402 JSON.stringify({
403 lastUpdated: 1761990000000,
404 plugins: plugins.map(({ pluginId, name, generation }) => ({
405 pluginId,
406 name,
407 ...(generation ? { generation } : {}),
408 })),
409 }),
410 );
411 yield* fs.writeFileString(path.join(synced, `.bucket-${organization}_${account}`), "");
412 return bucket;
413 });
414 const bucket = yield* writeBucket("66666666-7777-4888-9999-aaaaaaaaaaaa");
415 yield* writeBucket("77777777-8888-4999-aaaa-bbbbbbbbbbbb", "-other-account");
416 yield* fs.writeFileString(
417 path.join(configDir, ".claude.json"),
418 JSON.stringify({
419 oauthAccount: {
420 organizationUuid: organization,
421 accountUuid: "66666666-7777-4888-9999-aaaaaaaaaaaa",
422 },
423 }),
424 );
425​
426 assert.deepEqual(
427 (yield* discoverClaudeSkills({ homePath: configDir }, undefined, {})).map((skill) => [
428 skill.name,
429 skill.path,
430 ]),
431 [
432 [
433 "design:design-critique",
434 path.join(
435 bucket,
436 "0f6a7c9e-1111-4222-8333-444444444444~g2",
437 "skills",
438 "design-critique",
439 "SKILL.md",
440 ),
441 ],
442 ["pstack:poteto-mode", path.join(bucket, "pstack", "skills", "poteto-mode", "SKILL.md")],
443 ],
444 );
445 assert.deepEqual(
446 (yield* discoverClaudeSkills({ homePath: configDir }, undefined, {
447 CLAUDE_CODE_PLUGIN_CACHE_DIR: path.join(configDir, "relocated-cache"),
448 })).map((skill) => skill.name),
449 ["design:design-critique", "pstack:poteto-mode"],
450 );
451 assert.deepEqual(
452 (yield* discoverClaudeSkills({ homePath: configDir }, undefined, {
453 CLAUDE_CODE_OAUTH_TOKEN: "token",
454 CLAUDE_CODE_ACCOUNT_UUID: "77777777-8888-4999-aaaa-bbbbbbbbbbbb",
455 })).map((skill) => skill.name),
456 ["design:design-critique-other-account", "pstack:poteto-mode-other-account"],
457 );
458 yield* fs.writeFileString(
459 path.join(configDir, "settings.json"),
460 '{"enabledPlugins":{"pstack@synced":false}}',
461 );
462 assert.deepEqual(
463 (yield* discoverClaudeSkills({ homePath: configDir }, undefined, {})).map(
464 (skill) => skill.name,
465 ),
466 ["design:design-critique"],
467 );
468 yield* fs.writeFileString(
469 path.join(configDir, "settings.json"),
470 '{"syncClaudeAiPlugins":false}',
471 );
472 assert.deepEqual(yield* discoverClaudeSkills({ homePath: configDir }, undefined, {}), []);
473 }),
474 );
475​
476 it.effect("gives a synced namespace to an installed plugin, then the first synced row", () =>
477 Effect.gen(function* () {
478 const fs = yield* FileSystem.FileSystem;
479 const path = yield* Path.Path;
480 const configDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
481 const bucketName = "11111111-2222-4333-8444-555555555555_unbound";
482 const synced = path.join(configDir, "plugins", "synced");
483 const bucket = path.join(synced, bucketName);
484 for (const [directory, prefix, skill] of [
485 ["pstack", "pstack", "poteto-mode"],
486 ["pstack-copy", "pstack", "copied"],
487 ["tools", "tools", "synced-tool"],
488 ["a_b", undefined, "renamed"],
489 ["PSTACK", "PSTACK", "shouted"],
490 ] as const) {
491 yield* writeSkill(path.join(bucket, directory, "skills"), skill, "# Synced");
492 if (prefix === undefined) continue;
493 yield* fs.makeDirectory(path.join(bucket, directory, ".claude-plugin"));
494 yield* fs.writeFileString(
495 path.join(bucket, directory, ".claude-plugin", "plugin.json"),
496 JSON.stringify({ name: prefix }),
497 );
498 }
499 yield* fs.writeFileString(
500 path.join(bucket, "manifest.json"),
501 JSON.stringify({
502 plugins: ["pstack", "pstack-copy", "tools", "a:b. ", "PSTACK", "no-id"].map(
503 (name, index) => (name === "no-id" ? { name } : { pluginId: `plugin_0${index}`, name }),
504 ),
505 }),
506 );
507 yield* fs.writeFileString(path.join(synced, `.bucket-${bucketName}`), "");
508 const installed = path.join(configDir, "plugins", "cache", "shop", "tools");
509 yield* writeSkill(path.join(installed, "skills"), "installed-tool", "# Installed");
510 yield* fs.writeFileString(
511 path.join(configDir, "plugins", "installed_plugins.json"),
512 JSON.stringify({
513 plugins: {
514 "tools@shop": [{ scope: "user", installPath: installed }],
515 "pstack@shop": [{ scope: "user", installPath: path.join(configDir, "missing") }],
516 },
517 }),
518 );
519 const names = (enabled: boolean) =>
520 Effect.gen(function* () {
521 yield* fs.writeFileString(
522 path.join(configDir, "settings.json"),
523 JSON.stringify({ enabledPlugins: { "tools@shop": enabled, "pstack@shop": true } }),
524 );
525 const skills = yield* discoverClaudeSkills({ homePath: configDir }, undefined, {
526 CLAUDE_CODE_ORGANIZATION_UUID: "11111111-2222-4333-8444-555555555555",
527 CLAUDE_CODE_ACCOUNT_UUID: "not-a-uuid",
528 });
529 return skills.map((skill) => skill.name);
530 });
531​
532 assert.deepEqual(yield* names(true), [
533 "a_b:renamed",
534 "pstack:poteto-mode",
535 "tools:installed-tool",
536 ]);
537 assert.deepEqual(yield* names(false), [
538 "a_b:renamed",
539 "pstack:poteto-mode",
540 "tools:synced-tool",
541 ]);
542 yield* writeSkill(path.join(bucket, "no-id", "skills"), "unlisted", "# Synced");
543 assert.notInclude(
544 (yield* discoverClaudeSkills({ homePath: configDir }, undefined, {
545 CLAUDE_CODE_ORGANIZATION_UUID: "11111111-2222-4333-8444-555555555555",
546 })).map((skill) => skill.name),
547 "no-id:unlisted",
548 );
549 }),
550 );
551​
552 it.effect("hides synced plugins from local settings but not shared project settings", () =>
553 Effect.gen(function* () {
554 const fs = yield* FileSystem.FileSystem;
555 const path = yield* Path.Path;
556 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
557 const configDir = path.join(tempDir, "claude-home");
558 const workspace = path.join(tempDir, "workspace");
559 const bucketName =
560 "11111111-2222-4333-8444-555555555555_66666666-7777-4888-9999-aaaaaaaaaaaa";
561 const synced = path.join(configDir, "plugins", "synced");
562 yield* writeSkill(path.join(synced, bucketName, "pstack", "skills"), "poteto-mode", "# S");
563 yield* fs.writeFileString(
564 path.join(synced, bucketName, "manifest.json"),
565 '{"plugins":[{"pluginId":"plugin_01pstack","name":"pstack"}]}',
566 );
567 yield* fs.writeFileString(path.join(synced, `.bucket-${bucketName}`), "");
568 yield* fs.makeDirectory(path.join(workspace, ".claude"), { recursive: true });
569 yield* fs.writeFileString(
570 path.join(workspace, ".claude", "settings.json"),
571 '{"syncClaudeAiPlugins":false}',
572 );
573 const environment = {
574 CLAUDE_CODE_ORGANIZATION_UUID: "11111111-2222-4333-8444-555555555555",
575 CLAUDE_CODE_ACCOUNT_UUID: "66666666-7777-4888-9999-AAAAAAAAAAAA",
576 };
577 const names = Effect.map(
578 discoverClaudeSkills({ homePath: configDir }, workspace, environment),
579 (skills) => skills.map((skill) => skill.name),
580 );
581 assert.deepEqual(yield* names, ["pstack:poteto-mode"]);
582 yield* fs.writeFileString(
583 path.join(workspace, ".claude", "settings.local.json"),
584 '{"syncClaudeAiPlugins":false}',
585 );
586 assert.deepEqual(yield* names, []);
587 }),
588 );
589​
590 it.effect("discovers user and project skills with frontmatter metadata", () =>
591 Effect.gen(function* () {
592 const fs = yield* FileSystem.FileSystem;
593 const path = yield* Path.Path;
594 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
595 const configDir = path.join(tempDir, "claude-home");
596 const workspace = path.join(tempDir, "workspace");
597​
598 yield* writeSkill(
599 path.join(configDir, "skills"),
600 "codex-review",
601 [
602 "---",
603 "name: codex-review",
604 "description: Ask Codex for a review.",
605 "---",
606 "",
607 "# Body",
608 ].join("\n"),
609 );
610 yield* writeSkill(
611 path.join(workspace, ".claude", "skills"),
612 "deploy",
613 ["---", "name: deploy", "description: Deploy the app.", "---", "", "# Deploy"].join("\n"),
614 );
615​
616 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
617​
618 assert.deepEqual(skills, [
619 {
620 name: "codex-review",
621 path: path.join(configDir, "skills", "codex-review", "SKILL.md"),
622 enabled: true,
623 scope: "user",
624 description: "Ask Codex for a review.",
625 },
626 {
627 name: "deploy",
628 path: path.join(workspace, ".claude", "skills", "deploy", "SKILL.md"),
629 enabled: true,
630 scope: "project",
631 description: "Deploy the app.",
632 },
633 ]);
634 }),
635 );
636​
637 it.effect("discovers skills from the instance's --add-dir launch args", () =>
638 Effect.gen(function* () {
639 const fs = yield* FileSystem.FileSystem;
640 const path = yield* Path.Path;
641 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
642 const configDir = path.join(tempDir, "claude-home");
643 const workspace = path.join(tempDir, "workspace");
644 const extraDir = path.join(workspace, "extra skills");
645 yield* fs.makeDirectory(workspace, { recursive: true });
646 yield* writeSkill(
647 path.join(extraDir, ".claude", "skills"),
648 "demo",
649 ["---", "description: From an additional directory.", "---"].join("\n"),
650 );
651​
652 assert.deepEqual(yield* discoverClaudeSkills({ homePath: configDir }, workspace), []);
653 for (const launchArgs of [
654 `--add-dir "${extraDir}"`,
655 `--add-dir="${extraDir}"`,
656 '--add-dir "extra skills"',
657 '--add-dir="extra skills"',
658 `--add-dir missing --add-dir "${extraDir}"`,
659 `--add-dir "${extraDir}" --add-dir missing`,
660 `--add-dir missing "${extraDir}"`,
661 ]) {
662 const settings = { homePath: configDir, launchArgs };
663 const skills = yield* discoverClaudeSkills(settings, workspace);
664 assert.deepEqual(skills, [
665 {
666 name: "demo",
667 path: path.join(extraDir, ".claude", "skills", "demo", "SKILL.md"),
668 enabled: true,
669 scope: "project",
670 description: "From an additional directory.",
671 },
672 ]);
673 }
674 const settings = { homePath: configDir, launchArgs: `--add-dir "${extraDir}"` };
675 const skills = yield* discoverClaudeSkills(settings, workspace);
676 assert.deepEqual(
677 planClaudeSkillDispatch(
678 "$demo",
679 new Map(skills.map((skill) => [skill.name, { path: skill.path }])),
680 ),
681 {
682 leadingText: undefined,
683 commandText: "/demo",
684 },
685 );
686 yield* writeSkill(
687 path.join(workspace, ".claude", "skills"),
688 "demo",
689 "---\ndescription: Project copy.\n---",
690 );
691 const projectSkills = yield* discoverClaudeSkills(settings, workspace);
692 assert.equal(projectSkills[0]?.description, "Project copy.");
693 for (const launchArgs of ["--add-dir", '--add-dir=""', '--add-dir "extra skills"']) {
694 const settings = { homePath: configDir, launchArgs };
695 assert.deepEqual(yield* discoverClaudeSkills(settings), []);
696 }
697 }),
698 );
699​
700 it.effect("prefers managed then user skills on collisions, even with a stray .agents copy", () =>
701 Effect.gen(function* () {
702 const fs = yield* FileSystem.FileSystem;
703 const path = yield* Path.Path;
704 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
705 const configDir = path.join(tempDir, "claude-home");
706 const workspace = path.join(tempDir, "workspace");
707​
708 yield* writeSkill(
709 path.join(configDir, "skills"),
710 "deploy",
711 ["---", "name: deploy", "description: User deploy.", "---"].join("\n"),
712 );
713 yield* writeSkill(
714 path.join(workspace, ".agents", "skills"),
715 "deploy",
716 ["---", "name: deploy", "description: Agents deploy.", "---"].join("\n"),
717 );
718 yield* writeSkill(
719 path.join(workspace, ".claude", "skills"),
720 "deploy",
721 ["---", "name: deploy", "description: Claude deploy.", "---"].join("\n"),
722 );
723​
724 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
725​
726 assert.deepEqual(skills, [
727 {
728 name: "deploy",
729 path: path.join(configDir, "skills", "deploy", "SKILL.md"),
730 enabled: true,
731 scope: "user",
732 description: "User deploy.",
733 },
734 ]);
735​
736 const programFiles = path.join(tempDir, "Program Files");
737 const programData = path.join(tempDir, "ProgramData");
738 yield* writeSkill(
739 path.join(programData, "ClaudeCode", ".claude", "skills"),
740 "legacy-only",
741 "# Legacy skills must not be discovered",
742 );
743 yield* fs.writeFileString(
744 path.join(programData, "ClaudeCode", "managed-settings.json"),
745 '{"skillOverrides":{"deploy":"off"}}',
746 );
747 for (const ProgramFiles of [undefined, "", programFiles]) {
748 const legacySkills = yield* discoverClaudeSkills({ homePath: configDir }, workspace, {
749 PROGRAMDATA: programData,
750 ...(ProgramFiles !== undefined ? { ProgramFiles } : {}),
751 });
752 assert.deepEqual(
753 legacySkills,
754 skills.map((skill) => ({ ...skill, enabled: false })),
755 );
756 }
757 yield* writeSkill(
758 path.join(programFiles, "ClaudeCode", ".claude", "skills"),
759 "deploy",
760 ["---", "name: deploy", "description: Managed deploy.", "---"].join("\n"),
761 );
762 yield* fs.writeFileString(
763 path.join(configDir, "settings.json"),
764 '{"skillOverrides":{"deploy":"off"}}',
765 );
766 yield* fs.writeFileString(
767 path.join(programFiles, "ClaudeCode", "managed-settings.json"),
768 '{"skillOverrides":{"deploy":"on"}}',
769 );
770 const managedSkills = yield* discoverClaudeSkills({ homePath: configDir }, workspace, {
771 ProgramFiles: programFiles,
772 PROGRAMDATA: programData,
773 });
774​
775 assert.deepEqual(managedSkills, [
776 {
777 name: "deploy",
778 path: path.join(programFiles, "ClaudeCode", ".claude", "skills", "deploy", "SKILL.md"),
779 enabled: true,
780 scope: "user",
781 description: "Managed deploy.",
782 },
783 ]);
784 assert.deepEqual(
785 yield* discoverClaudeSkills({ homePath: configDir }, workspace, {
786 PROGRAMFILES: ` ${programFiles} `,
787 PROGRAMDATA: programData,
788 }),
789 managedSkills,
790 );
791 }),
792 );
793​
794 it.effect("recovers colon-bearing descriptions with invocation metadata intact", () =>
795 Effect.gen(function* () {
796 const fs = yield* FileSystem.FileSystem;
797 const path = yield* Path.Path;
798 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
799 const configDir = path.join(tempDir, "claude-home");
800​
801 for (const [description, comment] of [
802 ["Browser automation + AI test authoring via kane-cli: run browser objectives, ...", ""],
803 ['Read C:\\skills\\guide#tag: continue with "quoted".', " # trailing: comment"],
804 ] as const) {
805 yield* writeSkill(
806 path.join(configDir, "skills"),
807 "kane-cli",
808 [
809 "---",
810 "name: frontmatter-alias",
811 `description: ${description}${comment}`,
812 "allowed-tools: [Read, Write]",
813 "disable-model-invocation: yes",
814 "user-invocable: no",
815 "---",
816 ].join("\n"),
817 );
818​
819 const skills = yield* discoverClaudeSkills({ homePath: configDir }, undefined);
820​
821 assert.deepEqual(skills, [
822 {
823 name: "kane-cli",
824 path: path.join(configDir, "skills", "kane-cli", "SKILL.md"),
825 enabled: true,
826 scope: "user",
827 description,
828 userInvocationOnly: true,
829 userInvocable: false,
830 },
831 ]);
832 }
833 }),
834 );
835​
836 it.effect("falls back to the directory name and skips malformed frontmatter", () =>
837 Effect.gen(function* () {
838 const fs = yield* FileSystem.FileSystem;
839 const path = yield* Path.Path;
840 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
841 const configDir = path.join(tempDir, "claude-home");
842 const skillsDir = path.join(configDir, "skills");
843​
844 yield* writeSkill(skillsDir, "no-frontmatter", "# Just a heading\n");
845 for (const [directoryName, field] of [
846 ["broken-yaml", "name: [unclosed"],
847 ["broken-tools", "allowed-tools: [Read, Write"],
848 ["broken-quoted", 'name: "unclosed: text'],
849 ] as const) {
850 yield* writeSkill(
851 skillsDir,
852 directoryName,
853 ["---", "description: Run: browser objectives.", field, "---"].join("\n"),
854 );
855 }
856 yield* fs.makeDirectory(skillsDir, { recursive: true });
857 yield* fs.writeFileString(path.join(skillsDir, "README.md"), "not a skill");
858​
859 const skills = yield* discoverClaudeSkills({ homePath: configDir }, undefined);
860​
861 // Claude falls back to directory names without frontmatter, but skips malformed frontmatter.
862 assert.deepEqual(
863 skills.map((skill) => skill.name),
864 ["no-frontmatter"],
865 );
866 assert.equal(skills[0]?.description, undefined);
867 }),
868 );
869​
870 it.effect("honors CLAUDE_CONFIG_DIR from the environment when homePath is unset", () =>
871 Effect.gen(function* () {
872 const fs = yield* FileSystem.FileSystem;
873 const path = yield* Path.Path;
874 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
875 const environmentConfigDir = path.join(tempDir, "env-config");
876​
877 yield* writeSkill(
878 path.join(environmentConfigDir, "skills"),
879 "env-skill",
880 ["---", "name: env-skill", "description: From env config dir.", "---"].join("\n"),
881 );
882​
883 const skills = yield* discoverClaudeSkills({ homePath: "" }, undefined, {
884 CLAUDE_CONFIG_DIR: environmentConfigDir,
885 });
886​
887 assert.deepEqual(
888 skills.map((skill) => skill.name),
889 ["env-skill"],
890 );
891​
892 const explicitHome = path.join(tempDir, "explicit-home");
893 yield* writeSkill(
894 path.join(explicitHome, "skills"),
895 "explicit-skill",
896 ["---", "name: explicit-skill", "---"].join("\n"),
897 );
898 const explicitSkills = yield* discoverClaudeSkills({ homePath: explicitHome }, undefined, {
899 CLAUDE_CONFIG_DIR: environmentConfigDir,
900 });
901 assert.deepEqual(
902 explicitSkills.map((skill) => skill.name),
903 ["explicit-skill"],
904 );
905 }),
906 );
907​
908 it.effect("resolves a relative CLAUDE_CONFIG_DIR against the workspace cwd", () =>
909 Effect.gen(function* () {
910 const fs = yield* FileSystem.FileSystem;
911 const path = yield* Path.Path;
912 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
913 const workspace = path.join(tempDir, "workspace");
914 yield* fs.makeDirectory(workspace, { recursive: true });
915​
916 // The CLI resolves relative CLAUDE_CONFIG_DIR against workspace cwd.
917 yield* writeSkill(
918 path.join(workspace, "relative-config", "skills"),
919 "relative-skill",
920 ["---", "name: relative-skill", "---"].join("\n"),
921 );
922​
923 const skills = yield* discoverClaudeSkills({ homePath: "" }, workspace, {
924 CLAUDE_CONFIG_DIR: "relative-config",
925 });
926​
927 assert.deepEqual(
928 skills.map((skill) => skill.name),
929 ["relative-skill"],
930 );
931 assert.equal(skills[0]?.scope, "user");
932 }),
933 );
934​
935 it.effect("disables skills switched off by skillOverrides", () =>
936 Effect.gen(function* () {
937 const fs = yield* FileSystem.FileSystem;
938 const path = yield* Path.Path;
939 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
940 const configDir = path.join(tempDir, "claude-home");
941 const workspace = path.join(tempDir, "workspace");
942​
943 for (const name of ["kept", "off-by-user", "off-by-project"]) {
944 yield* writeSkill(
945 path.join(configDir, "skills"),
946 name,
947 ["---", `name: ${name}`, "---", "", "# Body"].join("\n"),
948 );
949 }
950​
951 yield* fs.makeDirectory(configDir, { recursive: true });
952 yield* fs.writeFileString(
953 path.join(configDir, "settings.json"),
954 '{ "skillOverrides": { "off-by-user": "off", "kept": "on" } }',
955 );
956 yield* fs.makeDirectory(path.join(workspace, ".claude"), { recursive: true });
957 yield* fs.writeFileString(
958 path.join(workspace, ".claude", "settings.json"),
959 '{ "skillOverrides": { "off-by-project": "off" } }',
960 );
961​
962 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
963​
964 assert.deepEqual(
965 skills.map((skill) => [skill.name, skill.enabled]),
966 [
967 ["kept", true],
968 ["off-by-project", false],
969 ["off-by-user", false],
970 ],
971 );
972 }),
973 );
974​
975 it.effect("ignores unreadable settings when resolving skillOverrides", () =>
976 Effect.gen(function* () {
977 const fs = yield* FileSystem.FileSystem;
978 const path = yield* Path.Path;
979 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
980 const configDir = path.join(tempDir, "claude-home");
981​
982 yield* writeSkill(
983 path.join(configDir, "skills"),
984 "kept",
985 ["---", "name: kept", "---", "", "# Body"].join("\n"),
986 );
987 yield* fs.writeFileString(path.join(configDir, "settings.json"), "{ not json");
988​
989 const skills = yield* discoverClaudeSkills({ homePath: configDir });
990​
991 assert.deepEqual(
992 skills.map((skill) => [skill.name, skill.enabled]),
993 [["kept", true]],
994 );
995 }),
996 );
997​
998 it.effect("treats a user-invocable-only override like disable-model-invocation", () =>
999 Effect.gen(function* () {
1000 const fs = yield* FileSystem.FileSystem;
1001 const path = yield* Path.Path;
1002 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
1003 const configDir = path.join(tempDir, "claude-home");
1004​
1005 yield* writeSkill(
1006 path.join(configDir, "skills"),
1007 "ask-matt",
1008 ["---", "name: ask-matt", "---", "", "# Body"].join("\n"),
1009 );
1010 yield* fs.writeFileString(
1011 path.join(configDir, "settings.json"),
1012 '{ "skillOverrides": { "ask-matt": "user-invocable-only" } }',
1013 );
1014​
1015 const skills = yield* discoverClaudeSkills({ homePath: configDir });
1016​
1017 assert.deepEqual(
1018 skills.map((skill) => [skill.name, skill.enabled, skill.userInvocationOnly === true]),
1019 [["ask-matt", true, true]],
1020 );
1021 }),
1022 );
1023​
1024 it.effect("drops every override in a file when one value is invalid, as Claude Code does", () =>
1025 Effect.gen(function* () {
1026 const fs = yield* FileSystem.FileSystem;
1027 const path = yield* Path.Path;
1028 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
1029 const configDir = path.join(tempDir, "claude-home");
1030​
1031 for (const name of ["unknown-mode", "boolean-false", "sibling-off"]) {
1032 yield* writeSkill(
1033 path.join(configDir, "skills"),
1034 name,
1035 ["---", `name: ${name}`, "---", "", "# Body"].join("\n"),
1036 );
1038 // Claude ignores the entire override map when any value is an unknown string or boolean.
1039 yield* fs.writeFileString(
1040 path.join(configDir, "settings.json"),
1041 '{ "skillOverrides": { "unknown-mode": "some-future-mode", "boolean-false": false, "sibling-off": "off" } }',
1042 );
1043​
1044 const skills = yield* discoverClaudeSkills({ homePath: configDir });
1045​
1046 assert.deepEqual(
1047 skills.map((skill) => [skill.name, skill.enabled]),
1049 ["boolean-false", true],
1050 ["sibling-off", true],
1051 ["unknown-mode", true],
1052 ],
1053 );
1054 }),
1055 );
1056​
1057 it.effect("reads repository root settings from a nested workspace", () =>
1058 Effect.gen(function* () {
1059 const fs = yield* FileSystem.FileSystem;
1060 const path = yield* Path.Path;
1061 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
1062 const configDir = path.join(tempDir, "claude-home");
1063 const repo = path.join(tempDir, "repo");
1064 const workspace = path.join(repo, "packages", "app");
1065​
1066 for (const name of ["root-off", "root-off-cwd-on", "cwd-off-root-on"]) {
1067 yield* writeSkill(
1068 path.join(configDir, "skills"),
1069 name,
1070 ["---", `name: ${name}`, "---", "", "# Body"].join("\n"),
1071 );
1073 yield* fs.makeDirectory(path.join(repo, ".git"), { recursive: true });
1074 yield* fs.makeDirectory(path.join(repo, ".claude"), { recursive: true });
1075 yield* fs.makeDirectory(path.join(workspace, ".claude"), { recursive: true });
1076 // The CLI ignores the root's plain settings.json from a nested cwd.
1077 yield* fs.writeFileString(
1078 path.join(repo, ".claude", "settings.json"),
1079 '{ "skillOverrides": { "cwd-off-root-on": "off" } }',
1080 );
1081 // The root local file outranks the workspace local file, as in the CLI.
1082 yield* fs.writeFileString(
1083 path.join(repo, ".claude", "settings.local.json"),
1084 '{ "skillOverrides": { "root-off": "off", "root-off-cwd-on": "off", "cwd-off-root-on": "on" } }',
1085 );
1086 yield* fs.writeFileString(
1087 path.join(workspace, ".claude", "settings.local.json"),
1088 '{ "skillOverrides": { "root-off-cwd-on": "on", "cwd-off-root-on": "off" } }',
1089 );
1090​
1091 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
1092​
1093 assert.deepEqual(
1094 skills.map((skill) => [skill.name, skill.enabled]),
1096 ["cwd-off-root-on", true],
1097 ["root-off", false],
1098 ["root-off-cwd-on", false],
1099 ],
1100 );
1101 }),
1102 );
1103​
1104 it.effect("ignores ancestor settings outside a repository", () =>
1105 Effect.gen(function* () {
1106 const fs = yield* FileSystem.FileSystem;
1107 const path = yield* Path.Path;
1108 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
1109 const configDir = path.join(tempDir, "claude-home");
1110 const parent = path.join(tempDir, "not-a-repo");
1111 const workspace = path.join(parent, "workspace");
1112​
1113 yield* writeSkill(
1114 path.join(configDir, "skills"),
1115 "kept",
1116 ["---", "name: kept", "---", "", "# Body"].join("\n"),
1117 );
1118 yield* fs.makeDirectory(path.join(parent, ".claude"), { recursive: true });
1119 yield* fs.makeDirectory(workspace, { recursive: true });
1120 yield* fs.writeFileString(
1121 path.join(parent, ".claude", "settings.local.json"),
1122 '{ "skillOverrides": { "kept": "off" } }',
1123 );
1124​
1125 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
1126​
1127 assert.deepEqual(
1128 skills.map((skill) => [skill.name, skill.enabled]),
1129 [["kept", true]],
1130 );
1131 }),
1132 );
1133​
1134 it.effect("identifies a skill by its directory, as Claude Code does", () =>
1135 Effect.gen(function* () {
1136 const fs = yield* FileSystem.FileSystem;
1137 const path = yield* Path.Path;
1138 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
1139 const configDir = path.join(tempDir, "claude-home");
1140​
1141 yield* writeSkill(
1142 path.join(configDir, "skills"),
1143 "probe-alias",
1144 ["---", "name: probe-alias-frontmatter", "---", "", "# Body"].join("\n"),
1145 );
1146 yield* fs.writeFileString(
1147 path.join(configDir, "settings.json"),
1148 '{ "skillOverrides": { "probe-alias-frontmatter": "off" } }',
1149 );
1150​
1151 const skills = yield* discoverClaudeSkills({ homePath: configDir });
1152​
1153 assert.deepEqual(
1154 skills.map((skill) => [skill.name, skill.enabled]),
1155 [["probe-alias", true]],
1156 );
1157 }),
1158 );
1159​
1160 // regression: #9128 skills picked from the composer did not run
1161 it.effect("switches a skill off by its directory name", () =>
1162 Effect.gen(function* () {
1163 const fs = yield* FileSystem.FileSystem;
1164 const path = yield* Path.Path;
1165 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
1166 const configDir = path.join(tempDir, "claude-home");
1167​
1168 yield* writeSkill(
1169 path.join(configDir, "skills"),
1170 "probe-alias",
1171 ["---", "name: probe-alias-frontmatter", "---", "", "# Body"].join("\n"),
1172 );
1173 yield* fs.writeFileString(
1174 path.join(configDir, "settings.json"),
1175 '{ "skillOverrides": { "probe-alias": "off" } }',
1176 );
1177​
1178 const skills = yield* discoverClaudeSkills({ homePath: configDir });
1179​
1180 assert.deepEqual(
1181 skills.map((skill) => [skill.name, skill.enabled]),
1182 [["probe-alias", false]],
1183 );
1184 }),
1185 );
1186​
1187 it.effect("accepts the YAML 1.1 boolean spellings Claude Code allows", () =>
1188 Effect.gen(function* () {
1189 const fs = yield* FileSystem.FileSystem;
1190 const path = yield* Path.Path;
1191 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
1192 const configDir = path.join(tempDir, "claude-home");
1193 const skillsDir = path.join(configDir, "skills");
1194​
1195 yield* writeSkill(
1196 skillsDir,
1197 "user-only-yes",
1198 ["---", "disable-model-invocation: yes", "---", "", "# Body"].join("\n"),
1199 );
1200 yield* writeSkill(
1201 skillsDir,
1202 "agent-only-no",
1203 ["---", "user-invocable: no", "---", "", "# Body"].join("\n"),
1204 );
1205 yield* writeSkill(
1206 skillsDir,
1207 "plain-off",
1208 ["---", "disable-model-invocation: off", "---", "", "# Body"].join("\n"),
1209 );
1210​
1211 const skills = yield* discoverClaudeSkills({ homePath: configDir });
1212​
1213 assert.deepEqual(
1214 skills.map((skill) => [
1215 skill.name,
1216 skill.userInvocationOnly === true,
1217 skill.userInvocable === false,
1218 ]),
1220 ["agent-only-no", false, true],
1221 ["plain-off", false, false],
1222 ["user-only-yes", true, false],
1223 ],
1224 );
1225 }),
1226 );
1227});