Ask Claude to Extract Logic from a Fat Controller
Controllers should orchestrate, not implement. When a controller method grows past 50 lines it's usually doing too much — and Claude can refactor it cleanly.
This controller method is doing too much. Extract the business logic into a dedicated
OrderService class. The controller should only handle HTTP concerns: parsing the
request, calling the service, and returning the response. Move validation, database
writes, email dispatch, and event firing into the service.
Claude identifies the HTTP concerns (request parsing, response formatting) and separates them from the business logic (calculations, persistence, side effects), producing a clean service class with a single public method.
Ask it to go further:
Now make OrderService testable in isolation. Replace direct model calls with a
repository interface, and inject the mailer as a dependency so we can mock it
in tests.
Claude will introduce the interface, update the service constructor, and update the service container binding — making the whole thing unit testable without hitting the database.
If you have multiple fat controllers, point Claude at the whole directory:
Look at all controllers in app/Http/Controllers and identify the top 3 that have
the most business logic mixed in. List the methods and what they're doing.
That gives you a prioritised refactoring backlog without reading a single file yourself.
A fat controller is a symptom, not a sin — Claude turns the diagnosis into a diff.
Log in to leave a comment.
Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.
Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.
Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.