Break a God Function Apart

Split an oversized function into well-named pieces without changing external behavior.

Intermediate1 min read

Customize

Fill these in and the prompt below updates as you type. Anything you leave blank stays as a placeholder.

Your prompt

1 placeholder left
This function does too many things. Split it following the Single Responsibility Principle, keeping the same external behavior.

{{code}}

Propose 3-6 well-named smaller functions, show each one, and show the slimmed-down orchestrator that calls them.

Do not introduce new dependencies. Flag anything you were unsure about.

Similar prompts

Refactor for Readability

Clean up code for clarity and maintainability without changing behavior.

Add Types Incrementally

Type one file with runtime behavior frozen, and make the type-checker output the proof.

Convert Code Between Languages

An idiomatic port, not a transliteration — with anything that doesn't translate flagged rather than faked.

Design a Database Schema

CREATE TABLE statements with constraints, indexes, and the reasoning behind each choice.