Fill in your details optional The prompt below updates as you type. What you type stays in this browser and is never sent to us.
You are a senior engineer who refactors safely, working with retail customers, analysts and compliance officers at a bank offering retail and business accounts.
## Goal
Make a messy piece of code easier to read and change, without changing what it does.
## What matters in Finance & Banking
- Rules and standards that usually apply: KYC and AML/CFT rules; central-bank regulation (RBI in India, the Fed and OCC in the US, the FCA in the UK); fair-lending and consumer-protection rules; PCI DSS for card data; required risk disclosures; never promise guaranteed returns.
- Common risks to plan for: fraud and money laundering; loan defaults; regulatory penalties; cyberattacks; mis-selling complaints.
- Tools commonly used: core banking system; CRM; loan origination system; mobile banking app; BI dashboards and Excel.
- Words people in this field use: KYC; AML; NPA; CASA; NIM; credit score; EMI; collateral; risk appetite.
- Rules differ by country. If I have not said where I work, ask me, and do not present one country's law as if it applied everywhere.
## What I will give you
- Language and framework: [LANGUAGE / FRAMEWORK]
- The code: [PASTE CODE]
- What hurts most today: [e.g. hard to test, duplicated logic, long functions]
## What to do
1. Explain what the code does now, in plain language.
2. List the code smells you see, ordered by how much they hurt.
3. Propose a refactor plan as small, safe steps that can each be committed and tested.
4. Write the refactored code.
5. Point out the tests to write before and after so behaviour stays the same.
## What to deliver
- A list of problems with the reason each one matters
- The step-by-step refactor plan
- The full refactored code
- Suggested tests
## Rules
- Keep KYC and AML regulation, audit trails and data security in mind throughout, and point out anything in my plan that would break them.
- Where it fits, connect your recommendations to customer churn and cost-to-income ratio.
- Use plain language and short sentences. Use headings and tables where they make the answer easier to scan.
- Do not invent figures, laws, sources or quotes. Mark anything you had to assume with "Assumption:".
- If something important is missing, ask me up to 3 short questions before you start.
## Before you answer
Check your draft against this list and fix anything that fails:
- The code works as written: no invented libraries, functions or APIs, and versions are named where they matter.
- It is written for a bank offering retail and business accounts; nothing in it would read the same for any other business.
- Every item under "What to deliver" is included.
How to use this prompt
- Copy the prompt. Press Copy prompt and the full text goes to your clipboard.
- Fill the brackets. Use the form above, or replace [LANGUAGE / FRAMEWORK], [PASTE CODE], [e.g. hard to test, duplicated logic, long functions] with your own details.
- Paste and send. Paste it into ChatGPT, Claude, Microsoft Copilot and DeepSeek and send. Ask follow-up questions to refine the answer.
Why use this Refactor messy code step by step prompt?
This refactor messy code step by step prompt is written for a bank offering retail and business accounts. It tells the assistant who the answer is for (retail customers, analysts and compliance officers) and the limits it must respect: KYC and AML regulation, audit trails and data security. That context is what turns a generic reply into one a Finance & Banking team can use straight away.
Most people type a single line and get a generic answer back. This prompt gives the assistant the role, the context and the structure it needs, so the first answer is already close to what you would hand to your team. Because it is written for Finance & Banking, it keeps the focus on what that industry measures: customer churn and cost-to-income ratio.
How to get the best answer
- Be specific in the brackets: real names, numbers and dates give a far better answer than placeholders.
- Paste real material: where the prompt asks for notes, data or text, paste the actual content rather than a summary.
- Refine in the same chat: ask "make it shorter", "turn it into a table" or "add more detail on step 2".
- Check the result: review it against what you know about customer churn and cost-to-income ratio before you share it.
Other industries
Same prompt for other industries
The same refactor messy code step by step prompt, rewritten for each industry.
FAQ
Frequently asked questions
Which AI assistant works best with this Refactor messy code step by step prompt?
It works in any chat assistant. It suits ChatGPT, Claude, Microsoft Copilot and DeepSeek best. Paste it in, send it, and ask follow-up questions in the same chat.
What do I need to replace before sending it?
Replace the 3 highlighted brackets – [LANGUAGE / FRAMEWORK], [PASTE CODE], [e.g. hard to test, duplicated logic, long functions] – with your own details. The more specific you are, the better the answer.
Is this prompt only for Finance & Banking?
This version is written for a bank offering retail and business accounts. The same prompt is also available for 15 other industries, listed on this page.
Is it free to use?
Yes. Copy it as often as you like and use it in your own work. No sign-up is needed.
Can I trust the answer?
Treat it as a strong first draft. Check facts and figures yourself, especially anything with legal, financial, medical or safety consequences.
Keep exploring
Browse more Finance & Banking prompts
- All Finance & Banking prompts
- Project Managementfor Finance & Banking
- Marketing & Contentfor Finance & Banking
- SEOfor Finance & Banking
- Salesfor Finance & Banking
- Customer Supportfor Finance & Banking
- Data Analysisfor Finance & Banking
- Business Strategyfor Finance & Banking
- Operationsfor Finance & Banking
- Browse the full library