refactor

Detect code smells and generate refactorings with before/after code.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/nijaru/dotfiles --skill refactor-nijaru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/nijaru/dotfiles/tree/main/private_dot_codex/skills/refactor
Command: npx skills add https://github.com/nijaru/dotfiles --skill refactor-nijaru

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Analyze code and suggest concrete refactorings to improve readability and maintainability.

Core Features & Use Cases

  • Naming improvements and removing magic numbers
  • Breaking large functions into smaller ones
  • Extracting classes or modules to reduce coupling

Quick Start

Ask me to analyze a file or snippet: 'refactor this function in utils.go' for a suggested refactor plan and before/after code.

Frequently Asked Questions about refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I identify code smells in my codebase?

Code smells are patterns indicating deeper problems: unclear naming, long methods exceeding 40 lines, deep nesting, and issues like Feature Envy or Data Clumps. Detecting them early during code reviews helps maintainability before they compound into larger architectural debt.

What refactoring techniques improve code readability?

Refactoring techniques include extracting helpers from long methods, replacing multiple parameters with parameter objects, reducing nesting with early returns, and improving variable and function names. These directly address maintainability and reduce cognitive load for future readers.

Can I apply refactorings across different programming languages?

Refactoring principles—extract helpers, replace parameter lists, reduce nesting, fix naming—apply across codebases regardless of language. Analysis detects language-agnostic structural issues and outputs before/after code in your target language.

How do I decide what code to refactor first?

Prioritize code with the most obvious smells: unclear names, methods over 40 lines, parameter lists exceeding four arguments, and deeply nested blocks. Focus on hot paths touched during maintenance or code reviews where clarity yields immediate value.

What's the difference between refactoring and rewriting?

Refactoring preserves external behavior while improving internal structure—naming, size, nesting. Rewriting changes what code does. Refactoring reduces risk and maintains correctness; detection outputs actionable steps with rationale and benefits for each change.