Squid Refactor logo

Squid Refactor

Community
iusztinpaul
squid-refactor

Plan a refactor as an ordered, commit-grain Tasks Plan with structural acceptance criteria (suite green at every step, no behaviour diff) that `/squid-implement-night` can execute end-to-end.

Overview

Publisheriusztinpaul
Repositorysquid
Skill namesquid-refactor
Stars
207
Forks
34
Bundled files
Instructions only
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.

  • Self-contained

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

  • Open source

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

Installation

Install the Squid 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/iusztinpaul/squid/tree/main/skills/squid-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/iusztinpaul/squid.git /tmp/squid
mkdir -p .claude/skills
cp -r /tmp/squid/skills/squid-refactor .claude/skills/squid-refactor
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Squid 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 Squid 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 Squid 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 — plan a no-behaviour-change structural improvement

A refactor is not a feature and not a bug, so the Product Architect's feature-grooming flow doesn't fit. This skill produces a Tasks Plan whose tasks are commit-grain (each one keeps main shippable, suite green at every commit) and whose AC are structural: imports, types, signatures, dependency direction, public surface, test coverage ("module X no longer imports module Y"). The output feeds /squid-implement-night directly.

You are the planner — you may delegate exploration but do NOT write code, do NOT execute steps. Your output is the plan file plus a hand-off message.

$ARGUMENTS is one of:

  • A free-form refactor goal ("extract auth.session into its own package", "replace ad-hoc retries with tenacity", "rename User.id to User.uid repo-wide").
  • A path to a markdown spec.
  • A tracker reference.

If empty, ask the user for one.

Read AGENTS.md first to confirm the active tracker mode (file or gh) and the pipeline map this plan plugs into.

When NOT to use

  • A feature with new user-visible behaviour — use /squid-plan (PA grooming) instead.
  • A rewrite — it's a feature whose user-visible behaviour is "the new system, but the same"; don't smuggle it in here.
  • A bug fix — use /squid-triage-issue, then /squid-implement-task or /squid-implement-night.
  • A one-file rename you can finish in five minutes — just do it; don't ceremony.

Step 1 — Resolve and frame the refactor

Identify what to refactor from $ARGUMENTS (same resolution rules as /squid-triage-issue's Step 1).

Capture three things explicitly — ask the user via AskUserQuestion if any are missing, one round of questions max:

  1. Goal — one sentence, structural. ("Move all auth code out of core/ and into auth/.")
  2. Definition of done — concrete, testable structural invariants. ("grep -r 'from core.auth' src/ returns nothing"; "auth/ has no imports from core/ except types"). At least 2.
  3. Hard constraints — what must not change. ("Public API of core.session.Session unchanged"; "no DB schema changes"; "feature flag X stays toggleable throughout").

If the user can't answer (1)–(3), the refactor isn't ready to plan. Surface that and stop — the user does the thinking, not you.

Step 2 — Map the blast radius

Spawn 1 Explore agent (parallel calls if scope is large enough to need 2):

Agent(
  subagent_type="Explore",
  prompt="""Refactor scope: {goal from Step 1}.

  Map: (1) every file that will be touched (rough count + paths); (2) every module/package that imports the affected code (call sites — file:line); (3) every test that exercises the affected code; (4) any public API surface (functions / classes / endpoints / CLI commands) that callers outside the codebase might depend on; (5) the depth of the existing test coverage on the affected modules — coarse estimate (good / thin / none).

  Be exhaustive on (1)–(3); a missed import becomes a broken commit. Report as five sections."""
)

When the agent returns:

  • Read the plan-critical files yourself. Don't trust a summary on the load-bearing modules.
  • Test-coverage gate. If coverage is none or thin on the affected modules, surface this to the user as a prerequisite task ("expand test coverage to cover the current behaviour of core/auth/* before refactoring") and ask: "Add this as the first task, or stop?" Do not silently plan a refactor on top of weak tests.

Step 3 — Decompose into commit-grain tasks

Each task must satisfy three rules:

  1. Reversible alone. Reverting just this commit leaves main green.
  2. Tests green at the boundary. The full unit + integration suite passes after this task and after every prior task.
  3. One coherent intention. "Move file X and update its imports" is one task. "Move file X, rename function Y, fix bug Z" is three.

Common refactor shapes and their canonical decomposition:

Refactor shapeTypical task sequence
Extract module(1) copy code to new location with old still in place + re-export shim; (2) move call sites in batches by package; (3) delete shim + old file.
Rename across codebase(1) introduce new name as alias of old; (2) migrate call sites in batches; (3) deprecate old name; (4) delete old name.
Library swap(1) introduce new lib alongside old behind an internal facade; (2) migrate call sites; (3) remove old lib.
Layer cleanup (e.g., remove cycle)(1) introduce the seam (new module / interface); (2) move responsibilities one batch at a time; (3) enforce direction with an architectural test.
Dead-code removal(1) delete callers; (2) delete leaves; (3) re-run unused-detector. Each in its own task only if the ordering matters; often this is one task.
De-abstraction / simplification(1) inline the single-implementation interface / factory / wrapper at its one call site; (2) swap hand-rolled logic for the stdlib / native / framework equivalent; (3) drop the now-unused dependency. Structural AC: the abstraction (or dep) is gone, public behaviour unchanged, suite green. Feeds directly from /squid-architecture-review over-engineering findings.

3–8 tasks is a healthy plan size. Fewer than 3 → it's too small for a Tasks Plan; do it as a single /squid-implement-task task. More than 8 → either decompose into multiple sequential refactors (file separate /squid-refactor plans), or you're sneaking feature work in.

Step 4 — Write the Tasks Plan

Use this template. Frontmatter follows squid-scaffold/specs/tracker-workflow.md, so /squid-implement-task and /squid-implement-night accept it without re-grooming.

markdown
# Refactor: {one-line goal}

**Type:** refactor
**Definition of done:**
- {invariant 1}
- {invariant 2}
- ...

**Hard constraints (must not change):**
- {constraint 1}
- ...

**Test-suite anchor:** `make pre-commit && make unit-tests && make integration-tests`. Every task ends with this command green.

## Tasks

### 1. {one-line task title}

**Scope:** {1–2 sentences on what this commit does and only what it does.}

**Files touched (expected):** `path/a.py`, `path/b.py`, ...

**Acceptance criteria:**
- [ ] {Structural assertion. e.g. `grep -r 'from core.auth' src/auth/ | wc -l` is 0.}
- [ ] {Behavioural invariant. e.g. Public API of `Session.login()` unchanged — verified by existing tests at `tests/auth/test_session.py`.}
- [ ] Test suite anchor green.
- [ ] No new unit tests required (this is a refactor) — but if you find a coverage gap that blocks the move, add the test before doing the move and call that out in the SWE log.

**Out of scope:**
- {explicit list — adjacent things that look related but belong to other tasks.}

### 2. ...

(Repeat for each task.)

## Rollback story

If task N goes sideways and the team needs to ship before it's resolved, revert commits {N..} only. Tasks {1..N-1} are independently shippable by construction.

## Notes for the SWE

- This is a refactor — **add no behaviour, fix no bugs**, even if you spot one. File a `/squid-triage-issue` for any bug found mid-refactor; do not let it ride along.
- If a task's AC turns out to be wrong (e.g., a hidden import the planner missed), update the plan via the orchestrator before adapting code — drift between plan and reality is the source of "refactor went off the rails" stories.

Step 5 — File the plan

Where it lands depends on tracker mode (per AGENTS.md).

File mode

There is no separate plan document — the Tasks Plan is the set of task files, same as /squid-plan's output. Write one tasks/<NNN>-<refactor-slug>-<k>.md per task (frontmatter status: pending, feature: refactor-<slug>; allocate NNN per squid-scaffold/specs/tracker-workflow.md). Each file carries its task's Scope, Files touched, Acceptance criteria, and Out of scope from the template; fold the hard constraints into every task's Out of scope, and the definition-of-done invariants into the final task's acceptance criteria so the PA acceptance review verifies them.

gh mode

Open one parent issue (label refactor,plan) with the full plan in the body, then one issue per task linked back to the parent (label refactor,task). Capture all numbers for the hand-off message.

Step 6 — Hand-off

Single markdown block:

markdown
## Refactor plan ready — {goal}

**Plan:** {tracker path or parent issue URL}
**Tasks ({N}):**
1. {NNN-slug or #N} — {title}
2. ...

**Definition of done:** {bulleted DoD from the plan}

### Recommended next step

`/squid-implement-night {plan-ref}` — the inner loop runs each task, the Tester gate enforces "tests green at every step", and the PA acceptance review verifies the structural DoD. The human still gates the merge.

If the refactor is small enough (≤ 2 tasks) and you'd rather supervise:

`/squid-implement-task {first-task-ref}` then `/squid-implement-task {next-task-ref}` — manual, one task at a time.

### Pre-flight checklist (before /squid-implement-night)

- [ ] Test-suite anchor is green on `main` *right now*. Do not start a refactor on a red base.
- [ ] No in-flight feature branches conflict with the affected files (avoidable merge churn).
- [ ] If the refactor touches the public API, the deprecation / migration story for downstream callers is captured in the plan or in an ADR (spec: `squid-scaffold/specs/adr.md`).

Frequently asked questions

What does the Squid Refactor AI skill do?

Plan a refactor as an ordered, commit-grain Tasks Plan with structural acceptance criteria (suite green at every step, no behaviour diff) that `/squid-implement-night` can execute end-to-end.

Why use Squid Refactor on TypingMind?

Because you install it once and use it with any model. Squid 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 Squid Refactor in TypingMind?

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

Which AI models can use Squid 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 Squid Refactor?

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

Is the Squid Refactor AI skill free?

Yes. It is published on GitHub by iusztinpaul 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 👇