20 of the best prompts for preventing code overwrites in windsurf, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
20 of the best prompts for preventing code overwrites in windsurf, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
Windsurf sometimes removes or overwrites code that was previously working when adding new features, causing unexpected failures. This can lead to broken functionality and increased debugging time. These prompts help developers identify the root cause, fix the issue, and prevent it from recurring. Built across 4 distinct stages covering Diagnose the Wall, Isolate and Fix, Verify the Resolution and more, this guide gives you one expert prompt per step so you never have to write from scratch or guess what the AI needs. The prompts work in ChatGPT, Claude, and Gemini and are designed to get usable output on the first try.
Identify the specific rules or instructions being ignored by Windsurf.
Check CLAUDE.md Compliance
Please review the following CLAUDE.md file content: [PASTE CONTENT]. Analyze the rules outlined within it and confirm your understanding of each rule. After your review, identify which specific rule should have been applied to the last task and explain why it is relevant. Provide a summary of your findings in a structured format, highlighting any areas of non-compliance and suggestions for improvement.
Identify Overwritten Code
Please review the latest changes in the codebase and identify any instances of overwritten code. For each instance, provide a detailed explanation of what specific code was replaced, including the original code and the new code that has taken its place. Additionally, analyze potential reasons for these changes, such as refactoring, bug fixes, or updates to functionality. Summarize your findings in a structured report format, highlighting any patterns or recurring issues that may need attention.
Analyze Cascade Mode Actions
Please analyze the changes made in Cascade mode during the last session. List all the files that were edited and provide a detailed explanation for each change, including the purpose of the modification and how it contributes to the overall functionality of the project. Additionally, discuss any potential impacts these changes may have on the existing codebase and any considerations that should be taken into account moving forward. Format your response as a structured report with clear headings for each file.
Review Autocomplete Suggestions
Please review the autocomplete suggestions generated during my last few code edits. Identify which suggestions were made and analyze if any of them contributed to overwriting previously working code. Provide a summary of the suggestions, highlighting any that may have led to issues, and suggest potential solutions or best practices to avoid this in the future. Additionally, include recommendations for improving the autocomplete feature to enhance code stability.
Check for Dependency Conflicts
Please analyze the dependencies involved in the recent changes to the codebase. Identify any conflicts that may have arisen with existing code, particularly focusing on whether any dependencies have overwritten critical functions or features. Provide a detailed report outlining which dependencies were involved, the nature of the conflicts, and any potential impacts on the overall functionality of the application. Include recommendations for resolving these conflicts and preventing similar issues in the future.
Focus on isolating the specific issue causing code overwrites and apply targeted fixes.
Undo Last Changes
Please revert the last set of changes made to the codebase. After completing the reversal, provide a detailed summary of what specific changes were undone, including the lines of code affected and the reasons for each change being necessary to revert. Additionally, explain any potential impacts this may have on the overall functionality of the project and suggest any further actions that may be needed to ensure stability moving forward.
Apply Correct Rule
Review the recent changes made in the codebase and reference the guidelines outlined in the CLAUDE.md file. Identify the specific rule that applies to these changes and explain how it has been implemented. Provide a summary of the modifications made as a result of applying this rule, including any relevant code snippets or examples to illustrate the changes. Confirm that the rule has been correctly applied and detail any potential impacts on the overall functionality of the code.
Resolve Cascade Conflicts
Identify any conflicts that have arisen due to edits made in Cascade mode. Provide a detailed analysis of each conflict, including the specific elements or code sections affected. For each conflict, outline the changes made to resolve it, explaining the rationale behind each adjustment. Format the response as a structured report, clearly labeling each conflict and its corresponding resolution.
Reapply Overwritten Code
Please restore the code that was overwritten in the project. Explain the steps you took to identify the overwritten sections and how you ensured that the restored code integrates correctly with the new features that have been added. Include details about any testing or validation processes you used to confirm that the integration is seamless and does not introduce any new issues. Additionally, provide a summary of any changes made to accommodate the new features while maintaining the functionality of the restored code.
Correct Autocomplete Errors
Please review the autocomplete suggestions provided and identify any errors present. For each error, explain what the incorrect suggestion was and provide the correct version along with a brief rationale for the correction. Additionally, summarize any patterns or common issues you observe in the autocomplete suggestions that could be addressed to improve accuracy in the future. Format your response in a clear, organized manner, detailing each correction and its justification.
Ensure the issue is resolved and the code functions as expected.
Run Comprehensive Tests
Please run a comprehensive suite of tests to verify that the code is functioning correctly after recent changes. Include unit tests, integration tests, and any relevant end-to-end tests. After executing the tests, provide a detailed report of the results, highlighting any failures or issues encountered, and confirm whether the original issue has been resolved. Additionally, summarize any improvements or changes made to the code that contributed to the resolution.
Confirm Rule Compliance
Please review the recent changes made to the code and verify if they comply with the CLAUDE.md rules. Provide a detailed confirmation of compliance, and if any discrepancies are found, highlight them clearly. Include specific sections of the code that do not align with the rules, and suggest possible corrections or improvements to ensure full compliance. Format your response in a structured manner, outlining each rule and the corresponding compliance status.
Validate Dependency Integrity
Please validate the integrity of all dependencies in my project. Check for any missing, outdated, or incompatible dependencies and ensure they are correctly integrated and functioning as expected. Provide a detailed summary of the validation results, including any issues found, recommended actions for resolution, and the overall status of dependency integrity. Format the results in a clear report that highlights critical issues, if any, and suggests best practices for maintaining dependency health in the future.
Check Code Consistency
Please review the codebase for consistency after the recent fixes have been applied. Ensure that all changes are functioning as intended and that no other parts of the code have been unintentionally affected. Provide a detailed report highlighting any inconsistencies found, along with suggestions for resolving them. Additionally, include a summary of the areas that were checked and confirm that the overall functionality remains intact.
Verify Cascade Mode Stability
Please verify the stability of Cascade mode in the system. Conduct a series of tests to assess its performance and identify any potential issues that may arise during operation. Provide a detailed report that includes the specific checks performed, the results of each test, and any anomalies or concerns discovered during the verification process. Additionally, summarize your findings and recommend any necessary actions to ensure optimal stability.
Create mechanisms to prevent similar issues from happening in the future.
Create a New CLAUDE.md Rule
Help me create a new rule for my CLAUDE.md document to prevent the recent issue from recurring. The rule should address the specific problem that occurred, outlining clear guidelines or actions to take in similar situations. Include the exact text I can copy and paste into my document, and ensure it is concise yet comprehensive enough to be easily understood. Additionally, provide a brief explanation of why this rule is important and how it will help prevent future occurrences.
Add Code Comments for Clarity
Please review the following code snippet where an issue occurred and insert detailed comments to clarify the correct implementation. The comments should explain the purpose of each section, the logic behind the code, and any important considerations that a developer should keep in mind. Ensure that the comments are clear and concise, making it easy for someone else to understand the code's functionality. Format the comments in a way that they can be directly added to the code, and provide a brief summary of the overall code's purpose at the beginning.
Develop a Session-Opener Checklist
Help me develop a comprehensive session-opener checklist to review before starting a new coding session. The checklist should include specific steps to prevent code overwrites, such as verifying version control status, ensuring backups are up to date, and confirming that all team members are aware of the current codebase changes. Additionally, include reminders for setting up the development environment correctly and reviewing any relevant documentation. Format the checklist in a clear, organized manner with bullet points for easy reference.
Establish a Naming Convention
Please propose a detailed naming convention that can be implemented to avoid conflicts in future code changes. Include specific guidelines on how to structure names for variables, functions, classes, and files. Provide examples that illustrate the convention in practice, ensuring that the names are clear, descriptive, and consistent. Additionally, explain the reasoning behind the chosen convention and how it can enhance code readability and maintainability.
Implement a Project Guard
Propose a project guard mechanism designed to automatically detect and prevent code overwrites in a software development environment. Outline the key features of this mechanism, including how it will monitor changes to the codebase, the criteria for identifying potential overwrites, and the actions it should take when an overwrite is detected. Additionally, explain how this guard can be integrated into existing workflows and any necessary configurations or tools that should be utilized to ensure its effectiveness. Provide a step-by-step implementation plan that includes testing and validation procedures to confirm that the guard is functioning as intended.
Windsurf's Cascade mode can autonomously edit multiple files, sometimes leading to overwrites if not properly configured. Ensuring CLAUDE.md rules are followed can mitigate this.
Use custom rules in your CLAUDE.md file to guide Windsurf's behavior. Regularly review and update these rules to align with project needs.
Utilize Windsurf's version control features to revert changes. Regular commits and backups can also aid in quick recovery.
Regularly review and test your CLAUDE.md rules against project requirements. Update rules to reflect any changes in project scope or technology.
Yes, you can influence autocomplete by refining your CLAUDE.md rules and providing feedback on suggestions to improve accuracy.
AI Prompts for Preventing Code Overwrites in Bolt
When adding new features in Bolt, existing code can be removed or overwritten, causing unexpected failures.
See promptsAI Prompts for Preventing Code Overwrites in Claude
Claude Code sometimes removes or overwrites existing, functional code when adding new features, causing unexpected regressions.
See promptsAI Prompts for Preventing Code Overwrites in Cursor
Cursor sometimes removes or overwrites previously working code when adding new features, causing unexpected regressions.
See prompts