How to use Claude to refactor a complex application
Claude Code analyzed a messy application through its invariants, prioritized remediation plans and implemented backend and frontend changes. The author reported a stable result but needed a simpler explanation of the analysis.
Prompt to try
Editorial adaptation, not the source author’s exact prompt. Replace bracketed inputs and review tool permissions first.
Analyze [application repository] through the mathematical structure of [domain]. Identify invariants and general laws, verify them against the code, and prioritize remediation. Implement the agreed fixes in [backend] and [frontend], then explain the analysis in plain language.
Reach people exploring AI agents
See placements →What happened
The author reports that Claude cleaned up both backend and frontend and transformed patchily connected proof-of-concepts into a coherent, stable application, exhausting the session limit four times.
Reported by cmenge on Hacker NewsHow the agent did it
- Direct Claude to identify and verify the problem’s invariants.
- Have Claude produce and prioritize remediation plans.
- Let Claude implement backend and frontend remediation.
Where a person stepped in
The author set the analysis direction and requested clearer prose. The post does not describe specific review or testing procedures.
A person set the goal and reviewed the result.
The author gave Claude a difficult cleanup task involving messy, bug-ridden code in a complex domain. The existing application had been assembled partly by hand and partly with Opus. Rather than asking only for individual bug fixes, the author directed the model to examine the mathematical structure of the problem, identify invariants and general laws, verify them, and plan remediation.
Claude produced an analysis of approximately 800 lines with remediation plans. The author says it sometimes spawned more than 130 research agents, prioritized the plans, and implemented them across both backend and frontend. The reported result was a coherent, stable application in place of a large collection of proof-of-concepts connected by patchy glue.
The analysis itself created a separate usability problem. The author found its prose and mathematical explanations too terse and difficult to follow, despite finding the code snippets and data models easier to understand. They asked for a less elaborate version to make sense of the document. The work also exhausted the session limit four times.
The author identifies Claude Code on the Max plan as the environment used. The post does not provide the application's domain, individual fixes, or independent stability measurements.
Who it's for: Developers with complex existing code who can articulate invariants and review a broad remediation plan.
Prompt
Suggested prompt (written by Agents In Use, not the author's)
Source: Hacker News · cmenge
Frequently asked questions
What analysis did the author ask Claude to perform?
The author instructed it to examine the mathematical substructure, identify invariants and general laws, verify them, and then plan remediation.
What did Claude produce and implement?
The author reports an approximately 800-line analysis with prioritized remediation plans, followed by implementation across backend and frontend. They describe the result as a coherent, stable application.
What human intervention was described?
The author provided the analytical direction and requested a less elaborate explanation because the document was difficult to understand. The post does not describe detailed code review or testing steps.
More details
Remaining steps
- Request a simpler version of the difficult analysis.
About this account
Claude generated a long analysis, prioritized remediation and implemented changes, with research agents assisting parts of the analysis.
Platform: Hacker News. Attribution: https://news.ycombinator.com/item?id=48495931. Prompt: Suggested (written by Agents In Use, not the author's). Sourced by the Agents In Use pipeline.
Credit: cmenge on Hacker News
Source published 11 Jun 2026
Source checked 14 Oct 2026
Tools and topics
Claude Code
Refactoring · Invariants · Code analysis
Editorial completeness: 100/100. Measures documented fields, not agent performance or verified outcomes.