20 of the best prompts for resolving nonexistent imports issue, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
20 of the best prompts for resolving nonexistent imports issue, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
GitHub Copilot sometimes suggests code that references modules or functions not present in the project, causing confusion and errors. This can lead to wasted time as developers search for non-existent code. These prompts help developers identify the root cause and implement a fix to prevent future occurrences. 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 which imports or functions are being incorrectly suggested.
List Missing Imports
Please analyze my current code file and provide a comprehensive list of all the import statements present. For each import, indicate whether it exists in the project or if it is missing. Additionally, explain the purpose of each import and suggest alternatives for any missing imports that may be relevant to the functionality of the code. Format the output as a structured report with sections for existing imports, missing imports, and suggested alternatives.
Identify Nonexistent Functions
Please analyze the code in the file [FILE NAME] and identify all the function calls present. For each function call, determine whether it is defined within the project or if it is a nonexistent function. Provide a list of the nonexistent functions along with their respective locations in the code, and include any relevant context that may help in understanding why these functions were suggested. Format the output as a clear report, categorizing the functions into defined and undefined.
Check Project Context
Based on the currently open files in this project, please analyze the context and provide a list of the modules and functions that are likely available for use. Include any relevant details about their purpose and how they might interact with each other. Additionally, if there are any potential dependencies or considerations I should be aware of when utilizing these modules or functions, please mention those as well. Format your response in a clear, organized manner for easy reference.
Compare Suggestions to Codebase
Please compare the import suggestions you generate with the actual modules present in my project. Identify any missing imports and provide a detailed list of these discrepancies. Additionally, explain why each missing import is relevant to the functionality of the codebase. Format your response in a clear table, with columns for the suggested import, the status (missing or present), and a brief explanation of its purpose in the project.
Review Recent Suggestions
Please review the last few code suggestions you provided and identify any instances where the recommendations were based on incorrect assumptions about available modules or functions. For each suggestion, provide a brief explanation of the assumption made and why it may be incorrect. Additionally, suggest the correct modules or functions that should have been used instead, along with examples of how to implement them properly in code.
Focus on correcting the specific instances of incorrect imports or function calls.
Remove Incorrect Imports
Please analyze the code in the provided file and identify any import statements that reference non-existent modules. For each incorrect import, provide a brief explanation of why it is deemed incorrect and suggest the appropriate action to take, whether that is to remove the import or to correct it if a valid module exists. Format your response as a list, clearly indicating the line number of each incorrect import and the suggested changes.
Replace Nonexistent Functions
Identify any function calls in the provided code file that do not exist within the project. For each nonexistent function, suggest alternative functions that could be used instead, ensuring that the alternatives align with the intended functionality of the original calls. Additionally, provide a brief explanation for each suggestion, outlining why the alternative function is appropriate and how it can be implemented in the code. Format your response in a clear and organized manner, listing the original function calls alongside their suggested replacements.
Add Missing Modules
Please analyze the current project code and identify any missing modules that are necessary to implement the suggested features. For each missing module, provide a brief explanation of its purpose and relevance to the project. Additionally, include the specific installation commands for each module, formatted for easy copying into a terminal. Ensure that the recommendations align with best practices for the project's programming language and framework.
Correct Function Definitions
Please analyze the code in this file and identify any missing function definitions that are referenced but not yet implemented. For each missing function, provide a suggested definition that includes the function name, parameters, and a brief description of its purpose. Additionally, include any relevant comments or documentation that would help clarify how the function should be used within the context of the code. Ensure that the suggested definitions are clear and follow best practices for coding standards.
Update Import Paths
Please analyze the import paths in the provided code file and identify any that are incorrect. For each incorrect import path, suggest the correct path along with a brief explanation of why the correction is necessary. Ensure that your suggestions are clear and formatted in a way that I can easily implement them in my code. Additionally, provide any relevant context about the potential impact of these corrections on the functionality of the code.
Ensure the fixes are correctly implemented and the issue is resolved.
Check Import Validity
Please check the validity of all import statements in the provided code file. Identify any imports that do not reference existing modules and provide a detailed report of the issues found. For each invalid import, include the line number, the import statement itself, and suggestions for correcting or removing the import. Additionally, summarize the overall status of the import statements in the file, indicating how many are valid and how many need attention.
Validate Function Calls
Please review the code in this file and validate that all function calls are correctly referencing functions that are defined within the project. Provide a detailed report highlighting any discrepancies, including the names of any undefined functions and the lines where they are called. Additionally, suggest corrections or alternatives for any function calls that do not match the defined functions in the project. Format the report clearly, separating valid calls from invalid ones for easy reference.
Run Code Check
Please analyze the code in the provided file and identify any unresolved references or imports. List each unresolved reference clearly, along with a brief explanation of why it is unresolved. Additionally, suggest possible solutions or corrections for each issue you find, and provide guidance on how to implement these changes effectively. Format your response in a clear and organized manner, making it easy to follow.
Confirm Module Availability
Please verify the availability of all modules that were previously suggested for the project. Provide a detailed list of each module, indicating whether it is present or missing. If any modules are missing, include recommendations for how to resolve the issue, such as alternative modules or steps to install the missing ones. Additionally, summarize any potential impact on the project if certain modules are not available.
Test Code Execution
Please simulate running the following code file to verify that it executes without any import errors. The code includes the following sections: [INSERT CODE HERE]. Ensure that all necessary imports are included and correctly referenced. If there are any issues, provide a detailed explanation of the errors encountered and suggest possible fixes. Additionally, confirm that the code adheres to best practices for structure and readability.
Create safeguards to avoid future occurrences of this issue.
Create Import Checklist
Please create a comprehensive checklist for verifying import statements in code before finalizing any suggestions. The checklist should include key elements such as ensuring all imported modules are necessary, checking for correct syntax, confirming that the module versions are compatible with the project, and verifying that there are no unused imports. Additionally, include steps for testing the imports to ensure they function as expected in the codebase. Format the checklist in bullet points for easy reference.
Add Code Comment
Please create a comment template that I can use in my code to remind myself to check for the existence of modules before adding imports. The comment should clearly state the importance of verifying module availability to avoid runtime errors. Include a checklist format with points such as: confirming the module is installed, verifying the correct version, and ensuring compatibility with existing code. The comment should be concise yet informative, suitable for inclusion at the top of my import statements.
Draft CLAUDE.md Rule
Please suggest a detailed rule for my CLAUDE.md that will prevent the acceptance of suggestions for non-existent imports in my code. The rule should clearly outline the criteria for identifying such imports, provide examples of common scenarios where this issue may arise, and explain the consequences of accepting these suggestions. Additionally, include guidelines on how to handle cases where an import might be valid but is not recognized by the system. Format your response as a structured markdown section that I can directly include in my CLAUDE.md file.
Establish Naming Convention
Please propose a comprehensive naming convention that can be used to differentiate between existing and non-existent modules in a codebase. The convention should include specific guidelines on how to name modules, such as prefixes or suffixes that indicate their status, and any best practices for maintaining clarity and consistency. Additionally, provide examples of naming conventions for both existing modules and those that are yet to be created, ensuring that the approach is scalable and easy to implement across different projects.
Create Session-Opener Checklist
Please create a detailed checklist to review before starting a coding session. The checklist should include steps to ensure that all necessary modules and dependencies are installed and available. Include items such as verifying the project environment, checking for required libraries, confirming version compatibility, and ensuring that any configuration files are properly set up. Format the checklist in a clear, numbered list for easy reference during the session.
GitHub Copilot generates suggestions based on patterns in the code and its training data, which may include references to common libraries or functions not present in your project.
Ensure your open files provide sufficient context and consider adding a CLAUDE.md rule to guide Copilot's suggestions.
Verify the function's existence in your project and ask Copilot to suggest alternatives or help define the function if needed.
Copilot doesn't have a configuration to restrict suggestions to existing modules, but you can guide it by providing clear context and using CLAUDE.md rules.
Copilot uses the open files in your editor to infer available modules and functions, but it does not traverse the entire project tree unless explicitly directed.
AI Prompts for Preventing Module Export Breakages
When GitHub Copilot changes a module's exports, it can break existing imports across your codebase.
See promptsAI 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 GitHub Copilot for Code Completion
Developers often face challenges with code completion and suggestions, leading to inefficiencies.
See prompts