PlaybookPrompts

Break a god class into smaller cohesive modules

Coding & Development refactoringarchitecturesolid

God classes accumulate responsibilities until they become untestable. This prompt guides an LLM to identify responsibility boundaries and produce a concrete extraction plan without rewriting everything at once.

Prompt
You are a software architect focused on maintainability. I have a class that has grown too large and handles too many concerns.

Language: {{LANGUAGE}}
Class code:
```
{{CLASS_CODE}}
```
Existing test coverage summary (describe what is and isn't tested, or paste test file):
{{TEST_COVERAGE_SUMMARY}}

Complete these steps:
1. List every distinct responsibility you can identify in this class. A responsibility is a reason the class might change independently of the others.
2. Group methods and fields by responsibility. Show which methods belong to which group.
3. Propose new class or module names for each group. Apply the Single Responsibility Principle — each proposed unit should have one reason to change.
4. Identify dependencies between the proposed units. Draw a simple dependency list (A depends on B) to surface any circular dependencies before they are created.
5. Recommend an extraction order that keeps the code functional at every step. Prioritize extracting units that are already well-tested.
6. For the first extraction in your recommended order, write the new class/module interface (method signatures and a one-line doc comment per method). Do not write the full implementation unless asked.
7. Flag any shared mutable state that would make extraction risky.
Variables to fill in
  • {{LANGUAGE}}
  • {{CLASS_CODE}}
  • {{TEST_COVERAGE_SUMMARY}}

How to use this prompt

  1. Copy the prompt above (Copy button on the top-right).
  2. Replace each {{VAR}} with your own value. Variables: {{LANGUAGE}}{{CLASS_CODE}}{{TEST_COVERAGE_SUMMARY}}.
  3. Paste it into one of the recommended tools below.
  4. Iterate: tighten constraints in the prompt if the output is generic.

Why this prompt is structured this way

The prompt is split into explicit steps because LLMs do better when the path is named, not implied. Each variable forces specificity at the input layer — vague inputs get vague outputs.

Heads up: some of the links on this page are affiliate links — meaning we may earn a commission if you sign up after clicking, at no extra cost to you. We only recommend tools we'd put on our own stack. You can see our full affiliate disclosure here.

Pair this prompt with a tool

The PlaybookPrompts weekly

One short email per week. The five sharpest prompts we found, one tool worth your attention, one anti-pattern to avoid. Unsubscribe in one click.

Newsletter signup is not configured. Set PUBLIC_NEWSLETTER_USERNAME in the build env.