AgentSkillsCN

patch

无语言依赖的代码生成与变更传播。当您需要为实体新增字段、跨文件重命名符号,或对多文件产生影响的变更进行传播时,可使用此技能。触发条件包括:“新增字段”、“全网重命名”、“传播变更”、“生成迁移脚本”、“更新所有引用”。 这是“邪恶搜索”(仅支持只读操作)的代码变异版。

SKILL.md
--- frontmatter
name: patch
description: |
  Language-agnostic code generation and change propagation. Use this skill when
  adding fields to entities, renaming symbols across files, or propagating changes
  that affect multiple files. Triggered by: "add field", "rename everywhere",
  "propagate change", "generate migration", "update all references".

  This is the CODE MUTATION counterpart to wicked-search (which is read-only).

wicked-patch

Generate and propagate code changes across your entire codebase using the symbol graph.

Quick Start

bash
# 1. Index your codebase (if not already done)
/wicked-search:index /path/to/project

# 2. Add a field to an entity
/wicked-patch:add-field "Entity.java::User" --name email --type String

# 3. Rename a field everywhere
/wicked-patch:rename "Entity.java::User" --old status --new state

# 4. See propagation plan
/wicked-patch:plan "Entity.java::User" --change add_field

Commands

CommandPurpose
/wicked-patch:planShow what would be affected
/wicked-patch:add-fieldAdd field with propagation
/wicked-patch:renameRename across all usages
/wicked-patch:removeRemove field everywhere
/wicked-patch:applyApply saved patches

Supported Languages

ExtensionFeatures
.javaJPA @Column, getters/setters, validation
.pySQLAlchemy, Pydantic, dataclass
.ts, .jsTypeORM, interfaces, types
.jspSpring form tags, EL expressions
.sqlALTER TABLE (PostgreSQL, Oracle, MySQL, SQL Server)

How It Works

code
ChangeSpec (add field "email" to User)
           │
           ▼
   ┌───────────────────┐
   │ Propagation Engine │  ← Uses wicked-search lineage graph
   └───────────────────┘
           │
    ┌──────┼──────┬──────────┐
    ▼      ▼      ▼          ▼
  Java   Python   SQL      JSP
   │       │       │         │
   ▼       ▼       ▼         ▼
Patches  Patches Patches  Patches

Examples

Add Field to JPA Entity

bash
/wicked-patch:add-field "User.java::User" \
  --name email \
  --type String \
  --column USER_EMAIL \
  --required

Generates:

java
// User.java
@Column(name = "USER_EMAIL")
@NotNull
private String email;

public String getEmail() { return this.email; }
public void setEmail(String email) { this.email = email; }
sql
-- migration.sql
ALTER TABLE USERS ADD COLUMN USER_EMAIL VARCHAR(255) NOT NULL;

Rename Field Everywhere

bash
/wicked-patch:rename "Order.java::Order" --old status --new orderStatus

Updates:

  • Entity field declaration
  • Getters/setters
  • JSP form bindings (${order.status}${order.orderStatus})
  • Service layer references
  • Test files (with warning)

Save and Review Patches

bash
# Generate patches without applying
/wicked-patch:add-field SYMBOL --name foo --type String --output patches.json

# Review the patches file
cat patches.json

# Apply when ready
/wicked-patch:apply patches.json

Type Mappings

Generic types are automatically mapped per language:

GenericJavaPythonTypeScriptSQL
stringStringstrstringVARCHAR(255)
integerIntegerintnumberINTEGER
booleanbooleanboolbooleanBOOLEAN
dateLocalDatedateDateDATE
datetimeLocalDateTimedatetimeDateTIMESTAMP
decimalBigDecimalDecimalnumberDECIMAL(18,2)

SQL Dialect Support

Auto-detected or specify via --dialect:

sql
-- PostgreSQL (default)
ALTER TABLE users ADD COLUMN email VARCHAR(255);

-- Oracle
ALTER TABLE users ADD (email VARCHAR2(255));

-- MySQL
ALTER TABLE users ADD COLUMN email VARCHAR(255);

-- SQL Server
ALTER TABLE users ADD email NVARCHAR(255);

Integration with wicked-search

wicked-patch reads from the wicked-search symbol database:

bash
# 1. wicked-search creates the graph
/wicked-search:index /project --derive-all

# 2. wicked-patch uses it for propagation
/wicked-patch:add-field SYMBOL --name foo --type String

Safety Features

  • Dry-run by default: Shows patches without applying
  • Confirmation prompt: Asks before applying
  • Patch files: Save for review before applying
  • Warnings: Highlights test files and unsupported types
  • Reversible: Use git to undo

CLI Reference

bash
cd ${CLAUDE_PLUGIN_ROOT}/scripts
python3 patch.py --help
python3 patch.py generators  # List supported languages