Skip to content

Recognize the function-returned slash command list of Claude Code 2.1.227+ - #953

Merged
bl-ue merged 1 commit into
Piebald-AI:mainfrom
VitalyOstanin:fix/slash-command-list-return-form
Aug 17, 2026
Merged

Recognize the function-returned slash command list of Claude Code 2.1.227+#953
bl-ue merged 1 commit into
Piebald-AI:mainfrom
VitalyOstanin:fix/slash-command-list-return-form

Conversation

@VitalyOstanin

Copy link
Copy Markdown
Contributor

Addresses the clear-screen half of #942.

Problem

Every patch that registers a slash command — clear-screen, conversation-title, toolsets — fails on recent Claude Code releases:

patch: findSlashCommandListEndPosition: failed to find arrayStartPattern
patch: writeSlashCommandDefinition: failed to find slash command array end position

findSlashCommandListEndPosition only scanned =>[ candidates. Claude Code moved the built-in command list out of an arrow-returned array and into the body of a named function (which a builtinCommandTable cache then memoizes), so there is no arrow-return candidate left to find. On 2.1.233 the list reads:

function $tS(){return[uOd,Wza,lHf,KKp,sPa,LYp,Sui,...t5n("fleetFork"),nEf,/* ... */,...h0f,...[]]}

Per #942 the failure starts with Claude Code 2.1.227; I verified the new shape on 2.1.233.

Fix

Accept return[ alongside =>[ as a candidate opener. Everything downstream is unchanged: the candidate still has to sit within 12k characters of name:"…" … description: and still has to contain at least 30 top-level items.

Verification

Ran the old and the new scan over every extracted bundle I have (2.1.88, 2.1.89, 2.1.92, 2.1.98, 2.1.113, 2.1.126, 2.1.144, 2.1.183, 2.1.195, 2.1.201, 2.1.204, 2.1.214, 2.1.219, 2.1.233):

  • On all 13 pre-2.1.227 bundles the new scan returns the exact same closing bracket as the old one, so the injected definition lands byte-identically.
  • On 2.1.233 the old scan returns null; the new one finds the 130-item list.
  • Exactly one candidate passes the anchor + item-count filter on every bundle, including 2.1.233 — the looser opener does not introduce ambiguity.
  • Worst case cost, a 26.6 MB already-patched bundle: 252 ms (the old pattern was ~44 ms on a raw bundle, the new one ~106 ms).

Applied to a real 2.1.233 native binary: clear-screen and a local command-registering patch both apply, and the resulting binary runs (2.1.233 (Claude Code)) with the new commands resolving.

New src/patches/slashCommands.test.ts covers both shapes, the small-array and no-anchor rejections, largest-candidate selection, and insertion through writeSlashCommandDefinition. Full suite, tsc, ESLint and Prettier are clean.

….227+

Claude Code moved the built-in slash command list out of an arrow-returned
array into a named function body, so the `=>[` scan in
findSlashCommandListEndPosition found no candidate at all and every patch
that registers a command failed with "failed to find arrayStartPattern".

Accept `return[` alongside `=>[`. The >= 30 item count and the
name/description anchor still select a single candidate: on the 2.1.195,
2.1.204, 2.1.214 and 2.1.219 bundles the new scan returns the exact same
closing bracket as before, and on 2.1.233 it finds the 130-item list.
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bl-ue
bl-ue enabled auto-merge (squash) August 17, 2026 17:50
@bl-ue
bl-ue merged commit 50aff66 into Piebald-AI:main Aug 17, 2026
2 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.

2 participants