Skip to content

feat(setup): install agent skills for detected roots#747

Merged
BYK merged 3 commits intomainfrom
feat/cross-agent-skill-install
Apr 14, 2026
Merged

feat(setup): install agent skills for detected roots#747
BYK merged 3 commits intomainfrom
feat/cross-agent-skill-install

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Apr 14, 2026

Summary

This updates the existing review branch with the smaller change built from main instead of the earlier unconditional .agents installer. It keeps the Claude-style flow, adds shared ~/.agents support only when that root already exists, and keeps setup output aligned with the file that was actually created.

Changes

  • detect existing ~/.agents and ~/.claude roots instead of creating a top-level shared root
  • reuse the existing skill path helper for both targets and keep each install independent
  • update setup and unit tests for no-agent silence, detected ~/.agents installs, and fresh-path reporting

Test Plan

  • bun test test/lib/agent-skills.test.ts
  • bun test test/commands/cli/setup.test.ts
  • bun run typecheck
  • bun run lint (passes with an existing unrelated warning in src/lib/formatters/markdown.ts)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (cli) Add sentry cli defaults command for persistent settings by BYK in #721
  • (docs) Auto-generate driftable documentation sections by BYK in #739
  • (issue-list) Add search syntax docs, case-insensitive AND/OR, and JSON syntax reference by BYK in #738
  • (setup) Install agent skills for detected roots by betegon in #747

Bug Fixes 🐛

Init

  • Treat no-op edits as passthrough instead of throwing by betegon in #731
  • Remove JSON minification that breaks edit-based codemods by betegon in #719

Resolve

  • Address review comments and add tests for fuzzy project recovery by BYK in #732
  • Fuzzy auto-recovery for project slug resolution by BYK in #728

Upgrade

  • Detect npm install method from node_modules path by BYK in #723
  • Add shell option on Windows for .cmd package managers by BYK in #722

Other

  • (ci) Add retry logic to ORAS/bsdiff downloads and upgrade ORAS by BYK in #741
  • (dashboard) Remove overly restrictive dataset-display cross-validation by BYK in #720
  • (errors) Improve ContextError wording for auto-detect failures by BYK in #726
  • (event-view) Add cross-org fallback when event not found by BYK in #744
  • (issue) Support share issue URLs by BYK in #718
  • (issue-list) Auto-correct AND and reject OR in --query to prevent 400 by BYK in #727
  • (telemetry) Rename isClientApiError to isUserApiError and exclude 400 by BYK in #729
  • Bug fixes from Sentry error monitoring (CLI-FR, CLI-RN) + auth default by BYK in #740

Internal Changes 🔧

  • Regenerate skill files by github-actions[bot] in ca16b2ff

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-747/

Built to branch gh-pages at 2026-04-14 13:24 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@betegon betegon marked this pull request as ready for review April 14, 2026 09:59
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Codecov Results 📊

134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1628 uncovered lines.
✅ Project coverage is 95.31%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.28%    95.31%    +0.03%
==========================================
  Files          234       234         —
  Lines        34644     34676       +32
  Branches         0         0         —
==========================================
+ Hits         33008     33048       +40
- Misses        1636      1628        -8
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon requested a review from BYK April 14, 2026 10:04
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: getSkillInstallPath is now unused in production code
    • Removed the unused getSkillInstallPath function and its test, as production code now constructs paths directly in writeSkillFiles.
  • ✅ Fixed: Fresh Claude install notification suppressed by stale agents result
    • Modified installAgentSkills to merge the created flags when both targets succeed, ensuring fresh Claude installs are reported even when .agents already existed.

Create PR

Or push these changes by commenting:

@cursor push 78e6498ad6
Preview (78e6498ad6)
diff --git a/src/lib/agent-skills.ts b/src/lib/agent-skills.ts
--- a/src/lib/agent-skills.ts
+++ b/src/lib/agent-skills.ts
@@ -38,14 +38,6 @@
 }
 
 /**
- * Get the installation path for the Sentry CLI skill in the cross-agent
- * standard location (~/.agents/skills/).
- */
-export function getSkillInstallPath(homeDir: string): string {
-  return join(homeDir, ".agents", "skills", "sentry-cli", "SKILL.md");
-}
-
-/**
  * Write skill files to a target directory.
  *
  * Checks that the parent directory is writable before attempting writes.
@@ -156,6 +148,14 @@
     }
   }
 
-  // Prefer the cross-agent standard path as the reported location
+  // Prefer the cross-agent standard path as the reported location.
+  // If both succeeded, prefer agents but merge the `created` flag so
+  // fresh Claude installs are reported even when .agents already existed.
+  if (agentsResult && claudeResult) {
+    return {
+      ...agentsResult,
+      created: agentsResult.created || claudeResult.created,
+    };
+  }
   return agentsResult ?? claudeResult;
 }

diff --git a/test/lib/agent-skills.test.ts b/test/lib/agent-skills.test.ts
--- a/test/lib/agent-skills.test.ts
+++ b/test/lib/agent-skills.test.ts
@@ -11,7 +11,6 @@
 import { join } from "node:path";
 import {
   detectClaudeCode,
-  getSkillInstallPath,
   installAgentSkills,
 } from "../../src/lib/agent-skills.js";
 
@@ -41,13 +40,6 @@
     });
   });
 
-  describe("getSkillInstallPath", () => {
-    test("returns cross-agent standard path under ~/.agents/skills", () => {
-      const path = getSkillInstallPath("/home/user");
-      expect(path).toBe("/home/user/.agents/skills/sentry-cli/SKILL.md");
-    });
-  });
-
   describe("installAgentSkills", () => {
     let testDir: string;
 
@@ -164,6 +156,34 @@
       expect(second!.path).toBe(first!.path);
     });
 
+    test("reports created: true when Claude is freshly installed but .agents already exists", async () => {
+      // First run without Claude
+      const first = await installAgentSkills(testDir);
+      expect(first!.created).toBe(true);
+      expect(first!.path).toBe(
+        join(testDir, ".agents", "skills", "sentry-cli", "SKILL.md")
+      );
+
+      // Install Claude Code
+      mkdirSync(join(testDir, ".claude"), { recursive: true });
+
+      // Second run with Claude
+      const second = await installAgentSkills(testDir);
+      // Should report created: true because Claude skills are fresh
+      expect(second!.created).toBe(true);
+      expect(second!.path).toBe(
+        join(testDir, ".agents", "skills", "sentry-cli", "SKILL.md")
+      );
+
+      // Both locations should exist
+      expect(
+        existsSync(join(testDir, ".agents", "skills", "sentry-cli", "SKILL.md"))
+      ).toBe(true);
+      expect(
+        existsSync(join(testDir, ".claude", "skills", "sentry-cli", "SKILL.md"))
+      ).toBe(true);
+    });
+
     test("claude install succeeds even if ~/.agents is not writable", async () => {
       mkdirSync(join(testDir, ".claude"), { recursive: true });
       mkdirSync(join(testDir, ".agents"), { recursive: true, mode: 0o444 });

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 352019d. Configure here.

Comment thread src/lib/agent-skills.ts Outdated
Comment thread src/lib/agent-skills.ts Outdated
Comment thread src/lib/agent-skills.ts Outdated
Comment thread src/lib/agent-skills.ts Outdated
Comment thread src/lib/agent-skills.ts Outdated
Comment thread src/lib/agent-skills.ts Outdated
Comment thread src/lib/agent-skills.ts Outdated
Comment thread src/lib/agent-skills.ts Outdated
Only install shared agent skills when a compatible agent root already
exists, so setup stays silent for users without agent tooling and avoids
creating ~/.agents unconditionally.

When a new target is added later, report the path that was actually
created and cover the detected-root behavior with focused setup tests.

Made-with: Cursor
Collapse the agent skill follow-up back toward the original Claude-only
shape so installAgentSkills owns the control flow again and getSkillInstallPath
is the single source of truth for Claude and shared agent paths.

Keep the detected-root behavior and fresh-path reporting, but drop the
extra wrapper helpers that made the review diff larger than necessary.

Made-with: Cursor
@betegon betegon force-pushed the feat/cross-agent-skill-install branch from 5a1cdd5 to ab573d1 Compare April 14, 2026 13:10
@betegon betegon changed the title feat(setup): install agent skills to ~/.agents/skills/ for cross-agent support feat(setup): install agent skills for detected roots Apr 14, 2026
@betegon betegon requested a review from BYK April 14, 2026 13:24
Copy link
Copy Markdown
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

We may wanna consider making the .claude one a symlink if both exists but that's a very minor and hard-to-get optimization. We can consider if there are more targets in the future (hope not! :D)

@BYK BYK merged commit 5c4bd00 into main Apr 14, 2026
26 checks passed
@BYK BYK deleted the feat/cross-agent-skill-install branch April 14, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants