Skip to main content

deslop-code

clean up code layering and unnecessary abstractions in drive-by fixes

Datos de origen

Repositorio
devdotfast/skills
Última actividad en el origen
4 de octubre de 2026 a las 06:14
Idioma detectado de SKILL.md
inglés
Estrellas
5
Forks
1

Opciones de instalación

De forma predeterminada está seleccionado el prompt que primero revisa el origen. Puedes cambiar a un comando directo o descargar una copia local.

Revisa los archivos de origen

Lee SKILL.md y los archivos complementarios que muestra SkillsMP antes de decidir si quieres instalarlo.

Explorador de archivos
2 archivos

Mostrando SKILL.md

SKILL.md
Instrucciones de origen · Vista previa de solo lectura
name
deslop-code
description
clean up code layering and unnecessary abstractions in drive-by fixes
disable-model-invocation
true
There are a few great levers when cleaning up code: 1. Cleaning up dead code. Analyze every line of the commit. Your reviewer will nitpick. Ask yourself: did this HAVE to change? If not, revert it. 2. Creating a drive-by fix PR or commit in the code to make it read better overall. Improves code quality and makes it easier to reason about. ## Part 1: Cleaning up dead code Be aggressive when deleting code; question the user if things are ok to delete but perhaps aren't covered in E2E tests or (formal) specifications (may be a missing edge case). Consult git history, trace storage, issue tracking, slack, etc. to autonomously come to a conclusion autonomously if you can; only refer to the human if you can't be sure. ## Part 2: Improving Codebase Quality Think in terms of John Ousterhout's "A Philosophy of Software Design"; specifically, in optimizing for deep modules over shallow ones. You want narrow interfaces which provide deep functionality. These sort of changes work best as no-op cleanup commits or PRs. Do not mix behavior changes with them if at all possible. You are trying to set up some "drive-by fixes" that leave the code better than you found it. It's best to write code like this from the start, but often coding changes leave room for consolidation; imagine a callstack that looks like: ``` handle_checkout() # A -> create_order() # B' -> insert_order() # C ``` where, in the process of feature work, B' has been modified. This is a great opportunity to look at A & C and consider whether those abstractions are shallow. Some rules of thumb: - Consider only the production code from the perspective of a new reader. How many hops do they need to "jump" in a codebase on this callstack to get to the "meat" of the functionality? You are trying to minimize the number of those hops for that person. - Ignore unit tests when thinking about this. Typically unit tests are fragile and tied to implementation. - Small, tiny functions which just call out to each other, unnecessary interfaces to provide "abstraction" are typically smells of this. i.e. it is very painful to read code that requires >1 jump to understand what an abstraction actually *does*. Once you refactor, you can repeat this process recursively (collapsing adjacent shallow layers of abstraction to form deeper modules). Example of a great diff: ```diff def run(args): - return f(args) - -def f(args): a, b = unpack(args) return g(a, b) def g(a, b): # do something ```
Ver en GitHub