@devries-cameron20 / t3code-1 / commits / 0bd447e51e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

perf(server): Claude skill discovery resolves each repository root once (#29757)

Co-authored-by: Taylor Dolezal <117500+onlydole@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Taylor Dolezal committed Nov 3, 2026 at 15:38 UTC 0bd447e51ee6e62f9e4cea5bf8753e7c01fc4c6d
2 files changed +77 -7
apps/server/src/provider/Drivers/ClaudeSkills.test.ts
+65
@@ -209,6 +209,71 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {
209 }),
210 );
211
212 + it.effect("resolves each install record's project repository once per discovery", () =>
213 + Effect.gen(function* () {
214 + const fs = yield* FileSystem.FileSystem;
215 + const path = yield* Path.Path;
216 + // Real path: macOS temp dirs sit behind a /var -> /private/var symlink.
217 + const tempDir = yield* fs.realPath(
218 + yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" }),
219 + );
220 + const configDir = path.join(tempDir, "claude-home");
221 + const workspace = path.join(tempDir, "workspace");
222 + const otherProject = path.join(tempDir, "other", "packages", "app");
223 + const sameRepoProject = path.join(workspace, "packages", "app");
224 + yield* fs.makeDirectory(path.join(workspace, ".git"), { recursive: true });
225 + yield* fs.makeDirectory(path.join(tempDir, "other", ".git"), { recursive: true });
226 + yield* fs.makeDirectory(otherProject, { recursive: true });
227 + yield* fs.makeDirectory(sameRepoProject, { recursive: true });
228 + const elsewhereInstall = path.join(configDir, "plugins", "elsewhere");
229 + const sameRepoInstall = path.join(configDir, "plugins", "same-repo");
230 + yield* writeSkill(path.join(elsewhereInstall, "skills"), "elsewhere", "# Elsewhere");
231 + yield* writeSkill(path.join(sameRepoInstall, "skills"), "same-repo", "# Same repo");
232 + const records = Array.from({ length: 4 }, () => ({
233 + scope: "project",
234 + projectPath: otherProject,
235 + installPath: elsewhereInstall,
236 + }));
237 + const plugins = ["a@shop", "b@shop", "c@shop"];
238 + yield* fs.writeFileString(
239 + path.join(configDir, "plugins", "installed_plugins.json"),
240 + JSON.stringify({
241 + plugins: {
242 + ...Object.fromEntries(plugins.map((key) => [key, records])),
243 + "d@shop": [
244 + { scope: "project", projectPath: sameRepoProject, installPath: sameRepoInstall },
245 + ],
246 + },
247 + }),
248 + );
249 + yield* fs.writeFileString(
250 + path.join(configDir, "settings.json"),
251 + JSON.stringify({
252 + enabledPlugins: Object.fromEntries([...plugins, "d@shop"].map((key) => [key, true])),
253 + }),
254 + );
255 +
256 + const probed: Array<string> = [];
257 + const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace).pipe(
258 + Effect.provideService(FileSystem.FileSystem, {
259 + ...fs,
260 + exists: (target) => {
261 + probed.push(target);
262 + return fs.exists(target);
263 + },
264 + }),
265 + );
266 + assert.strictEqual(
267 + probed.filter((target) => target === path.join(otherProject, ".git")).length,
268 + 1,
269 + );
270 + assert.deepEqual(
271 + skills.map((skill) => skill.name),
272 + ["d:same-repo"],
273 + );
274 + }),
275 + );
276 +
277 it.effect("publishes and dispatches canonical plugin folder names regardless of aliases", () =>
278 Effect.gen(function* () {
279 const fs = yield* FileSystem.FileSystem;
apps/server/src/provider/Drivers/ClaudeSkills.ts
+12 -7
@@ -143,7 +143,8 @@ function claudeSettingsPaths(
143 ];
144 }
145
146 -const findRepositoryRoot = Effect.fn("findRepositoryRoot")(function* (
146 +// Untraced: skill discovery resolves every distinct plugin project path, too often for spans.
147 +const findRepositoryRoot = Effect.fnUntraced(function* (
148 cwd: string,
149 ): Effect.fn.Return<string | undefined, never, FileSystem.FileSystem | Path.Path> {
150 const fileSystem = yield* FileSystem.FileSystem;
@@ -164,7 +165,7 @@ const findRepositoryRoot = Effect.fn("findRepositoryRoot")(function* (
165 }
166 });
167
167 -const findPluginRepositoryRoot = Effect.fn("findPluginRepositoryRoot")(function* (cwd: string) {
168 +const findPluginRepositoryRoot = Effect.fnUntraced(function* (cwd: string) {
169 const fileSystem = yield* FileSystem.FileSystem;
170 const path = yield* Path.Path;
171 const root = yield* findRepositoryRoot(cwd);
@@ -336,6 +337,8 @@ const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function*
337 cwd === undefined
338 ? undefined
339 : yield* fileSystem.realPath(cwd).pipe(Effect.orElseSucceed(() => path.resolve(cwd)));
340 + // Install records repeat project paths, often hundreds of times per discovery.
341 + const projectRepositoryRoots = new Map<string, string | undefined>();
342 const repositoryRoot =
343 workspace === undefined ? undefined : yield* findPluginRepositoryRoot(workspace);
344
@@ -347,11 +350,13 @@ const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function*
350 Effect.gen(function* () {
351 if (record.scope === "user" || record.scope === "managed") return true;
352 if (record.projectPath === undefined || workspace === undefined) return false;
350 - if (path.resolve(record.projectPath) === workspace) return true;
351 - return (
352 - repositoryRoot !== undefined &&
353 - (yield* findPluginRepositoryRoot(record.projectPath)) === repositoryRoot
354 - );
353 + const projectPath = path.resolve(record.projectPath);
354 + if (projectPath === workspace) return true;
355 + if (repositoryRoot === undefined) return false;
356 + if (!projectRepositoryRoots.has(projectPath)) {
357 + projectRepositoryRoots.set(projectPath, yield* findPluginRepositoryRoot(projectPath));
358 + }
359 + return projectRepositoryRoots.get(projectPath) === repositoryRoot;
360 }),
361 );
362 // The native loader keeps registry order, preferring the first install that exists.