[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6BYWTS1QWJY0MCQVPGDHFV2":3,"skill-same:01M6BYWTS1QWJY0MCQVPGDHFV2":63},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":15,"repositoryHtmlUrl":45,"repositoryHomepageUrl":17,"ownerHtmlUrl":46,"ownerBlogUrl":47,"ownerDescription":17,"updatedAt":48,"install":49,"resources":62},"01M6BYWTS1QWJY0MCQVPGDHFV2","refactor","代码重构与可维护性提升","Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.","以外科手术式的精准进行代码重构，在不改变行为的前提下提升可维护性。涵盖提取函数、重命名变量、拆分巨型函数（god function）、提升类型安全、消除代码异味和应用设计模式。相比 repo-rebuilder 改动更温和，适用于渐进式改进。","dhar174\u002Ftiny_village","dhar174","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F5241499?v=4","01M6BYF9MC8MSRSB98B92A5SHQ","Charles I Niswander II","01M6BYF9S9601AYJWN6CJR1V0Z",1,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Frefactor\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BT7QVANT4709358VEJK53E","代码实现","SCENARIO","使用场景",[5,31,32,33,34,35,36],"design","code","Type Safety","Safety","improve","refactoring","2026-11-10 10:12:30",false,"---\r\nname: refactor\r\ndescription: 'Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.'\r\nlicense: MIT\r\n---\r\n\r\n# Refactor\r\n\r\n## Overview\r\n\r\nImprove code structure and readability without changing external behavior. Refactoring is gradual evolution, not revolution. Use this for improving existing code, not rewriting from scratch.\r\n\r\n## When to Use\r\n\r\nUse this skill when:\r\n\r\n- Code is hard to understand or maintain\r\n- Functions\u002Fclasses are too large\r\n- Code smells need addressing\r\n- Adding features is difficult due to code structure\r\n- User asks \"clean up this code\", \"refactor this\", \"improve this\"\r\n\r\n---\r\n\r\n## Refactoring Principles\r\n\r\n### The Golden Rules\r\n\r\n1. **Behavior is preserved** - Refactoring doesn't change what the code does, only how\r\n2. **Small steps** - Make tiny changes, test after each\r\n3. **Version control is your friend** - Commit before and after each safe state\r\n4. **Tests are essential** - Without tests, you're not refactoring, you're editing\r\n5. **One thing at a time** - Don't mix refactoring with feature changes\r\n\r\n### When NOT to Refactor\r\n\r\n```\r\n- Code that works and won't change again (if it ain't broke...)\r\n- Critical production code without tests (add tests first)\r\n- When you're under a tight deadline\r\n- \"Just because\" - need a clear purpose\r\n```\r\n\r\n---\r\n\r\n## Common Code Smells & Fixes\r\n\r\n### 1. Long Method\u002FFunction\r\n\r\n```diff\r\n# BAD: 200-line function that does everything\r\n- async function processOrder(orderId) {\r\n-   \u002F\u002F 50 lines: fetch order\r\n-   \u002F\u002F 30 lines: validate order\r\n-   \u002F\u002F 40 lines: calculate pricing\r\n-   \u002F\u002F 30 lines: update inventory\r\n-   \u002F\u002F 20 lines: create shipment\r\n-   \u002F\u002F 30 lines: send notifications\r\n- }\r\n\r\n# GOOD: Broken into focused functions\r\n+ async function processOrder(orderId) {\r\n+   const order = await fetchOrder(orderId);\r\n+   validateOrder(order);\r\n+   const pricing = calculatePricing(order);\r\n+   await updateInventory(order);\r\n+   const shipment = await createShipment(order);\r\n+   await sendNotifications(order, pricing, shipment);\r\n+   return { order, pricing, shipment };\r\n+ }\r\n```\r\n\r\n### 2. Duplicated Code\r\n\r\n```diff\r\n# BAD: Same logic in multiple places\r\n- function calculateUserDiscount(user) {\r\n-   if (user.membership === 'gold') return user.total * 0.2;\r\n-   if (user.membership === 'silver') return user.total * 0.1;\r\n-   return 0;\r\n- }\r\n-\r\n- function calculateOrderDiscount(order) {\r\n-   if (order.user.membership === 'gold') return order.total * 0.2;\r\n-   if (order.user.membership === 'silver') return order.total * 0.1;\r\n-   return 0;\r\n- }\r\n\r\n# GOOD: Extract common logic\r\n+ function getMembershipDiscountRate(membership) {\r\n+   const rates = { gold: 0.2, silver: 0.1 };\r\n+   return rates[membership] || 0;\r\n+ }\r\n+\r\n+ function calculateUserDiscount(user) {\r\n+   return user.total * getMembershipDiscountRate(user.membership);\r\n+ }\r\n+\r\n+ function calculateOrderDiscount(order) {\r\n+   return order.total * getMembershipDiscountRate(order.user.membership);\r\n+ }\r\n```\r\n\r\n### 3. Large Class\u002FModule\r\n\r\n```diff\r\n# BAD: God object that knows too much\r\n- class UserManager {\r\n-   createUser() { \u002F* ... *\u002F }\r\n-   updateUser() { \u002F* ... *\u002F }\r\n-   deleteUser() { \u002F* ... *\u002F }\r\n-   sendEmail() { \u002F* ... *\u002F }\r\n-   generateReport() { \u002F* ... *\u002F }\r\n-   handlePayment() { \u002F* ... *\u002F }\r\n-   validateAddress() { \u002F* ... *\u002F }\r\n-   \u002F\u002F 50 more methods...\r\n- }\r\n\r\n# GOOD: Single responsibility per class\r\n+ class UserService {\r\n+   create(data) { \u002F* ... *\u002F }\r\n+   update(id, data) { \u002F* ... *\u002F }\r\n+   delete(id) { \u002F* ... *\u002F }\r\n+ }\r\n+\r\n+ class EmailService {\r\n+   send(to, subject, body) { \u002F* ... *\u002F }\r\n+ }\r\n+\r\n+ class ReportService {\r\n+   generate(type, params) { \u002F* ... *\u002F }\r\n+ }\r\n+\r\n+ class PaymentService {\r\n+   process(amount, method) { \u002F* ... *\u002F }\r\n+ }\r\n```\r\n\r\n### 4. Long Parameter List\r\n\r\n```diff\r\n# BAD: Too many parameters\r\n- function createUser(email, password, name, age, address, city, country, phone) {\r\n-   \u002F* ... *\u002F\r\n- }\r\n\r\n# GOOD: Group related parameters\r\n+ interface UserData {\r\n+   email: string;\r\n+   password: string;\r\n+   name: string;\r\n+   age?: number;\r\n+   address?: Address;\r\n+   phone?: string;\r\n+ }\r\n+\r\n+ function createUser(data: UserData) {\r\n+   \u002F* ... *\u002F\r\n+ }\r\n\r\n# EVEN BETTER: Use builder pattern for complex construction\r\n+ const user = UserBuilder\r\n+   .email('test@example.com')\r\n+   .password('secure123')\r\n+   .name('Test User')\r\n+   .address(address)\r\n+   .build();\r\n```\r\n\r\n### 5. Feature Envy\r\n\r\n```diff\r\n# BAD: Method that uses another object's data more than its own\r\n- class Order {\r\n-   calculateDiscount(user) {\r\n-     if (user.membershipLevel === 'gold') {\r\n+       return this.total * 0.2;\r\n+     }\r\n+     if (user.accountAge > 365) {\r\n+       return this.total * 0.1;\r\n+     }\r\n+     return 0;\r\n+   }\r\n+ }\r\n\r\n# GOOD: Move logic to the object that owns the data\r\n+ class User {\r\n+   getDiscountRate(orderTotal) {\r\n+     if (this.membershipLevel === 'gold') return 0.2;\r\n+     if (this.accountAge > 365) return 0.1;\r\n+     return 0;\r\n+   }\r\n+ }\r\n+\r\n+ class Order {\r\n+   calculateDiscount(user) {\r\n+     return this.total * user.getDiscountRate(this.total);\r\n+   }\r\n+ }\r\n```\r\n\r\n### 6. Primitive Obsession\r\n\r\n```diff\r\n# BAD: Using primitives for domain concepts\r\n- function sendEmail(to, subject, body) { \u002F* ... *\u002F }\r\n- sendEmail('user@example.com', 'Hello', '...');\r\n\r\n- function createPhone(country, number) {\r\n-   return `${country}-${number}`;\r\n- }\r\n\r\n# GOOD: Use domain types\r\n+ class Email {\r\n+   private constructor(public readonly value: string) {\r\n+     if (!Email.isValid(value)) throw new Error('Invalid email');\r\n+   }\r\n+   static create(value: string) { return new Email(value); }\r\n+   static isValid(email: string) { return \u002F^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\u002F.test(email); }\r\n+ }\r\n+\r\n+ class PhoneNumber {\r\n+   constructor(\r\n+     public readonly country: string,\r\n+     public readonly number: string\r\n+   ) {\r\n+     if (!PhoneNumber.isValid(country, number)) throw new Error('Invalid phone');\r\n+   }\r\n+   toString() { return `${this.country}-${this.number}`; }\r\n+   static isValid(country: string, number: string) { \u002F* ... *\u002F }\r\n+ }\r\n+\r\n+ \u002F\u002F Usage\r\n+ const email = Email.create('user@example.com');\r\n+ const phone = new PhoneNumber('1', '555-1234');\r\n```\r\n\r\n### 7. Magic Numbers\u002FStrings\r\n\r\n```diff\r\n# BAD: Unexplained values\r\n- if (user.status === 2) { \u002F* ... *\u002F }\r\n- const discount = total * 0.15;\r\n- setTimeout(callback, 86400000);\r\n\r\n# GOOD: Named constants\r\n+ const UserStatus = {\r\n+   ACTIVE: 1,\r\n+   INACTIVE: 2,\r\n+   SUSPENDED: 3\r\n+ } as const;\r\n+\r\n+ const DISCOUNT_RATES = {\r\n+   STANDARD: 0.1,\r\n+   PREMIUM: 0.15,\r\n+   VIP: 0.2\r\n+ } as const;\r\n+\r\n+ const ONE_DAY_MS = 24 * 60 * 60 * 1000;\r\n+\r\n+ if (user.status === UserStatus.INACTIVE) { \u002F* ... *\u002F }\r\n+ const discount = total * DISCOUNT_RATES.PREMIUM;\r\n+ setTimeout(callback, ONE_DAY_MS);\r\n```\r\n\r\n### 8. Nested Conditionals\r\n\r\n```diff\r\n# BAD: Arrow code\r\n- function process(order) {\r\n-   if (order) {\r\n-     if (order.user) {\r\n-       if (order.user.isActive) {\r\n-         if (order.total > 0) {\r\n-           return processOrder(order);\r\n+         } else {\r\n+           return { error: 'Invalid total' };\r\n+         }\r\n+       } else {\r\n+         return { error: 'User inactive' };\r\n+       }\r\n+     } else {\r\n+       return { error: 'No user' };\r\n+     }\r\n+   } else {\r\n+     return { error: 'No order' };\r\n+   }\r\n+ }\r\n\r\n# GOOD: Guard clauses \u002F early returns\r\n+ function process(order) {\r\n+   if (!order) return { error: 'No order' };\r\n+   if (!order.user) return { error: 'No user' };\r\n+   if (!order.user.isActive) return { error: 'User inactive' };\r\n+   if (order.total \u003C= 0) return { error: 'Invalid total' };\r\n+   return processOrder(order);\r\n+ }\r\n\r\n# EVEN BETER: Using Result type\r\n+ function process(order): Result\u003CProcessedOrder, Error> {\r\n+   return Result.combine([\r\n+     validateOrderExists(order),\r\n+     validateUserExists(order),\r\n+     validateUserActive(order.user),\r\n+     validateOrderTotal(order)\r\n+   ]).flatMap(() => processOrder(order));\r\n+ }\r\n```\r\n\r\n### 9. Dead Code\r\n\r\n```diff\r\n# BAD: Unused code lingers\r\n- function oldImplementation() { \u002F* ... *\u002F }\r\n- const DEPRECATED_VALUE = 5;\r\n- import { unusedThing } from '.\u002Fsomewhere';\r\n- \u002F\u002F Commented out code\r\n- \u002F\u002F function oldCode() { \u002F* ... *\u002F }\r\n\r\n# GOOD: Remove it\r\n+ \u002F\u002F Delete unused functions, imports, and commented code\r\n+ \u002F\u002F If you need it again, git history has it\r\n```\r\n\r\n### 10. Inappropriate Intimacy\r\n\r\n```diff\r\n# BAD: One class reaches deep into another\r\n- class OrderProcessor {\r\n-   process(order) {\r\n-     order.user.profile.address.street;  \u002F\u002F Too intimate\r\n-     order.repository.connection.config;  \u002F\u002F Breaking encapsulation\r\n+   }\r\n+ }\r\n\r\n# GOOD: Ask, don't tell\r\n+ class OrderProcessor {\r\n+   process(order) {\r\n+     order.getShippingAddress();  \u002F\u002F Order knows how to get it\r\n+     order.save();  \u002F\u002F Order knows how to save itself\r\n+   }\r\n+ }\r\n```\r\n\r\n---\r\n\r\n## Extract Method Refactoring\r\n\r\n### Before and After\r\n\r\n```diff\r\n# Before: One long function\r\n- function printReport(users) {\r\n-   console.log('USER REPORT');\r\n-   console.log('============');\r\n-   console.log('');\r\n-   console.log(`Total users: ${users.length}`);\r\n-   console.log('');\r\n-   console.log('ACTIVE USERS');\r\n-   console.log('------------');\r\n-   const active = users.filter(u => u.isActive);\r\n-   active.forEach(u => {\r\n-     console.log(`- ${u.name} (${u.email})`);\r\n-   });\r\n-   console.log('');\r\n-   console.log(`Active: ${active.length}`);\r\n-   console.log('');\r\n-   console.log('INACTIVE USERS');\r\n-   console.log('--------------');\r\n-   const inactive = users.filter(u => !u.isActive);\r\n-   inactive.forEach(u => {\r\n-     console.log(`- ${u.name} (${u.email})`);\r\n-   });\r\n-   console.log('');\r\n-   console.log(`Inactive: ${inactive.length}`);\r\n- }\r\n\r\n# After: Extracted methods\r\n+ function printReport(users) {\r\n+   printHeader('USER REPORT');\r\n+   console.log(`Total users: ${users.length}\\n`);\r\n+   printUserSection('ACTIVE USERS', users.filter(u => u.isActive));\r\n+   printUserSection('INACTIVE USERS', users.filter(u => !u.isActive));\r\n+ }\r\n+\r\n+ function printHeader(title) {\r\n+   const line = '='.repeat(title.length);\r\n+   console.log(title);\r\n+   console.log(line);\r\n+   console.log('');\r\n+ }\r\n+\r\n+ function printUserSection(title, users) {\r\n+   console.log(title);\r\n+   console.log('-'.repeat(title.length));\r\n+   users.forEach(u => console.log(`- ${u.name} (${u.email})`));\r\n+   console.log('');\r\n+   console.log(`${title.split(' ')[0]}: ${users.length}`);\r\n+   console.log('');\r\n+ }\r\n```\r\n\r\n---\r\n\r\n## Introducing Type Safety\r\n\r\n### From Untyped to Typed\r\n\r\n```diff\r\n# Before: No types\r\n- function calculateDiscount(user, total, membership, date) {\r\n-   if (membership === 'gold' && date.getDay() === 5) {\r\n-     return total * 0.25;\r\n-   }\r\n-   if (membership === 'gold') return total * 0.2;\r\n-   return total * 0.1;\r\n- }\r\n\r\n# After: Full type safety\r\n+ type Membership = 'bronze' | 'silver' | 'gold';\r\n+\r\n+ interface User {\r\n+   id: string;\r\n+   name: string;\r\n+   membership: Membership;\r\n+ }\r\n+\r\n+ interface DiscountResult {\r\n+   original: number;\r\n+   discount: number;\r\n+   final: number;\r\n+   rate: number;\r\n+ }\r\n+\r\n+ function calculateDiscount(\r\n+   user: User,\r\n+   total: number,\r\n+   date: Date = new Date()\r\n+ ): DiscountResult {\r\n+   if (total \u003C 0) throw new Error('Total cannot be negative');\r\n+\r\n+   let rate = 0.1; \u002F\u002F Default bronze\r\n+\r\n+   if (user.membership === 'gold' && date.getDay() === 5) {\r\n+     rate = 0.25; \u002F\u002F Friday bonus for gold\r\n+   } else if (user.membership === 'gold') {\r\n+     rate = 0.2;\r\n+   } else if (user.membership === 'silver') {\r\n+     rate = 0.15;\r\n+   }\r\n+\r\n+   const discount = total * rate;\r\n+\r\n+   return {\r\n+     original: total,\r\n+     discount,\r\n+     final: total - discount,\r\n+     rate\r\n+   };\r\n+ }\r\n```\r\n\r\n---\r\n\r\n## Design Patterns for Refactoring\r\n\r\n### Strategy Pattern\r\n\r\n```diff\r\n# Before: Conditional logic\r\n- function calculateShipping(order, method) {\r\n-   if (method === 'standard') {\r\n-     return order.total > 50 ? 0 : 5.99;\r\n-   } else if (method === 'express') {\r\n-     return order.total > 100 ? 9.99 : 14.99;\r\n+   } else if (method === 'overnight') {\r\n+     return 29.99;\r\n+   }\r\n+ }\r\n\r\n# After: Strategy pattern\r\n+ interface ShippingStrategy {\r\n+   calculate(order: Order): number;\r\n+ }\r\n+\r\n+ class StandardShipping implements ShippingStrategy {\r\n+   calculate(order: Order) {\r\n+     return order.total > 50 ? 0 : 5.99;\r\n+   }\r\n+ }\r\n+\r\n+ class ExpressShipping implements ShippingStrategy {\r\n+   calculate(order: Order) {\r\n+     return order.total > 100 ? 9.99 : 14.99;\r\n+   }\r\n+ }\r\n+\r\n+ class OvernightShipping implements ShippingStrategy {\r\n+   calculate(order: Order) {\r\n+     return 29.99;\r\n+   }\r\n+ }\r\n+\r\n+ function calculateShipping(order: Order, strategy: ShippingStrategy) {\r\n+   return strategy.calculate(order);\r\n+ }\r\n```\r\n\r\n### Chain of Responsibility\r\n\r\n```diff\r\n# Before: Nested validation\r\n- function validate(user) {\r\n-   const errors = [];\r\n-   if (!user.email) errors.push('Email required');\r\n+   else if (!isValidEmail(user.email)) errors.push('Invalid email');\r\n+   if (!user.name) errors.push('Name required');\r\n+   if (user.age \u003C 18) errors.push('Must be 18+');\r\n+   if (user.country === 'blocked') errors.push('Country not supported');\r\n+   return errors;\r\n+ }\r\n\r\n# After: Chain of responsibility\r\n+ abstract class Validator {\r\n+   abstract validate(user: User): string | null;\r\n+   setNext(validator: Validator): Validator {\r\n+     this.next = validator;\r\n+     return validator;\r\n+   }\r\n+   validate(user: User): string | null {\r\n+     const error = this.doValidate(user);\r\n+     if (error) return error;\r\n+     return this.next?.validate(user) ?? null;\r\n+   }\r\n+ }\r\n+\r\n+ class EmailRequiredValidator extends Validator {\r\n+   doValidate(user: User) {\r\n+     return !user.email ? 'Email required' : null;\r\n+   }\r\n+ }\r\n+\r\n+ class EmailFormatValidator extends Validator {\r\n+   doValidate(user: User) {\r\n+     return user.email && !isValidEmail(user.email) ? 'Invalid email' : null;\r\n+   }\r\n+ }\r\n+\r\n+ \u002F\u002F Build the chain\r\n+ const validator = new EmailRequiredValidator()\r\n+   .setNext(new EmailFormatValidator())\r\n+   .setNext(new NameRequiredValidator())\r\n+   .setNext(new AgeValidator())\r\n+   .setNext(new CountryValidator());\r\n```\r\n\r\n---\r\n\r\n## Refactoring Steps\r\n\r\n### Safe Refactoring Process\r\n\r\n```\r\n1. PREPARE\r\n   - Ensure tests exist (write them if missing)\r\n   - Commit current state\r\n   - Create feature branch\r\n\r\n2. IDENTIFY\r\n   - Find the code smell to address\r\n   - Understand what the code does\r\n   - Plan the refactoring\r\n\r\n3. REFACTOR (small steps)\r\n   - Make one small change\r\n   - Run tests\r\n   - Commit if tests pass\r\n   - Repeat\r\n\r\n4. VERIFY\r\n   - All tests pass\r\n   - Manual testing if needed\r\n   - Performance unchanged or improved\r\n\r\n5. CLEAN UP\r\n   - Update comments\r\n   - Update documentation\r\n   - Final commit\r\n```\r\n\r\n---\r\n\r\n## Refactoring Checklist\r\n\r\n### Code Quality\r\n\r\n- [ ] Functions are small (\u003C 50 lines)\r\n- [ ] Functions do one thing\r\n- [ ] No duplicated code\r\n- [ ] Descriptive names (variables, functions, classes)\r\n- [ ] No magic numbers\u002Fstrings\r\n- [ ] Dead code removed\r\n\r\n### Structure\r\n\r\n- [ ] Related code is together\r\n- [ ] Clear module boundaries\r\n- [ ] Dependencies flow in one direction\r\n- [ ] No circular dependencies\r\n\r\n### Type Safety\r\n\r\n- [ ] Types defined for all public APIs\r\n- [ ] No `any` types without justification\r\n- [ ] Nullable types explicitly marked\r\n\r\n### Testing\r\n\r\n- [ ] Refactored code is tested\r\n- [ ] Tests cover edge cases\r\n- [ ] All tests pass\r\n\r\n---\r\n\r\n## Common Refactoring Operations\r\n\r\n| Operation                                     | Description                           |\r\n| --------------------------------------------- | ------------------------------------- |\r\n| Extract Method                                | Turn code fragment into method        |\r\n| Extract Class                                 | Move behavior to new class            |\r\n| Extract Interface                             | Create interface from implementation  |\r\n| Inline Method                                 | Move method body back to caller       |\r\n| Inline Class                                  | Move class behavior to caller         |\r\n| Pull Up Method                                | Move method to superclass             |\r\n| Push Down Method                              | Move method to subclass               |\r\n| Rename Method\u002FVariable                        | Improve clarity                       |\r\n| Introduce Parameter Object                    | Group related parameters              |\r\n| Replace Conditional with Polymorphism         | Use polymorphism instead of switch\u002Fif |\r\n| Replace Magic Number with Constant            | Named constants                       |\r\n| Decompose Conditional                         | Break complex conditions              |\r\n| Consolidate Conditional                       | Combine duplicate conditions          |\r\n| Replace Nested Conditional with Guard Clauses | Early returns                         |\r\n| Introduce Null Object                         | Eliminate null checks                 |\r\n| Replace Type Code with Class\u002FEnum             | Strong typing                         |\r\n| Replace Inheritance with Delegation           | Composition over inheritance          |\r\n","# Refactor\r\n\r\n## Overview\r\n\r\nImprove code structure and readability without changing external behavior. Refactoring is gradual evolution, not revolution. Use this for improving existing code, not rewriting from scratch.\r\n\r\n## When to Use\r\n\r\nUse this skill when:\r\n\r\n- Code is hard to understand or maintain\r\n- Functions\u002Fclasses are too large\r\n- Code smells need addressing\r\n- Adding features is difficult due to code structure\r\n- User asks \"clean up this code\", \"refactor this\", \"improve this\"\r\n\r\n---\r\n\r\n## Refactoring Principles\r\n\r\n### The Golden Rules\r\n\r\n1. **Behavior is preserved** - Refactoring doesn't change what the code does, only how\r\n2. **Small steps** - Make tiny changes, test after each\r\n3. **Version control is your friend** - Commit before and after each safe state\r\n4. **Tests are essential** - Without tests, you're not refactoring, you're editing\r\n5. **One thing at a time** - Don't mix refactoring with feature changes\r\n\r\n### When NOT to Refactor\r\n\r\n```\r\n- Code that works and won't change again (if it ain't broke...)\r\n- Critical production code without tests (add tests first)\r\n- When you're under a tight deadline\r\n- \"Just because\" - need a clear purpose\r\n```\r\n\r\n---\r\n\r\n## Common Code Smells & Fixes\r\n\r\n### 1. Long Method\u002FFunction\r\n\r\n```diff\r\n# BAD: 200-line function that does everything\r\n- async function processOrder(orderId) {\r\n-   \u002F\u002F 50 lines: fetch order\r\n-   \u002F\u002F 30 lines: validate order\r\n-   \u002F\u002F 40 lines: calculate pricing\r\n-   \u002F\u002F 30 lines: update inventory\r\n-   \u002F\u002F 20 lines: create shipment\r\n-   \u002F\u002F 30 lines: send notifications\r\n- }\r\n\r\n# GOOD: Broken into focused functions\r\n+ async function processOrder(orderId) {\r\n+   const order = await fetchOrder(orderId);\r\n+   validateOrder(order);\r\n+   const pricing = calculatePricing(order);\r\n+   await updateInventory(order);\r\n+   const shipment = await createShipment(order);\r\n+   await sendNotifications(order, pricing, shipment);\r\n+   return { order, pricing, shipment };\r\n+ }\r\n```\r\n\r\n### 2. Duplicated Code\r\n\r\n```diff\r\n# BAD: Same logic in multiple places\r\n- function calculateUserDiscount(user) {\r\n-   if (user.membership === 'gold') return user.total * 0.2;\r\n-   if (user.membership === 'silver') return user.total * 0.1;\r\n-   return 0;\r\n- }\r\n-\r\n- function calculateOrderDiscount(order) {\r\n-   if (order.user.membership === 'gold') return order.total * 0.2;\r\n-   if (order.user.membership === 'silver') return order.total * 0.1;\r\n-   return 0;\r\n- }\r\n\r\n# GOOD: Extract common logic\r\n+ function getMembershipDiscountRate(membership) {\r\n+   const rates = { gold: 0.2, silver: 0.1 };\r\n+   return rates[membership] || 0;\r\n+ }\r\n+\r\n+ function calculateUserDiscount(user) {\r\n+   return user.total * getMembershipDiscountRate(user.membership);\r\n+ }\r\n+\r\n+ function calculateOrderDiscount(order) {\r\n+   return order.total * getMembershipDiscountRate(order.user.membership);\r\n+ }\r\n```\r\n\r\n### 3. Large Class\u002FModule\r\n\r\n```diff\r\n# BAD: God object that knows too much\r\n- class UserManager {\r\n-   createUser() { \u002F* ... *\u002F }\r\n-   updateUser() { \u002F* ... *\u002F }\r\n-   deleteUser() { \u002F* ... *\u002F }\r\n-   sendEmail() { \u002F* ... *\u002F }\r\n-   generateReport() { \u002F* ... *\u002F }\r\n-   handlePayment() { \u002F* ... *\u002F }\r\n-   validateAddress() { \u002F* ... *\u002F }\r\n-   \u002F\u002F 50 more methods...\r\n- }\r\n\r\n# GOOD: Single responsibility per class\r\n+ class UserService {\r\n+   create(data) { \u002F* ... *\u002F }\r\n+   update(id, data) { \u002F* ... *\u002F }\r\n+   delete(id) { \u002F* ... *\u002F }\r\n+ }\r\n+\r\n+ class EmailService {\r\n+   send(to, subject, body) { \u002F* ... *\u002F }\r\n+ }\r\n+\r\n+ class ReportService {\r\n+   generate(type, params) { \u002F* ... *\u002F }\r\n+ }\r\n+\r\n+ class PaymentService {\r\n+   process(amount, method) { \u002F* ... *\u002F }\r\n+ }\r\n```\r\n\r\n### 4. Long Parameter List\r\n\r\n```diff\r\n# BAD: Too many parameters\r\n- function createUser(email, password, name, age, address, city, country, phone) {\r\n-   \u002F* ... *\u002F\r\n- }\r\n\r\n# GOOD: Group related parameters\r\n+ interface UserData {\r\n+   email: string;\r\n+   password: string;\r\n+   name: string;\r\n+   age?: number;\r\n+   address?: Address;\r\n+   phone?: string;\r\n+ }\r\n+\r\n+ function createUser(data: UserData) {\r\n+   \u002F* ... *\u002F\r\n+ }\r\n\r\n# EVEN BETTER: Use builder pattern for complex construction\r\n+ const user = UserBuilder\r\n+   .email('test@example.com')\r\n+   .password('secure123')\r\n+   .name('Test User')\r\n+   .address(address)\r\n+   .build();\r\n```\r\n\r\n### 5. Feature Envy\r\n\r\n```diff\r\n# BAD: Method that uses another object's data more than its own\r\n- class Order {\r\n-   calculateDiscount(user) {\r\n-     if (user.membershipLevel === 'gold') {\r\n+       return this.total * 0.2;\r\n+     }\r\n+     if (user.accountAge > 365) {\r\n+       return this.total * 0.1;\r\n+     }\r\n+     return 0;\r\n+   }\r\n+ }\r\n\r\n# GOOD: Move logic to the object that owns the data\r\n+ class User {\r\n+   getDiscountRate(orderTotal) {\r\n+     if (this.membershipLevel === 'gold') return 0.2;\r\n+     if (this.accountAge > 365) return 0.1;\r\n+     return 0;\r\n+   }\r\n+ }\r\n+\r\n+ class Order {\r\n+   calculateDiscount(user) {\r\n+     return this.total * user.getDiscountRate(this.total);\r\n+   }\r\n+ }\r\n```\r\n\r\n### 6. Primitive Obsession\r\n\r\n```diff\r\n# BAD: Using primitives for domain concepts\r\n- function sendEmail(to, subject, body) { \u002F* ... *\u002F }\r\n- sendEmail('user@example.com', 'Hello', '...');\r\n\r\n- function createPhone(country, number) {\r\n-   return `${country}-${number}`;\r\n- }\r\n\r\n# GOOD: Use domain types\r\n+ class Email {\r\n+   private constructor(public readonly value: string) {\r\n+     if (!Email.isValid(value)) throw new Error('Invalid email');\r\n+   }\r\n+   static create(value: string) { return new Email(value); }\r\n+   static isValid(email: string) { return \u002F^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\u002F.test(email); }\r\n+ }\r\n+\r\n+ class PhoneNumber {\r\n+   constructor(\r\n+     public readonly country: string,\r\n+     public readonly number: string\r\n+   ) {\r\n+     if (!PhoneNumber.isValid(country, number)) throw new Error('Invalid phone');\r\n+   }\r\n+   toString() { return `${this.country}-${this.number}`; }\r\n+   static isValid(country: string, number: string) { \u002F* ... *\u002F }\r\n+ }\r\n+\r\n+ \u002F\u002F Usage\r\n+ const email = Email.create('user@example.com');\r\n+ const phone = new PhoneNumber('1', '555-1234');\r\n```\r\n\r\n### 7. Magic Numbers\u002FStrings\r\n\r\n```diff\r\n# BAD: Unexplained values\r\n- if (user.status === 2) { \u002F* ... *\u002F }\r\n- const discount = total * 0.15;\r\n- setTimeout(callback, 86400000);\r\n\r\n# GOOD: Named constants\r\n+ const UserStatus = {\r\n+   ACTIVE: 1,\r\n+   INACTIVE: 2,\r\n+   SUSPENDED: 3\r\n+ } as const;\r\n+\r\n+ const DISCOUNT_RATES = {\r\n+   STANDARD: 0.1,\r\n+   PREMIUM: 0.15,\r\n+   VIP: 0.2\r\n+ } as const;\r\n+\r\n+ const ONE_DAY_MS = 24 * 60 * 60 * 1000;\r\n+\r\n+ if (user.status === UserStatus.INACTIVE) { \u002F* ... *\u002F }\r\n+ const discount = total * DISCOUNT_RATES.PREMIUM;\r\n+ setTimeout(callback, ONE_DAY_MS);\r\n```\r\n\r\n### 8. Nested Conditionals\r\n\r\n```diff\r\n# BAD: Arrow code\r\n- function process(order) {\r\n-   if (order) {\r\n-     if (order.user) {\r\n-       if (order.user.isActive) {\r\n-         if (order.total > 0) {\r\n-           return processOrder(order);\r\n+         } else {\r\n+           return { error: 'Invalid total' };\r\n+         }\r\n+       } else {\r\n+         return { error: 'User inactive' };\r\n+       }\r\n+     } else {\r\n+       return { error: 'No user' };\r\n+     }\r\n+   } else {\r\n+     return { error: 'No order' };\r\n+   }\r\n+ }\r\n\r\n# GOOD: Guard clauses \u002F early returns\r\n+ function process(order) {\r\n+   if (!order) return { error: 'No order' };\r\n+   if (!order.user) return { error: 'No user' };\r\n+   if (!order.user.isActive) return { error: 'User inactive' };\r\n+   if (order.total \u003C= 0) return { error: 'Invalid total' };\r\n+   return processOrder(order);\r\n+ }\r\n\r\n# EVEN BETER: Using Result type\r\n+ function process(order): Result\u003CProcessedOrder, Error> {\r\n+   return Result.combine([\r\n+     validateOrderExists(order),\r\n+     validateUserExists(order),\r\n+     validateUserActive(order.user),\r\n+     validateOrderTotal(order)\r\n+   ]).flatMap(() => processOrder(order));\r\n+ }\r\n```\r\n\r\n### 9. Dead Code\r\n\r\n```diff\r\n# BAD: Unused code lingers\r\n- function oldImplementation() { \u002F* ... *\u002F }\r\n- const DEPRECATED_VALUE = 5;\r\n- import { unusedThing } from '.\u002Fsomewhere';\r\n- \u002F\u002F Commented out code\r\n- \u002F\u002F function oldCode() { \u002F* ... *\u002F }\r\n\r\n# GOOD: Remove it\r\n+ \u002F\u002F Delete unused functions, imports, and commented code\r\n+ \u002F\u002F If you need it again, git history has it\r\n```\r\n\r\n### 10. Inappropriate Intimacy\r\n\r\n```diff\r\n# BAD: One class reaches deep into another\r\n- class OrderProcessor {\r\n-   process(order) {\r\n-     order.user.profile.address.street;  \u002F\u002F Too intimate\r\n-     order.repository.connection.config;  \u002F\u002F Breaking encapsulation\r\n+   }\r\n+ }\r\n\r\n# GOOD: Ask, don't tell\r\n+ class OrderProcessor {\r\n+   process(order) {\r\n+     order.getShippingAddress();  \u002F\u002F Order knows how to get it\r\n+     order.save();  \u002F\u002F Order knows how to save itself\r\n+   }\r\n+ }\r\n```\r\n\r\n---\r\n\r\n## Extract Method Refactoring\r\n\r\n### Before and After\r\n\r\n```diff\r\n# Before: One long function\r\n- function printReport(users) {\r\n-   console.log('USER REPORT');\r\n-   console.log('============');\r\n-   console.log('');\r\n-   console.log(`Total users: ${users.length}`);\r\n-   console.log('');\r\n-   console.log('ACTIVE USERS');\r\n-   console.log('------------');\r\n-   const active = users.filter(u => u.isActive);\r\n-   active.forEach(u => {\r\n-     console.log(`- ${u.name} (${u.email})`);\r\n-   });\r\n-   console.log('');\r\n-   console.log(`Active: ${active.length}`);\r\n-   console.log('');\r\n-   console.log('INACTIVE USERS');\r\n-   console.log('--------------');\r\n-   const inactive = users.filter(u => !u.isActive);\r\n-   inactive.forEach(u => {\r\n-     console.log(`- ${u.name} (${u.email})`);\r\n-   });\r\n-   console.log('');\r\n-   console.log(`Inactive: ${inactive.length}`);\r\n- }\r\n\r\n# After: Extracted methods\r\n+ function printReport(users) {\r\n+   printHeader('USER REPORT');\r\n+   console.log(`Total users: ${users.length}\\n`);\r\n+   printUserSection('ACTIVE USERS', users.filter(u => u.isActive));\r\n+   printUserSection('INACTIVE USERS', users.filter(u => !u.isActive));\r\n+ }\r\n+\r\n+ function printHeader(title) {\r\n+   const line = '='.repeat(title.length);\r\n+   console.log(title);\r\n+   console.log(line);\r\n+   console.log('');\r\n+ }\r\n+\r\n+ function printUserSection(title, users) {\r\n+   console.log(title);\r\n+   console.log('-'.repeat(title.length));\r\n+   users.forEach(u => console.log(`- ${u.name} (${u.email})`));\r\n+   console.log('');\r\n+   console.log(`${title.split(' ')[0]}: ${users.length}`);\r\n+   console.log('');\r\n+ }\r\n```\r\n\r\n---\r\n\r\n## Introducing Type Safety\r\n\r\n### From Untyped to Typed\r\n\r\n```diff\r\n# Before: No types\r\n- function calculateDiscount(user, total, membership, date) {\r\n-   if (membership === 'gold' && date.getDay() === 5) {\r\n-     return total * 0.25;\r\n-   }\r\n-   if (membership === 'gold') return total * 0.2;\r\n-   return total * 0.1;\r\n- }\r\n\r\n# After: Full type safety\r\n+ type Membership = 'bronze' | 'silver' | 'gold';\r\n+\r\n+ interface User {\r\n+   id: string;\r\n+   name: string;\r\n+   membership: Membership;\r\n+ }\r\n+\r\n+ interface DiscountResult {\r\n+   original: number;\r\n+   discount: number;\r\n+   final: number;\r\n+   rate: number;\r\n+ }\r\n+\r\n+ function calculateDiscount(\r\n+   user: User,\r\n+   total: number,\r\n+   date: Date = new Date()\r\n+ ): DiscountResult {\r\n+   if (total \u003C 0) throw new Error('Total cannot be negative');\r\n+\r\n+   let rate = 0.1; \u002F\u002F Default bronze\r\n+\r\n+   if (user.membership === 'gold' && date.getDay() === 5) {\r\n+     rate = 0.25; \u002F\u002F Friday bonus for gold\r\n+   } else if (user.membership === 'gold') {\r\n+     rate = 0.2;\r\n+   } else if (user.membership === 'silver') {\r\n+     rate = 0.15;\r\n+   }\r\n+\r\n+   const discount = total * rate;\r\n+\r\n+   return {\r\n+     original: total,\r\n+     discount,\r\n+     final: total - discount,\r\n+     rate\r\n+   };\r\n+ }\r\n```\r\n\r\n---\r\n\r\n## Design Patterns for Refactoring\r\n\r\n### Strategy Pattern\r\n\r\n```diff\r\n# Before: Conditional logic\r\n- function calculateShipping(order, method) {\r\n-   if (method === 'standard') {\r\n-     return order.total > 50 ? 0 : 5.99;\r\n-   } else if (method === 'express') {\r\n-     return order.total > 100 ? 9.99 : 14.99;\r\n+   } else if (method === 'overnight') {\r\n+     return 29.99;\r\n+   }\r\n+ }\r\n\r\n# After: Strategy pattern\r\n+ interface ShippingStrategy {\r\n+   calculate(order: Order): number;\r\n+ }\r\n+\r\n+ class StandardShipping implements ShippingStrategy {\r\n+   calculate(order: Order) {\r\n+     return order.total > 50 ? 0 : 5.99;\r\n+   }\r\n+ }\r\n+\r\n+ class ExpressShipping implements ShippingStrategy {\r\n+   calculate(order: Order) {\r\n+     return order.total > 100 ? 9.99 : 14.99;\r\n+   }\r\n+ }\r\n+\r\n+ class OvernightShipping implements ShippingStrategy {\r\n+   calculate(order: Order) {\r\n+     return 29.99;\r\n+   }\r\n+ }\r\n+\r\n+ function calculateShipping(order: Order, strategy: ShippingStrategy) {\r\n+   return strategy.calculate(order);\r\n+ }\r\n```\r\n\r\n### Chain of Responsibility\r\n\r\n```diff\r\n# Before: Nested validation\r\n- function validate(user) {\r\n-   const errors = [];\r\n-   if (!user.email) errors.push('Email required');\r\n+   else if (!isValidEmail(user.email)) errors.push('Invalid email');\r\n+   if (!user.name) errors.push('Name required');\r\n+   if (user.age \u003C 18) errors.push('Must be 18+');\r\n+   if (user.country === 'blocked') errors.push('Country not supported');\r\n+   return errors;\r\n+ }\r\n\r\n# After: Chain of responsibility\r\n+ abstract class Validator {\r\n+   abstract validate(user: User): string | null;\r\n+   setNext(validator: Validator): Validator {\r\n+     this.next = validator;\r\n+     return validator;\r\n+   }\r\n+   validate(user: User): string | null {\r\n+     const error = this.doValidate(user);\r\n+     if (error) return error;\r\n+     return this.next?.validate(user) ?? null;\r\n+   }\r\n+ }\r\n+\r\n+ class EmailRequiredValidator extends Validator {\r\n+   doValidate(user: User) {\r\n+     return !user.email ? 'Email required' : null;\r\n+   }\r\n+ }\r\n+\r\n+ class EmailFormatValidator extends Validator {\r\n+   doValidate(user: User) {\r\n+     return user.email && !isValidEmail(user.email) ? 'Invalid email' : null;\r\n+   }\r\n+ }\r\n+\r\n+ \u002F\u002F Build the chain\r\n+ const validator = new EmailRequiredValidator()\r\n+   .setNext(new EmailFormatValidator())\r\n+   .setNext(new NameRequiredValidator())\r\n+   .setNext(new AgeValidator())\r\n+   .setNext(new CountryValidator());\r\n```\r\n\r\n---\r\n\r\n## Refactoring Steps\r\n\r\n### Safe Refactoring Process\r\n\r\n```\r\n1. PREPARE\r\n   - Ensure tests exist (write them if missing)\r\n   - Commit current state\r\n   - Create feature branch\r\n\r\n2. IDENTIFY\r\n   - Find the code smell to address\r\n   - Understand what the code does\r\n   - Plan the refactoring\r\n\r\n3. REFACTOR (small steps)\r\n   - Make one small change\r\n   - Run tests\r\n   - Commit if tests pass\r\n   - Repeat\r\n\r\n4. VERIFY\r\n   - All tests pass\r\n   - Manual testing if needed\r\n   - Performance unchanged or improved\r\n\r\n5. CLEAN UP\r\n   - Update comments\r\n   - Update documentation\r\n   - Final commit\r\n```\r\n\r\n---\r\n\r\n## Refactoring Checklist\r\n\r\n### Code Quality\r\n\r\n- [ ] Functions are small (\u003C 50 lines)\r\n- [ ] Functions do one thing\r\n- [ ] No duplicated code\r\n- [ ] Descriptive names (variables, functions, classes)\r\n- [ ] No magic numbers\u002Fstrings\r\n- [ ] Dead code removed\r\n\r\n### Structure\r\n\r\n- [ ] Related code is together\r\n- [ ] Clear module boundaries\r\n- [ ] Dependencies flow in one direction\r\n- [ ] No circular dependencies\r\n\r\n### Type Safety\r\n\r\n- [ ] Types defined for all public APIs\r\n- [ ] No `any` types without justification\r\n- [ ] Nullable types explicitly marked\r\n\r\n### Testing\r\n\r\n- [ ] Refactored code is tested\r\n- [ ] Tests cover edge cases\r\n- [ ] All tests pass\r\n\r\n---\r\n\r\n## Common Refactoring Operations\r\n\r\n| Operation                                     | Description                           |\r\n| --------------------------------------------- | ------------------------------------- |\r\n| Extract Method                                | Turn code fragment into method        |\r\n| Extract Class                                 | Move behavior to new class            |\r\n| Extract Interface                             | Create interface from implementation  |\r\n| Inline Method                                 | Move method body back to caller       |\r\n| Inline Class                                  | Move class behavior to caller         |\r\n| Pull Up Method                                | Move method to superclass             |\r\n| Push Down Method                              | Move method to subclass               |\r\n| Rename Method\u002FVariable                        | Improve clarity                       |\r\n| Introduce Parameter Object                    | Group related parameters              |\r\n| Replace Conditional with Polymorphism         | Use polymorphism instead of switch\u002Fif |\r\n| Replace Magic Number with Constant            | Named constants                       |\r\n| Decompose Conditional                         | Break complex conditions              |\r\n| Consolidate Conditional                       | Combine duplicate conditions          |\r\n| Replace Nested Conditional with Guard Clauses | Early returns                         |\r\n| Introduce Null Object                         | Eliminate null checks                 |\r\n| Replace Type Code with Class\u002FEnum             | Strong typing                         |\r\n| Replace Inheritance with Delegation           | Composition over inheritance          |\r\n",{"name":5,"license":16,"description":7},"main","16528f2130fc4b890558a1fccd590ad29e9bae7a",".github\u002Fskills\u002Frefactor","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village","https:\u002F\u002Fgithub.com\u002Fdhar174","https:\u002F\u002Fcharlesniswanderinnovations.com\u002F","2026-11-14 23:02:40",{"source":9,"skillName":5,"commands":50,"prompt":60,"zipAvailable":61},[51,54,57],{"tool":52,"command":53},"npx","npx skills add dhar174\u002Ftiny_village --skill refactor",{"tool":55,"command":56},"bunx","bunx skills add dhar174\u002Ftiny_village --skill refactor",{"tool":58,"command":59},"pnpm","pnpm dlx skills add dhar174\u002Ftiny_village --skill refactor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Frefactor\u002FSKILL.md",true,[],[64,87,107,125,150,173],{"skillNo":65,"name":66,"nameZh":67,"description":68,"descriptionZh":69,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":70,"licenseFileUrl":71,"sourceHtmlUrl":72,"categories":73,"keywords":80,"publishedAt":86},"01M6BYXCZEA8AY4FYGSC49K9TM","skill-installer","Codex 技能安装","Install Codex skills into $CODEX_HOME\u002Fskills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).","从精选列表或 GitHub 仓库路径将 Codex 技能安装到 $CODEX_HOME\u002Fskills。当用户要求列出可安装技能、安装精选技能，或从其他仓库（包括私有仓库）安装技能时使用。","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fskill-installer\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fskill-installer\u002FSKILL.md",[74,77],{"categoryNo":75,"categoryName":76,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRN0CV1NMDZ5TEJX1GVM29","插件与技能管理",{"categoryNo":78,"categoryName":79,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BRZZF9D7PVFN5MXSPWWD61","AI 工程师",[81,82,83,84,85],"skill installer","openai","github","codex","repos","2026-11-15 14:19:17",{"skillNo":88,"name":89,"nameZh":90,"description":91,"descriptionZh":92,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":70,"licenseFileUrl":93,"sourceHtmlUrl":94,"categories":95,"keywords":98,"publishedAt":86},"01M6BYXA68CRDJ09Y1YYGGATPA","skill-creator","Codex 技能创建","Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Codex's capabilities with specialized knowledge, workflows, or tool integrations.","创建高效技能的指南。当用户想要创建新技能（或更新现有技能），通过专业知识、工作流或工具集成来扩展 Codex 的能力时使用此技能。","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fskill-creator\u002Flicense.txt","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fskill-creator\u002FSKILL.md",[96,97],{"categoryNo":75,"categoryName":76,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":78,"categoryName":79,"taxonomyType":23,"taxonomyTypeDesc":24},[99,84,100,101,102,103,104,105,106],"skill creator","workflows","create","update","capabilities","knowledge","tool","integrations",{"skillNo":108,"name":109,"nameZh":110,"description":111,"descriptionZh":112,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":70,"licenseFileUrl":113,"sourceHtmlUrl":114,"categories":115,"keywords":122,"publishedAt":86},"01M6BYX6YJM7PKG2HSM9R3GD5K","screenshot","桌面与系统截图","Use when the user explicitly asks for a desktop or system screenshot (full screen, specific app or window, or a pixel region), or when tool-specific capture capabilities are unavailable and an OS-level capture is needed.","当用户明确要求截取桌面或系统截图（全屏、特定应用或窗口，或某个像素区域），或当特定工具的截图功能不可用、需要操作系统级别的截图时使用。","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fscreenshot\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fscreenshot\u002FSKILL.md",[116,119],{"categoryNo":117,"categoryName":118,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BS5011KJDVSRXG1DC4P666","普通用户",{"categoryNo":120,"categoryName":121,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8CA13THC860NJPQTJFG0V51","屏幕截图与OCR识别",[109,123,103,124,105],"desktop","system",{"skillNo":126,"name":127,"nameZh":128,"description":129,"descriptionZh":130,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":70,"licenseFileUrl":131,"sourceHtmlUrl":132,"categories":133,"keywords":140,"publishedAt":86},"01M6BYX15KYRHQN5JQ0YHTPNK5","render-deploy","Render 平台应用部署","Deploy applications to Render by analyzing codebases, generating render.yaml Blueprints, and providing Dashboard deeplinks. Use when the user wants to deploy, host, publish, or set up their application on Render's cloud platform.","通过分析代码库、生成 render.yaml Blueprints 并提供 Dashboard 深链接，将应用部署到 Render。当用户想要在 Render 云平台上部署、托管、发布或搭建应用时使用。","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Frender-deploy\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Frender-deploy\u002FSKILL.md",[134,137],{"categoryNo":135,"categoryName":136,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD4WETX0HM3SM9QKQ15B","SRE 工程师",{"categoryNo":138,"categoryName":139,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQNXPY1AV6BSR5VKHDMWRH","部署与发布管理",[141,142,143,144,145,146,147,148,149],"render deploy","deploy","applications","SET","dashboard","yaml","cloud","publish","analyzing",{"skillNo":151,"name":152,"nameZh":153,"description":154,"descriptionZh":155,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":70,"licenseFileUrl":156,"sourceHtmlUrl":157,"categories":158,"keywords":163,"publishedAt":86},"01M6BYVXM7MX9KA6B1T4Y66S12","playwright","Playwright浏览器自动化","Use when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction, UI-flow debugging) via `playwright-cli` or the bundled wrapper script.","当任务需要通过 `playwright-cli` 或捆绑的包装脚本从终端自动化真实浏览器（导航、表单填写、快照、截图、数据提取、UI 流程调试）时使用。","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fplaywright\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fplaywright\u002FSKILL.md",[159,160],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":161,"categoryName":162,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8C9MTTAN0PZ8RC9QAZW0AZJ","浏览器自动化与网页交互",[152,164,165,166,167,168,169,170,171,172],"browser","screenshots","cli","terminal","debugging","extraction","ui","flow","data",{"skillNo":174,"name":175,"nameZh":176,"description":177,"descriptionZh":178,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":70,"licenseFileUrl":179,"sourceHtmlUrl":180,"categories":181,"keywords":184,"publishedAt":86},"01M6BYVTMQ8X2MXS4BD97RJYGR","playwright-interactive","Playwright 浏览器交互调试","Persistent browser and Electron interaction through `js_repl` for fast iterative UI debugging.","通过 `js_repl` 进行持久化的浏览器和 Electron 交互，以实现快速迭代的 UI 调试。","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fplaywright-interactive\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdhar174\u002Ftiny_village\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fplaywright-interactive\u002FSKILL.md",[182,183],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":161,"categoryName":162,"taxonomyType":28,"taxonomyTypeDesc":29},[152,185,186,168,164,170,187,188],"playwright interactive","electron","fast","js"]