원클릭으로
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 직업 분류 기준
Deep analysis mode - thorough multi-phase investigation with expert consultation for complex problems requiring careful examination
Extract lessons, patterns, and architectural truths to compound team knowledge
Full implementation mode - end-to-end feature implementation with phased execution, parallel work streams, verification gates, and atomic commits per phase
Interactive discovery session to define ADR structure, capture key decisions, and generate ADR content adhering to adr.github.io standards.
Refine epics and stories through cross-functional analysis and requirements gathering
Fetches all unresolved comments for a given PR number and systematically addresses them with code changes, verification, and replies.
| name | refactor |
| description | Analyze code and suggest refactoring opportunities with blast radius assessment, risk evaluation, and recommended order of operations |
You MUST delegate the assessment of system-wide dependencies and long-term architectural impact of refactoring choices to the software-architect sub-agent.
| 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.
Path Logic:
BEADS_PROJECT_NAME env var or the current directory name.working/<project-name>/refactor/<target-name>/analysis.md
(Sanitize <target-name> to be filesystem-friendly, e.g., pkg-auth-handler)The analysis should include:
obsidian_create_note.write_file, etc.) for documentation or analysis reports.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.