Get the FREE Ultimate OpenClaw Setup Guide →

refactoring-skills

npx machina-cli add skill wayne930242/Reflexive-Claude-Code/refactoring-skills --openclaw
Files (1)
SKILL.md
6.3 KB

Refactoring Skills

Overview

Refactoring skills IS applying clean code principles to documentation.

Consolidate, simplify, extract shared conventions, remove redundancy.

Core principle: Fewer focused skills > many overlapping skills.

Violating the letter of the rules is violating the spirit of the rules.

Task Initialization (MANDATORY)

Before ANY action, create task list using TaskCreate:

TaskCreate for EACH task below:
- Subject: "[refactoring-skills] Task N: <action>"
- ActiveForm: "<doing action>"

Tasks:

  1. Discover all skills
  2. Analyze and classify
  3. Execute refactoring plan
  4. Extract shared conventions
  5. Validate results
  6. Generate report

Announce: "Created 6 tasks. Starting execution..."

Execution rules:

  1. TaskUpdate status="in_progress" BEFORE starting each task
  2. TaskUpdate status="completed" ONLY after verification passes
  3. If task fails → stay in_progress, diagnose, retry
  4. NEVER skip to next task until current is completed
  5. At end, TaskList to confirm all completed

Task 1: Discover All Skills

Goal: Find all skills in the project.

Search locations:

find . -name "SKILL.md" -type f 2>/dev/null
ls -la .claude/skills/ 2>/dev/null

Also check:

  • Plugin directories
  • User-level skills (~/.claude/skills/)

Document:

  • Skill name
  • Location
  • Brief description

Verification: Complete list of all skills with locations.

Task 2: Analyze and Classify

Goal: Classify each skill for action.

Classification Matrix

StatusCriteriaAction
KeepWell-structured, unique purpose, follows standardsNone
RefactorHas issues but valuableUse writing-skills to improve
MergeOverlaps with another skillConsolidate into primary
ExtractHas conventions shared by othersMove to rule file
DeleteRedundant, unused, or supersededRemove entirely

Analysis Questions

For each skill:

  1. Is the purpose clear and unique?
  2. Does it overlap with another skill?
  3. Does it contain shared conventions (→ extract to rule)?
  4. Is it actually used?
  5. Does it follow current standards?

Optional: External Search

If claude-skills-mcp is available:

mcp__claude-skills-mcp__search_skills query="[skill domain]"

Compare with community implementations. Better patterns exist?

Verification: Each skill has a classification and action.

Task 3: Execute Refactoring Plan

Goal: Apply the classified actions.

For Skills to Refactor

Invoke the writing-skills skill with the existing skill path.

For Skills to Merge

  1. Identify the primary skill (keep this one)
  2. Extract unique content from secondary skill
  3. Integrate into primary skill
  4. Delete secondary skill directory

For Skills to Delete

  1. Confirm no dependencies (grep for skill name)
  2. Remove entire skill directory
  3. Remove from any manifest references

CRITICAL: One action at a time. Verify after each.

Verification: All classified actions executed.

Task 4: Extract Shared Conventions

Goal: Move duplicated conventions to rule files.

Signs of shared conventions:

  • Same constraint appears in 2+ skills
  • Convention is about "what" not "how"
  • Convention is path-specific

Process:

  1. Identify duplicated constraint
  2. Invoke writing-rules skill to create rule
  3. Remove constraint from all skills
  4. Verify rule auto-injects correctly

Verification: No duplicated conventions across skills.

Task 5: Validate Results

Goal: Verify all remaining skills are valid.

For each skill:

python3 scripts/validate_skill.py <skill-path>

Or manual checklist:

  • Frontmatter has name and description
  • Description starts with "Use when..."
  • Body < 300 lines
  • No duplicated conventions (now in rules)

Verification: All remaining skills pass validation.

Task 6: Generate Report

Goal: Document what was done.

Report Format

## Refactoring Summary

### Skills Analyzed: N

### Actions Taken:
| Skill | Action | Notes |
|-------|--------|-------|
| skill-name | kept/refactored/merged/deleted | details |

### Rules Extracted:
| Rule | Source Skills |
|------|--------------|
| rule-name | skill-a, skill-b |

### Recommendations:
- [Future improvements]

Verification: Report accurately reflects all changes.

Red Flags - STOP

These thoughts mean you're rationalizing. STOP and reconsider:

  • "Keep all skills, they might be useful"
  • "Too much overlap is fine"
  • "Don't need to extract conventions"
  • "Skip validation, I just fixed them"
  • "Report is busywork"

All of these mean: You're about to leave mess behind. Follow the process.

Common Rationalizations

ExcuseReality
"Keep everything"Unused skills are clutter. Delete them.
"Overlap is fine"Overlap = confusion. Merge or differentiate.
"Skip extraction"Duplicated conventions drift. Extract to rules.
"Skip validation"Fixed skills can still be broken. Validate.
"Skip report"Report documents decisions for future you.

Flowchart: Skill Refactoring

digraph refactor_skills {
    rankdir=TB;

    start [label="Refactor skills", shape=doublecircle];
    discover [label="Task 1: Discover\nall skills", shape=box];
    analyze [label="Task 2: Analyze\nand classify", shape=box];
    execute [label="Task 3: Execute\nrefactoring plan", shape=box];
    extract [label="Task 4: Extract\nshared conventions", shape=box];
    validate [label="Task 5: Validate\nresults", shape=box];
    valid [label="All\nvalid?", shape=diamond];
    report [label="Task 6: Generate\nreport", shape=box];
    done [label="Refactoring complete", shape=doublecircle];

    start -> discover;
    discover -> analyze;
    analyze -> execute;
    execute -> extract;
    extract -> validate;
    validate -> valid;
    valid -> report [label="yes"];
    valid -> execute [label="no\nfix"];
    report -> done;
}

References

  • Use writing-skills skill for improving skills
  • Use writing-rules skill for extracting conventions
  • Use skill-reviewer subagent for quality checks

Source

git clone https://github.com/wayne930242/Reflexive-Claude-Code/blob/main/plugins/rcc/skills/refactoring-skills/SKILL.mdView on GitHub

Overview

Refactoring skills apply clean code principles to project documentation by consolidating and simplifying skills, extracting shared conventions, and removing redundancy. The core principle is that fewer, well-scoped skills outperform many overlapping ones. This skill orchestrates a six-task workflow to discover, classify, refactor, extract conventions, validate, and report results.

How This Skill Works

It orchestrates a six-task workflow using TaskCreate to list actions, then sequentially updates task statuses with TaskUpdate before and after work. It leverages writing-skills for actual refactoring and writing-rules for extracting shared conventions into rule files. Tasks are executed one at a time with verification after each, and a final TaskList confirms completion.

When to Use It

  • When skills are messy or overlapping and need consolidation.
  • When a project requires a skill review or cleanup triggered by user intent (e.g., 'refactor skills', 'cleanup skills', 'consolidate skills', 'skill review').
  • During a formal refactoring or documentation audit to classify each skill (Keep/Refactor/Merge/Extract/Delete).
  • Before generating a final skills report or clean manifest to avoid duplicates.
  • When external patterns indicate shared conventions that should be moved to rules.

Quick Start

  1. Step 1: TaskCreate for EACH task below: - Subject: "[refactoring-skills] Task N: <action>" - ActiveForm: "<doing action>"
  2. Step 2: For each task, run TaskUpdate status="in_progress" before starting, and status="completed" after verification passes
  3. Step 3: After all tasks, run TaskList to confirm all tasks are completed and generate the final report

Best Practices

  • Start by Discovering All Skills to get a complete map.
  • Use the Classification Matrix to decide action per skill.
  • Refactor one action at a time; verify after each step.
  • Extract shared conventions into rule files using writing-rules.
  • Validate results with the provided verification steps and run tests (validate_skill).

Example Use Cases

  • A project with dozens of overlapping skills is cleaned up to a few focused skills.
  • Two nearly identical skills are merged into a primary skill with content extracted.
  • Shared conventions like naming schemes moved to a rule file via extraction.
  • A task failure triggers diagnostics and retry rather than skipping ahead.
  • A final report lists all completed tasks and their locations for auditability.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers