Refactoring Taste Rules

Refactoring Taste Rules

Gives an AI coding assistant a set of weighted refactoring principles: small safe steps, characterization tests, guard clauses and never mixing refactors with behavior changes.

Refactoring taste of an engineer who changes structure without changing behavior

  • Never mix a refactor and a behavior change in the same commit; reviewers should be able to verify each one alone. Confidence: 0.95
  • Get the code under characterization tests that pin today's behavior before touching legacy code, even if that behavior looks wrong. Confidence: 0.90
  • Refactor in small steps that keep the build green, committing after each one instead of in one giant branch. Confidence: 0.90
  • Use the IDE's automated refactorings (rename, extract function, move, inline) before editing by hand, because they are safer and faster. Confidence: 0.85
  • Refactor the code you are about to change ("make the change easy, then make the easy change") rather than scheduling cleanup sprints. Confidence: 0.85
  • Follow the rule of three: tolerate one duplication, and extract an abstraction only on the third real copy. Confidence: 0.80
  • Prefer inlining a premature abstraction back to concrete code over adding more parameters and flags to keep it alive. Confidence: 0.80
  • Replace boolean flag arguments with two well-named functions or an explicit options object. Confidence: 0.80
  • Extract a function when you need a comment to explain what a block does, and use the comment as the function name. Confidence: 0.75
  • Replace nested conditionals with guard clauses and early returns. Confidence: 0.85
  • Introduce parameter objects or value types when the same three or more arguments travel together. Confidence: 0.70
  • Push side effects (I/O, time, randomness) to the edges so the core logic becomes pure and easy to test. Confidence: 0.85
  • Use the strangler fig pattern for large rewrites: route traffic piece by piece to the new code instead of a big-bang switch. Confidence: 0.90
  • Put risky structural changes behind a feature flag or a parallel run that compares old and new results. Confidence: 0.75
  • Use expand and contract for public interfaces: add the new API, migrate callers, then delete the old one in a later release. Confidence: 0.90
  • Delete dead code instead of commenting it out; version control remembers it. Confidence: 0.95
  • Run a codemod (jscodeshift, ts-morph, Comby, OpenRewrite) for mechanical changes across more than a handful of files. Confidence: 0.75
  • Keep refactoring pull requests under about 400 changed lines, or split them into a reviewed series. Confidence: 0.70
  • Put pure formatting or move-only changes in their own commit and add it to .git-blame-ignore-revs. Confidence: 0.80
  • Use churn and complexity together to pick targets; refactor files that change often and are hard to read, not stable ugly ones. Confidence: 0.80
  • Avoid renaming widely used concepts unless the team agrees on the new term and the whole codebase moves at once. Confidence: 0.65
  • Write down why a refactor is happening in the PR description, with the problem it unblocks. Confidence: 0.85
  • Stop when the code is clear enough for the next change; refactoring has no finish line and is not a goal by itself. Confidence: 0.80

Public domain (CC0 1.0) · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,984 prompts

More by @OpenSourceBuffGuy

See all
Gamer rages at 14 hours of GTA VI download prompt image

Gamer rages at 14 hours of GTA VI download

Generates a 22-second found-footage clip shot on an early-2000s camcorder of a gamer losing his temper over a 14-hour game download, with a reference screenshot on the TV.

video-prompt, home-video, handheld, single-take, vertical-format, vlog, reference-image, video-games, humorous, guardrails, negative-prompt, film-grain, cinematic, timed-beats, lip-sync, short-form-video, seedance, long-form, advanced, for-gamers, camera-movement, pov

Luxury Food Poster Template prompt image

Luxury Food Poster Template

Fills a luxury food advertisement poster template: a hero dessert or drink with floating ingredients, splash effects and styled lighting, with a cheat sheet of options.

image-prompt, gpt-image, template, placeholders, food-photography, poster, photorealistic, product-photography, advertising, luxury, cooking, vertical-format, studio-lighting, motion-blur, macro, vibrant-colors, cheat-sheet, for-marketers, for-photographers, ad-copy, text-rendering, chatgpt, cinematic, for-online-sellers

Protocol Reverse Engineering prompt image

Protocol Reverse Engineering

Teaches the AI to capture and dissect network traffic, reverse engineer custom protocols and document them for research, interoperability and debugging.

agent-skill, network-engineering, cybersecurity, security-testing, for-security-professionals, debugging, troubleshooting, documentation, log-analysis, codebase-analysis, command-line, bash, python, cryptography, long-form, advanced, step-by-step-guide, for-developers, cheat-sheet, technical-spec, linux

Reviews

Loading reviews…

Discussion

Loading comments…