agentleFS
DailybotHQDailybotHQ/deepworkplan-website/.agents/skills/refactor-safe/SKILL.md

refactor-safe

Skill15 starsChanged 5 months agoMITView on GitHub

Safe refactor in bounded scope (1-10 files, no behavior change). Use proactively for safe, bounded refactoring tasks.

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 11 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Does NOT change public API or behavior

    line 24
  2. Distinctive:

    Does NOT add new features

    line 25
  3. Distinctive:

    Does NOT do large-scale or cross-module architecture changes

    line 26
  4. Distinctive:

    Does NOT touch security-related logic without explicit scope

    line 27
  5. Distinctive:

    Before running this skill, ensure:

    line 48
  6. Distinctive:

    Run build and note current behavior

    line 58
  7. Distinctive:

    Ensure each step keeps build working

    line 65
  8. Very specific:

    Run pnpm run biome:check and pnpm run astro:check after each step

    line 70
  9. Distinctive:

    Commit after each step if desired (incremental commits)

    line 71
  10. Distinctive:

    Stop and escalate: if:

    line 118
  11. Distinctive:

    Escalate to architect: if: cross-module design, API changes, or large-scale restructure needed.

    line 135
  12. Very specific:

    Create src/lib/date.ts with formatDate function

    line 148
  13. Very specific:

    Update MethodologyPage.astro to import from lib/

    line 149
  14. Very specific:

    Create subcomponents (e.g., HeroTitle.astro, HeroActions.astro)

    line 163
  15. Distinctive:

    Import in main component

    line 164

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “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

Skill: Refactor Safe

Objective

Refactor code in a bounded scope (1-10 files, up to ~500 LOC) without changing observable behavior. Extract functions, rename for clarity, reorder imports, split modules. Adapted for this repo: Astro, Svelte, TypeScript; follow docs/STANDARDS.md and AGENTS.md.

Non-Goals

  • Does NOT change public API or behavior
  • Does NOT add new features
  • Does NOT do large-scale or cross-module architecture changes
  • Does NOT touch security-related logic without explicit scope

Tier Classification

Tier: 2 - Standard

Reasoning: Moderate reasoning (dependencies, component impact); scope 1-10 files, 100-500 LOC; safe, reversible refactors only.

Inputs

Required Parameters

  • $TARGET: File(s) or directory to refactor (e.g., src/components/pages/)
  • $GOAL: What to refactor (e.g., "extract helper", "rename for clarity", "split into smaller components")

Optional Parameters

  • $CONSTRAINTS: What not to change (e.g., "keep component props unchanged")

Prerequisites

Before running this skill, ensure:

  • Build passes (pnpm run build)
  • Scope is clear and bounded (1-10 files)
  • No concurrent changes to same files

Steps

Step 1: Establish Baseline

  • Run build and note current behavior
  • List files and dependencies in scope
  • Identify what must not change (props, exports, behavior)

Step 2: Plan Refactor

  • Break into small steps (extract one function, then rename, etc.)
  • Ensure each step keeps build working

Step 3: Execute Step by Step

  • One logical change at a time
  • Run pnpm run biome:check and pnpm run astro:check after each step
  • Commit after each step if desired (incremental commits)

Step 4: Final Validation

pnpm run biome:check
pnpm run astro:check
pnpm run build

Output Format

Success Output

## ✅ Refactor Safe Complete

### Target
{What was refactored}

### Changes
- `{file1}`: {what changed}
- `{file2}`: {what changed}

### Behavior
- No intentional behavior change
- Build passes

### Validation
- pnpm run biome:check: ✅
- pnpm run astro:check: ✅
- pnpm run build: ✅

### Commit Message
refactor: {brief description}

Guardrails

Scope Limits

  • Maximum files: 10
  • Maximum LOC changed: 500
  • Allowed: Extract, rename, reorder, split within same module/area

Stop Conditions

Stop and escalate if:

  • Public API or behavior must change
  • More than 10 files or 500 LOC
  • Build starts failing and root cause is unclear
  • Data flow significantly affected

Definition of Done

  • Refactor goal achieved within scope
  • pnpm run biome:check passes
  • pnpm run astro:check passes
  • pnpm run build passes
  • No intentional behavior change

Escalation Conditions

Escalate to architect if: cross-module design, API changes, or large-scale restructure needed.

Examples

Example 1: Extract Utility Function

Input:

$TARGET: src/components/pages/MethodologyPage.astro
$GOAL: Extract date formatting to lib/

Execution:

  1. Create src/lib/date.ts with formatDate function
  2. Update MethodologyPage.astro to import from lib/
  3. Run validation
  4. Commit with refactor: extract date formatting to lib/

Example 2: Split Large Component

Input:

$TARGET: src/components/home/HeroSection/HeroSection.astro
$GOAL: Split into smaller subcomponents

Execution:

  1. Identify logical sections
  2. Create subcomponents (e.g., HeroTitle.astro, HeroActions.astro)
  3. Import in main component
  4. Run validation
  5. Commit with refactor: split HeroSection into subcomponents

Related

  • quick-fix - Small fixes
  • write-tests - Add/expand tests
  • reviewer - Review refactor
  • architect - For design decisions

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.