refactor-and-safety-pass
Skill0 starsChanged 5 months agoMITView on GitHub
Refactoring safety guard. Use when the user asks to refactor, rename, extract, move, restructure, or reorganize code. Ensures all consumers are updated, no references are orphaned, and changes are verified.
In this repository18 other files it gives its agents.
- app-icon-gridSkill
- archive-manualSkill
- commitSkill
- component-consistencySkill
- component-locatorSkill
- debug-triageSkill
- gemini-iconSkill
- parity-auditorSkill
- prd-writingSkill
- release-helperSkill
- smellSkill
- streamdeck-aerospace-rewireSkill
- streamdeck-workspace-buttonSkill
- svg-icon-renderSkill
- test-conventionsSkill
- verification-gateSkill
- work-breakdownSkill
- yt-audioSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 14 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Before touching any code:
- Very specific: line 22
Update barrel files (index.ts, index.js) when moving or renaming exports.
- Distinctive: line 24
Keep git commits atomic: one logical change per commit.
- Distinctive: line 25
If renaming: grep the entire project for string references — test IDs, route names, analytics events, config keys, comments.
- Distinctive: line 31
Check dynamic references (string interpolation, object key access).
- Distinctive: line 36
Update barrel files if the project uses them.
- Distinctive: line 39
Update all import paths that reference the old location.
- Distinctive: line 41
Check for relative path breakage in nearby files.
- Distinctive: line 42
Delete the old file — do not leave a copy behind.
- Distinctive: line 45
Update all call sites to match the new signature.
- Distinctive: line 47
Update tests that call the function or component.
- Distinctive: line 50
Verify the abstraction has a single usage (or very few) before inlining.
- Distinctive: line 51
Remove the now-dead abstraction after inlining.
- Distinctive: line 52
Remove its export from barrel files.
- Distinctive: line 56
After completing the refactor:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
Refactor & Safety Pass
You are performing a guarded refactoring operation. Follow every section in order — do not skip the pre-check or post-check.
Pre-Refactor Checklist
Before touching any code:
- Identify all consumers — grep for imports and usages of the target across the entire project.
- Check test coverage — find test files that cover the target (matching file names, import paths, or direct references).
- Note public API surface — list every exported type, function, component, or constant from the target.
- Assess blast radius — count how many files will change. If >20 files, warn the user and confirm before proceeding.
During Refactor — Safety Rules
- Preserve all public exports, or update every consumer that depends on them.
- Update barrel files (
index.ts,index.js) when moving or renaming exports. - Maintain backward-compatible type signatures unless the user explicitly intends a breaking change.
- Keep git commits atomic: one logical change per commit.
- If renaming: grep the entire project for string references — test IDs, route names, analytics events, config keys, comments.
Refactor Patterns
Rename
- Find-and-replace across the entire project, including strings, comments, and test IDs.
- Check dynamic references (string interpolation, object key access).
Extract function / component
- Move to the appropriate directory following existing project conventions.
- Export from the new location, update the original to import from it.
- Update barrel files if the project uses them.
Move file
- Update all import paths that reference the old location.
- Update barrel exports.
- Check for relative path breakage in nearby files.
- Delete the old file — do not leave a copy behind.
Change signature
- Update all call sites to match the new signature.
- Update type definitions.
- Update tests that call the function or component.
Inline
- Verify the abstraction has a single usage (or very few) before inlining.
- Remove the now-dead abstraction after inlining.
- Remove its export from barrel files.
Post-Refactor Verification
After completing the refactor:
- Grep for old name/path — should return zero hits. If any remain, update them.
- Check for orphaned files — if a new file was created, confirm the old file was deleted (unless intentionally keeping both).
- Check for dead exports — things still exported but no longer imported anywhere.
- Verify tests reference valid targets — test imports and assertions should point to the new name/path.
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
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.

