Skills Plugins MCP Prompt Model 博客 我的中心

patch-creation

Create and register new patches for tweakcc. Use when adding new customizations to Claude Code.

DeepseekModel 官方收录技能 质量 优秀 · 90 v1.0.0

获取

https://deepseekmodel.com/api/download.php?id=piebald-ai-tweakcc-claude-skills-patch-creation-skill-md&format=skill
下载 .skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用
.skill 文件中 system_prompt 字段的实际内容。
name patch-creation description Create and register new patches for tweakcc. Use when adding new customizations to Claude Code. 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_DEFINITIONS array (id, name, group, description) Add to patchImplementations object (fn, condition) src/ui/components/MiscView.tsx - Add UI controls (optional) Patch Groups PatchGroup.ALWAYS_APPLIED - Core patches that are always applied PatchGroup.MISC_CONFIGURABLE - User-configurable misc settings PatchGroup.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 \b for 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 null on 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 build to compile Run npx tweakcc --apply to apply patches Check console output for patch success/failure Run Claude Code to verify behavior
Agent 识别该技能的关键词,点击任意一个即可复制。

该技能未提供触发词。

下载的 .skill 包内含以下字段。
字段 说明
format格式标识(skill/v1)
skill_id技能唯一 ID
name技能名称
version版本号
description技能描述
category所属分类(数组)
trigger_words触发词列表
tags标签列表
source来源标识
source_url来源链接(本页地址)
exported_at导出时间(每次下载生成)
system_prompt系统提示词正文
model_config模型参数:provider / model / temperature / max_tokens / top_p
examples示例
install_guide各平台导入说明(Coze / Dify / Claude / 自定义框架)
同一份技能可按不同平台格式导出。
.skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用 下载
.skillpro 增强格式,额外含脚本 / 工具 / 依赖 / 钩子占位 下载
.json 纯 JSON 导出,只含 system_prompt 与模型参数 下载
Coze 带 frontmatter 的 Markdown,Coze 平台导入用 下载
Dify Dify DSL,创建应用后直接导入 下载

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。