Bug Fix and Refactoring

A shared folder with AI prompts and code snippets

From workspace: Bolt

Team: Main

Total snippets: 7

Bolt

Bug Fix and Refactoring

7 snippets

Debug Undefined Value

Trace where a variable is returning `undefined` and ensure a proper value is returned.

Find where a variable is returning `undefined` unexpectedly and fix it. Include: – Add fallback or default values – Trace data from its origin – Do not break the existing output

Refactor Duplicate Logic

Find repeated code blocks in this file and refactor them into reusable functions or constants.

Refactor this file by extracting repeated code into reusable functions or constants. Include: – Don’t rename existing variables unless repeated – Preserve comments and types – Avoid any functional changes in behavior

Simplify Conditional Logic

Rewrite deeply nested if/else logic into a cleaner structure using guard clauses or switches.

Refactor the complex conditional logic in this file into a clean, readable structure. Include: – Prefer early returns – Use switch or lookup maps where cleaner – Maintain the same outputs and edge case coverage

Fix Form Submit Bug

Repair a form’s submit handler so the button works and data is processed.

Fix the submit button in this form. It currently does not trigger the intended handler. Include: – Ensure onClick or onSubmit connects properly – Validate input before submitting – Show a success or error message

Resolve Infinite Loop

Identify and stop the logic that’s causing an infinite loop.

Fix the infinite loop crashing the app in this file. Include: – Trace recursive or re-render triggers – Keep core logic intact – Add safe guards or exit conditions

Clean Unused Code

Remove all unused imports, variables, and functions from this file.

Clean up this file by removing all unused imports, variables, and functions. Include: – Only remove if not used at all – Preserve formatting – Do not modify active logic

Fix Console Errors

Identify and fix all errors printed in the browser console without modifying unrelated logic.

Fix all console errors in this file or its imports. Include: – Keep unrelated logic untouched – Match the error message line and context – Ensure the console remains clean on page load