Skip to content

Instantly share code, notes, and snippets.

@anthrotype
Created February 25, 2026 10:54
Show Gist options
  • Select an option

  • Save anthrotype/2f2a9e74383bd0e267ecd566fefe759e to your computer and use it in GitHub Desktop.

Select an option

Save anthrotype/2f2a9e74383bd0e267ecd566fefe759e to your computer and use it in GitHub Desktop.
Skill to help Claude update thinking and tool-visibility patches from https://github.com/aleks-apostle/claude-code-patches/pull/9 and pull/12
name description
update-patches
Update both patch scripts (thinking visibility + tool visibility) for new Claude Code versions. Use this skill when: (1) A new Claude Code version is released and the patches need updating (2) Either patch reports "Pattern not found" errors (3) User asks to update/fix patches for a new version (4) User mentions claude code version number and patch in the same request

Update Patches for New Claude Code Versions

Claude Code's minified JavaScript changes with each release. This skill guides updating both patch scripts to match new minified patterns:

  1. patch-thinking.js — Forces thinking content to always be visible
  2. patch-tool-visibility.js — Forces Read/Glob/Grep tool calls to show individual file paths instead of collapsed summaries

Process

1. Install New Version in Temp Directory

rm -rf /tmp/claude-code-test && mkdir -p /tmp/claude-code-test && cd /tmp/claude-code-test && npm init -y && npm install @anthropic-ai/claude-code@<VERSION>

Replace <VERSION> with target version (e.g., 2.1.42) or omit for latest.

2. Find New Patterns

Thinking Visibility Pattern:

perl -nle 'while (/(case"thinking":\{if\(![A-Za-z_]+&&![A-Za-z_]+(?:&&![A-Za-z_]+)?\)return null;let [A-Za-z]+=.{50,300}isTranscriptMode:[A-Za-z]+,(?:verbose:[A-Za-z_]+,)?hideInTranscript:[A-Za-z]+\}[^}]*\})/g) { print $1 }' /tmp/claude-code-test/node_modules/@anthropic-ai/claude-code/cli.js

Tool Visibility Pattern:

perl -nle 'print $1 if /(case"collapsed_read_search":return [A-Za-z0-9]+\.createElement\([A-Za-z0-9]+,\{[^}]+\}\))/' /tmp/claude-code-test/node_modules/@anthropic-ai/claude-code/cli.js

3. Extract Pattern Elements

From the thinking pattern, extract:

  • Variable checks: Letters in if(!X&&!Y) or if(!X&&!Y&&!Z) (may be 2 or 3 checks)
  • createElement namespace: Before .createElement (e.g., g5)
  • Component name: First createElement arg (e.g., Kf1)
  • Memo cache indices: q[N] values
  • Props: Note any new props (e.g., verbose:_ was added in v2.1.56)
  • hideInTranscript: Expression to set to !1

From the tool visibility pattern, extract:

  • createElement namespace: Before .createElement (e.g., F5)
  • Collapsed renderer component: First createElement arg (e.g., yQ4)
  • Verbose variable: The value of verbose: prop (e.g., w)
  • Other prop variable names: message, inProgressToolUseIDs, shouldAnimate, tools, lookups, isActiveGroup

4. Update patch-thinking.js

Version strings (2 locations, ~line 16 and ~line 30):

console.log('Claude Code Thinking Visibility Patcher v<NEW_VERSION>');

Search/Replace patterns (~line 190-191): Update thinkingSearchPattern and thinkingReplacement with new variable names. The replacement removes the guard (if(...)return null), forces isTranscriptMode:!0 and hideInTranscript:!1. Any other props (e.g., verbose:_) should be preserved as-is in the replacement.

Comments (~line 179-189): Update version notes.

5. Update patch-tool-visibility.js

Version strings (2 locations, ~line 16 and ~line 36):

console.log('Claude Code Tool Visibility Patcher v<NEW_VERSION>');

Search/Replace patterns (~line 180-181): Update toolVisSearchPattern and toolVisReplacement with new variable names. The replacement changes verbose:<VAR> to verbose:!0. Everything else stays the same.

Comments: Update version notes.

6. Update README.md

Add new version to:

  • Patch 2 history (~line 156)
  • Version table (~line 455)
  • "Current Version" header (~line 25)
  • Prerequisites (~line 161)
  • Verification commands (~line 270)
  • Footer (~line 696)

7. Test Both Patches

# Verify both patterns exist
node patch-thinking.js --dry-run
node patch-tool-visibility.js --dry-run
# Both should show "Pattern found - ready to apply"

8. Update This Skill File

After completing the updates, update this skill file itself so it stays accurate for the next round:

  1. Pattern Reference tables: Add a new row for the version you just updated to, recording the component name, variable names, createElement namespace, memo indices, and any structural notes.

  2. Regex patterns in Step 2: If the new version introduced structural changes not covered by the current regex (e.g., new guard checks, new props), update the perl regex to match the new pattern shape. Use optional groups (?:...)? to keep backward compatibility with older patterns.

  3. Step 3 "Extract Pattern Elements": If new props or structural elements appeared, add them to the extraction checklist.

  4. Step 4/5 instructions: If the replacement strategy changed (e.g., a new prop that must be preserved, or a prop that should be forced), update the instructions accordingly.

Why: This skill is the institutional memory for how patterns evolve across versions. If it falls behind, the next update round will miss important context.

9. Commit Changes

Commit the updated patch files, README, and any other changed files:

git add patch-thinking.js patch-tool-visibility.js README.md
git commit -m "Update patches for Claude Code v<VERSION>"

Pattern Reference — Thinking Visibility

Version Component Vars createElement NS Memo indices Notes
2.0.62 X59 F,G Last with separate banner
2.0.71 mn2 H,G Banner deprecated
2.0.73 Gt2 D,Z
2.0.75 co2 D,Z
2.0.76 lo2 D,Z
2.1.2 ybA F,Z o8 Added hideInTranscript, {} braces
2.1.6 _bA F,Z
2.1.7 gkA F,Z
2.1.12 fI1 D,H,T Added memo cache
2.1.17 oG1 D,H,T
2.1.19 oG1 D,H,T
2.1.20 Ej1 D,H,T
2.1.22 iM1 D,H,T
2.1.31 _j6 j,V K9 q[21] Verbose removed
2.1.34 sD6 M,Z I5 q[21]
2.1.37 Mj6 j,Z b5 q[21]
2.1.39 pM6 j,Z F5 q[22]
2.1.42 dW6 D,Z F5 q[22]
2.1.44 dW6 D,Z F5 q[22] Unchanged from 2.1.42
2.1.56 Kf1 X,V,_ g5 q[22] 3 guard checks, verbose prop added, 6 memo slots

Pattern Reference — Tool Visibility

Version createElement NS Collapsed Renderer Verbose Var Props (msg, ids, anim, tools, lookups, group)
2.1.42 F5 yQ4 w A, H, O, Y, q, M
2.1.44 F5 SQ4 w A, H, O, Y, q, M
2.1.56 g5 Mc4 w A, _, H, Y, q, M

Troubleshooting

  • "Pattern not found": Run this update process for the affected patch
  • No banner function: Normal since v2.0.71 (thinking patch), mark as deprecated
  • collapsed_read_search not found: The string literal is stable; if missing, the feature may have been restructured
  • Multiple matches: Make search pattern more specific
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment