Agent skill

Refactor

by dcodesdev in dcodesdev/LetterSpace

Use this when the user wants to refactor the codebase, clean up code, reduce duplication, or says 'refactor' / 'new refactor'.

MITAuto-check passedDevelopment

Install Refactor

skills CLI
$ npx skills add dcodesdev/LetterSpace --skill refactor -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dcodesdev/LetterSpace refactor --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dcodesdev/LetterSpace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/refactor .claude/skills/refactor && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
refactor
GitHub stars
100
Token cost
~1.4k tokens
SKILL.md length
536 words
Files
1
Skills in repo
5
Repo updated
First seen
Licence
MIT

At a glance

Use this when the user wants to refactor the codebase, clean up code, reduce duplication, or says 'refactor' / 'new refactor'.

  • Wants to refactor the codebase
  • SKILL.md covers Overview, The Process and Key Principles
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Reduce duplication

What it does

Refactor is an agent skill from dcodesdev/LetterSpace. Use this when the user wants to refactor the codebase, clean up code, reduce duplication, or says 'refactor' / 'new refactor'. This skill explores the codebase to find concrete refactoring opportunities (DRY, file splitting, shared helpers), then writes a phased SPEC.md and PROGRESS.md into a timestamped plans/ directory and points PROMPT.md at it so the Ralph loop can execute the refactor phase by phase.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Refactoring. The repository describes itself as: Self-hosted open source newsletter platform for managing subscribers and sending campaigns. The licence is MIT.

When your agent uses it

  • Wants to refactor the codebase
  • Reduce duplication
  • Says refactor / new refactor

Example prompts

  • “refactor”
  • “new refactor”
  • “/refactor”

What it can do on your machine

Read from SKILL.md and the folder at commit a06ec86. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are markdown and yaml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Refactor loads about 1.4k tokens when it runs. Until then it costs about 104 tokens; SKILL.md has 536 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~104
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dcodesdev/LetterSpace at commit a06ec86, republished under its MIT licence (© dcodesdev). 536 words, ~1,403 tokens.

Download SKILL.mdSave it as .claude/skills/refactor/SKILL.md (or your agent's skills folder).
name
refactor
description
Use this when the user wants to refactor the codebase, clean up code, reduce duplication, or says 'refactor' / 'new refactor'. This skill explores the codebase to find concrete refactoring opportunities (DRY, file splitting, shared helpers), then writes a phased SPEC.md and PROGRESS.md into a timestamped plans/ directory and points PROMPT.md at it so the Ralph loop can execute the refactor phase by phase.

Refactor

Overview

Create a structured refactor plan by exploring the codebase for concrete opportunities to reduce duplication, shorten files, and split responsibilities — then write a phased plan to disk and wire it up to PROMPT.md so the Ralph loop can execute it one phase at a time.

This skill is a sibling of new-plan: same output shape (plans/YYYY-MM-DD-HHMM-<name>/SPEC.md + PROGRESS.md, PROMPT.md frontmatter updated), but the content is specifically a refactor plan grounded in real findings from the codebase.

The Process

1. Explore the codebase thoroughly before writing anything:

The plan must be grounded in real findings, not generic advice. Before writing the SPEC.md, do a real exploration pass:

  • Map the project structure: top-level directories, packages, entry points
  • Read key files end to end so you understand current patterns and conventions
  • Identify duplicated logic, copy-pasted blocks, near-identical functions across files
  • Identify long files (rough heuristic: > ~300 lines, or files mixing many concerns)
  • Identify files that mix multiple responsibilities and could be split into focused modules/components
  • Identify utilities that exist inline but should be shared (DRY candidates)
  • Note existing conventions (naming, module layout, test layout) so the refactor stays consistent

Record specific file paths and line ranges in the plan. Vague tasks like "clean up utils" are not acceptable — every task should name the files involved.

2. Be conservative — do not force refactors:

  • Only propose changes where the benefit is clear: real duplication, real complexity, real readability win
  • If two pieces of code look similar but serve different purposes, leave them alone
  • Premature abstraction is worse than duplication — three similar lines is fine
  • Skip churn-only changes (renames, restyling) unless the user asked for them
  • Prefer small, contained refactors over sweeping restructures
  • Do not change behavior. Refactors must be behavior-preserving unless the user explicitly asks otherwise

3. Break the work into phases / chunks:

Each phase should be small enough to complete in a single Ralph loop iteration and behavior-preserving on its own. Suggested chunking strategies (pick what fits):

Show full SKILL.md (212 more words)Show less
  • By area: one package or directory per phase
  • By concern: extract shared helpers first, then split files, then thin out call sites
  • By file: one large file's split per phase

If a phase has many tasks, split it into sub-phases (Phase 2.a, 2.b, ...) of ~5 tasks each.

4. Write the SPEC.md:

Create the plan file at ./plans/YYYY-MM-DD-HHMM-<name>/SPEC.md where:

  • YYYY-MM-DD-HHMM is the current date and time (e.g. 2026-04-27-1530)
  • <name> is a short kebab-case name like refactor-core, refactor-cli-commands, refactor-ui

Use this structure:

markdown
# <Refactor Name>

## Goal

One paragraph: what we're refactoring and why. Call out the user-visible promise — usually "no behavior change, just cleaner internals."

## Findings

Concrete observations from exploration. Each finding names files and what's wrong:

- `path/to/file.ts` — 600+ lines mixing X, Y, Z; split candidates: ...
- `pkg/a/foo.ts` and `pkg/b/bar.ts` share ~40 lines of nearly identical logic — extract to `pkg/shared/...`
- ...

## Phases

### Phase 1: <Name>

- [ ] Specific task naming files (e.g. "Extract `formatError` from `apps/cli/commands/run.ts` and `apps/cli/commands/build.ts` into `packages/core/errors.ts`")
- [ ] ...

### Phase 2: <Name>

- [ ] ...

(as many phases as needed — keep them small, focused, and behavior-preserving)
(if a phase has too many tasks, split into 2.a, 2.b, ...)

## Constraints

- Behavior must be preserved (unless the user explicitly relaxes this)
- All existing tests must continue to pass; type-check must stay green
- Follow existing project conventions (module layout, naming)
- No drive-by feature changes, no dependency upgrades

## Success Criteria

- Tests + type-check pass at the end of every phase
- Targeted files are measurably shorter / less duplicated
- No behavior change observable from the outside

5. Update PROMPT.md:

Update the frontmatter in ./PROMPT.md to point to the new plan:

yaml
---
plan: plans/YYYY-MM-DD-HHMM-<name>
---

The Ralph loop will pick up the new plan and execute one phase per iteration.

6. Create an empty PROGRESS.md:

In the same directory as the spec:

markdown
# Progress

## Completed Phases

(none yet)

## Current Phase

Not started.

## Notes

Key Principles

  • Findings first — no phase makes it into the plan without a concrete finding behind it
  • Behavior-preserving — refactors do not change semantics
  • One phase = one iteration — each phase is completable in a single Ralph loop run
  • Split large phases — break into sub-phases (2.a, 2.b, ...) of ~5 tasks each
  • DRY where it pays off — only extract shared code when the duplication is real and the abstraction is obvious
  • Split files where it helps — only split when a file mixes clearly separable concerns
  • YAGNI — do not refactor speculatively for hypothetical future needs

© dcodesdev, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/refactor of dcodesdev/LetterSpace.

Open the folder on GitHubat commit a06ec86

Compare with similar skills

Refactor next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Refactor compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Refactor this skilldcodesdev/LetterSpace100—~1.4kAutomated safety check: PassMIT
Guidelinesakash-network/node1.1k22 repos~577Automated safety check: PassMIT
Component Refactoringlangflow-ai/langflow156k—~3.5kAutomated safety check: PassMIT
Migrate Core Code to Submodulestinyhumansai/openhuman42k—~2.6kAutomated safety check: PassGPL-3.0
Systematic Code Refactoringluongnv89/claude-howto42k—~3kAutomated safety check: PassMIT
Codexskills-directory/skill-codex1.5k3 repos~1.8kAutomated safety check: PassMIT

Similar skills

  • Guidelines

    akash-network/node

    Behavioral guidelines to reduce common LLM coding mistakes. An agent skill from akash-network/node.

    1.1k GitHub starsUsed in 22 repos~577 tokens
    DevelopmentAuto-check passed
  • Component Refactoring

    langflow-ai/langflow

    Refactor high-complexity React components in Langflow frontend.

    156k GitHub stars~3.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Migrate Core Code to Submodules

    tinyhumansai/openhuman

    Plans and carries out moving non-host-specific code and its tests from the OpenHuman core into vendored tiny submodule libraries, then releases the submodule and re-pins the host.

    42k GitHub stars~2.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Systematic Code Refactoring

    luongnv89/claude-howto

    Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.

    42k GitHub stars~3k tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • Codex

    skills-directory/skill-codex

    A skill your agent uses when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing

    1.5k GitHub starsUsed in 3 repos~1.8k tokens
    DevelopmentAuto-check passed
  • Ponytail

    DavidObando/gsharp

    Forces the laziest solution that actually works, simplest, shortest, most minimal.

    565 GitHub starsUsed in 8 repos~1.7k tokens
    DevelopmentAuto-check passed

More from dcodesdev/LetterSpace

  • Design Brief

    dcodesdev/LetterSpace

    Use this when the user wants something designed — a screen, page, flow, app, or redesign — or says 'design', 'design brief', 'UI for'.

    100 GitHub stars~1.4k tokensUpdated 5 days ago
    Auto-check passed
  • New Plan

    dcodesdev/LetterSpace

    Use this when the user wants to create a new plan, start a new feature, begin a new project, or says 'new plan'.

    100 GitHub stars~1.2k tokensUpdated 5 days ago
    Auto-check passed
  • Document

    dcodesdev/LetterSpace

    Use this when writing or updating documentation — a README, docs/ page, CLAUDE.md, changelog entry, or doc comments — or when the user says 'document this'.

    100 GitHub stars~461 tokensUpdated 5 days ago
    Auto-check passed
  • Brainstorm

    dcodesdev/LetterSpace

    Use this when the user wants to brainstorm, think through an idea, explore approaches, weigh options, or says 'brainstorm' / 'let's think about'.

    100 GitHub stars~380 tokensUpdated 5 days ago
    Auto-check passed

Categories

Questions about Refactor

What does Refactor do?

Use this when the user wants to refactor the codebase, clean up code, reduce duplication, or says 'refactor' / 'new refactor'. Refactor is an agent skill from dcodesdev/LetterSpace. Use this when the user wants to refactor the codebase, clean up code, reduce duplication, or says 'refactor' / 'new refactor'.

When should I use Refactor?

Refactor fits situations like: wants to refactor the codebase; reduce duplication; says refactor / new refactor.

How do I install Refactor in Claude Code?

Run `npx skills add dcodesdev/LetterSpace --skill refactor -a claude-code`. Or copy the skill folder (.claude/skills/refactor in dcodesdev/LetterSpace) into .claude/skills/refactor in your project. Claude Code loads it when a task matches its description.

How do I install Refactor in Codex?

Run `npx skills add dcodesdev/LetterSpace --skill refactor -a codex`. Or copy the skill folder (.claude/skills/refactor in dcodesdev/LetterSpace) into .agents/skills/refactor in your project. Codex loads it when a task matches its description.

Can I use Refactor in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dcodesdev/LetterSpace --skill refactor -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactor, .gemini/skills/refactor, .github/skills/refactor and .opencode/skills/refactor in your project.

What does Refactor need to run?

SKILL.md names no scripts, command-line tools or credentials: Refactor is instructions for the agent only.

Does Refactor access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Refactor safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Refactor use?

Refactor is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Refactor use?

About 1.4k tokens (SKILL.md is roughly 5.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Refactor?

Skills that share tags, products or a category with Refactor: Guidelines (akash-network/node, 1.1k stars), Component Refactoring (langflow-ai/langflow, 156k stars), Migrate Core Code to Submodules (tinyhumansai/openhuman, 42k stars) and Systematic Code Refactoring (luongnv89/claude-howto, 42k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Refactor?

dcodesdev (a GitHub user) maintains it in dcodesdev/LetterSpace, which has 100 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on October 2, 2026.

Source: dcodesdev/LetterSpace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.