AI Prompts for Preventing Module Export Breakages

20 of the best prompts for preventing module export breakages, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

AI Prompts for Preventing Module Export Breakages

20 of the best prompts for preventing module export breakages, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

Scroll to explore

When Cursor changes a module's exports without updating dependent files, it causes import errors and breaks the build. This leads to runtime failures and wasted debugging time. These prompts guide developers to diagnose, fix, verify, and prevent such issues efficiently. 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.

Diagnose the Wall

Identify which modules have had their exports changed and which files import from them.

List Changed Exports

Please provide a detailed list of all the exports in [MODULE_FILE_PATH] that have been modified recently. For each export, include both the previous and current export signatures, along with the date of modification. Additionally, summarize the nature of the changes made to each export and any potential impacts these changes may have on dependent modules or components. Format the output in a clear table for easy reference.

Diagnose the Wall

Identify Importing Files

Please identify all files in the project that import from [MODULE_FILE_PATH]. For each file, provide the full path and list the specific imports used within that file. Additionally, include any relevant details about how these imports are utilized in the context of the project, such as the functions or classes they are associated with and any potential issues that may arise from these imports.

Diagnose the Wall

Check Import Errors

Please scan the project for any import errors related to [MODULE_FILE_PATH]. Provide a detailed list of all files where these errors occur, including the specific line numbers for each error. Additionally, include a brief description of the nature of each error to help identify potential solutions. Format the output as a structured report that I can easily reference while troubleshooting the issues.

Diagnose the Wall

Review Dependency Tree

Please generate a detailed dependency tree for the module located at [MODULE_FILE_PATH]. In your analysis, highlight any broken links that may have arisen due to recent export changes. Additionally, provide a brief explanation for each broken link, including the specific changes that caused the issue and any recommendations for resolving these problems. Format the output in a clear, structured manner that allows for easy identification of the dependencies and their statuses.

Diagnose the Wall

Analyze Recent Changes

Please analyze the commit history for the file located at [MODULE_FILE_PATH]. Focus specifically on the modifications related to exports, detailing the nature of each change. For each modification, identify the author of the change and the date it was made. Summarize any patterns or trends in the export modifications that may indicate potential issues or improvements. Present your findings in a structured format that includes a timeline of changes and key insights.

Diagnose the Wall

Isolate and Fix

Focus on updating imports in all affected files to match the new exports.

Update Import Statements

Please review each file that imports from [MODULE_FILE_PATH] and update the import statements to align with the new export signatures. Ensure that all instances of the old import syntax are replaced with the correct new syntax. Provide a summary of the changes made, including any files that required significant modifications. Additionally, check for any potential issues that may arise from these updates and suggest solutions if necessary.

Isolate and Fix

Resolve Import Errors

Identify and resolve any import errors in the project related to [MODULE_FILE_PATH]. Provide a detailed explanation of each error found and the specific changes made to fix them. Additionally, ensure that all imports are valid and suggest any necessary adjustments to the code structure to prevent future import issues. Format your response as a summary report that includes the original code snippets with errors and the corrected versions.

Isolate and Fix

Synchronize Export Changes

Please synchronize the export changes in [MODULE_FILE_PATH] with all dependent files in the project. Ensure that all imports are updated accordingly to reflect these changes. Additionally, provide a summary of any files that were modified and highlight any potential issues that may arise from the updates. Format the output as a detailed report, including a list of affected files and the specific changes made to each import.

Isolate and Fix

Refactor Import Logic

Refactor the import logic in the files that depend on [MODULE_FILE_PATH] to align with the new export structure. Identify all instances where the old import syntax is used and update them to reflect the new format. Ensure that all dependencies are correctly imported and that there are no broken references in the code. After making the changes, run tests to confirm that the functionality remains intact and document any modifications made for future reference.

Isolate and Fix

Patch Import Paths

Identify and correct any incorrect import paths in the files that are importing from [MODULE_FILE_PATH]. Review the current project structure and ensure that all import statements are updated to reflect the correct paths. Provide a summary of the changes made, including the original and corrected import paths for clarity. Format the output as a list, detailing each file affected and the specific modifications applied.

Isolate and Fix

Verify the Resolution

Ensure that all import statements are correct and the project builds successfully.

Run Build Process

Execute the build process for the project located at [PROJECT_PATH]. After running the build, please provide a detailed report of any errors or warnings that arise, specifically focusing on issues related to imports from [MODULE_FILE_PATH]. Include information on the nature of the errors, potential causes, and suggestions for resolving them. Additionally, summarize the overall success of the build process and any relevant logs that may assist in troubleshooting.

Verify the Resolution

Test Import Functionality

Please run tests on all modules that import from [MODULE_FILE_PATH] to ensure they function correctly with the updated exports. For each module, provide a detailed report that includes the test results, any errors encountered, and suggestions for resolving those errors. Additionally, summarize any changes in functionality that may have occurred due to the updates. Ensure the report is structured clearly, with sections for each module and a conclusion that highlights overall import functionality.

Verify the Resolution

Check for Remaining Errors

Please scan the entire project for any remaining import errors related to [MODULE_FILE_PATH]. Provide a detailed report of your findings, indicating whether any errors were found and, if so, specify the files and lines where these errors occur. Additionally, suggest possible resolutions for each error identified, including any necessary changes to the import statements or dependencies. Confirm that the project is free of import errors if none are found, and summarize the overall status of the imports in the project.

Verify the Resolution

Validate Dependency Integrity

Please validate the integrity of the dependency tree for the module located at [MODULE_FILE_PATH]. Check for any broken links or missing dependencies and provide a detailed report of any issues found. Include suggestions for resolving these issues and ensure that all dependencies are correctly linked and functional. Format the report in a clear, structured manner, highlighting any critical errors that need immediate attention.

Verify the Resolution

Confirm Export Consistency

Please verify that the exports in [MODULE_FILE_PATH] are consistent across all files that import it. Conduct a thorough review of each importing file to identify any discrepancies or inconsistencies in the exported elements. Summarize your findings in a structured report, detailing the specific exports checked, any inconsistencies found, and recommendations for resolving these issues. Include examples of any problematic imports and suggest how to ensure consistency moving forward.

Verify the Resolution

Prevent Recurrence

Create mechanisms to avoid future export-related issues.

Draft CLAUDE.md Rule

Draft a new rule for CLAUDE.md that ensures all import statements are automatically updated whenever there are changes to exports. The rule should include specific conditions under which the updates should occur, such as the types of exports affected and any exceptions that may apply. Additionally, outline the process for implementing this rule, including any necessary checks or validations to ensure that the updates are applied correctly. Provide examples of how the rule would function in practice, illustrating both successful updates and potential pitfalls to avoid.

Prevent Recurrence

Add Code Comments

Please add detailed comments to the code in [MODULE_FILE_PATH]. Explain the export structure clearly, including the purpose of each export and how they interact with one another. Additionally, identify any dependencies that are crucial to understand when making changes to this module. Ensure the comments are clear and concise, providing enough context for future developers to grasp the functionality and potential pitfalls. Aim for a thorough explanation that enhances the readability and maintainability of the code.

Prevent Recurrence

Create Session Checklist

Please create a detailed checklist for session openers that ensures export and import consistency across the project. The checklist should include specific items to verify, such as data formats, compatibility of import/export settings, and any necessary validation steps to confirm successful data transfer. Additionally, include guidelines on how to handle discrepancies and document any issues found during the verification process. Format the checklist in a clear, organized manner with bullet points for easy reference.

Prevent Recurrence

Establish Naming Conventions

Propose a comprehensive set of naming conventions for exports and imports in software development that will minimize the risk of breakage when changes occur. Include guidelines for naming variables, functions, and modules, ensuring clarity and consistency across the codebase. Discuss how these conventions can help maintain backward compatibility and facilitate easier refactoring in the future. Provide examples of good and bad naming practices, and outline the potential impact of following these conventions on team collaboration and code maintainability.

Prevent Recurrence

Implement Project Guard

Create a project guard script that automatically checks for import-export mismatches in a codebase during development. The script should analyze the source files to identify any discrepancies between imported and exported modules, providing a detailed report of any issues found. Include functionality to run this check at specified intervals or before commits, and ensure it can be easily integrated into existing development workflows. Additionally, provide clear instructions on how to set up and configure the script for different project structures.

Prevent Recurrence

Frequently asked questions

Why does Cursor change exports without updating imports?+

Cursor may not automatically update imports if the changes to exports are not explicitly linked to their dependencies in the project tree. Ensuring all files are open and visible to Cursor can help mitigate this.

How can I track changes to module exports?+

Use version control systems like Git to track changes to module exports. Cursor can also show recent changes if configured to monitor specific files.

What should I do if import errors persist?+

Ensure that all relevant files are open in Cursor and that the project tree is fully loaded. Run diagnostics to identify any overlooked dependencies.

Can Cursor automatically fix import errors?+

Yes, Cursor can automatically fix import errors if it has access to all relevant files and the project structure is well-defined. Use the appropriate prompts to guide this process.

How do I ensure consistent exports across modules?+

Establish clear export rules in your CLAUDE.md file and use Cursor's capabilities to enforce these rules during development sessions.