Skip to content
Agent Memory
Skill

/openlore-execute-refactor

Apply a confirmed .openlore/refactor-plan.md with a test gate after each change. Use when asked to execute or continue an OpenLore refactoring plan.

From plugin
openlore
36712 skills1 command1 MCP

Claude Code

$ npx -y skills add clay-good/OpenLore --skill openlore-execute-refactor --agent claude-code

SKILL.md

openlore-execute-refactor.SKILL.md
name: openlore-execute-refactor
description: Apply a confirmed .openlore/refactor-plan.md with a test gate after each change. Use when asked to execute or continue an OpenLore refactoring plan.

openlore: Execute Refactor

When to use this skill

Trigger this skill when the user asks to **apply a refactoring plan**, with phrasings like:

  • "apply the refactor plan"
  • "execute the planned refactoring"
  • explicit command `/openlore-execute-refactor`

**Prerequisite**: the `openlore-plan-refactor` skill must have been run and the plan confirmed. The file `.openlore/refactor-plan.md` must exist.

---

⚠️ Fundamental principle — each change is a complete mini-development

Each change in the plan is treated as an **independent, self-contained development unit**. The cycle for every single change, without exception:

READ plan entry
  → EDIT  (targeted tool, ≤ 50 lines touched)
  → DIFF  (git diff --stat + git diff — verify no lost code)
  → TEST  (run the test gate from the plan)
     ├─ green → mark ✅ in plan, move to next change
     └─ red   → git checkout HEAD -- <file>
                diagnose the failure
                retry from EDIT (attempt 2, then 3)
                if still red after 3 attempts → STOP (see circuit-breaker below)

**Never accumulate broken state. Never skip the test gate. Never batch two changes before testing.**

Circuit-breaker — 3 failed attempts

If a change fails its test gate 3 times in a row, stop immediately and report:

> "Change N (`<label>`) failed after 3 attempts. The working tree has been restored to the last green state. > Options: > a) Split this change into smaller sub-changes (≤ 50 lines each) and update the plan > b) Return to planning (`/openlore-plan-refactor`) to redesign this step > c) Skip this change and continue — note the acceptance criteria may not be fully met"

Do not attempt a 4th retry without explicit user instruction.

---

Step 1 — Read the plan

Read `.openlore/refactor-plan.md` from the project directory.

If the file does not exist, stop immediately: > "No refactor plan found at `.openlore/refactor-plan.md`. Please run `/openlore-plan-refactor` first."

Extract and display a summary:

  • Target function, file, and line range
  • Strategy and risk score
  • Number of changes planned
  • Test command
  • Acceptance criteria

**Ask the user to confirm before proceeding.**

> **Execution mode**: once confirmed, execute all changes in the plan **without asking for permission between steps**. The only valid reasons to pause mid-execution are: (a) a test fails and 3 retries are exhausted (circuit-breaker), (b) you detect potentially lost code (`git diff` shows far more deletions than additions with no new file created), or (c) Step 6 is explicitly requested. Any other pause is non-compliant with this skill.

---

Step 2 — Establish a green baseline

Confirm the test suite is passing using the test command from the plan.

**If tests are already failing, stop and tell the user. Under no circumstances continue on a red baseline — not even if the failures appear pre-existing.** Pre-existing failures must be fixed or explicitly acknowledged in the plan before any refactoring starts. Do not offer to "proceed at your own risk" on a red baseline.

If a coverage tool is available, run it on the target file and compare against the coverage baseline in the plan.

**Coverage thresholds:**

| Coverage on files to touch | Recommendation | |---|---| | ≥ 70% lines | Safe — proceed | | 40–69% lines | Caution — write characterisation tests first | | < 40% lines | **Stop.** Strongly recommend writing tests first | | 0% (no tests) | **Blocked.** Propose a minimal test harness, then restart |

If coverage is below 40%: > "Coverage on the target file is X%. Refactoring without test coverage risks introducing silent regressions. Would you like me to suggest test cases based on the function signatures, or do you want to proceed at your own risk?"

Only continue past this point with **explicit user confirmation**.

**Large file warning**: if the target function spans more than 300 lines: > "This function is X lines long. Small models may lose code when editing files of this size in a single pass. The plan must decompose each change to ≤ 50 lines. Verify the plan respects this before continuing."

---

Step 3 — Set the restore point

Verify the working tree is clean:

git status            # must show: nothing to commit, working tree clean
git log --oneline -1  # note this commit hash — your restore point

If there are uncommitted changes, stop and ask the user to commit or stash them first.

Fill in the `Restore point` section of `.openlore/refactor-plan.md` with the current commit hash.

---

Step 4 — Apply changes (mini-development loop)

Before the first change, call `record_decision` with the directory, target function, selected strategy, rationale, consequences, and affected files. Record any additional architectural choice discovered during the refactor as it arises.

For **each change** in the plan, execute the full mini-development cycle below. Do not move to the next change until the current one is marked ✅.

Before each change

Re-read `.openlore/refactor-plan.md` to confirm:

  • Which change you are on (check for ✅ markers)
  • Exactly what to extract, where to put it, and which call sites to update
  • The test gate command for this specific change

Editing tool rule

Always prefer a targeted edit tool over a full-file rewrite. Only use a full rewrite if the file is under 100 lines. If a change seems to require a full rewrite on a larger file, stop and split it into smaller targeted edits.

**Small model constraint**: each edit must touch a contiguous block of at most **50 lines**. If the planned change exceeds this, split it into sub-changes before proceeding — do not attempt an oversized edit.

Mini-development cycle (execute for each change)

**Attempt counter**: reset to 1 at the start of each new

Read more
@clay-good
Ships withopenlore

Deterministic, local-first code and contract intelligence for AI coding agents, with no LLM in the hot path.

36712 skills1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
367
Star history of clay-good/OpenLore on GitHub, a chart by star-history.com

Other skills on openlore.

openlore-orient

openlore-orient

Retrieve relevant functions, callers, spec sections, and insertion points from OpenLore before reading source files. Use when…

@clay-good@clay-goodInstall Skill
openlore-brainstorm

openlore-brainstorm

Transform a feature idea into an annotated story using a Domain Sketch or Constrained Option Tree. Use when asked to brainstorm,…

@clay-good@clay-goodInstall Skill
openlore-debug

openlore-debug

Debug with OpenLore structural context, an explicit root-cause hypothesis, and RED/GREEN verification. Use when a bug, failure,…

@clay-good@clay-goodInstall Skill
openlore-generate

openlore-generate

Author a new OpenSpec domain specification from deterministic OpenLore MCP evidence. Use when asked to reverse-engineer,…

@clay-good@clay-goodInstall Skill

More skills from other plugins.

agent-cost-report

agent-cost-report

Believable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude…

@thedotmack@thedotmackInstall Skill
bot-handoff

bot-handoff

Keep a durable record of work passed between Bots in the shared Hindsight memory bank. Use when handing work to another Bot, when…

hindsight10d60k
@vectorize-io@vectorize-ioInstall Skill
mempalace

mempalace

Install, configure, and operate MemPalace, including a private local palace, a shared-brain hub, or a client joining an existing…

@mempalace@mempalaceInstall Skill
mempalace

mempalace

Install, configure, and operate MemPalace, including a private local palace, a shared-brain hub, or a client joining an existing…

@milla-jovovich@milla-jovovichInstall Skill

Questions about openlore-execute-refactor.

Which coding agents can use openlore-execute-refactor?
openlore-execute-refactor installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.