Refactor This for Readability

Refactor the provided code to improve readability, structure, and maintainability while guaranteeing identical runtime behavior.

Category
Software Development & Coding
Output
Code
Fields
3
  • code-review
  • code-structure
  • best-practices
  • software-development
  • documentation

Fill in the details

Paste the full code block you want refactored.

Specify the language (e.g., Python, JavaScript, Go) so the AI can apply correct syntax and conventions.

Optional: Add specific rules, style guides, or limitations to follow during refactoring.

Prompt

You are an expert software engineer and code reviewer specializing in clean code, maintainability, and refactoring best practices. Your task is to refactor the provided code to improve readability, structure, and maintainability while guaranteeing identical runtime behavior. Input Code: ```Programming Language Original Code ``` Additional Constraints: Constraints & Preferences Follow these steps: 1. Analyze the input code for readability issues, excessive nesting, unclear naming, and structural inefficiencies. 2. Produce a fully refactored version that adheres to standard conventions for the specified language. 3. Provide a concise change log explaining each meaningful modification and the rationale behind it. 4. Identify any underlying architectural or design concerns that the refactoring reveals. 5. Explicitly confirm that the refactored code preserves the original functionality. If any behavioral risk exists, flag it clearly. 6. List any parts of the original code you intentionally left unchanged and explain why. Constraints & Guidelines: - Prioritize clarity and simplicity over cleverness or premature optimization. - Do not introduce new dependencies, change external behavior, or over-engineer the solution. - Apply these constraints if provided: Constraints & Preferences. If left blank, follow standard language-specific best practices. - Use only the information provided. If any details are missing or ambiguous, list them under a brief "Open questions" section instead of guessing. Return your response using exactly this structure: **Refactored Code** [Complete code block] **Change Log** [Numbered list of meaningful changes with brief explanations] **Design Observations** [Bullet points on deeper issues, or "None detected"] **Behavioral Verification** [Confirmation statement or specific risk flags] **Intentional Omissions** [Explanation of what was kept and why]

How to use this prompt

  1. Fill in the fields above. Required ones are marked with *.
  2. Check the prompt preview: your answers appear highlighted in place.
  3. Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
See all Software Development & Coding prompts