Skip to content

fix(claude-code): hoist a selected skill to the front of the prompt - #6576

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-broken-link-in-documentation-thr_qxhkw7c2ae
Oct 29, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-broken-link-in-documentation-thr_qxhkw7c2ae

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Claude Code expands a skill only when its /skill-name command leads the prompt. When a user selected a skill mid-sentence or in a later input fragment, the Claude bridge only swapped $ for / in place, so the command stayed embedded and Claude treated it as plain text. The skill body never reached the model. Skills with disable-model-invocation: true had no fallback, because the model can't load them through the Skill tool. Investigation report: https://get-bb.github.io/reports/issues/6562.html

What changed

  • plugins/provider-claude-code/src/bridge/bridge.ts (buildPromptText): when exactly one skill is selected, the bridge removes its token from the text and sends /<skill> <remaining text>. This matches the Pi provider (plugins/provider-pi/src/bridge/turn-input.ts). With multiple selections, the existing in-place $ to / translation still applies, since only one command can lead.
  • No wire, protocol, CLI, or SDK changes.

How you verified

  • Turned the bridge test into a table: mid-sentence $ skill, mid-sentence / skill, leading skill, skill in a later input fragment, and multiple skills. On unchanged production code, the three non-leading single-skill cases fail; with the fix, all five pass.
  • Ran the real @anthropic-ai/claude-agent-sdk against a local capture endpoint with a disable-model-invocation: true fixture skill. The skill body reaches the outgoing model request for the prompt shapes the fix produces (/manual-probe Please use to inspect the fixture, /manual-probe Inspect this fixture.\n), and not for the old embedded form (Please use /manual-probe to inspect the fixture).
  • pnpm exec turbo run test lint typecheck --filter=bb-plugin-provider-claude-code: 414/414 tests pass; lint and typecheck are clean.

Fixes #6562

🤖 Generated with Claude Code

AGENT GENERATED

Claude Code only expands a slash command that leads the prompt. When a user
picked a skill mid-sentence or in a later input fragment, the bridge only
swapped "$" for "/" in place, so the skill body never reached the model. Skills
with disable-model-invocation: true could not be recovered through the Skill
tool either.

When exactly one skill is selected, remove its token and send
"/<skill> <remaining text>", matching the Pi provider. Multiple selections keep
the existing in-place translation.

Fixes #6562

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 56c16ec into main Oct 29, 2026
31 checks passed
@ymichael
ymichael deleted the bb/fix-broken-link-in-documentation-thr_qxhkw7c2ae branch October 29, 2026 20:34
ymichael added a commit that referenced this pull request Oct 29, 2026
…it (#6581)

## Human comments

## What was wrong

A composer pill (skill, file, thread, …) is an atomic node whose text
(`/poteto-mode`, `@src/foo.ts`) was joined directly to the text beside
it. The only separator was the space the picker inserts at pick time,
and that space is easy to lose:
- Send trims it when the pill is the last token.
- History recall and queued/sent-message edit rebuild the draft from
that trimmed text, leaving the caret right after the pill.
- Voice insertion reads the pill as `"\n"` and decides it needs no
leading space.
- Deleting the space by hand.

Text typed next to the pill is then sent glued to it (`/poteto-modeAlso
testing`). The pill has a border but no margin, so it looks separated on
screen. The model and `bb thread log` see the corrupted word, and a file
pill sends a broken path. Investigation report:
https://get-bb.github.io/reports/issues/2318.html

Since #6576, all three providers (Claude Code, Codex, Pi) find a skill
by its mention range, so the glue no longer stops the skill from
running. This PR fixes the text.

## What changed

- `plugins/composer/src/editor/prompt-editor-serialization.ts`: when the
editor contents are turned into text, one space is emitted where a pill
directly touches a letter, a digit or another pill on the same line.
  - Punctuation is left alone: `@foo.ts,` stays as typed.
- The separator is not mapped in `offsetMapping`, like the `"\n"` for
hard breaks. Mention ranges still cover exactly the pill text.
- The editor document is untouched, so the caret, undo and IME
composition are unaffected.
- This covers every entry path: typing, restore, voice, paste and copy.
- I considered and rejected giving the pill node a `leafText`. An
explicit `leafText` argument to `textBetween` takes priority over the
node spec, every caller passes `"\n"`, and trigger detection relies on
the pill reading as a line break.
- No wire, protocol, CLI or SDK changes.

## How you verified

- New serialization table in `prompt-editor-serialization.test.ts`:
  - Pill/word, word/pill, pill/pill and pill-in-quote cases separate.
  - Each result is stable when converted back and forth.
  - Punctuation, whitespace and line breaks are unchanged.
- Two `PromptBoxInternal` tests: typing after a restored trailing pill,
and a voice transcript inserted after it.
- The separation cases and both composer tests fail on unchanged code
and pass with the fix.
- `pnpm exec turbo run test typecheck lint
--filter=bb-plugin-bb--composer --filter=@bb/app` passes (96 + 6,474
tests).
- Live, on an isolated dev app with Claude Code:
- Picked a skill, deleted the space the picker added, typed `Also
testing`. The editor had the pill directly followed by the text; the
server stored `I am lost. /poteto-mode Also testing` with the mention on
`/poteto-mode`.
- Typing `, then reply.` straight after a pill was stored as
`/poteto-mode, then reply.`.

Fixes #2318

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Claude can't see skills that have disable-model-invocation: true when you invoke the skill directly.

1 participant