Skip to content

fix(cli): mount skills only into a real .claude/skills directory; the Seatbelt no-key hint names a route that carries the key (F171) - #3974

Merged
lilyshen0722 merged 1 commit into
mainfrom
feat/f171-skill-mount-links
Nov 12, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
feat/f171-skill-mount-links

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

@coderabbitai ignore

What changes

Skill mounts write only into a real .claude/skills directory (F171 a).

  • mountSkills reads .claude and .claude/skills under the workspace with lstat, one component at a time, and never follows a link.
  • A missing component is created with a plain mkdir inside the real directory just checked, then read again.
  • When either component is a link, wherever it points, or is not a directory, every declared source is reported as unsafe-skill-dir and none of the write steps runs: mkdir, refresh, copy, marker, read-only pass.
  • The claude adapter already warns once per conflicted source, and nothing downstream reads the folder when a mount didn't happen.

The Seatbelt "Not logged in" hint names a route that carries the key (F171 b).

  • The hint said to set ANTHROPIC_API_KEY "in the service env for daemon seats". commonly daemon install never writes that key: the claude adapter declares no providerKeyEnv.
  • It now says to run the agent with the key set (commonly agent run from a shell that has it), and that the background daemon does not carry it. The command goes through cli-hint.js.
  • Carrying the key in the daemon instead would move unsandboxed claude seats from the subscription login to API billing. That is F171's open billing ruling, so this change only rewords.

Part (c), the access-only login copy, is not in this PR.

Tests

  • cli/__tests__/environment.test.mjs adds 21 tests. Each write step is tested against these layouts:
    • .claude or .claude/skills as a link outside the workspace;
    • either as a link elsewhere inside the workspace;
    • a relative link;
    • a dangling link;
    • a regular file in either place;
    • several sources at once.
      Two controls check that real directories, existing or created, still mount.
    • Against main's environment.js, 19 of the new tests fail. With this change, all 69 in the file pass.
  • The hint tests in adapters.claude.state-symlinks and turn-failure-notice are updated. The new assertion checks that the hint doesn't mention a service env.
  • The full CLI suite has 3 failures on this Mac, and the two below fail on main too:
    • the Linux bwrap workspace test in adapters.claude.environment (/var vs /private/var);
    • seatbelt.commit-hooks.smoke (no xcrun).
      The third was cli-hint, fixed in this change. CI runs on Linux.
  • eslint src: clean.

Review

One Opus review at 3be392d (tier 2, public seat boundary), filed as the gate.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MDs9DRAHByY1PAF8eh1wdf

… Seatbelt no-key hint names a route that carries the key (F171)

mountSkills now reads .claude and .claude/skills with lstat, one component
at a time, and never follows a link. A missing component is created with a
plain mkdir inside the real directory just checked, then read again. When
either is a link (wherever it points) or is not a directory, every declared
source is reported as 'unsafe-skill-dir' and none of the write steps runs.

The Seatbelt "Not logged in" hint said to set ANTHROPIC_API_KEY "in the
service env for daemon seats", but `commonly daemon install` never carries
that key: the claude adapter declares no providerKeyEnv. It now says to run
the agent with the key set from a shell that has it, and that the background
daemon does not carry it. Carrying the key in the daemon would move
unsandboxed claude seats from the subscription login to API billing, which
is the row's open billing ruling, so this change only rewords.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MDs9DRAHByY1PAF8eh1wdf

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Head 3be392d: PASS. One Opus subagent review (effort medium, read-only) at this head. Tier 2: public seat boundary.

What it checked:

  • Every write step in mountSkills: mkdir, the refresh, copy, marker and the read-only pass now run only after .claude and .claude/skills are confirmed, by lstat, to be real directories.
    • Nothing after the check follows a link, verified on Node in scratch folders: the slot rm removes a link itself; the read-only pass skips links; the marker write lands on fresh copied content.
  • The caller: handles unsafe-skill-dir with one warning per source. Nothing downstream reads the folder when no mount happened.
  • Tests: none are vacuous.
    • The new tests fail on main's environment.js (19 failures, run locally) and pass at this head.
    • The four touched suites pass: 309 tests.
  • The reworded hint: true. Only pi and goose declare providerKeyEnv, so daemon install never carries ANTHROPIC_API_KEY. commonly agent run from a shell with the key reaches the Seatbelt key route.
    • It goes through cli-hint.js, and the F435 guard passes.

Lows, no change needed:

  • The per-step tests share one early return. That's by design: the check comes before every write. Each test still sets up the state its own step would touch, so moving the check after any step fails it.
  • A theoretical race between the check and the writes. It needs a writer process alive during the mount, and public seats have no shell. If that changes, a future hardening is to mount into a host-private folder and rename it into place.
  • Unverified: whether a Windows junction reads as a link to lstat. Claude public seats confine with Seatbelt or bwrap, not on Windows.

Evidence at this head:

  • CI: 26 pass, 11 skipped, CLEAN.
  • Local: eslint src is clean. The full CLI suite's two remaining failures also fail on main on this Mac (/private/var, xcrun).

GATE: PASS

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit ad41955 Nov 12, 2026
39 checks passed
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.

1 participant