patch-creation
Create and register new patches for tweakcc. Use when adding new customizations to Claude Code.
Install
mkdir -p .claude/skills/patch-creation && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4681" && unzip -o skill.zip -d .claude/skills/patch-creation && rm skill.zipInstalls to .claude/skills/patch-creation
About this skill
Patch Creation & Registration
Overview
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.
Creating a New Patch
1. Create the patch file
Create src/patches/myPatch.ts:
// 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;
};
2. Add config type (if patch is configurable)
Edit src/types.ts - add to MiscConfig or create a new interface:
export interface MiscConfig {
// ... existing fields ...
myNewSetting: string | null; // null = disabled
}
3. Add default value
Edit src/defaultSettings.ts:
misc: {
// ... existing fields ...
myNewSetting: null, // or a sensible default
},
4. Register in index.ts
Edit src/patches/index.ts:
4a. Add import:
import { writeMyPatch } from './myPatch';
4b. Add patch definition (in PATCH_DEFINITIONS array):
{
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):
'my-patch': {
fn: c => writeMyPatch(c, config.settings.misc!.myNewSetting!),
condition: !!config.settings.misc?.myNewSetting,
},
5. Add UI (optional)
Edit src/ui/components/MiscView.tsx to add a toggle or input for the setting.
Key Files
| 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 |
Registration Checklist
When adding a new patch, update these locations:
-
src/patches/myPatch.ts- Create the patch file with exported function -
src/types.ts- Add config type (if configurable) -
src/defaultSettings.ts- Add default value (if configurable) -
src/patches/index.ts:- Import the patch function
- Add to
PATCH_DEFINITIONSarray (id, name, group, description) - Add to
patchImplementationsobject (fn, condition)
-
src/ui/components/MiscView.tsx- Add UI controls (optional)
Patch Groups
PatchGroup.ALWAYS_APPLIED- Core patches that are always appliedPatchGroup.MISC_CONFIGURABLE- User-configurable misc settingsPatchGroup.FEATURES- Feature patches that can be enabled/disabled
Pattern Writing Tips
-
Use
[$\w]+for identifiers - Not\w+, because$is valid in JS identifiers and common in minified code -
Start patterns with boundary characters - Use
,,;,{,}at the start to dramatically speed up matching (can reduce 1.5s to 30ms) -
Don't use
\bfor word boundaries - It doesn't treat$as a word character, so\b[$\w]+won't match,$= -
Extract function bodies carefully - Count braces to find matching
}when you need the full function -
Use
showDiff()for debugging - Always call it to log what the patch is changing -
Return
nullon failure - Let the patch system know the patch couldn't be applied -
Handle multiple CC versions - Code patterns may change between versions; try multiple patterns if needed
Example: Simple Toggle Patch
// 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;
Example: Replace a Value
// 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;
Testing
- Run
npm run buildto compile - Run
npx tweakcc --applyto apply patches - Check console output for patch success/failure
- Run Claude Code to verify behavior
You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversConnect Blender to Claude AI for seamless 3D modeling. Use AI 3D model generator tools for faster, intuitive, interactiv
JsonDiffPatch: compare and patch JSON with a compact delta format capturing additions, edits, deletions, and array moves
Create modern React UI components instantly with Magic AI Agent. Integrates with top IDEs for fast, stunning design and
Structured spec-driven development workflow for AI-assisted software development. Creates detailed specifications before
Effortlessly create 25+ chart types with MCP Server Chart. Visualize complex datasets using TypeScript and AntV for powe
Vizro creates and validates data-visualization dashboards from natural language, auto-generating chart code and interact
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.