SKILL

safe-refactor

Refactor JavaScript/TypeScript or Python code without changing behavior — extract functions, rename, split large files, remove duplication, modernize syntax, add types — with tests as a safety net. Use whenever the user asks to refactor, clean up, simplify, "rapikan kode", restructure, migrate JS to TS, add type hints, or reduce complexity.

Target: Software development & testing. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original English text

Topics in the source

  • Safe Refactor
  • 1. Baseline
  • 2. Plan
  • 3. Small steps, green between each
  • 4. Don't sneak in behavior changes
  • 5. Language-specific notes
  • 6. Finish

Refactoring = changing structure without changing behavior. The whole skill is about proving behavior didn't change. Run the tests that cover the target code; record the result. Also run type check and lint (tsc --noEmit, eslint; mypy/pyright, ruff). If coverage of the target is weak, write characterization tests first: tests that pin current behavior (including weird behavior) for the main inputs. Commit or stash-point here so you can roll back. If tests are failing before you start, tell the user — don't refactor on a red baseline. Write a short plan listing each transformation and the risk. Show it to the user if the refactor touches more than 3 files or changes a public API. Find all usages before renaming/moving anything: Watch for dynamic usages grep might miss: string-based lookups, getattr, re-exports in index.ts/init.py, templates, config files. Do one transformation at a time and rerun tests after each: Extract function / component / hook Rename (symbol + all usages + imports) Replace conditional chains with lookup tables or early returns Remove dead code (confirm it's truly unused first) Split a large module; keep a re-export at the old path if external code imports it I

This is an excerpt. Refer to the complete source and its current requirements.

Source repository
KILN-skills/kiln
Source file
skills/safe-refactor/SKILL.md
Fixed revision
555d7ea59d05910b4ef6fb39780da5f906be832b
Read the complete original documentation ↗

Requirements

  • Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.

A small first task

先阅读原作者说明,再决定是否在自己的 AI 工具中使用。

Instructions for your AI tool

Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: KILN-skills/kiln · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-10T04:00:15.445Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.