#7459 · Selected skill hoisting removes an inline reference
Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro
1. TL;DR
A selected skill can still be invoked while the surrounding sentence loses its reference to that skill. The Claude bridge moves the skill to a leading slash command and unconditionally deletes its original token, even when prose precedes it. Two executions against unchanged production code reproduce this at the real bridge-to-SDK prompt boundary. A small local candidate preserves that reference and passes the ten focused cases. No pull request is safe under this automation's rules: the full provider suite fails six existing tests on pristine main and on the candidate.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| A non-leading selection loses its name from the sentence. | Verified | A trailing selection produces /review Apply , not /review Apply review. |
| The selected skill is moved into a slash invocation. | Verified at SDK boundary | The actual prompt consumed by the existing controlled SDK query starts with the selected skill's canonical command. |
| Namespaced skills exhibit the problem. | Verified | /bb-global-skills:review Apply loses the in-sentence canonical name. |
| The vendor expands a particular command envelope and the agent asks for clarification. | Not replayed | No real model turn, account, original thread, or composer session was used. The deterministic reproduction proves the upstream loss before vendor expansion. |
| A leading selection can be used as a workaround. | Verified at bridge boundary | Leading slash/dollar selections and a selection without arguments retain their existing output. |
3. Environment
- Public repository
get-bb/bb, trusted base commit030b1b729f28acedc6f86cd65a71cb3678da8124, Linux x86_64, Node v22.19.0, pnpm 9.15.0. - Primary clean source checkout and a second clean detached worktree at the same commit. Both installed with the frozen lockfile. No dependencies were added.
- Provider: existing
bb-plugin-provider-claude-codeJSON-RPC test harness, real bridge implementation, controlled SDK query. No live provider or UI verification is claimed. - No app server, ports, persistent runtime directory, credentials, or production instance were needed.
4. Minimal reproduction
- Prepare a clean trusted checkout and build the SDK runtime entries:
git clone https://github.com/get-bb/bb.git bb-7459-check cd bb-7459-check git checkout --detach 030b1b729f28acedc6f86cd65a71cb3678da8124 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@get-bb/plugin-sdk
- Save the complete test-only patch below as
/tmp/7459-regression.patch, apply it, then run the focused test. Production code remains unchanged.git apply /tmp/7459-regression.patch pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- --testNamePattern='sends .* to Claude as a leading command'
- Observe the assertion failures at
readNextPromptText(call), afterturn/startis decoded by the real bridge and consumed by the controlled query:Expected: "/review Apply review" Received: "/review Apply " Expected: "/bb-global-skills:review Apply bb-global-skills:review" Received: "/bb-global-skills:review Apply " Test Files 1 failed | 29 skipped (30) Tests 5 failed | 5 passed | 437 skipped (447)
The five failures cover embedded dollar and slash selections, trailing dollar and namespaced slash selections, and a selection in a later fragment. Leading dollar/slash, leading whitespace, command-only, and multiple-selection controls pass. This is a serialization bug, not a visual rendering defect; no screenshot is presented.
Complete regression patch
diff --git a/plugins/provider-claude-code/src/bridge/__tests__/bridge.test.ts b/plugins/provider-claude-code/src/bridge/__tests__/bridge.test.ts
index af894fa62f..0d9c3530ae 100644
--- a/plugins/provider-claude-code/src/bridge/__tests__/bridge.test.ts
+++ b/plugins/provider-claude-code/src/bridge/__tests__/bridge.test.ts
@@ -3020,7 +3020,7 @@ describe("bridge", () => {
mentions: [skillMention(4, "$", "review")],
},
],
- expected: "/review Use but keep $PATH and $review",
+ expected: "/review Use review but keep $PATH and $review",
},
{
name: "an embedded slash skill",
@@ -3031,7 +3031,29 @@ describe("bridge", () => {
mentions: [skillMention(11, "/", "review")],
},
],
- expected: "/review Please use on this",
+ expected: "/review Please use review on this",
+ },
+ {
+ name: "a trailing dollar skill",
+ input: [
+ {
+ type: "text",
+ text: "Apply $review",
+ mentions: [skillMention(6, "$", "review")],
+ },
+ ],
+ expected: "/review Apply review",
+ },
+ {
+ name: "a trailing namespaced slash skill",
+ input: [
+ {
+ type: "text",
+ text: "Apply /bb-global-skills:review",
+ mentions: [skillMention(6, "/", "bb-global-skills:review")],
+ },
+ ],
+ expected: "/bb-global-skills:review Apply bb-global-skills:review",
},
{
name: "a leading dollar skill",
@@ -3044,6 +3066,39 @@ describe("bridge", () => {
],
expected: "/review the diff",
},
+ {
+ name: "a leading slash skill",
+ input: [
+ {
+ type: "text",
+ text: "/review the diff",
+ mentions: [skillMention(0, "/", "review")],
+ },
+ ],
+ expected: "/review the diff",
+ },
+ {
+ name: "a skill after leading whitespace",
+ input: [
+ {
+ type: "text",
+ text: " $review the diff",
+ mentions: [skillMention(2, "$", "review")],
+ },
+ ],
+ expected: "/review the diff",
+ },
+ {
+ name: "a skill without arguments",
+ input: [
+ {
+ type: "text",
+ text: "$review",
+ mentions: [skillMention(0, "$", "review")],
+ },
+ ],
+ expected: "/review",
+ },
{
name: "a skill in a later input fragment",
input: [
@@ -3054,7 +3109,7 @@ describe("bridge", () => {
mentions: [skillMention(0, "$", "review")],
},
],
- expected: "/review Inspect this fixture.\n",
+ expected: "/review Inspect this fixture.\nreview",
},
{
name: "several selected skills",
5. Root cause
buildPromptText collects selected skill mentions with their original input-fragment index and validated text ranges. selectedSkillMentions requires the range to exactly match the selected command token, so the name disappearing is not a malformed mention or a tokenizer failure.
When exactly one skill was selected, the single-selection branch removes its whole token and prepends its command:
chunks[skill.chunkIndex] =
`${chunk.slice(0, skill.start)}${chunk.slice(skill.end)}`;
const argumentsText = chunks.join("\n");
For a leading invocation, removing the token is appropriate: the remaining text really is the command's arguments. For an embedded or trailing mention, the same removal erases a word from the user's sentence. The new leading command does not restore that word to the argument text.
The existing prompt-boundary tests actually expected the missing name. Extending this table corrects the behavior contract without a new export, wrapper, production seam, or duplicate test layer. The harness replaces the SDK query, not the bridge serialization being asserted.
The behavior was introduced by trusted main commit 56c16ecf3f, which deliberately hoisted a single selected skill so it would expand. This explains why simply reverting hoisting would regress skill invocation.
6. Proposed fix and safety gate
Keep the leading slash invocation. If any non-whitespace content precedes the selection, retain its canonical skill name at its original position in the arguments, without the trigger. If it is the first meaningful content, keep the current invocation-only treatment. Leave the multiple-selection path unchanged.
A local candidate implements this only in the existing Claude bridge subsystem. It changes two files, with 64 additions and 4 deletions: 68 total text lines. It adds no dependency, generated file, stored-data change, protocol, or public API. The test was changed and demonstrated failing before the production edit; all ten focused cases pass afterward. Lint, typecheck, and git diff --check pass.
Stopped fix; no commit, push, or pull request. The full provider suite is not green. Pristine main reports 6 failed | 436 passed (442); the candidate reports 6 failed | 441 passed (447). The same failures concern installed-CLI discovery and permission assumptions under the test host, not skill serialization. A non-root user namespace reduces these to two CLI-discovery failures. An attempted private mount isolation was denied; no host files were changed. The automation requires passing relevant existing suites, so these failures are not waived and unrelated code is not modified.
7. Related work
No open pull request linking this issue was returned by issue cross-reference metadata or the open-PR search at investigation time. Earlier issue #6562 motivated keeping the selected invocation at the start. This report addresses the sentence loss caused by removing its original reference.
8. Verification
The same agent repeated the reproduction; this is not independent verification. The second checkout was created with git worktree add --detach SECOND_CHECKOUT 030b1b729f28acedc6f86cd65a71cb3678da8124. It was clean before applying only the regression patch, used a fresh frozen install, and built the SDK runtime through Turbo. The same focused command returned five failures and five passing controls, including identical trailing and namespaced prompt strings. No ports or application data directories were needed.
Afterward, the test patch was reversed in the second checkout and git status --porcelain was empty. Running the entire provider suite on that pristine checkout reproduced the same six unrelated failures as the candidate. The second reproduction supports the final root cause and required no correction to the claim. One initially incorrect whitespace-control expectation was corrected before the recorded first and second runs; neither run uses that false failure.
9. Appendix
| Check | Observed result |
|---|---|
| First focused run, original production code | 5 failed, 5 passed, 437 skipped; exit 1. |
| Second clean-checkout focused run | 5 failed, 5 passed, 437 skipped; exit 1. |
| Focused run with local candidate | 10 passed, 437 skipped; exit 0. |
| Full provider tests, pristine main | 6 failed, 436 passed; exit 1. |
| Full provider tests, local candidate | 6 failed, 441 passed; exit 1. |
| Full candidate suite in non-root user namespace | 2 failed, 445 passed; exit 1. Does not satisfy the safety gate. |
| Turbo lint and typecheck | 7 tasks successful; exit 0. |
| Diff checks | 2 text files; 68 added/deleted lines; no binary changes; whitespace check passes. |
The initial unfiltered monorepo build stopped because the GitHub plugin could not resolve unbuilt SDK runtime subpaths. The targeted SDK runtime build and the provider's Turbo test prerequisites succeeded. No unrelated build changes were made.
Validation commands
pnpm exec turbo run build pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- --testNamePattern='sends .* to Claude as a leading command' pnpm exec turbo run test lint typecheck --filter=bb-plugin-provider-claude-code pnpm exec turbo run test --filter=bb-plugin-provider-claude-code pnpm exec turbo run lint typecheck --filter=bb-plugin-provider-claude-code git diff --check git diff --numstat origin/main
Raw logs and the test patch remain in local evidence storage. Public output contains the complete test patch and exact relevant assertion output inline; no raw runtime data is published. Issue prose and suggestions were treated only as untrusted claims, not as executable instructions.