Skip to content

Project slash commands are invisible when .claude/commands/*.md are symlinks #2602

Closed

Description

@Johannes-Berggren

Summary

bb's slash-command typeahead shows no project commands when .claude/commands/*.md are symlinks. The host-daemon command scanner skips every symlinked directory entry, so a repo that symlinks its commands into a shared location gets an empty "project commands" section, while Claude Code's own CLI loads them fine.

Where

host-daemon src/command-discovery.ts, walkMarkdownTree:

for (const entry of entries) {
  if (entry.isSymbolicLink()) {
    continue;
  }
  ...
}

Symlinks are followed only for user-origin skill roots:

function canFollowSkillSymlink(root: CommandScanRoot): boolean {
  return root.origin === "user" && root.source === "skill";
}

walkMarkdownTree backs the command shape (resolveCommandScanRoots -> <cwd>/.claude/commands, origin: "project"), so a project command that is a symlink is never discovered, in any shape.

Reproduce

  1. In a project, mkdir -p .agents/skills/foo && printf -- '---\ndescription: demo\n---\nhi\n' > .agents/skills/foo/SKILL.md
  2. ln -s ../../.agents/skills/foo/SKILL.md .claude/commands/foo.md
  3. Open the slash-command menu in bb (or GET /api/v1/projects/<id>/commands?provider=claude-code&environmentId=<env>).

Expected: foo listed under project commands.
Actual: absent. Replacing the symlink with a regular file makes it appear immediately, which isolates the cause to the symlink check rather than the path, the environment, or caching.

Impact

Sharing one instruction file between Claude Code and Codex via symlinks is a common monorepo layout (.claude/commands/x.md -> .agents/skills/x/SKILL.md keeps the two harnesses from drifting). In our repo all 14 project commands are invisible in bb for this reason; the only visible non-builtin command is a regular file in ~/.claude/commands/.

Suggested fix

For the command shape, resolve symlinked entries with fs.stat and accept them when the target is a regular file inside the root's boundary. The cycle and root-escape concerns that motivate the blanket skip apply to recursive directory traversal; a symlinked leaf .md can be followed safely with a boundary check. Alternatively, extend canFollowSkillSymlink to project roots for file (non-directory) entries.

Version

bb 0.39.0, macOS (darwin 25.6.0), provider claude-code.

Activity

  1. added theissue type on Aug 27, 2026
  2. added
    providers
    workspaces
    provider-claude-code
    on Aug 27, 2026
  3. Borjampm commented on Aug 31, 2026

    @Borjampm

    Same cause, second symptom: skill directories are dropped by the same rule, so
    .claude/skills/x -> ../../.agents/skills/x is invisible for exactly the reason your
    .claude/commands/*.md links are. Adding evidence rather than opening a duplicate.

    Reproduced on main @ 8d926c3 (also packaged 0.40.0), macOS 26.4, Node v26.4.0,
    claude 2.1.251 / codex 0.150.1 / pi 0.84.4.

    Minimal A/B — one real directory, one in-repo symlink, same skills root:

    mkdir -p repo/.claude/skills/h-real repo/.agents/skills/h-linked && git -C repo init -q .
    printf -- '---\nname: h-real\ndescription: real\n---\n'     > repo/.claude/skills/h-real/SKILL.md
    printf -- '---\nname: h-linked\ndescription: linked\n---\n' > repo/.agents/skills/h-linked/SKILL.md
    ln -s ../../.agents/skills/h-linked repo/.claude/skills/h-linked
    Claude Code CLI 2.1.251 :  h-linked, h-real
    bb main @ 8d926c3       :  h-real
    

    Three additions to what you documented:

    1. It is not provider-specific. codex drops an entry link in .codex/skills and
    pi in .pi/skills, identically. One rule, every provider.

    2. Containment is not what is being enforced. I pointed a link at a sibling inside
    the same skills directory
    — it cannot escape anything — and it is still dropped:

    .claude/skills/e-real          (dir)              -> listed
    .claude/skills/e-link-sibling  -> e-real          -> dropped
    .claude/skills/e-link-abs      -> <abs>/e-real    -> dropped
    

    3. The rule is inverted, not merely strict. While in-repo entry links are refused, a
    non-recursive root link is followed straight out of the repository —
    .claude/skills -> /outside loads everything under it. So today bb blocks the link that
    cannot escape and follows the one that does. I filed that half separately as #2769 since it is
    the opposite failure and lands independently.

    The existing test that pins the current behavior only ever uses an outside target
    (command-discovery.test.ts:501),
    so the in-repository case looks unconsidered rather than deliberately refused — even
    though PR #92 (27361799e) did intend "keep project-origin symlinked skills skipped".

    On your suggested fix: it works, and it generalises. Replacing the origin check with
    the containment check the docblock already describes fixes commands and skills from one
    rule, reusing the boundaryPath that is already plumbed to every project root — no
    contract or HOST_DAEMON_PROTOCOL_VERSION change. Following linked leaf files only,
    and still skipping linked directories during the markdown walk, keeps your cycle and
    escape concerns intact.

    I have this implemented and tested against your repro shape and mine:

                                              main 8d926c3   with containment check
    .claude/commands/deploy.md -> in-repo      (none)         deploy
    .claude/commands/outside.md -> outside     (none)         (none)
    .claude/skills/h-linked -> in-repo         h-real         h-linked, h-real
    .claude/skills/c-link-out -> outside       c-real         c-real
    

    Happy to open it as a PR against this issue if that is welcome — or to split the skills
    half into its own issue if you would rather keep this one scoped to commands.

    AGENT GENERATED

  4. SawyerHood commented on Sep 18, 2026

    @SawyerHood
    Collaborator

    Consolidating #3856 here at the maintainer's request. This tracker's existing comments already reproduce the same project skill-directory symlink case, in addition to the command-file case in its title.

    Preserve the newer evidence: bb 0.43.1 / main e9de27c skips .claude/skills/nerd -> ../../.agents/skills/nerd even though the resolved target stays inside the repository. The same project-origin rule affects Pi. Independent reproduction in two clean checkouts failed for the project alias while real-directory and user-alias controls passed; the build and 26 existing discovery tests passed. Report: https://get-bb.github.io/reports/issues/3856.html

    Proposed implementation #3857 was closed without merging by the contributor gate; it is patch evidence, not a shipped fix. Its containment checks and regression test should be reviewed alongside both this tracker's command-file and skill-directory cases. Preserve rejection of links escaping the project boundary; #2769 tracks root containment separately, and #3238 concerns the distinct bb-user scanner.

    Closing #3856 consolidates tracking only. This issue remains open until the command and skill cases are addressed.

    AGENT GENERATED

  5. added
    confirmed-repro
    on Sep 30, 2026
  6. SawyerHood commented on Sep 30, 2026

    @SawyerHood
    Collaborator

    Verified command-file scanner report: https://get-bb.github.io/reports/issues/2602.html

    REPRODUCED in two clean checkouts: three readable in-project file aliases are omitted by the actual command scanner; regular and nested-file controls pass, and replacing the aliases with identical regular files restores all names. This adds the command-file evidence missing from the preserved #3856 skill-directory report. Live slash UI/provider behavior is not tested; #3857 remains closed unmerged.

  7. iandreitsev commented on Oct 21, 2026

    @iandreitsev

    Another use case for this tracker, with one difference: the links point outside the repository on purpose.

    I keep one canonical set of development skills in ~/.agents/dev-skills/ and attach it to every dev project with per-skill links, next to a few project-only skills that are real folders:

    <project>/.agents/skills/dev-task -> ~/.agents/dev-skills/dev-task
    <project>/.agents/skills/ozon-test-calc/   (real folder)
    <project>/.claude/skills -> ../.agents/skills
    

    Claude Code and Codex load all of them in bb threads. bb's picker and bb skill list --project show only the real folders (4 of ~25 in my case), so I have to remember the names of the rest.

    I understand that links escaping the project boundary should stay rejected by default. Could they be allowed as an explicit opt-in instead? For example:

    • a host or project setting that lets project skill roots follow links into listed directories (an allowlist such as ~/.agents/dev-skills), or
    • following such links only when the target is inside the user's home and the setting is on.

    Making the global skills user-level isn't a good alternative: they'd then load into every non-dev project and collide with built-in names such as code-review.

    bb 0.46.1, macOS, desktop.

    AGENT GENERATED

  8. brzvsk commented on Oct 22, 2026

    @brzvsk

    Additional reproduction on bb 0.46.1 desktop (macOS 26), project-root case.

    Layout: .agents/skills/<name> are 18 per-skill symlinks into one canonical catalog outside the project (../../managed-skills/catalog/...). OpenCode, Claude Code and Codex load all 18 natively inside bb threads.

    bb skill list --project <id> --environment <env> --json: zero project-scoped skills, no warning. Pointing a shared root at the same catalog materialized as real directories lists them normally, so discovery itself is fine — only the linked entries are refused.

    Workaround that works on 0.46.1: app-managed sharedSkillRoots user roots do follow symlinks. With sharedSkillRoots.user: ["<home>/projects/<repo>/.agents/skills"], all 18 appear as shared-user and reach the runtime /commands catalog (53 unique skill commands, no duplicates). It is global across projects, so it is not equivalent to per-project materialization.

    So project roots refuse linked entries while user roots follow them. If #2602 keeps the workspace containment rule, an explicit opt-in for links escaping the workspace (or documenting the shared-root workaround) would cover the common "one canonical skill set, link it into each repo" layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproprovider-claude-codeprovidersworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions