The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 14:45 UTC
fix(server): skills from CLAUDE_CODE_PLUGIN_DIRS plugins show in the composer (#33341)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
David Mendes committed
Nov 14, 2026 at 16:32 UTC
5a15495de4c148bb141f08b99949728f9df8dfea
2 files changed
+197
-14
apps/server/src/provider/Drivers/ClaudeSkills.test.ts
+90
@@ -587,6 +587,96 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {
587
}),
588
);
589
590
+ it.effect("discovers inline plugins from CLAUDE_CODE_PLUGIN_DIRS over installed namesakes", () =>
591
+ Effect.gen(function* () {
592
+ const fs = yield* FileSystem.FileSystem;
593
+ const path = yield* Path.Path;
594
+ const workspace = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
595
+ const configDir = path.join(workspace, "config");
596
+ const named = path.join(workspace, "named");
597
+ const unnamed = path.join(workspace, "unnamed");
598
+ const inherited = path.join(workspace, "inherited");
599
+ const muted = path.join(workspace, "muted");
600
+ const installed = path.join(workspace, "installed-acme");
601
+ yield* fs.makeDirectory(path.join(named, ".claude-plugin"), { recursive: true });
602
+ yield* fs.writeFileString(
603
+ path.join(named, ".claude-plugin", "plugin.json"),
604
+ '{"name":"acme"}',
605
+ );
606
+ yield* writeSkill(path.join(named, "skills"), "qa", "---\ndescription: QA a ticket\n---\n");
607
+ yield* writeSkill(path.join(installed, "skills"), "old", "# Old");
608
+ yield* writeSkill(path.join(unnamed, "skills"), "lint", "# Lint");
609
+ yield* writeSkill(path.join(muted, "skills"), "hidden", "# Hidden");
610
+ const quiet = path.join(workspace, "quiet");
611
+ yield* fs.makeDirectory(path.join(quiet, ".claude-plugin"), { recursive: true });
612
+ yield* fs.writeFileString(
613
+ path.join(quiet, ".claude-plugin", "plugin.json"),
614
+ '{"name":"quiet","defaultEnabled":false}',
615
+ );
616
+ yield* writeSkill(path.join(quiet, "skills"), "hush", "# Hush");
617
+ const bundle = path.join(workspace, "bundle");
618
+ yield* fs.makeDirectory(path.join(bundle, "tools", ".claude-plugin"), { recursive: true });
619
+ yield* fs.writeFileString(
620
+ path.join(bundle, "tools", ".claude-plugin", "plugin.json"),
621
+ '{"name":"tools"}',
622
+ );
623
+ yield* writeSkill(path.join(bundle, "tools", "skills"), "fmt", "# Fmt");
624
+ yield* writeSkill(path.join(bundle, "loose", "skills"), "ignored", "# Ignored");
625
+ yield* writeSkill(path.join(inherited, "skills"), "stale", "# Stale");
626
+ yield* writeSkill(path.join(workspace, "relative", "skills"), "skipped", "# Skipped");
627
+ yield* fs.makeDirectory(path.join(configDir, "plugins"), { recursive: true });
628
+ yield* fs.writeFileString(
629
+ path.join(configDir, "plugins", "installed_plugins.json"),
630
+ JSON.stringify({ plugins: { "acme@shop": [{ scope: "user", installPath: installed }] } }),
631
+ );
632
+ yield* fs.writeFileString(
633
+ path.join(configDir, "settings.json"),
634
+ JSON.stringify({
635
+ enabledPlugins: { "acme@shop": true, "muted@inline": false },
636
+ env: {
637
+ CLAUDE_CODE_PLUGIN_DIRS: [named, "relative", ` ${unnamed} `, muted, quiet, bundle].join(
638
+ ";",
639
+ ),
640
+ },
641
+ }),
642
+ );
643
+
644
+ const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace, {
645
+ CLAUDE_CODE_PLUGIN_DIRS: inherited,
646
+ });
647
+ assert.deepEqual(
648
+ skills.map(({ name, scope, description }) => ({ name, scope, description })),
649
+ [
650
+ { name: "acme:qa", scope: "user", description: "QA a ticket" },
651
+ { name: "tools:fmt", scope: "user", description: undefined },
652
+ { name: "unnamed:lint", scope: "user", description: undefined },
653
+ ],
654
+ );
655
+
656
+ // Managed enabledPlugins entries lock their plugin name against inline copies.
657
+ const programFiles = path.join(workspace, "program-files");
658
+ yield* fs.makeDirectory(path.join(programFiles, "ClaudeCode"), { recursive: true });
659
+ yield* fs.writeFileString(
660
+ path.join(programFiles, "ClaudeCode", "managed-settings.json"),
661
+ '{"enabledPlugins":{"acme@shop":true}}',
662
+ );
663
+ assert.deepEqual(
664
+ (yield* discoverClaudeSkills({ homePath: path.join(workspace, "empty") }, workspace, {
665
+ CLAUDE_CODE_PLUGIN_DIRS: [named, unnamed].join(";"),
666
+ ProgramFiles: programFiles,
667
+ })).map((skill) => skill.name),
668
+ ["unnamed:lint"],
669
+ );
670
+
671
+ assert.deepEqual(
672
+ (yield* discoverClaudeSkills({ homePath: path.join(workspace, "empty") }, workspace, {
673
+ CLAUDE_CODE_PLUGIN_DIRS: inherited,
674
+ })).map((skill) => skill.name),
675
+ ["inherited:stale"],
676
+ );
677
+ }),
678
+ );
679
+
680
it.effect("discovers user and project skills with frontmatter metadata", () =>
681
Effect.gen(function* () {
682
const fs = yield* FileSystem.FileSystem;
apps/server/src/provider/Drivers/ClaudeSkills.ts
+107
-14
@@ -129,6 +129,20 @@ function claudeManagedDirectory(
129
return "/etc/claude-code";
130
}
131
132
+function claudeManagedSettingsPaths(
133
+ path: Path.Path,
134
+ platform: NodeJS.Platform,
135
+ environment: NodeJS.ProcessEnv,
136
+): ReadonlyArray<string> {
137
+ const managedDirectory = claudeManagedDirectory(path, platform, environment);
138
+ const programData =
139
+ platform === "win32" ? windowsEnvironmentValue(environment, "ProgramData") : undefined;
140
+ return [
141
+ ...(programData ? [path.join(programData, "ClaudeCode", "managed-settings.json")] : []),
142
+ ...(managedDirectory ? [path.join(managedDirectory, "managed-settings.json")] : []),
143
+ ];
144
+}
145
+
146
/** Claude Code settings files, lowest precedence first. */
147
function claudeSettingsPaths(
148
path: Path.Path,
@@ -138,9 +152,6 @@ function claudeSettingsPaths(
152
environment: NodeJS.ProcessEnv,
153
repositoryRoot?: string,
154
): ReadonlyArray<string> {
141
- const managedDirectory = claudeManagedDirectory(path, platform, environment);
142
- const programData =
143
- platform === "win32" ? windowsEnvironmentValue(environment, "ProgramData") : undefined;
155
const root = repositoryRoot !== undefined && repositoryRoot !== cwd ? repositoryRoot : undefined;
156
return [
157
path.join(configDirPath, "settings.json"),
@@ -151,8 +162,7 @@ function claudeSettingsPaths(
162
]
163
: []),
164
...(root ? [path.join(root, ".claude", "settings.local.json")] : []),
154
- ...(programData ? [path.join(programData, "ClaudeCode", "managed-settings.json")] : []),
155
- ...(managedDirectory ? [path.join(managedDirectory, "managed-settings.json")] : []),
165
+ ...claudeManagedSettingsPaths(path, platform, environment),
166
];
167
}
168
@@ -261,6 +271,8 @@ const readSkillSettings = Effect.fn("readSkillSettings")(function* (
271
const platform = yield* HostProcess.Platform;
272
const overridesByName = new Map<string, SkillOverride>();
273
const enabledPlugins = new Map<string, boolean>();
274
+ const managedPluginNames = new Set<string>();
275
+ const managedPaths = new Set(claudeManagedSettingsPaths(path, platform, environment));
276
let syncedPluginsHidden = false;
277
const repositoryRoot = cwd === undefined ? undefined : yield* findRepositoryRoot(cwd);
278
const projectSettingsPath =
@@ -296,6 +308,9 @@ const readSkillSettings = Effect.fn("readSkillSettings")(function* (
308
for (const [key, enabled] of Object.entries(parsed?.enabledPlugins ?? {})) {
309
if (typeof enabled === "boolean") {
310
enabledPlugins.set(key, enabled);
311
+ if (managedPaths.has(settingsPath) && key.includes("@")) {
312
+ managedPluginNames.add(pluginNameKey(key.slice(0, key.indexOf("@"))));
313
+ }
314
} else {
315
// Extended formats replace lower-precedence values without enabling the plugin here.
316
enabledPlugins.delete(key);
@@ -307,7 +322,12 @@ const readSkillSettings = Effect.fn("readSkillSettings")(function* (
322
}
323
}
324
310
- return { skillOverrides: overridesByName, enabledPlugins, syncedPluginsHidden };
325
+ return {
326
+ skillOverrides: overridesByName,
327
+ enabledPlugins,
328
+ managedPluginNames,
329
+ syncedPluginsHidden,
330
+ };
331
});
332
333
const InstalledPlugins = Schema.fromJsonString(
@@ -324,6 +344,7 @@ const PluginManifest = Schema.fromJsonString(
344
Schema.Struct({
345
name: Schema.optional(Schema.NonEmptyString),
346
skills: Schema.optional(Schema.Union([Schema.String, Schema.Array(Schema.String)])),
347
+ defaultEnabled: Schema.optional(Schema.Unknown),
348
}),
349
);
350
@@ -444,10 +465,66 @@ const resolveSyncedPluginBucket = Effect.fn("resolveSyncedPluginBucket")(functio
465
return `${organizationId.toLowerCase()}_${accountId.toLowerCase()}`;
466
});
467
468
+/** A plugin folder itself, or else the manifest-bearing plugins directly inside it. */
469
+const expandInlinePluginDirectory = Effect.fn("expandInlinePluginDirectory")(function* (
470
+ directory: string,
471
+) {
472
+ const fileSystem = yield* FileSystem.FileSystem;
473
+ const path = yield* Path.Path;
474
+ const exists = (candidate: string) =>
475
+ fileSystem.exists(candidate).pipe(Effect.orElseSucceed(() => false));
476
+ for (const component of [path.join(".claude-plugin", "plugin.json"), "skills", "SKILL.md"]) {
477
+ if (yield* exists(path.join(directory, component))) return [directory];
478
+ }
479
+ const children = yield* fileSystem
480
+ .readDirectory(directory)
481
+ .pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []));
482
+ return yield* Effect.filter(
483
+ [...children].sort().map((child) => path.join(directory, child)),
484
+ (child) => exists(path.join(child, ".claude-plugin", "plugin.json")),
485
+ );
486
+});
487
+
488
+/** Plugin folders Claude Code loads inline from CLAUDE_CODE_PLUGIN_DIRS, and their plugin names. */
489
+const discoverInlinePluginSkillRoots = Effect.fn("discoverInlinePluginSkillRoots")(function* (
490
+ pluginDirectories: string | undefined,
491
+ enabledPlugins: ReadonlyMap<string, boolean>,
492
+ managedPluginNames: ReadonlySet<string>,
493
+) {
494
+ const path = yield* Path.Path;
495
+ const home = yield* HostProcess.HomeDirectory;
496
+ const platform = yield* HostProcess.Platform;
497
+ const roots: Array<ClaudeSkillRoot> = [];
498
+ const names = new Set<string>();
499
+ const seen = new Set<string>();
500
+ for (const entry of (pluginDirectories ?? "").split(platform === "win32" ? ";" : ":")) {
501
+ const directory = expandHomePath(entry.trim(), home);
502
+ // Claude skips relative entries rather than resolving them against its cwd.
503
+ if (!directory || !path.isAbsolute(directory)) continue;
504
+ for (const installPath of yield* expandInlinePluginDirectory(path.resolve(directory))) {
505
+ if (seen.has(installPath)) continue;
506
+ seen.add(installPath);
507
+ const manifest = yield* readPluginManifest(installPath);
508
+ const prefix = manifest?.name ?? path.basename(installPath);
509
+ // A `<name>@inline` setting wins; otherwise the manifest's `defaultEnabled` decides.
510
+ const setting = enabledPlugins.get(`${prefix}@inline`);
511
+ if (setting === false || (setting === undefined && manifest?.defaultEnabled === false)) {
512
+ continue;
513
+ }
514
+ // Managed enabledPlugins entries, true or false, lock the name against inline copies.
515
+ if (managedPluginNames.has(pluginNameKey(prefix))) continue;
516
+ names.add(pluginNameKey(prefix));
517
+ roots.push(...(yield* pluginSkillRoots(installPath, "user", prefix, manifest)));
518
+ }
519
+ }
520
+ return { roots, names };
521
+});
522
+
523
const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function* (
524
configDirPath: string,
525
cwd: string | undefined,
526
enabledPlugins: ReadonlyMap<string, boolean>,
527
+ inlinePluginNames: ReadonlySet<string>,
528
syncedBucket: string | undefined,
529
environment: NodeJS.ProcessEnv,
530
) {
@@ -465,7 +542,8 @@ const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function*
542
Effect.orElseSucceed(() => undefined),
543
);
544
const roots: Array<ClaudeSkillRoot> = [];
468
- const claimedPluginNames = new Set<string>();
545
+ // An enabled inline plugin replaces installed and synced plugins of the same name.
546
+ const claimedPluginNames = new Set(inlinePluginNames);
547
// The CLI's process.cwd() resolves symlinks; registry projectPath values remain lexical.
548
const workspace =
549
cwd === undefined
@@ -505,7 +583,7 @@ const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function*
583
const installPath = path.resolve(cwd ?? ".", install.installPath);
584
const manifest = yield* readPluginManifest(installPath);
585
const prefix = manifest?.name ?? key.split("@")[0];
508
- if (!prefix) continue;
586
+ if (!prefix || inlinePluginNames.has(pluginNameKey(prefix))) continue;
587
// A registry record whose install is gone loads nothing and claims no namespace.
588
if (Option.isSome(existing)) claimedPluginNames.add(pluginNameKey(prefix));
589
roots.push(...(yield* pluginSkillRoots(installPath, scope, prefix, manifest)));
@@ -571,6 +649,7 @@ const resolveClaudeConfigDirPath = Effect.fn("resolveClaudeConfigDirPath")(funct
649
const SettingsEnv = Schema.Struct({
650
ANTHROPIC_BASE_URL: Schema.optional(Schema.String),
651
CLAUDE_CODE_ENTRYPOINT: Schema.optional(Schema.String),
652
+ CLAUDE_CODE_PLUGIN_DIRS: Schema.optional(Schema.String),
653
// Unquoted JSON values must not fail the decode and drop ANTHROPIC_BASE_URL with them.
654
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY: Schema.optional(Schema.Unknown),
655
CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY_TIMEOUT_MS: Schema.optional(Schema.Unknown),
@@ -648,11 +727,8 @@ export const discoverClaudeSkills = Effect.fn("discoverClaudeSkills")(function*
727
const path = yield* Path.Path;
728
const env = environment ?? process.env;
729
const configDirPath = yield* resolveClaudeConfigDirPath(config, env, cwd);
651
- const { skillOverrides, enabledPlugins, syncedPluginsHidden } = yield* readSkillSettings(
652
- configDirPath,
653
- cwd,
654
- env,
655
- );
730
+ const { skillOverrides, enabledPlugins, managedPluginNames, syncedPluginsHidden } =
731
+ yield* readSkillSettings(configDirPath, cwd, env);
732
const managedDirectory = claudeManagedDirectory(path, yield* HostProcess.Platform, env);
733
// Most installs have no synced folder; skip reading `.claude.json` for them.
734
const hasSyncedPlugins =
@@ -663,6 +739,15 @@ export const discoverClaudeSkills = Effect.fn("discoverClaudeSkills")(function*
739
const syncedBucket = hasSyncedPlugins
740
? yield* resolveSyncedPluginBucket(config, configDirPath, env)
741
: undefined;
742
+ // Claude applies its settings `env` over the inherited environment.
743
+ const inlinePluginDirectories =
744
+ (yield* readClaudeSettingsEnv(config, cwd, env)).CLAUDE_CODE_PLUGIN_DIRS ??
745
+ env.CLAUDE_CODE_PLUGIN_DIRS;
746
+ const inlinePlugins = yield* discoverInlinePluginSkillRoots(
747
+ inlinePluginDirectories,
748
+ enabledPlugins,
749
+ managedPluginNames,
750
+ );
751
752
const roots: ReadonlyArray<ClaudeSkillRoot> = [
753
...(managedDirectory
@@ -676,7 +761,15 @@ export const discoverClaudeSkills = Effect.fn("discoverClaudeSkills")(function*
761
directory: path.join(path.resolve(cwd ?? ".", directory), ".claude", "skills"),
762
scope: "project" as const,
763
})),
679
- ...(yield* discoverPluginSkillRoots(configDirPath, cwd, enabledPlugins, syncedBucket, env)),
764
+ ...inlinePlugins.roots,
765
+ ...(yield* discoverPluginSkillRoots(
766
+ configDirPath,
767
+ cwd,
768
+ enabledPlugins,
769
+ inlinePlugins.names,
770
+ syncedBucket,
771
+ env,
772
+ )),
773
];
774
775
const skillsByName = new Map<string, ServerProviderSkill>();