Refactor logo

Refactor

Community
boshu2
refactor

Restructure or clean up code with no behavior change, proved by before-and-after checks. Use when: asked to clean up, extract, dedupe or simplify, even one function.

Overview

Publisherboshu2
Repositoryagentops
Skill namerefactor
Stars
450
Forks
42
Bundled files
2
LicenseApache-2.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.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by boshu2 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.
    https://github.com/boshu2/agentops/tree/main/plugin/skills/refactor
  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/boshu2/agentops.git /tmp/agentops
mkdir -p .claude/skills
cp -r /tmp/agentops/plugin/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.

Refactor — one structural experiment

Refactor changes structure while preserving observable behavior. It performs one caller-selected transformation and reports the result. "Behavior-preserving" is a claim to prove with before/after checks, never to assert.

What counts as behavior

Unless the caller explicitly excluded a surface, all of these must survive:

  • Messages and exit codes. Error and output text compares byte-for-byte; exit codes, error types and which input raises which error stay the same. Scripts and callers parse them. Preserve an inconsistent message and report it; normalizing it is a behavior change.
  • Differences between near-duplicates. When merging duplicated branches, carry every difference (constants, comparisons, messages, extra steps) as a parameter or a branch. Do not unify a difference the caller has not declared accidental.
  • Interfaces. Public signatures, defaults, return types, persisted field names, protocol values and CLI flags. Renaming one is a compatibility change unless the accepted scope provides for it.
  • Order and coverage. Branch priority, default handling, evaluation count, side-effect order, and the set of tests that run. A pre-existing red that vanishes, or a test that stops running, is a behavior change.
  • Protective checks. Trust-boundary validation, data-loss guards, security controls and accessibility affordances stay, even when another layer, upstream or downstream, duplicates one or no test reaches it. The neutrality gates cannot see their removal, so looking redundant is no reason to delete one.

Procedure

  1. Name the preserved behavior, the focused acceptance surface and the concrete structural problem for its callers, in the caller's domain terms.
  2. Run the focused check and the smallest regression check the changed surface justifies, and record that honest baseline, including reproducible ambient failures. For an evaluation comparing executable behavior, pin the starting source, build its baseline before edits and keep that binary and the comparison inputs.
  3. Apply one bounded transformation: extract, rename, inline, simplify, encapsulate, move, substitute existing code, or delete dead code; the refactoring catalog holds per-pattern safety checks. Judge it by what callers must understand and where a domain rule must change, not by file size.
  4. A bug or suspicious inconsistency found on the way is reported separately (location, why it looks wrong) and left unfixed. Fixing it inside the refactor hides a behavior change the caller did not authorize.
  5. Rerun the same focused check and the smallest justified regression check over the same inputs, including error paths.
  6. Report, then stop. A red result is evidence for the caller; this skill does not revert, narrow, retry, commit, validate, or route subsequent work.

When nothing can be executed (no runtime, no tests, code supplied in a message), neutrality is unproven: give the exact before/after commands and inputs the caller must run, error paths included, and list every surface under behavior not checked.

text
transformation: <the one change>
preserved:      <behavior and surfaces from step 1>
checks:         <command>: before -> <result>; after -> <result>   (or "not run")
outputs:        <before/after hashes when the surface produces output>
diff:           <files touched>; only those the transformation names
suspected bugs: <file:line, why>; reported, not fixed
not checked:    <surfaces no check covered>; present even when empty

Responsibility and interface cost

Before adding an interface or splitting a module, inspect representative callers. Count the concepts they must coordinate: required setup, ordering, states, error handling and repeated domain rules. A useful boundary puts a cohesive rule under one owner and lets callers request an outcome without reproducing that rule. Reject a wrapper that only adds another name or pushes the same coordination into its callers. Existing boundaries are sufficient when no concrete caller problem warrants changing them.

When choosing a target, prefer friction in the caller-selected area: repeated changes to the same rule, repeated caller setup, or defects spread across cooperating files. Recent history can locate that friction when the caller has not named it; churn alone does not justify a refactor. State the expected saving in concrete work, such as changing one rule in one place, against the caller migration and regression cost. Leave a stable, cheap boundary alone.

Check a proposed extraction by imagining its removal: would callers have to rebuild a cohesive rule, or would only a forwarding step disappear? Keep internal test seams private when callers need no substitution. Exercise the preserved behavior through the caller-facing boundary; retain existing tests until equivalent coverage of their distinct cases is demonstrated. Moving a test is not permission to delete the behavior it protected.

Use the caller's vocabulary for extracted operations and types. A naming ambiguity that changes behavior belongs with the existing domain definition; consult Domain only when that distinction needs work.

When the transformation needs a seam — an extraction boundary, interface, or module split — and more than one candidate seam exists, probe before you cut. Run the probe in disposable isolation (a scratch branch, worktree, or copied tree the caller's policy allows): rough in the seam, see what it forces — signature churn, import cycles, test rewrites — then discard the probe and keep only the knowledge. Stop condition: at most two probes; if the second candidate seam also fights back, report both findings to the caller instead of trying a third. Cutting the first imaginable seam directly into the working tree is the premature seam failure mode: the wrong boundary calcifies because reverting it now costs more than living with it.

Neutrality gates

Gate the transformation on behavior-identical proof:

  • The focused check and the package-level regression check pass both before and after, with the same set of pre-existing failures: no new red and no vanished red.
  • For output-producing surfaces (generators, serializers, formatters, reports), capture output hashes over identical inputs before the change and compare byte-for-byte after. A mismatch is a behavior diff to surface and explain, never to shrug at; the caller decides whether to keep, narrow, or reverse it.

A neutrality gate that was skipped or narrowed after the fact is the post-hoc neutrality failure mode — the diff decides what got tested. Name any surface the gates did not cover under behavior not checked.

References

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Refactor AI skill do?

Restructure or clean up code with no behavior change, proved by before-and-after checks. Use when: asked to clean up, extract, dedupe or simplify, even one function.

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/boshu2/agentops/tree/main/plugin/skills/refactor. TypingMind reads its SKILL.md and bundles its files 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 boshu2 under the Apache-2.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 👇