Refactor logo

Refactor

CommunityPopular
FlorianBruniaux
refactor

Analyze code for SOLID violations and suggest targeted improvements

Overview

PublisherFlorianBruniaux
Repositoryclaude-code-ultimate-guide
Skill namerefactor
Stars
6K
Forks
782
Bundled files
Instructions only
LicenseCC-BY-SA-4.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by FlorianBruniaux on GitHub. Read the source before you install it.

Installation

Install the Refactor AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/FlorianBruniaux/claude-code-ultimate-guide.git /tmp/claude-code-ultimate-guide
mkdir -p .claude/skills
cp -r /tmp/claude-code-ultimate-guide/examples/skills/refactor .claude/skills/refactor
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Refactor in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Refactor on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Refactor is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

SOLID Refactoring Assistant

Analyze code for SOLID violations and suggest targeted improvements.

Purpose

Identify refactoring opportunities based on:

  • SOLID principle violations
  • Code smells and anti-patterns
  • Complexity metrics
  • Duplication detection

Instructions

Step 1: Scope Analysis

Determine the refactoring scope from user input:

  • Single file: Deep analysis
  • Directory: Pattern detection across files
  • Function/class: Focused extraction suggestions
bash
# Get file/directory stats
if [ -f "$TARGET" ]; then
  wc -l "$TARGET"
  echo "Single file analysis"
elif [ -d "$TARGET" ]; then
  find "$TARGET" -type f \( -name "*.ts" -o -name "*.js" -o -name "*.py" \) | wc -l
  echo "Directory analysis"
fi

Step 2: SOLID Violations Detection

S - Single Responsibility

Look for:

  • Files > 300 lines
  • Functions > 50 lines
  • Classes with > 10 methods
  • Mixed concerns (data + UI + business logic)
bash
# Find large files
find . -name "*.{ts,js,py}" -exec wc -l {} + 2>/dev/null | sort -rn | head -10

# Functions with high line count (approximate)
grep -rn "function\|def \|fn " --include="*.{ts,js,py,rs}" . | head -20
O - Open/Closed Principle

Look for:

  • Switch/case statements on types
  • Repeated if/else type checking
  • Direct modifications vs extensions
L - Liskov Substitution

Look for:

  • Overridden methods that throw "not implemented"
  • Type checks before method calls
  • Empty method overrides
I - Interface Segregation

Look for:

  • Large interfaces (> 10 methods)
  • Classes implementing unused interface methods
  • Fat service classes
D - Dependency Inversion

Look for:

  • Direct instantiation of dependencies (new Service())
  • Hardcoded class references
  • Missing dependency injection

Step 3: Code Smells

bash
# Duplication patterns
grep -rn --include="*.{ts,js,py}" . 2>/dev/null | \
  awk -F: '{print $3}' | sort | uniq -c | sort -rn | head -10

# Long parameter lists (> 4 params)
grep -rn "function.*,.*,.*,.*," --include="*.{ts,js}" . 2>/dev/null | head -10

# Deep nesting (4+ levels)
grep -rn "^\s\{16,\}" --include="*.{ts,js,py}" . 2>/dev/null | head -10

Step 4: Complexity Assessment

For each issue found, assess:

  • Impact: How much code is affected?
  • Risk: What could break?
  • Effort: Lines to change, tests needed?

Output Format


🔧 Refactoring Analysis

Target: [file/directory] Lines Analyzed: [count]

📊 SOLID Scorecard

PrincipleStatusIssues Found
Single Responsibility🟡3 large classes
Open/Closed🟢OK
Liskov Substitution🟢OK
Interface Segregation🔴2 fat interfaces
Dependency Inversion🟡5 direct instantiations

🎯 Priority Refactorings

1. [Highest Impact] - Extract class from UserService

Violation: Single Responsibility Current: 450 lines handling auth + profile + notifications Suggested:

UserService.ts (450 lines)
    ↓ Extract
AuthService.ts (~150 lines)
ProfileService.ts (~150 lines)
NotificationService.ts (~100 lines)

Risk: Medium (update imports) Tests Needed: Update dependency injection in tests

2. [Second Priority] - Replace switch with polymorphism

Location: src/handlers/payment.ts:45 Current:

typescript
switch (paymentType) {
  case 'card': // 50 lines
  case 'bank': // 50 lines
  case 'crypto': // 50 lines
}

Suggested: Strategy pattern with PaymentProcessor interface Risk: Low (isolated change)

📝 Code Smells

SmellLocationSeverity
Long Methodapi.ts:calculateTotal (120 lines)🟠 High
Duplicate Codeutils/*.ts (3 similar blocks)🟡 Medium
Deep Nestingparser.ts:parse (6 levels)🟡 Medium

🚀 Quick Wins (Low Risk, High Value)

  1. Extract validateEmail() to shared utils (used in 4 places)
  2. Replace magic numbers with named constants
  3. Add early returns to reduce nesting in processOrder()

⚠️ Technical Debt Notes

  • [Item to track for future sprints]

Refactoring Safety Checklist

Before applying suggestions:

  • Tests exist for affected code
  • Create feature branch
  • Commit current state
  • Apply one refactoring at a time
  • Run tests after each change
  • Review diff before committing

Usage

Analyze specific file:

/refactor src/services/user.ts

Analyze directory:

/refactor src/api/

Focus on specific principle:

/refactor --focus=srp src/services/

With complexity threshold:

/refactor --threshold=high

References

  • Martin Fowler's Refactoring Catalog
  • Clean Code by Robert C. Martin
  • SOLID principles by Robert C. Martin

$ARGUMENTS

Frequently asked questions

What does the Refactor AI skill do?

Analyze code for SOLID violations and suggest targeted improvements

Why use Refactor on TypingMind?

Because you install it once and use it with any model. Refactor is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Refactor in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/FlorianBruniaux/claude-code-ultimate-guide/tree/main/examples/skills/refactor. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Refactor?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Refactor?

As many as you like. As long as a model supports skills, you can use Refactor with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Refactor AI skill free?

Yes. It is published on GitHub by FlorianBruniaux under the CC-BY-SA-4.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇