agentleFS
Art4Art4/continuous-refactoring/skills/refactor-prioritize/SKILL.md

refactor-prioritize

Skill1 starsChanged 2 months agoMITView on GitHub

Rank refactor-scan's proposals and recommend the next one to work on, or say why nothing should start this pass. For a gate-shaped winner, also selects the concrete candidate within it and drafts its issue.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Only runs on this second, fresh dispatch — never inline after step 3 in the same context, and never for a winner that's already concrete …

    line 76
  2. Very specific:

    Select mode: every candidate found as a draft (minimal fields, admission tier, Signal), the single recommended one marked — refactor-loop …

    line 97

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Refactor Prioritize

Rank the proposals refactor-scan handed refactor-loop this pass, and recommend the single one to work on next. The loop's value comes from working the right thing next, not from working any of them.

Runs in one of two modes, both dispatched by refactor-loop — never one calling the other inline:

  • Rank mode (default, steps 1–3): picks the next node to work on.
  • Select mode (step 4): refactor-loop re-invokes this skill, as a fresh dispatch, only when Rank mode's winner was a gate (structural-scan, a PHPStan baseline-shrink family) — a name, not yet a concrete candidate. Select mode does the actual exploration (codebase or baseline) that Rank mode's own declarative ranking never does, picks one concrete candidate, and drafts each found candidate's issue minimally. A fresh dispatch, not a continuation of Rank mode's own context, so the exploration never bleeds into the (much lighter) ranking reasoning, or vice versa.

Process

1. Check whether anything should start at all

Get the remembered set of in-flight suite MRs: docs/agents/issue-tracker.md names a native-label tracker (GitHub, GitLab) → every open refactor:candidate issue that carries a linked pull request (the tracker's native issue↔closing-PR cross-reference); otherwise the Refactoring Notes' merge-requests.md directly. Drop any proposal already in that set — it already has an open MR, so it isn't something to start. How many suite MRs are open is not this skill's concern: refactor-loop gates that once, right before implementation (its step 5), for new merge requests only.

An in-flight ## Investigation Open entry never reaches this skill at all — refactor-scan step 2 routes it straight to refactor-design (not yet planned) or refactor-implement (already planned), bypassing Rank and Select mode both; see refactor-scan/SKILL.md step 2 and refactor-loop's own step 1.

2. Rank

refactor:priority narrows the pool first. At least one surviving proposal's issue already carries the refactor:priority label (a human set it directly — nothing here sets it automatically) → rank only among those this pass, the rest wait for a future one regardless of how they'd otherwise score. None carry it → rank the full surviving pool, unchanged. Track nodes excluded. This pool contains only proposals refactor-scan handed forward — never a node sitting in a Track's own Open list (Safety Net, Guardrails). Track nodes are worked top to bottom by refactor-scan's own Open walk (../refactor-scan/references/track-open-processing.md), not ranked here. Otherwise the label is only a tie-breaker between equally ranked candidates; it never preempts a Track's Open walk — a labeled issue waits until Open is empty (Safety Net) or has no workable node left (Guardrails). It takes no part in Track selection and cannot bypass the Safety Net blockade.

For each proposal in that pool, assess:

FactorQuestion
HeatIn a hot spot (frequently changing area)? Pays off faster, unblocks more upcoming change.
LeverageHow much future change does deepening this module unlock? A module many others call is high-leverage; an uncalled leaf is not.
Tooling pressureIs the fulfilled tooling (PHPStan, Rector, style) actively flagging it? If so it's re-failing every CI run until fixed.
RiskHow hard to reverse, how wide the blast radius? Prefer reversible, low-risk refactors early while the habit is forming.
AgeTooling-tree proposals only (refactor-scan/SKILL.md step 3b surfaces each one's own issue creation date alongside it — native tracker: created_at; Local Markdown: its Filed: line). How long has it sat open without being chosen, relative to how often this loop actually runs? The longer, the more it weighs toward choosing it now, so a proposal that never wins on the other four alone doesn't sit forever — one factor among five, not a forced pick. A gate name or externally-labeled candidate carries no age here; their own tiering (Select mode, below) already covers this.

Tooling-tree node: read its Purpose in the tree doc to reason about what it unlocks — node-detail data beyond that Purpose line isn't a maintained source yet.

Draft as you read — three exclusions to check first, every time, before drafting anything:

  • A gate name (structural-scan, a baseline-shrink family) → never draft an issue for the gate itself. It stays a bare name — never Tooling tree: Structural Scan, never any issue at all — until Select mode's own exploration turns it into one or more concrete candidates, each with its own title (below). This is the one exclusion most easily missed, because a gate arrives here the same way any other tooling-tree proposal does (by bare Name) — check for it first, before applying the mechanic below to anything.
  • A proposal that arrives already issue-backed (refactor-scan step 3b: an earlier pass's own filing, or a human-labeled issue) → nothing to file, rank it as-is.
  • A Track node (Safety Net, Guardrails) → never drafted here at all. Those are tracked in the Track's own Open list and their issues are created only when the node is worked via the Open walk (../refactor-scan/references/track-open-processing.md), not pre-filed.

None of the three above → a tooling-tree proposal handed forward by bare Name (refactor-scan/SKILL.md step 4 — an ordinary node, not yet an issue) → draft its candidate issue now, right after reading its Purpose line above, titled exactly Tooling tree: <Name> (never the slug) — the same title refactor-loop looks for before creating one, so whichever proposal later wins a ranking is recognized as already created, updated in place by refactor-design rather than duplicated. This skill never creates the issue itself — refactor-loop does, per ../continuous-refactoring/references/filing-a-ticket.md, which also decides whether the human is asked first. Minimal fields only: the title, label refactor:candidate, body = that same Purpose line. No plan — still refactor-design's job, only once this candidate wins a ranking, possibly a later one. Mirrors structural-scan's own Select mode, which already drafts every concrete finding it discovers, not only the winner — this is the same move for the proposals that arrive already concrete. A proposal drafted this way scores Age zero and carries no refactor:priority — both trivially true of an issue that has, at most, existed for the length of this same pass.

Present the ranking as a short ordered list of Names only (never slugs) — save the rationale for the winner for step 3.

3. Recommend

Name the single next candidate by its Name (never slug); one line why it wins, one line what choosing it unlocks (the next node(s), per the tree doc, or the module/area it deepens for structural-scan). Two lines total — this is the ## Output payload, not a separate report. Close call → call it out and let the user decide.

A proposable tooling-tree node is a strong default recommendation — the loop's structural work compounds faster once the underlying tooling is in place. Still a recommendation, not a required edge — the user may pick something else.

This default only ever applies to a pool made entirely of tooling-tree proposals — it grants no tilt the moment an issue-backed candidate (step 3b: structural, baseline-shrink, or externally-labeled) is ranked alongside one. Among several simultaneously-unblocked tooling-tree nodes (an ordinary Safety Net/Guardrails scan), every candidate already satisfies the default equally, so it never has to pick a winner there — it does real work only where a gate-shaped tooling-tree proposal (structural-scan, a PHPStan baseline-shrink family) meets an issue-backed one, which today only happens inside an Investigation pass. There, the default doesn't apply at all: rank the gate on the same four factors as everything else, no tilt either way. It can still win on real merit (hot, high-leverage, tooling-flagged, low-risk), but never merely for being tooling-tree-shaped or for having "just" become proposable — for structural-scan that state is permanent once Safety Net/Guardrails close, and even a baseline-shrink gate can stay proposable for many passes while its baseline is non-empty; either framing, taken at face value, would out-rank an issue-backed candidate every single time by an argument that never expires. Leverage, applied to a gate itself rather than to a candidate it might later produce, is judged on what's already concretely known to deepen (a named hot spot, an existing candidate's own module) — never on a future scan's own open-ended promise of finding something better.

Nothing survived step 1's filtering (every proposal already in flight, or scan proposed nothing) → report that explicitly instead; refactor-loop ends the pass here.

4. Select (Select mode only — a gate won)

Only runs on this second, fresh dispatch — never inline after step 3 in the same context, and never for a winner that's already concrete (an ordinary tooling-tree node, an externally-labeled candidate — those go straight to refactor-design, this step doesn't apply).

  • Winner is structural-scan → run references/structural-candidate-search.md in full.
  • Winner is a "PHPStan Level N — baseline shrink" proposal → run references/baseline-shrink-selection.md in full.

Both end the same way: every genuine candidate found gets drafted (minimal fields, never the full plan — that's refactor-design's job, added as a comment only on the one this pass pursues), sorted into a priority or capped admission tier by its Signal (references/signals.md), and the single strongest is this pass's recommendation, carried forward.

This mode writes no ## Investigation Open entry — it can't, the issue doesn't exist yet. refactor-design adds it for the recommended candidate as soon as refactor-loop hands it the created issue's number (its step 5), on every tracker, native-label ones included.

Output

This skill creates no issue and writes nothing to the target; it names the drafts it returns.

Rank mode: step 3's two lines, verbatim, → refactor-loop, or "nothing to do, because …" → refactor-loop ends the pass. Plus the drafts for every tooling-tree proposal ranked this step that had no issue yet (step 2's Draft as you read), the winner's marked as such — refactor-loop creates them per filing-a-ticket.md and hands the winner's issue to refactor-design. The non-winning ones simply sit open once created, the same way Select mode's own non-winning findings do below.

Select mode: every candidate found as a draft (minimal fields, admission tier, Signal), the single recommended one marked — refactor-loop creates them and hands the recommended one's issue (number + its minimal fields) to refactor-design; the others sit as ordinary open issues for a future pass.

Fallback

  • /codebase-design: installed → use its vocabulary in Select mode's structural-candidate search (references/structural-candidate-search.md). Otherwise the vocabulary (module, interface, depth, seam, leverage, locality) is already inline in that same reference file — nothing else needed.

Completion criterion

Rank mode: either a single next candidate is recommended with a reason and what it unlocks, or the pass is explicitly reported as having nothing to start — never both. Select mode: the candidate is returned as a draft naming Where/Problem/Signal (structural) or the chosen group (baseline-shrink), the recommended one marked — no plan yet, that's refactor-design's completion criterion.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.