一键导入
refactor
Analyze code and suggest refactoring opportunities with blast radius assessment, risk evaluation, and recommended order of operations
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Analyze code and suggest refactoring opportunities with blast radius assessment, risk evaluation, and recommended order of operations
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Consult the whizz-mind knowledge base for documentation and answers. Use when the user asks questions that might be answered by stored documentation or when explicitly asked to check whizz-mind.
Run accessibility and visual design review
Interact with Figma design files via the web browser using the Figma Plugin API. Can create shapes, modify properties, extract information from design files.
Research-driven content writing with citations, iterative outlines, and real-time feedback. Transforms writing from solo effort to collaborative partnership.
Full implementation mode - end-to-end feature implementation with phased execution, parallel work streams, verification gates, and atomic commits per phase
Deep analysis mode - thorough multi-phase investigation with expert consultation for complex problems requiring careful examination
| name | refactor |
| description | Analyze code and suggest refactoring opportunities with blast radius assessment, risk evaluation, and recommended order of operations |
| license | MIT |
| compatibility | ["runtime:any"] |
| allowed-tools | ["Read","Glob","Grep"] |
| metadata | {"author":"thoreinstein","version":"1.0.0"} |
Analyze code and suggest refactoring opportunities with rationale. This is an analysis-only skill - it identifies and documents refactoring opportunities but does not execute them.
| Pattern | Description |
|---|---|
| Extract function/method | Pull out reusable logic |
| Inline function/variable | Remove unnecessary indirection |
| Rename | Improve clarity (with blast radius assessment) |
| Move | Relocate to better home (file, package, module) |
| Replace conditional with polymorphism | Simplify branching |
| Introduce parameter object | Group related parameters |
| Dependency inversion | Decouple via interfaces/abstractions |
| Pattern | Description |
|---|---|
| Extract interface | Define behavior contracts |
| Consolidate error handling | Reduce repetitive error checks |
| Replace concrete with interface | Improve testability |
| Extract middleware | Separate cross-cutting concerns |
| Table-driven refactor | Convert repetitive code to data-driven |
| Pattern | Description |
|---|---|
| Extract component | Break down large components |
| Extract custom hook | Reuse stateful logic |
| Lift state up | Move state to common ancestor |
| Push state down | Colocate state with usage |
| Extract render function | Simplify complex JSX |
| Memoization | Optimize re-renders |
Document the analysis using the template at references/templates/refactor-analysis.md.
The analysis should include:
Refactoring Analysis: pkg/auth/handler.go
Target:
- Path: pkg/auth/handler.go
- Scope: file
- Concern: complexity
Summary:
The auth handler has grown to 450 lines with 3 code smells identified.
Recommend extracting token validation and session management into
separate services. Low-risk changes that improve testability.
Code Smells Identified:
1. Long Function (validateAndCreateSession)
- Location: handler.go:145-280
- Description: 135-line function handling validation, session
creation, and response formatting
- Impact: Hard to test, multiple responsibilities
2. Feature Envy (token validation)
- Location: handler.go:156-198
- Description: Handler reaches into token package internals
- Impact: Tight coupling, changes ripple across packages
Suggested Refactorings:
1. Extract TokenValidator service
- Type: Extract
- Target: handler.go:156-198
- Rationale: Encapsulates token validation logic
- Blast Radius: handler.go, handler_test.go
- Risk: Low — isolated logic, good test coverage
- Test Impact: Add TokenValidator unit tests
2. Extract SessionManager service
- Type: Extract
- Target: handler.go:200-250
- Rationale: Separates session concerns from HTTP handling
- Blast Radius: handler.go, session.go, handler_test.go
- Risk: Medium — touches session storage
- Test Impact: Update integration tests
Recommended Order:
1. TokenValidator first (lowest risk, no dependencies)
2. SessionManager second (depends on cleaner handler)
Begin by identifying the target code and any specific concerns to focus on.