Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Create and register new patches for tweakcc. Use when adding new customizations to Claude Code.
.claude/skills/piebald-ai-patch-creation/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 18% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 40% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 34% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 24% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 11% | 0% |
Patches are code modifications applied to Claude Code's cli.js (or native binary). Each patch finds specific patterns in the minified code and replaces/injects new behavior.
Create src/patches/myPatch.ts:
`typescript// Please see the note about writing patches in ./index import { showDiff } from './index'; /** * Description of what this patch does. * * CC X.Y.Z: * ```diff * // Show before/after of the code change * -oldCode * +newCode * ``` */ export const writeMyPatch = ( file: string, configValue: string // Add parameters as needed ): string | null => { // Pattern to find in minified code // IMPORTANT: Use [$\w]+ for identifiers (not \w+) because $ is valid in JS identifiers // IMPORTANT: Start patterns with a boundary char (,;}{) for HIGH performance (e.g. 1.5s -> 30ms) const pattern = /,somePattern([$\w]+)/; const match = file.match(pattern); if (!match || match.index === undefined) { console.error('patch: myPatch: failed to find pattern'); return null; } const replacement = `,newCode${match[1]}`; const startIndex = match.index; const endIndex = startIndex + match[0].length; const newFile = file.slice(0, startIndex) + replacement + file.slice(endIndex); showDiff(file, newFile, replacement, startIndex, endIndex); return newFile; };
Edit src/types.ts - add to MiscConfig or create a new interface:
typescriptexport interface MiscConfig { // ... existing fields ... myNewSetting: string | null; // null = disabled }
Edit src/defaultSettings.ts:
typescriptmisc: { // ... existing fields ... myNewSetting: null, // or a sensible default },
Edit src/patches/index.ts:
4a. Add import:
typescriptimport { writeMyPatch } from './myPatch';
4b. Add patch definition (in PATCH_DEFINITIONS array):
typescript{ id: 'my-patch', name: 'My patch', group: PatchGroup.FEATURES, // or ALWAYS_APPLIED, MISC_CONFIGURABLE description: 'What this patch does for the user', },
4c. Add patch implementation (in patchImplementations object):
typescript'my-patch': { fn: c => writeMyPatch(c, config.settings.misc!.myNewSetting!), condition: !!config.settings.misc?.myNewSetting, },
Edit src/ui/components/MiscView.tsx to add a toggle or input for the setting.
| File | Purpose | | -------------------------------- | -------------------------------------------------- | | src/patches/*.ts | Individual patch implementations | | src/patches/index.ts | Patch registry, definitions, and application logic | | src/types.ts | Config type definitions (MiscConfig, etc.) | | src/defaultSettings.ts | Default values for all settings | | src/ui/components/MiscView.tsx | UI for misc settings |
When adding a new patch, update these locations:
src/patches/myPatch.ts - Create the patch file with exported functionsrc/types.ts - Add config type (if configurable)src/defaultSettings.ts - Add default value (if configurable)src/patches/index.ts:PATCH_DEFINITIONS array (id, name, group, description)patchImplementations object (fn, condition)src/ui/components/MiscView.tsx - Add UI controls (optional)PatchGroup.ALWAYS_APPLIED - Core patches that are always appliedPatchGroup.MISC_CONFIGURABLE - User-configurable misc settingsPatchGroup.FEATURES - Feature patches that can be enabled/disabled[$\w]+ for identifiers - Not \w+, because $ is valid in JS identifiers and common in minified code,, ;, {, } at the start to dramatically speed up matching (can reduce 1.5s to 30ms)\b for word boundaries - It doesn't treat $ as a word character, so \b[$\w]+ won't match ,$=} when you need the full functionshowDiff() for debugging - Always call it to log what the patch is changingnull on failure - Let the patch system know the patch couldn't be appliedtypescript// Bypass a feature flag check const pattern = /function [$\w]+\(\)\{return [$\w]+\("my_feature_flag"/; const match = file.match(pattern); if (!match || match.index === undefined) { console.error('patch: myPatch: failed to find feature flag'); return null; } const insertIndex = match.index + match[0].indexOf('{') + 1; const insertion = 'return true;'; const newFile = file.slice(0, insertIndex) + insertion + file.slice(insertIndex); showDiff(file, newFile, insertion, insertIndex, insertIndex); return newFile;
typescript// Replace a hardcoded value const pattern = /(someConfig=)\d+(;)/; const match = file.match(pattern); if (!match || match.index === undefined) { console.error('patch: myPatch: failed to find config value'); return null; } const replacement = match[1] + newValue + match[2]; const startIndex = match.index; const endIndex = startIndex + match[0].length; const newFile = file.slice(0, startIndex) + replacement + file.slice(endIndex); showDiff(file, newFile, replacement, startIndex, endIndex); return newFile;
npm run build to compilenpx tweakcc --apply to apply patches| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 11,766 | 6,165 | -48% | 1 | 1 | 0% | 2,550 | 3,000 | +18% | 0 | 0 | — |
case-02 | fail→pass | 11,103 | 6,129 | -45% | 1 | 1 | 0% | 2,119 | 2,958 | +40% | 0 | 0 | — |
case-03 | fail→pass | 10,191 | 4,911 | -52% | 1 | 1 | 0% | 1,901 | 2,543 | +34% | 0 | 0 | — |
case-04 | fail→pass | 13,826 | 6,325 | -54% | 1 | 1 | 0% | 2,219 | 2,750 | +24% | 0 | 0 | — |
case-05 | pass→pass | 13,611 | 5,264 | -61% | 1 | 1 | 0% | 2,349 | 2,550 | +9% | 0 | 0 | — |
case-06 | pass→pass | 12,983 | 1,730 | -87% | 1 | 1 | 0% | 2,032 | 1,983 | -2% | 0 | 0 | — |
case-07 | fail→pass | 12,146 | 3,538 | -71% | 1 | 1 | 0% | 2,182 | 2,415 | +11% | 0 | 0 | — |
case-08 | fail→pass | 10,013 | 2,036 | -80% | 1 | 1 | 0% | 1,498 | 1,972 | +32% | 0 | 0 | — |
case-09 | pass→pass | 8,972 | 1,531 | -83% | 1 | 1 | 0% | 1,666 | 1,894 | +14% | 0 | 0 | — |
case-10 | fail→pass | 12,623 | 1,603 | -87% | 1 | 1 | 0% | 1,849 | 1,927 | +4% | 0 | 0 | — |
case-11 | fail→pass | 10,734 | 1,353 | -87% | 1 | 1 | 0% | 1,790 | 1,808 | +1% | 0 | 0 | — |
case-12 | fail→pass | 9,645 | 1,582 | -84% | 1 | 1 | 0% | 1,486 | 1,868 | +26% | 0 | 0 | — |
case-13 | fail→pass | 28,633 | 6,803 | -76% | 1 | 1 | 0% | 2,769 | 2,968 | +7% | 0 | 0 | — |
case-14 | fail→pass | 7,015 | 1,282 | -82% | 1 | 1 | 0% | 1,173 | 1,876 | +60% | 0 | 0 | — |
case-15 | fail→pass | 5,589 | 1,520 | -73% | 1 | 1 | 0% | 1,033 | 1,883 | +82% | 0 | 0 | — |
case-16 | pass→pass | 11,967 | 4,903 | -59% | 1 | 1 | 0% | 2,070 | 2,665 | +29% | 0 | 0 | — |
case-17 | pass→pass | 16,464 | 6,734 | -59% | 1 | 1 | 0% | 2,774 | 2,912 | +5% | 0 | 0 | — |
case-18 | fail→pass | 17,616 | 11,180 | -37% | 1 | 1 | 0% | 2,628 | 3,560 | +35% | 0 | 0 | — |
case-19 | pass→pass | 17,303 | 5,996 | -65% | 1 | 1 | 0% | 2,862 | 2,680 | -6% | 0 | 0 | — |
case-20 | pass→pass | 7,479 | 6,263 | -16% | 1 | 1 | 0% | 1,341 | 2,471 | +84% | 0 | 0 | — |
case-21 | pass→pass | 8,433 | 8,904 | +6% | 1 | 1 | 0% | 1,623 | 3,304 | +104% | 0 | 0 | — |
case-22 | pass→pass | 13,998 | 8,050 | -42% | 1 | 1 | 0% | 2,534 | 3,130 | +24% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +59 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.