universal-dev-standards 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,15 +10,15 @@ description: |
10
10
 
11
11
  > **Language**: English | [繁體中文](../../../locales/zh-TW/skills/claude-code/refactoring-assistant/SKILL.md)
12
12
 
13
- **Version**: 1.0.0
14
- **Last Updated**: 2026-01-12
13
+ **Version**: 2.0.0
14
+ **Last Updated**: 2026-01-21
15
15
  **Applicability**: Claude Code Skills
16
16
 
17
17
  ---
18
18
 
19
19
  ## Purpose
20
20
 
21
- This skill provides decision frameworks for refactoring vs rewriting, large-scale refactoring patterns, and technical debt management.
21
+ This skill provides decision frameworks for refactoring vs rewriting, large-scale refactoring patterns, and technical debt management. Strategies are organized into three tiers: Tactical (daily), Strategic (architectural), and Safety (legacy code).
22
22
 
23
23
  ---
24
24
 
@@ -51,68 +51,142 @@ rewrite_antipatterns:
51
51
  - "Ignoring lessons from existing system"
52
52
  quote: "The second system is the most dangerous system a person ever designs. — Fred Brooks"
53
53
 
54
- # === SCALE: Refactoring Strategies ===
55
- scales:
56
- small:
57
- duration: "5-15 min"
54
+ # === TACTICAL: Daily Refactoring Strategies ===
55
+ tactical:
56
+ preparatory_refactoring:
57
+ definition: "Restructure code to make upcoming change easier"
58
+ quote: "First make the change easy (this might be hard), then make the easy change. — Kent Beck"
59
+ when: [feature_blocked, reduce_friction, upcoming_changes]
60
+ workflow:
61
+ 1: "Identify the change you want to make"
62
+ 2: "Identify what makes this change difficult"
63
+ 3: "Refactor to make the change easy"
64
+ 4: "Make the (now easy) change"
65
+ principles:
66
+ - "Preparatory refactoring is separate commit from feature"
67
+ - "Each step maintains passing tests"
68
+ - "Don't combine refactoring with feature work"
69
+
70
+ boy_scout_rule:
71
+ definition: "Leave code cleaner than you found it (opportunistic refactoring)"
72
+ quote: "Leave the campground cleaner than you found it. — Robert C. Martin"
73
+ when: [any_maintenance, bug_fixes, feature_additions, fighting_entropy]
74
+ guidelines:
75
+ - "Only small improvements (minutes, not hours)"
76
+ - "Don't change behavior"
77
+ - "Don't break existing tests"
78
+ - "Keep scope within current task"
79
+ examples:
80
+ - "Rename confusingly-named variable"
81
+ - "Extract lines into well-named method"
82
+ - "Remove dead code"
83
+ - "Add clarifying comment"
84
+ antipatterns:
85
+ - "Turning bug fix into major refactoring"
86
+ - "Refactoring unrelated code"
87
+ - "Changes without test coverage"
88
+ - "Scope creep beyond original task"
89
+
90
+ red_green_refactor:
91
+ definition: "TDD refactoring phase"
92
+ duration: "5-15 min per cycle"
58
93
  scope: "single method/class"
59
94
  techniques: [extract_method, rename, inline_var, replace_magic_number]
60
- medium:
61
- duration: "hours-days"
62
- scope: "one feature/module"
63
- checklist: [define_scope, identify_entry_points, "coverage>80%", incremental_commits, communicate]
64
- large:
65
- duration: "weeks-months"
66
- scope: "multiple modules/system"
67
- patterns: [strangler_fig, branch_by_abstraction, parallel_change]
68
-
69
- # === PATTERNS: Large-Scale Refactoring ===
70
- strangler_fig:
71
- phases:
72
- 1_intercept: "Request Facade → Legacy(100%)"
73
- 2_migrate: "Request Facade → [New(FeatureA), Legacy(Rest)]"
74
- 3_complete: "Request New(100%) [Legacy decommissioned]"
75
- checklist: [identify_interception_point, create_event_capture, implement_first_feature, route_incrementally, monitor_compare, decommission]
76
-
77
- branch_by_abstraction:
78
- steps:
79
- 1: "Client → Abstraction(interface) → OldImpl"
80
- 2: "Client Abstraction [OldImpl, NewImpl(toggled)]"
81
- 3: "Client NewImpl [OldImpl removed]"
82
- principles: [all_changes_on_trunk, feature_toggles, coexist_during_transition]
83
-
84
- expand_migrate_contract:
85
- phases:
86
- expand: "Add new alongside old, new code uses new, old still works"
87
- migrate: "Update all clients to new, verify, data migration"
88
- contract: "Remove old, clean up, update docs"
89
-
90
- # === LEGACY CODE: Strategies ===
91
- legacy:
92
- definition: "Code without tests (regardless of age)"
93
- dilemma: "Need tests to change safely → Need to change to add tests"
94
- solution: "Safe techniques to add tests first"
95
-
96
- characterization_tests:
97
- purpose: "Capture existing behavior (not verify correctness)"
98
- process:
99
- 1: "Call code to understand"
100
- 2: "Write assertion expected to FAIL"
101
- 3: "Run, see actual result"
102
- 4: "Update assertion to match actual"
103
- 5: "Repeat until behavior covered"
104
-
105
- seams:
106
- object: "Override via polymorphism (inject test double)"
107
- preprocessing: "Compile-time substitution (macros)"
108
- link: "Replace at link time (DI, module replacement)"
109
-
110
- sprout_wrap:
111
- sprout_method: "New logic create new method, call from old"
112
- sprout_class: "New logic evolves independently new class"
113
- wrap_method: "Add before/after rename original, create wrapper"
114
- wrap_class: "Decorate existing → decorator pattern"
115
- principle: "New code uses TDD; legacy untouched until tested"
95
+ reference: "→ See TDD Standards"
96
+
97
+ # === STRATEGIC: Architectural Refactoring ===
98
+ strategic:
99
+ strangler_fig:
100
+ definition: "Gradually replace legacy by routing to new system"
101
+ origin: "Named after strangler fig trees"
102
+ phases:
103
+ 1_intercept: "Request → Facade → Legacy(100%)"
104
+ 2_migrate: "Request Facade [New(Feature), Legacy(Rest)]"
105
+ 3_complete: "Request → New(100%) [Legacy decommissioned]"
106
+ checklist:
107
+ - "Identify interception point"
108
+ - "Create event capture layer"
109
+ - "Implement first feature in new"
110
+ - "Route traffic incrementally"
111
+ - "Monitor and compare"
112
+ - "Decommission legacy"
113
+
114
+ anti_corruption_layer:
115
+ definition: "Translation layer preventing legacy model from polluting new system"
116
+ origin: "Eric Evans, Domain-Driven Design (2003)"
117
+ when:
118
+ - "New and legacy must coexist and interact"
119
+ - "Legacy has chaotic domain model"
120
+ - "Protecting new system's Bounded Context"
121
+ components:
122
+ facade: "Simplifies complex legacy interfaces"
123
+ adapter: "Converts legacy data to new domain model"
124
+ translator: "Maps legacy terminology to ubiquitous language"
125
+ checklist:
126
+ - "Define clear ACL interface"
127
+ - "Map legacy entities to new model"
128
+ - "Handle data format conversions"
129
+ - "Implement error translation"
130
+ - "Add logging for debugging"
131
+ - "Test ACL isolation thoroughly"
132
+ vs_strangler:
133
+ strangler: "Goal is to replace legacy"
134
+ acl: "Goal is to coexist with legacy"
135
+
136
+ branch_by_abstraction:
137
+ steps:
138
+ 1: "Client Abstraction(interface) → OldImpl"
139
+ 2: "Client → Abstraction → [OldImpl, NewImpl(toggled)]"
140
+ 3: "Client → NewImpl [OldImpl removed]"
141
+ principles: [all_changes_on_trunk, feature_toggles, coexist_during_transition]
142
+
143
+ parallel_change:
144
+ aka: "Expand-Migrate-Contract"
145
+ phases:
146
+ expand: "Add new alongside old, new code uses new, old still works"
147
+ migrate: "Update all clients to new, verify, data migration"
148
+ contract: "Remove old, clean up, update docs"
149
+
150
+ # === SAFETY: Legacy Code Strategies ===
151
+ safety:
152
+ legacy:
153
+ definition: "Code without tests (regardless of age)"
154
+ dilemma: "Need tests to change safely → Need to change to add tests"
155
+ solution: "Safe techniques to add tests first"
156
+
157
+ characterization_tests:
158
+ purpose: "Capture existing behavior (not verify correctness)"
159
+ process:
160
+ 1: "Call code to understand"
161
+ 2: "Write assertion expected to FAIL"
162
+ 3: "Run, see actual result"
163
+ 4: "Update assertion to match actual"
164
+ 5: "Repeat until behavior covered"
165
+ principle: "Document what code DOES, not what it SHOULD do"
166
+
167
+ scratch_refactoring:
168
+ definition: "Refactor to understand, discard all changes"
169
+ workflow:
170
+ 1: "Create scratch branch (or git stash)"
171
+ 2: "Aggressively refactor to understand"
172
+ 3: "Take notes on learnings"
173
+ 4: "Discard changes (git reset --hard)"
174
+ 5: "Apply learnings to write characterization tests"
175
+ when: [code_too_complex, no_docs, need_mental_model_fast]
176
+ principle: "Goal is understanding, not clean code"
177
+
178
+ seams:
179
+ definition: "Place to alter behavior without editing code"
180
+ object: "Override via polymorphism (inject test double)"
181
+ preprocessing: "Compile-time substitution (macros)"
182
+ link: "Replace at link time (DI, module replacement)"
183
+
184
+ sprout_wrap:
185
+ sprout_method: "New logic → create new method, call from old"
186
+ sprout_class: "New logic evolves independently → new class"
187
+ wrap_method: "Add before/after → rename original, create wrapper"
188
+ wrap_class: "Decorate existing → decorator pattern"
189
+ principle: "New code uses TDD; legacy untouched until tested"
116
190
 
117
191
  # === DATABASE: Refactoring ===
118
192
  db_expand_contract:
@@ -159,6 +233,29 @@ priority:
159
233
 
160
234
  tracking:
161
235
  fields: [description, impact, estimated_effort, risk_if_ignored, related_code]
236
+
237
+ # === DECISION MATRIX SUMMARY ===
238
+ decision_matrix:
239
+ - {strategy: "Preparatory Refactoring", scale: "Small", risk: "Low", use: "Reduce friction before feature work"}
240
+ - {strategy: "Boy Scout Rule", scale: "Very Small", risk: "Low", use: "Continuous debt repayment"}
241
+ - {strategy: "Red-Green-Refactor", scale: "Small", risk: "Low", use: "TDD development cycle"}
242
+ - {strategy: "Strangler Fig", scale: "Large", risk: "Medium", use: "System replacement"}
243
+ - {strategy: "Anti-Corruption Layer", scale: "Medium", risk: "Low", use: "New-legacy coexistence"}
244
+ - {strategy: "Branch by Abstraction", scale: "Large", risk: "Medium", use: "Trunk refactoring"}
245
+ - {strategy: "Parallel Change", scale: "Medium", risk: "Low", use: "Interface/schema migration"}
246
+ - {strategy: "Characterization Tests", scale: "—", risk: "—", use: "Prerequisite for legacy refactoring"}
247
+ - {strategy: "Scratch Refactoring", scale: "Small", risk: "Low", use: "Understanding black-box code"}
248
+
249
+ # === STRATEGY SELECTION ===
250
+ selection_guide:
251
+ feature_blocked_by_messy_code: "Preparatory Refactoring"
252
+ touching_code_during_bug_fix: "Boy Scout Rule"
253
+ writing_new_code_with_tdd: "Red-Green-Refactor"
254
+ replacing_entire_legacy_system: "Strangler Fig"
255
+ integrating_without_pollution: "Anti-Corruption Layer"
256
+ refactoring_shared_code_on_trunk: "Branch by Abstraction"
257
+ changing_widely_used_interface: "Parallel Change"
258
+ working_with_untested_legacy: "Characterization Tests + Scratch Refactoring FIRST"
162
259
  ```
163
260
 
164
261
  ---
@@ -194,6 +291,7 @@ For complete standards, see:
194
291
 
195
292
  | Version | Date | Changes |
196
293
  |---------|------|---------|
294
+ | 2.0.0 | 2026-01-21 | Added tactical strategies (Preparatory Refactoring, Boy Scout Rule), Anti-Corruption Layer, Decision Matrix Summary. Reorganized into Tactical/Strategic/Safety tiers. |
197
295
  | 1.0.0 | 2026-01-12 | Initial release |
198
296
 
199
297
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-dev-standards",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "CLI tool for adopting Universal Development Standards",
5
5
  "keywords": [
6
6
  "documentation",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "version": "4.0.0",
4
- "lastUpdated": "2026-01-20",
3
+ "version": "4.1.0",
4
+ "lastUpdated": "2026-01-21",
5
5
  "description": "Standards registry for universal-dev-standards with integrated skills and AI-optimized formats",
6
6
  "formats": {
7
7
  "ai": {
@@ -48,14 +48,14 @@
48
48
  "standards": {
49
49
  "name": "universal-dev-standards",
50
50
  "url": "https://github.com/AsiaOstrich/universal-dev-standards",
51
- "version": "4.0.0"
51
+ "version": "4.1.0"
52
52
  },
53
53
  "skills": {
54
54
  "name": "universal-dev-standards",
55
55
  "url": "https://github.com/AsiaOstrich/universal-dev-standards",
56
56
  "localPath": "skills/claude-code",
57
57
  "rawUrl": "https://raw.githubusercontent.com/AsiaOstrich/universal-dev-standards/main/skills/claude-code",
58
- "version": "4.0.0",
58
+ "version": "4.1.0",
59
59
  "note": "Skills are now included in the main repository under skills/"
60
60
  }
61
61
  },
@@ -256,7 +256,11 @@
256
256
  "skills/claude-code/commands/update.md",
257
257
  "skills/claude-code/commands/reverse-spec.md",
258
258
  "skills/claude-code/commands/reverse-bdd.md",
259
- "skills/claude-code/commands/reverse-tdd.md"
259
+ "skills/claude-code/commands/reverse-tdd.md",
260
+ "skills/claude-code/commands/refactor.md"
261
+ ],
262
+ "refactoring-assistant": [
263
+ "skills/claude-code/refactoring-assistant/SKILL.md"
260
264
  ],
261
265
  "methodology-system": [
262
266
  "skills/claude-code/methodology-system/SKILL.md",
@@ -814,10 +818,10 @@
814
818
  "human": "core/refactoring-standards.md",
815
819
  "ai": "ai/standards/refactoring-standards.ai.yaml"
816
820
  },
817
- "category": "reference",
818
- "skillName": null,
821
+ "category": "skill",
822
+ "skillName": "refactoring-assistant",
819
823
  "level": 2,
820
- "description": "Comprehensive refactoring guidelines covering legacy code strategies, large-scale patterns, database refactoring, metrics, and team collaboration"
824
+ "description": "Comprehensive refactoring guidelines with tactical, strategic, and legacy code safety strategies including decision matrix"
821
825
  },
822
826
  {
823
827
  "id": "csharp-style",