20 of the best prompts for correcting nonexistent imports in code, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
20 of the best prompts for correcting nonexistent imports in code, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
Windsurf generates code that references modules or functions not present in the project, causing build failures and runtime errors. This leads to wasted time as developers must manually identify and correct these issues. These prompts help developers quickly diagnose and resolve the problem, ensuring smoother coding sessions. 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 missing modules or functions causing the issue.
List Missing Imports
Identify all the imports in the current file that are not present in the project. Please provide a detailed list of these missing imports, including the specific names of the imports and any relevant information about their expected usage or purpose within the project. Additionally, if possible, suggest alternatives or solutions for each missing import to help resolve the issue. Format the response as a clear list for easy reference.
Check Project Dependencies
Please review the project's dependency files and identify any missing dependencies that could lead to import errors. For each missing dependency, provide a brief explanation of its purpose and why it is necessary for the project. Additionally, suggest specific steps to resolve these issues, including how to install the missing dependencies and any potential impacts on the project if they are not addressed. Format your response as a structured report, highlighting each missing dependency and its resolution in separate sections.
Analyze Recent Changes
Analyze the recent changes in the codebase for [PROJECT NAME] that may have led to missing imports. Please summarize the specific modifications made, including the files affected and the nature of the changes. Additionally, identify any patterns or common factors that could have contributed to these missing imports. Provide your findings in a structured format, highlighting the most critical changes and their potential impact on the functionality of the project.
Review Import Paths
Please review the import paths in the current file and identify any that are incorrect or do not resolve properly. For each incorrect path, provide a brief explanation of why it is incorrect and suggest the correct path if possible. Additionally, include the line numbers where these incorrect imports are found to facilitate easy navigation. Format your response as a structured list, clearly indicating each issue and its corresponding details.
Identify Unused Imports
Please analyze the current file and identify any imports that are not being used. Provide a list of these unused imports along with a brief explanation of why each one can be safely removed. Additionally, suggest best practices for managing imports in future code to prevent unnecessary clutter. Format your response in a clear and organized manner, highlighting the benefits of maintaining clean code.
Focus on correcting the identified import issues.
Add Missing Modules
Identify all missing imports in the current project code. For each missing import, suggest the correct module or package that needs to be added. Additionally, provide the installation command for each module, formatted for easy copy-pasting into a terminal. Ensure that your suggestions include a brief explanation of what each module does and why it is necessary for the project.
Correct Import Paths
Please review the project's directory structure and identify any incorrect import paths. For each incorrect path, provide the correct import path along with a brief explanation of why the correction is necessary. Ensure that your suggestions are clear and follow the conventions used within the project. Format your response as a list, specifying both the incorrect and corrected paths, and include any relevant details that may help in understanding the changes.
Remove Unused Imports
Please analyze the current file and identify all unused imports. Create a revised version of the file that removes these unused imports while ensuring that the remaining code functions correctly. Provide a summary of the changes made, including the names of the imports that were removed and any potential impact on the code's functionality. Ensure the revised file maintains proper formatting and adheres to best coding practices.
Update Dependency Files
Review the project's current dependency files and identify any missing modules that need to be included. Provide a detailed list of these missing modules along with the necessary code snippets to update each dependency file. Ensure that the updated content is formatted correctly and includes version specifications where applicable. Additionally, explain any potential impacts of these updates on the project's functionality or performance.
Refactor Code for Clarity
Please refactor the following code to enhance clarity and ensure that all imports are necessary. The code is as follows: [INSERT CODE HERE]. In your response, provide a revised version of the file, highlighting any changes made to the import statements and explaining why certain imports were removed or retained. Additionally, ensure that the overall structure of the code is organized and easy to understand, with comments where appropriate to clarify the purpose of each section.
Ensure the import issues are resolved and the code functions correctly.
Run Build Process
Please execute the build process for the project and provide a detailed report on any errors encountered, specifically those related to imports. Additionally, confirm whether the build was successful or not. If there are any issues, please include suggestions for resolving the import errors and any relevant context that may help in troubleshooting.
Test Import Functionality
Please run a series of tests on the current file to verify that all import statements are functioning correctly. Include details on each import, such as whether it was successfully loaded, any errors encountered, and the specific lines of code where each import is utilized. Summarize the overall results, highlighting any issues that need to be addressed and suggesting potential solutions for any failed imports. Format the output in a clear report that can be easily reviewed.
Check for New Errors
Please scan the codebase for any new errors that may have been introduced after the recent fixes to the imports. Provide a detailed list of any issues you find, including the file names, line numbers, and a brief description of each error. Additionally, categorize the errors by severity (e.g., critical, major, minor) and suggest possible resolutions for each identified issue.
Confirm Dependency Updates
Please verify that all necessary dependencies for the project are updated to their latest versions and correctly installed. List each dependency along with its current version and indicate whether it is up to date. If any dependencies are outdated or missing, provide recommendations for updates or installations. Finally, generate a confirmation message summarizing the status of the dependencies.
Validate Code Execution
Please validate the main functionality of the project by executing the code with the fixed imports. I need a detailed report on the execution results, including any errors encountered, the output produced, and whether the functionality meets the expected behavior. Additionally, summarize any discrepancies or issues that arise during the execution process, and suggest potential solutions or areas for further investigation. Format your findings in a clear and organized manner for easy review.
Create safeguards to avoid future import issues.
Create Import Checklist
Please create a detailed checklist for verifying imports in a codebase before committing changes. The checklist should include steps such as: checking for unused imports, ensuring all necessary imports are included, verifying import paths are correct, and confirming that there are no circular dependencies. Additionally, include a section for best practices related to organizing imports and any common pitfalls to avoid. Format the checklist in a clear, numbered list for easy reference.
Write CLAUDE.md Rule
Please draft a new rule for the CLAUDE.md file aimed at preventing future import issues. The rule should clearly outline the specific conditions or practices that must be followed to avoid similar problems. Include examples of what constitutes acceptable and unacceptable imports, and suggest any necessary procedures for verifying imports before they are finalized. Format the rule in a clear and concise manner, ensuring it is easy to understand and implement.
Add Code Comment Guidelines
Please create a comprehensive set of guidelines for commenting on imports in code. The guidelines should include best practices for clarity, consistency, and relevance. Cover aspects such as when to comment, what information to include (e.g., purpose of the import, any dependencies), and examples of well-commented imports versus poorly commented ones. Format the guidelines in a clear, numbered list for easy reference.
Establish Naming Conventions
Help me establish clear and consistent naming conventions for modules and functions in my project to minimize import errors. The conventions should include guidelines on naming styles (e.g., camelCase, snake_case), rules for naming modules versus functions, and any specific prefixes or suffixes that should be used to indicate the purpose of each module or function. Additionally, provide examples of well-named modules and functions that adhere to these conventions, and explain how following these guidelines can help improve code readability and maintainability.
Implement Project Guard
Help me implement a project guard that automatically checks for missing imports during the build process. I need detailed steps on how to configure this guard, including the specific settings required for different programming languages or frameworks. Please outline any necessary scripts or commands to run, and explain how to integrate this guard into the existing build pipeline. Additionally, include best practices for maintaining and updating the configuration over time to ensure it remains effective.
Windsurf may suggest imports based on incomplete context or outdated project information. Ensuring your project files and dependencies are up-to-date can help mitigate this issue.
Using the Cascade mode carefully and setting strict rules in your CLAUDE.md file can help control the scope of changes Windsurf makes.
Review the changes Windsurf makes in Cascade mode and adjust your CLAUDE.md rules to restrict unwanted file modifications.
Regularly update your CLAUDE.md file with clear and specific rules. Use Windsurf's feedback to refine these rules over time.
Keep your dependency files updated and use Windsurf's diagnostic tools to identify and resolve any missing dependencies promptly.
AI Prompts for Resolving Nonexistent Imports in Code
Code generated by Bolt references modules or functions that do not exist, leading to runtime errors and broken functionality.
See promptsAI Prompts for Addressing Nonexistent Imports
Cursor sometimes generates code with imports that do not exist in the project, causing errors and confusion.
See promptsAI Prompts for Resolving Missing Imports Issue
Lovable sometimes generates code referencing non-existent modules or functions, causing build failures and confusion.
See prompts