Open History to see the last commit
1import * as NodePath from "@effect/platform-node/NodePath";
2import * as NodeServices from "@effect/platform-node/NodeServices";
3import { assert, it } from "@effect/vitest";
4import * as Effect from "effect/Effect";
5import * as FileSystem from "effect/FileSystem";
6import * as Path from "effect/Path";
7
8import { discoverClaudeSkills, skillOverrideSettingsPaths } from "./ClaudeSkills.ts";
9
10const writeSkill = Effect.fn(function* (
11 skillsDir: string,
12 directoryName: string,
13 contents: string,
14) {
15 const fs = yield* FileSystem.FileSystem;
16 const path = yield* Path.Path;
17 const skillDir = path.join(skillsDir, directoryName);
18 yield* fs.makeDirectory(skillDir, { recursive: true });
19 yield* fs.writeFileString(path.join(skillDir, "SKILL.md"), contents);
20});
21
22it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {
23 it.effect("discovers user and project skills with frontmatter metadata", () =>
24 Effect.gen(function* () {
25 const fs = yield* FileSystem.FileSystem;
26 const path = yield* Path.Path;
27 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
28 const configDir = path.join(tempDir, "claude-home");
29 const workspace = path.join(tempDir, "workspace");
30
31 yield* writeSkill(
32 path.join(configDir, "skills"),
33 "codex-review",
34 [
35 "---",
36 "name: codex-review",
37 "description: Ask Codex for a review.",
38 "---",
39 "",
40 "# Body",
41 ].join("\n"),
42 );
43 yield* writeSkill(
44 path.join(workspace, ".claude", "skills"),
45 "deploy",
46 ["---", "name: deploy", "description: Deploy the app.", "---", "", "# Deploy"].join("\n"),
47 );
48
49 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
50
51 assert.deepEqual(skills, [
52 {
53 name: "codex-review",
54 path: path.join(configDir, "skills", "codex-review", "SKILL.md"),
55 enabled: true,
56 scope: "user",
57 description: "Ask Codex for a review.",
58 },
59 {
60 name: "deploy",
61 path: path.join(workspace, ".claude", "skills", "deploy", "SKILL.md"),
62 enabled: true,
63 scope: "project",
64 description: "Deploy the app.",
65 },
66 ]);
67 }),
68 );
69
70 it.effect("ignores .agents/skills, which Claude Code does not load", () =>
71 Effect.gen(function* () {
72 const fs = yield* FileSystem.FileSystem;
73 const path = yield* Path.Path;
74 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
75 const configDir = path.join(tempDir, "claude-home");
76 const workspace = path.join(tempDir, "workspace");
77
78 // Verified against the CLI: `/review` here is answered with
79 // `Unknown command`, so offering it would dispatch a dead command.
80 yield* writeSkill(
81 path.join(workspace, ".agents", "skills"),
82 "review",
83 ["---", "name: review", "description: Review the changes.", "---"].join("\n"),
84 );
85
86 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
87
88 assert.deepEqual(skills, []);
89 }),
90 );
91
92 it.effect("prefers user skills on name collisions even with a stray .agents copy", () =>
93 Effect.gen(function* () {
94 const fs = yield* FileSystem.FileSystem;
95 const path = yield* Path.Path;
96 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
97 const configDir = path.join(tempDir, "claude-home");
98 const workspace = path.join(tempDir, "workspace");
99
100 yield* writeSkill(
101 path.join(configDir, "skills"),
102 "deploy",
103 ["---", "name: deploy", "description: User deploy.", "---"].join("\n"),
104 );
105 yield* writeSkill(
106 path.join(workspace, ".agents", "skills"),
107 "deploy",
108 ["---", "name: deploy", "description: Agents deploy.", "---"].join("\n"),
109 );
110 yield* writeSkill(
111 path.join(workspace, ".claude", "skills"),
112 "deploy",
113 ["---", "name: deploy", "description: Claude deploy.", "---"].join("\n"),
114 );
115
116 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
117
118 assert.deepEqual(skills, [
119 {
120 name: "deploy",
121 path: path.join(configDir, "skills", "deploy", "SKILL.md"),
122 enabled: true,
123 scope: "user",
124 description: "User deploy.",
125 },
126 ]);
127 }),
128 );
129
130 it.effect("prefers user skills over project skills on name collisions", () =>
131 Effect.gen(function* () {
132 const fs = yield* FileSystem.FileSystem;
133 const path = yield* Path.Path;
134 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
135 const configDir = path.join(tempDir, "claude-home");
136 const workspace = path.join(tempDir, "workspace");
137
138 yield* writeSkill(
139 path.join(configDir, "skills"),
140 "deploy",
141 ["---", "name: deploy", "description: User deploy.", "---"].join("\n"),
142 );
143 yield* writeSkill(
144 path.join(workspace, ".claude", "skills"),
145 "deploy",
146 ["---", "name: deploy", "description: Project deploy.", "---"].join("\n"),
147 );
148
149 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
150
151 assert.equal(skills.length, 1);
152 assert.equal(skills[0]?.scope, "user");
153 assert.equal(skills[0]?.description, "User deploy.");
154 }),
155 );
156
157 it.effect("recovers colon-bearing descriptions with invocation metadata intact", () =>
158 Effect.gen(function* () {
159 const fs = yield* FileSystem.FileSystem;
160 const path = yield* Path.Path;
161 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
162 const configDir = path.join(tempDir, "claude-home");
163
164 for (const [description, comment] of [
165 ["Browser automation + AI test authoring via kane-cli: run browser objectives, ...", ""],
166 ['Read C:\\skills\\guide#tag: continue with "quoted".', " # trailing: comment"],
167 ] as const) {
168 yield* writeSkill(
169 path.join(configDir, "skills"),
170 "kane-cli",
171 [
172 "---",
173 "name: frontmatter-alias",
174 `description: ${description}${comment}`,
175 "allowed-tools: [Read, Write]",
176 "disable-model-invocation: yes",
177 "user-invocable: no",
178 "---",
179 ].join("\n"),
180 );
181
182 const skills = yield* discoverClaudeSkills({ homePath: configDir }, undefined);
183
184 assert.deepEqual(skills, [
185 {
186 name: "kane-cli",
187 path: path.join(configDir, "skills", "kane-cli", "SKILL.md"),
188 enabled: true,
189 scope: "user",
190 description,
191 userInvocationOnly: true,
192 userInvocable: false,
193 },
194 ]);
195 }
196 }),
197 );
198
199 it.effect("falls back to the directory name and skips malformed frontmatter", () =>
200 Effect.gen(function* () {
201 const fs = yield* FileSystem.FileSystem;
202 const path = yield* Path.Path;
203 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
204 const configDir = path.join(tempDir, "claude-home");
205 const skillsDir = path.join(configDir, "skills");
206
207 yield* writeSkill(skillsDir, "no-frontmatter", "# Just a heading\n");
208 for (const [directoryName, field] of [
209 ["broken-yaml", "name: [unclosed"],
210 ["broken-tools", "allowed-tools: [Read, Write"],
211 ["broken-quoted", 'name: "unclosed: text'],
212 ] as const) {
213 yield* writeSkill(
214 skillsDir,
215 directoryName,
216 ["---", "description: Run: browser objectives.", field, "---"].join("\n"),
217 );
218 }
219 yield* fs.makeDirectory(skillsDir, { recursive: true });
220 yield* fs.writeFileString(path.join(skillsDir, "README.md"), "not a skill");
221
222 const skills = yield* discoverClaudeSkills({ homePath: configDir }, undefined);
223
224 // A skill with no frontmatter falls back to its directory name; a skill
225 // whose frontmatter fails to parse is skipped entirely (Claude Code
226 // won't load it either).
227 assert.deepEqual(
228 skills.map((skill) => skill.name),
229 ["no-frontmatter"],
230 );
231 assert.equal(skills[0]?.description, undefined);
232 }),
233 );
234
235 it.effect("honors CLAUDE_CONFIG_DIR from the environment when homePath is unset", () =>
236 Effect.gen(function* () {
237 const fs = yield* FileSystem.FileSystem;
238 const path = yield* Path.Path;
239 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
240 const environmentConfigDir = path.join(tempDir, "env-config");
241
242 yield* writeSkill(
243 path.join(environmentConfigDir, "skills"),
244 "env-skill",
245 ["---", "name: env-skill", "description: From env config dir.", "---"].join("\n"),
246 );
247
248 const skills = yield* discoverClaudeSkills({ homePath: "" }, undefined, {
249 CLAUDE_CONFIG_DIR: environmentConfigDir,
250 });
251
252 assert.deepEqual(
253 skills.map((skill) => skill.name),
254 ["env-skill"],
255 );
256
257 const explicitHome = path.join(tempDir, "explicit-home");
258 yield* writeSkill(
259 path.join(explicitHome, "skills"),
260 "explicit-skill",
261 ["---", "name: explicit-skill", "---"].join("\n"),
262 );
263 const explicitSkills = yield* discoverClaudeSkills({ homePath: explicitHome }, undefined, {
264 CLAUDE_CONFIG_DIR: environmentConfigDir,
265 });
266 assert.deepEqual(
267 explicitSkills.map((skill) => skill.name),
268 ["explicit-skill"],
269 );
270 }),
271 );
272
273 it.effect("resolves a relative CLAUDE_CONFIG_DIR against the workspace cwd", () =>
274 Effect.gen(function* () {
275 const fs = yield* FileSystem.FileSystem;
276 const path = yield* Path.Path;
277 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
278 const workspace = path.join(tempDir, "workspace");
279 yield* fs.makeDirectory(workspace, { recursive: true });
280
281 // The spawned CLI resolves a relative CLAUDE_CONFIG_DIR against its own
282 // cwd (the workspace), so discovery must do the same.
283 yield* writeSkill(
284 path.join(workspace, "relative-config", "skills"),
285 "relative-skill",
286 ["---", "name: relative-skill", "---"].join("\n"),
287 );
288
289 const skills = yield* discoverClaudeSkills({ homePath: "" }, workspace, {
290 CLAUDE_CONFIG_DIR: "relative-config",
291 });
292
293 assert.deepEqual(
294 skills.map((skill) => skill.name),
295 ["relative-skill"],
296 );
297 assert.equal(skills[0]?.scope, "user");
298 }),
299 );
300
301 it.effect("marks skills that only the user can invoke", () =>
302 Effect.gen(function* () {
303 const fs = yield* FileSystem.FileSystem;
304 const path = yield* Path.Path;
305 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
306 const configDir = path.join(tempDir, "claude-home");
307 const workspace = path.join(tempDir, "workspace");
308
309 yield* writeSkill(
310 path.join(workspace, ".claude", "skills"),
311 "re-release-version",
312 [
313 "---",
314 "name: re-release-version",
315 "description: Move the current tag forward.",
316 "disable-model-invocation: true",
317 "---",
318 "",
319 "# Body",
320 ].join("\n"),
321 );
322 yield* writeSkill(
323 path.join(workspace, ".claude", "skills"),
324 "release-version",
325 ["---", "name: release-version", "description: Cut a release.", "---", "", "# Body"].join(
326 "\n",
327 ),
328 );
329
330 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
331
332 assert.equal(
333 skills.find((skill) => skill.name === "re-release-version")?.userInvocationOnly,
334 true,
335 );
336 assert.equal(
337 skills.find((skill) => skill.name === "release-version")?.userInvocationOnly,
338 undefined,
339 );
340 }),
341 );
342
343 it.effect("disables skills switched off by skillOverrides", () =>
344 Effect.gen(function* () {
345 const fs = yield* FileSystem.FileSystem;
346 const path = yield* Path.Path;
347 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
348 const configDir = path.join(tempDir, "claude-home");
349 const workspace = path.join(tempDir, "workspace");
350
351 for (const name of ["kept", "off-by-user", "off-by-project"]) {
352 yield* writeSkill(
353 path.join(configDir, "skills"),
354 name,
355 ["---", `name: ${name}`, "---", "", "# Body"].join("\n"),
356 );
357 }
358
359 yield* fs.makeDirectory(configDir, { recursive: true });
360 yield* fs.writeFileString(
361 path.join(configDir, "settings.json"),
362 '{ "skillOverrides": { "off-by-user": "off", "kept": "on" } }',
363 );
364 yield* fs.makeDirectory(path.join(workspace, ".claude"), { recursive: true });
365 yield* fs.writeFileString(
366 path.join(workspace, ".claude", "settings.json"),
367 '{ "skillOverrides": { "off-by-project": "off" } }',
368 );
369
370 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
371
372 assert.deepEqual(
373 skills.map((skill) => [skill.name, skill.enabled]),
374 [
375 ["kept", true],
376 ["off-by-project", false],
377 ["off-by-user", false],
378 ],
379 );
380 }),
381 );
382
383 it.effect("ignores unreadable settings when resolving skillOverrides", () =>
384 Effect.gen(function* () {
385 const fs = yield* FileSystem.FileSystem;
386 const path = yield* Path.Path;
387 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
388 const configDir = path.join(tempDir, "claude-home");
389
390 yield* writeSkill(
391 path.join(configDir, "skills"),
392 "kept",
393 ["---", "name: kept", "---", "", "# Body"].join("\n"),
394 );
395 yield* fs.writeFileString(path.join(configDir, "settings.json"), "{ not json");
396
397 const skills = yield* discoverClaudeSkills({ homePath: configDir });
398
399 assert.deepEqual(
400 skills.map((skill) => [skill.name, skill.enabled]),
401 [["kept", true]],
402 );
403 }),
404 );
405
406 it.effect("treats a user-invocable-only override like disable-model-invocation", () =>
407 Effect.gen(function* () {
408 const fs = yield* FileSystem.FileSystem;
409 const path = yield* Path.Path;
410 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
411 const configDir = path.join(tempDir, "claude-home");
412
413 yield* writeSkill(
414 path.join(configDir, "skills"),
415 "ask-matt",
416 ["---", "name: ask-matt", "---", "", "# Body"].join("\n"),
417 );
418 yield* fs.writeFileString(
419 path.join(configDir, "settings.json"),
420 '{ "skillOverrides": { "ask-matt": "user-invocable-only" } }',
421 );
422
423 const skills = yield* discoverClaudeSkills({ homePath: configDir });
424
425 assert.deepEqual(
426 skills.map((skill) => [skill.name, skill.enabled, skill.userInvocationOnly === true]),
427 [["ask-matt", true, true]],
428 );
429 }),
430 );
431
432 it.effect("drops every override in a file when one value is invalid, as Claude Code does", () =>
433 Effect.gen(function* () {
434 const fs = yield* FileSystem.FileSystem;
435 const path = yield* Path.Path;
436 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
437 const configDir = path.join(tempDir, "claude-home");
438
439 for (const name of ["unknown-mode", "boolean-false", "sibling-off"]) {
440 yield* writeSkill(
441 path.join(configDir, "skills"),
442 name,
443 ["---", `name: ${name}`, "---", "", "# Body"].join("\n"),
444 );
445 }
446 // Verified against the CLI: with an unknown string or a boolean in the
447 // map, the valid "off" sibling is ignored too and every skill runs.
448 yield* fs.writeFileString(
449 path.join(configDir, "settings.json"),
450 '{ "skillOverrides": { "unknown-mode": "some-future-mode", "boolean-false": false, "sibling-off": "off" } }',
451 );
452
453 const skills = yield* discoverClaudeSkills({ homePath: configDir });
454
455 assert.deepEqual(
456 skills.map((skill) => [skill.name, skill.enabled]),
457 [
458 ["boolean-false", true],
459 ["sibling-off", true],
460 ["unknown-mode", true],
461 ],
462 );
463 }),
464 );
465
466 it.effect("reads repository root settings from a nested workspace", () =>
467 Effect.gen(function* () {
468 const fs = yield* FileSystem.FileSystem;
469 const path = yield* Path.Path;
470 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
471 const configDir = path.join(tempDir, "claude-home");
472 const repo = path.join(tempDir, "repo");
473 const workspace = path.join(repo, "packages", "app");
474
475 for (const name of ["root-off", "root-off-cwd-on", "cwd-off-root-on"]) {
476 yield* writeSkill(
477 path.join(configDir, "skills"),
478 name,
479 ["---", `name: ${name}`, "---", "", "# Body"].join("\n"),
480 );
481 }
482 yield* fs.makeDirectory(path.join(repo, ".git"), { recursive: true });
483 yield* fs.makeDirectory(path.join(repo, ".claude"), { recursive: true });
484 yield* fs.makeDirectory(path.join(workspace, ".claude"), { recursive: true });
485 // The CLI ignores the root's plain settings.json from a nested cwd.
486 yield* fs.writeFileString(
487 path.join(repo, ".claude", "settings.json"),
488 '{ "skillOverrides": { "cwd-off-root-on": "off" } }',
489 );
490 // The root local file outranks the workspace local file, as in the CLI.
491 yield* fs.writeFileString(
492 path.join(repo, ".claude", "settings.local.json"),
493 '{ "skillOverrides": { "root-off": "off", "root-off-cwd-on": "off", "cwd-off-root-on": "on" } }',
494 );
495 yield* fs.writeFileString(
496 path.join(workspace, ".claude", "settings.local.json"),
497 '{ "skillOverrides": { "root-off-cwd-on": "on", "cwd-off-root-on": "off" } }',
498 );
499
500 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
501
502 assert.deepEqual(
503 skills.map((skill) => [skill.name, skill.enabled]),
504 [
505 ["cwd-off-root-on", true],
506 ["root-off", false],
507 ["root-off-cwd-on", false],
508 ],
509 );
510 }),
511 );
512
513 it.effect("ignores ancestor settings outside a repository", () =>
514 Effect.gen(function* () {
515 const fs = yield* FileSystem.FileSystem;
516 const path = yield* Path.Path;
517 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
518 const configDir = path.join(tempDir, "claude-home");
519 const parent = path.join(tempDir, "not-a-repo");
520 const workspace = path.join(parent, "workspace");
521
522 yield* writeSkill(
523 path.join(configDir, "skills"),
524 "kept",
525 ["---", "name: kept", "---", "", "# Body"].join("\n"),
526 );
527 yield* fs.makeDirectory(path.join(parent, ".claude"), { recursive: true });
528 yield* fs.makeDirectory(workspace, { recursive: true });
529 yield* fs.writeFileString(
530 path.join(parent, ".claude", "settings.local.json"),
531 '{ "skillOverrides": { "kept": "off" } }',
532 );
533
534 const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace);
535
536 assert.deepEqual(
537 skills.map((skill) => [skill.name, skill.enabled]),
538 [["kept", true]],
539 );
540 }),
541 );
542
543 it.effect("lets the administrator's managed policy outrank every other settings file", () =>
544 Effect.gen(function* () {
545 const path = yield* Path.Path.pipe(Effect.provide(NodePath.layerPosix));
546 const win32Path = yield* Path.Path.pipe(Effect.provide(NodePath.layerWin32));
547
548 for (const [platform, expected] of [
549 ["darwin", "/Library/Application Support/ClaudeCode/managed-settings.json"],
550 ["linux", "/etc/claude-code/managed-settings.json"],
551 ] as const) {
552 const paths = skillOverrideSettingsPaths(path, "/home/.claude", "/workspace", platform, {});
553 assert.deepEqual(paths, [
554 "/home/.claude/settings.json",
555 "/workspace/.claude/settings.json",
556 "/workspace/.claude/settings.local.json",
557 expected,
558 ]);
559 }
560
561 assert.deepEqual(
562 skillOverrideSettingsPaths(win32Path, "C:\\Users\\me\\.claude", undefined, "win32", {
563 PROGRAMDATA: "C:\\ProgramData",
564 }).at(-1),
565 "C:\\ProgramData\\ClaudeCode\\managed-settings.json",
566 );
567 assert.deepEqual(
568 skillOverrideSettingsPaths(win32Path, "C:\\Users\\me\\.claude", undefined, "win32", {}),
569 ["C:\\Users\\me\\.claude\\settings.json"],
570 );
571
572 assert.deepEqual(
573 skillOverrideSettingsPaths(
574 path,
575 "/home/.claude",
576 "/repo/packages/app",
577 "linux",
578 {},
579 "/repo",
580 ),
581 [
582 "/home/.claude/settings.json",
583 "/repo/packages/app/.claude/settings.json",
584 "/repo/packages/app/.claude/settings.local.json",
585 "/repo/.claude/settings.local.json",
586 "/etc/claude-code/managed-settings.json",
587 ],
588 );
589 assert.deepEqual(
590 skillOverrideSettingsPaths(path, "/home/.claude", "/repo", "linux", {}, "/repo"),
591 [
592 "/home/.claude/settings.json",
593 "/repo/.claude/settings.json",
594 "/repo/.claude/settings.local.json",
595 "/etc/claude-code/managed-settings.json",
596 ],
597 );
598 }),
599 );
600
601 it.effect("records a skill Claude Code keeps out of its own slash commands", () =>
602 Effect.gen(function* () {
603 const fs = yield* FileSystem.FileSystem;
604 const path = yield* Path.Path;
605 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
606 const configDir = path.join(tempDir, "claude-home");
607
608 yield* writeSkill(
609 path.join(configDir, "skills"),
610 "agent-only",
611 ["---", "name: agent-only", "user-invocable: false", "---", "", "# Body"].join("\n"),
612 );
613
614 const skills = yield* discoverClaudeSkills({ homePath: configDir });
615
616 assert.deepEqual(
617 skills.map((skill) => [skill.name, skill.userInvocable]),
618 [["agent-only", false]],
619 );
620 }),
621 );
622
623 it.effect("identifies a skill by its directory, as Claude Code does", () =>
624 Effect.gen(function* () {
625 const fs = yield* FileSystem.FileSystem;
626 const path = yield* Path.Path;
627 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
628 const configDir = path.join(tempDir, "claude-home");
629
630 yield* writeSkill(
631 path.join(configDir, "skills"),
632 "probe-alias",
633 ["---", "name: probe-alias-frontmatter", "---", "", "# Body"].join("\n"),
634 );
635 yield* fs.writeFileString(
636 path.join(configDir, "settings.json"),
637 '{ "skillOverrides": { "probe-alias-frontmatter": "off" } }',
638 );
639
640 const skills = yield* discoverClaudeSkills({ homePath: configDir });
641
642 assert.deepEqual(
643 skills.map((skill) => [skill.name, skill.enabled]),
644 [["probe-alias", true]],
645 );
646 }),
647 );
648
649 it.effect("switches a skill off by its directory name", () =>
650 Effect.gen(function* () {
651 const fs = yield* FileSystem.FileSystem;
652 const path = yield* Path.Path;
653 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
654 const configDir = path.join(tempDir, "claude-home");
655
656 yield* writeSkill(
657 path.join(configDir, "skills"),
658 "probe-alias",
659 ["---", "name: probe-alias-frontmatter", "---", "", "# Body"].join("\n"),
660 );
661 yield* fs.writeFileString(
662 path.join(configDir, "settings.json"),
663 '{ "skillOverrides": { "probe-alias": "off" } }',
664 );
665
666 const skills = yield* discoverClaudeSkills({ homePath: configDir });
667
668 assert.deepEqual(
669 skills.map((skill) => [skill.name, skill.enabled]),
670 [["probe-alias", false]],
671 );
672 }),
673 );
674
675 it.effect("accepts the YAML 1.1 boolean spellings Claude Code allows", () =>
676 Effect.gen(function* () {
677 const fs = yield* FileSystem.FileSystem;
678 const path = yield* Path.Path;
679 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
680 const configDir = path.join(tempDir, "claude-home");
681 const skillsDir = path.join(configDir, "skills");
682
683 yield* writeSkill(
684 skillsDir,
685 "user-only-yes",
686 ["---", "disable-model-invocation: yes", "---", "", "# Body"].join("\n"),
687 );
688 yield* writeSkill(
689 skillsDir,
690 "agent-only-no",
691 ["---", "user-invocable: no", "---", "", "# Body"].join("\n"),
692 );
693 yield* writeSkill(
694 skillsDir,
695 "plain-off",
696 ["---", "disable-model-invocation: off", "---", "", "# Body"].join("\n"),
697 );
698
699 const skills = yield* discoverClaudeSkills({ homePath: configDir });
700
701 assert.deepEqual(
702 skills.map((skill) => [
703 skill.name,
704 skill.userInvocationOnly === true,
705 skill.userInvocable === false,
706 ]),
707 [
708 ["agent-only-no", false, true],
709 ["plain-off", false, false],
710 ["user-only-yes", true, false],
711 ],
712 );
713 }),
714 );
715
716 it.effect("returns an empty list when no skill roots exist", () =>
717 Effect.gen(function* () {
718 const fs = yield* FileSystem.FileSystem;
719 const path = yield* Path.Path;
720 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
721
722 const skills = yield* discoverClaudeSkills(
723 { homePath: path.join(tempDir, "missing-home") },
724 path.join(tempDir, "missing-workspace"),
725 );
726
727 assert.deepEqual(skills, []);
728 }),
729 );
730});