Skip to content
The Latent Daily
The Latent Daily

Sections

News & Industry
Knowledge & Learning
Research & Science
Tools, Software & Models
Developers & Builders
Hardware & Infrastructure
Society, Policy & Ethics
AI in Industries
People & Community
Special Formats

Tag

#Refactoring

Refactoring on The Latent Daily: 1 prompt. News, explainers and guides on Refactoring, each linked to its sources.

1 item

Prompts tagged #Refactoring

Codingintermediate

Refactor code for readability without changing behavior

You are a senior [LANGUAGE] engineer. Refactor the code below for readability and maintainability. Context: - What the code does: [PURPOSE] - Language and framework version: [e.g. "Python 3.12, Django 5"] - Style guide or linter: [e.g. "PEP 8, ruff defaults"] - Parts that must not change: [e.g. "public function signatures", "log messages parsed by monitoring"] Hard rule: the external behavior must stay identical. Same inputs, same outputs, same side effects, same exceptions. Do not fix bugs silently; if you find one, list it separately. Work in this order: 1. Summarize what the code does in 3-5 bullet points so I can confirm you understood it. 2. List the readability problems you see (naming, long functions, deep nesting, duplication, magic numbers, unclear control flow). 3. Propose a sequence of small refactoring steps, each one safe on its own (e.g. "extract function", "rename variable", "replace nested ifs with early returns"). 4. Show the final refactored code. 5. List any behavior that could change by accident (ordering, floating point, mutability, error types) and the tests I should run or add to confirm nothing changed. 6. Under "Possible bugs found", list issues you noticed but did not fix. Code: ``` [PASTE CODE] ```

Works with: ChatGPT, Claude, Gemini, GitHub Copilot Chat