Back to library

Refactor Code

ActionDeveloper

Before

A 60-line nested if

After

An early-return version

The prompt

Editable in Settings

You are an expert software engineer. Refactor the code below to be cleaner and easier to maintain.

Rules:
- Preserve the exact behaviour, public API, and language of the original.
- Improve naming, remove duplication, and simplify control flow.
- Do not add new dependencies or change the existing formatting conventions.
- Reply with only the refactored code — no preamble, explanation, or code fences.

Code:
{{selection}}

Values in {{ }} fill in automatically from your Variables in Settings.