Skip to content

chore: add refactoring skill for behavior-preserving code changes#147

Open
jamesmblair wants to merge 6 commits into
mainfrom
chore/refactor-skill
Open

chore: add refactoring skill for behavior-preserving code changes#147
jamesmblair wants to merge 6 commits into
mainfrom
chore/refactor-skill

Conversation

@jamesmblair
Copy link
Copy Markdown
Member

Summary

Adds a refactoring skill and CLAUDE.md principle to enforce behavior preservation during structural code changes. Born from a real incident where cooldown enforcement was silently dropped during a model migration (cases vs applications refactor in DC-257).

What's included

  • CLAUDE.md — One-line principle: "Refactoring preserves behavior — tests prove it"
  • Refactoring skill (.claude/skills/refactoring/SKILL.md) — Process flowchart, yellow-light change guidance, red flags
  • Safe refactorings reference (safe-refactorings.md) — 14 mechanical transformations safe without test coverage, with "safe because" rationale and "watch for" caveats

Key concepts

  • Tests are the proof that behavior is preserved — if tests must be deleted or weakened, it's not a refactor
  • Yellow-light changes (type swaps, field migrations) require human confirmation
  • Missing fields on a target model should be added, not used as justification to remove behavior
  • Structural changes and behavioral changes belong in separate commits

Adds a refactoring skill that enforces behavior preservation during
structural code changes. Includes process flowchart, yellow-light
change guidance (type swaps, field migrations), safe refactorings
reference, and red flags. Born from a real incident where cooldown
enforcement was silently dropped during a model migration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
James Blair and others added 2 commits April 29, 2026 08:05
…ter process

Add a Scope Discipline section naming the two failure modes (drift, "I notice
this is messy" trap), broaden the description to cover "clean up,"
"reorganize," "extract," etc., remove the Mermaid flowchart in favor of
prose, and label SEBT-specific examples as illustrative.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jamesmblair jamesmblair changed the title docs: add refactoring skill for behavior-preserving code changes chore: add refactoring skill for behavior-preserving code changes Apr 29, 2026
@jamesmblair jamesmblair marked this pull request as ready for review April 29, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant