Refactor

From Pageloom/weft-id · View interactive version

Refactor is an AI agent skill from the GitHub repository Pageloom/weft-id. Refactor Agent - Identify refactoring opportunities and technical debt

How to use this skill

Skill file

Refactor Agent - Code Quality Analysis Mode

Identify refactoring opportunities and technical debt. Primary goal: make code easy for Claude to traverse.

Quick Reference

Before You Start

  1. Read .claude/THOUGHT_ERRORS.md to avoid past mistakes
  2. Read .claude/REFACTOR_HISTORY.md to see what's been scanned recently

Primary Priority: Claude Traversability

| Factor | Target | Why |

|--------|--------|-----|

| File size | <500 lines, <300 preferred | Large files don't fit in context |

| Module boundaries | Single responsibility | One file = one concept |

| Consistent patterns | Same everywhere | No re-learning per file |

| Self-documenting | Names match contents | Navigate without exploration |

Categories

1. File Structure (Highest Priority)

2. Code Duplication

3. Complex Functions

4. Inconsistent Patterns

5. Dead Code

6. Poor Abstractions

7. Tight Coupling

8. Quality of Test Code

See .claude/references/refactor-patterns.md for detailed patterns and examples.

Workflow

1. Review History

Check .claude/REFACTOR_HISTORY.md to understand:

2. Ask User

3. Systematic Scanning

File Structure (do first):

Per Category:

4. Report as GitHub issues

One issue per opportunity, labelled enhancement plus one prio-* label (High impact: prio-high, Medium: prio-medium, Low: prio-low), with the issue format below as the body (its heading, without the tag, becomes the title). See .claude/references/issue-tracking.md for the commands.

5. Update History

After scanning, update .claude/REFACTOR_HISTORY.md with:

Thresholds

| Metric | Flag | Critical |

|--------|------|----------|

| File lines | >500 | >1000 |

| Function lines | >50 | >100 |

| Nesting levels | >3 | >5 |

| Parameters | >5 | >7 |

| Imports from same module | >3 | - |

Issue Format

## [REFACTOR] [Category]: [Brief Description]

**Found in:** [File:line]
**Impact:** High/Medium/Low
**Category:** [File Structure | Duplication | Complexity | etc.]
**Description:** [What's wrong]
**Evidence:** [Code snippet]
**Why It Matters:** [Maintainability, bugs, development speed]
**Suggested Refactoring:** [Specific approach]
**Files Affected:** [List]

Example:

Before:

[problematic code]

After:

[improved code]


---

What You Cannot Do

Start Here

  1. Read .claude/REFACTOR_HISTORY.md
  2. Ask about scope, focus, and depth
  3. Recommend areas based on history
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.