AI Prompts for Preventing Test Failures from Edits

20 of the best prompts for preventing test failures from edits, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

AI Prompts for Preventing Test Failures from Edits

20 of the best prompts for preventing test failures from edits, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

Scroll to explore

Published June 28, 2026

Getting Preventing Test Failures from Edits right takes more than a single prompt. This 4-stage guide covers Diagnose the Wall, Isolate and Fix, Verify the Resolution, and more, breaking the whole process into focused steps where each prompt builds on the last. Windsurf sometimes makes changes that cause previously passing tests to fail, which disrupts the development process. This can lead to wasted time and effort as developers try to identify and fix the new issues. These prompts help developers diagnose the problem, apply targeted fixes, verify the resolution, and prevent future occurrences. Every prompt is optimized and runs in ChatGPT, Claude, and Gemini.

Diagnose the Wall

Identify which changes caused the tests to fail.

Identify Changed Files

Identify all files that were modified in the last session. For each file, provide a detailed description of the specific changes made, including the type of modifications such as added, removed, or altered code. Explain how these changes could potentially impact existing tests, and include any relevant context that may help in understanding the implications for testing. Format the response clearly, listing each file separately along with its associated changes and impacts.

Diagnose the Wall

Check Test Dependencies

Analyze the dependencies of the failing tests in the project related to windsurf-breaking-existing-tests. Provide a detailed report that includes a list of all dependencies, their current versions, and any recent changes made to them. Additionally, identify which changes may have contributed to the test failures and suggest potential solutions or adjustments that could resolve the issues. Ensure the report is formatted clearly and organized, highlighting critical dependencies and changes for easy reference.

Diagnose the Wall

Review Test Logs

Review the logs of the failing tests for the windsurf-breaking-existing-tests use case. Identify any errors or warnings present, summarize the key issues that could indicate the cause of the failure, and categorize the errors by severity. Provide insights into potential areas to investigate further and suggest possible next steps for troubleshooting. Present your findings in a clear and organized format.

Diagnose the Wall

Compare Code Versions

Compare the current version of the code with the last known working version. Identify and highlight any differences that could potentially lead to test failures. For each difference, provide a detailed explanation, including the specific lines of code that have changed and how these changes might impact the functionality or stability of the code. Organize your response in a clear, structured manner, with distinct sections for each identified difference and its implications.

Diagnose the Wall

Analyze Cascade Changes

Analyze the cascade changes made during the last edit in the project. Explain the specific modifications that were implemented and discuss how these changes could potentially impact unrelated files. Provide examples of possible effects on those files, including any dependencies or interactions that may arise. Summarize your findings in a structured format, highlighting key areas of concern and offering recommendations for further testing or review.

Diagnose the Wall

Isolate and Fix

Focus on correcting the specific changes that caused test failures.

Revert Problematic Changes

Revert the changes made in [FILE_NAME] that are causing the test failures. Provide a detailed explanation of the specific changes that led to the issues and describe how they affected the overall functionality. After reverting these changes, confirm that the original functionality has been successfully restored and that all tests are passing. Additionally, outline any further steps required to maintain stability in the codebase moving forward.

Isolate and Fix

Adjust Test Conditions

Adjust the conditions of the failing tests in the codebase to ensure they align with the recent changes made to the logic. Identify the specific areas where the tests do not reflect the updated functionality, and provide a detailed explanation of the modifications needed. Ensure that the tests cover all relevant scenarios and edge cases based on the new logic. Format your response as a list of changes with clear descriptions for each adjustment.

Isolate and Fix

Refactor Impacted Code

Refactor the code in [FILE_NAME] to maintain its current functionality while preventing any test failures. Analyze the existing tests to identify potential areas of conflict and ensure that all functionalities remain intact after the refactor. Provide comments within the code to explain any changes made, and outline how the refactored code aligns with the existing test cases. Additionally, include a brief summary of the changes and discuss any implications for future development.

Isolate and Fix

Update Test Data

Update the test data used in the failing tests to align with the new code logic. Review the recent changes in the codebase to ensure that the test data accurately reflects the current requirements and scenarios. Provide a detailed explanation of the changes made, including specific values or structures that were adjusted, and ensure that the updated test data comprehensively covers all relevant cases. Format the updated test data in a clear and organized manner for easy reference.

Isolate and Fix

Correct Dependency Issues

Identify and resolve any dependency issues that are causing the tests to fail in the windsurf-breaking-existing-tests project. Provide a detailed list of the dependencies that need to be updated or corrected, including their current versions and the recommended versions. Explain the steps taken to fix these issues, verify that all tests now pass successfully, and include any relevant notes on potential impacts of these changes on the overall project.

Isolate and Fix

Verify the Resolution

Ensure that the fixes have resolved the test failures.

Run All Tests

Execute all tests related to the previous failures in the windsurf-breaking-existing-tests use case. After running the tests, provide a detailed summary of the results, including the number of tests that passed, failed, and any that were skipped. Additionally, highlight any errors encountered during the testing process and suggest potential next steps based on the outcomes.

Verify the Resolution

Check Specific Tests

Run the following specific tests that were previously failing: [LIST OF TESTS]. Confirm that each test passes without any errors and provide a summary of the results. If any tests still fail, include details on which tests did not pass and any error messages encountered. Additionally, suggest potential reasons for the failures and outline the next steps for troubleshooting.

Verify the Resolution

Validate Code Integrity

Conduct a thorough code integrity check on the latest version of the codebase for the windsurf-breaking-existing-tests use case. Ensure that no new issues or bugs have been introduced during recent updates or changes. Provide a detailed report of your findings, including any identified issues, their severity, and recommendations for resolution. Additionally, summarize the overall health of the codebase and highlight any areas that may require further attention or improvement.

Verify the Resolution

Confirm Dependency Stability

Check the stability and configuration of all dependencies in the project related to windsurf-breaking-existing-tests. Provide a detailed report that includes the current version of each dependency, any known issues or conflicts, and specific recommendations for resolving any instability. Additionally, confirm that all dependencies are compatible with each other and document any steps taken to address issues found during your assessment.

Verify the Resolution

Review Test Coverage

Analyze the current test coverage for the project related to windsurf-breaking-existing-tests. Ensure that all critical paths are thoroughly tested and provide a detailed report on the coverage metrics. Highlight any areas that may have decreased after the recent fixes, and suggest improvements or additional tests to enhance overall coverage and reliability. Include specific examples of critical paths and their corresponding coverage percentages in your report.

Verify the Resolution

Prevent Recurrence

Implement measures to avoid similar issues in the future.

Create a CLAUDE.md Rule

Draft a new rule for the CLAUDE.md file that aims to prevent recent test failures in windsurf-breaking-existing-tests. The rule should specifically address the issues that led to these failures and provide clear, actionable guidelines for future tests to avoid similar problems. Include the exact text to be added to CLAUDE.md and explain the rationale behind the rule to ensure team members understand its significance and importance.

Prevent Recurrence

Add Code Comments

Insert detailed comments in [FILE_NAME] that explain the recent changes made to the code. Include the purpose of each change, how it affects the existing tests, and any potential implications for future development. Ensure that the comments are clear and concise, providing enough context for future developers to understand the reasoning behind the modifications. Aim for a thorough explanation that covers both technical aspects and the overall impact on the project.

Prevent Recurrence

Develop a Checklist

Develop a comprehensive checklist to follow before committing changes to a codebase. Include specific steps to verify the stability of existing tests, ensure the integrity of dependencies, and confirm that all new changes are properly documented. Additionally, provide guidelines for conducting a code review and outline any necessary approvals that must be obtained. Format the checklist in a clear, numbered list for easy reference.

Prevent Recurrence

Establish Naming Conventions

Define a comprehensive set of naming conventions for test-related code that enhances clarity and reduces confusion. Include detailed guidelines for naming test functions, test classes, and related variables, providing specific examples for each category to illustrate the conventions. Ensure that the names are descriptive and follow a consistent format. Additionally, explain the rationale behind each naming convention to clarify its importance in maintaining organized and readable test code.

Prevent Recurrence

Implement a Project Guard

Create a project guard for [PROJECT_NAME] that automatically checks for test failures after any code changes. Outline the specific configuration settings needed for efficient operation, including the types of tests to monitor, the frequency of checks, and the notification process for the team in case of failures. Additionally, provide detailed guidance on how to integrate this guard into the existing workflow and outline best practices for its ongoing maintenance.

Prevent Recurrence

Frequently asked questions

Why do my tests fail after using Windsurf?+

Windsurf's Cascade mode can make changes across multiple files, which might inadvertently affect existing tests. Identifying and isolating these changes is crucial to maintaining test integrity.

How can I track changes made by Windsurf?+

Use Windsurf's version control integration to track changes. This allows you to see a history of modifications and identify which changes might have caused test failures.

What should I do if Windsurf breaks my code?+

Immediately diagnose the issue by reviewing the changes made. Use the prompts to isolate the problem and apply targeted fixes to restore functionality.

Can I prevent Windsurf from editing certain files?+

Yes, you can configure Windsurf to follow specific rules by updating your CLAUDE.md file. This can restrict changes to certain files or code sections.

How do I ensure my tests are up-to-date with code changes?+

Regularly review and update your tests to align with code changes. Use Windsurf to automate this process by setting up rules in your CLAUDE.md file.