20 of the best prompts for resolving nonexistent imports, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
20 of the best prompts for resolving nonexistent imports, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
Claude Code generates code with references to nonexistent modules or functions, causing runtime errors and wasted debugging time. This disrupts development flow and leads to frustration. These prompts help developers guide Claude Code to correctly identify and use existing project components. 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.
Examine the project's CLAUDE.md file and recent AI-generated code for discrepancies.
Identify Missing Modules
Please review the code I generated in the last session and provide a comprehensive list of all modules and functions that were referenced. For each item, identify whether it exists in the current project files or if it is missing. Additionally, provide a brief explanation of the purpose of each missing module or function and suggest possible alternatives or solutions to address these gaps in the project. Format your response in a clear, organized manner for easy reference.
Check CLAUDE.md Compliance
Please review the following CLAUDE.md file content: [PASTE CONTENT]. Confirm whether the rules outlined in the document are being followed in your recent actions. Additionally, identify any discrepancies or areas where compliance may not have been met, and provide specific examples or suggestions for improvement based on the content of the CLAUDE.md file.
Review Recent Changes
Please review the most recent changes made in the codebase. Identify and highlight any lines that reference a module or function that is not present in the project. Provide a summary of these issues, including the specific lines of code and the names of the missing modules or functions. Additionally, suggest potential solutions or alternatives for each missing reference to help resolve the issues effectively.
Trace Import Errors
Please help me diagnose import errors in my project. I will provide you with the codebase, and I need you to run the project to identify any import-related issues. For each error, please list the exact error message along with the corresponding line of code where the error occurs. Additionally, provide a brief explanation of what might be causing each error and suggest potential solutions to resolve them.
Analyze Context Window
Please analyze how the context window may have influenced your understanding of the project structure in relation to the imports used. Discuss specific instances where context loss occurred and how it contributed to incorrect imports in the code. Provide examples of the types of information that were missing or unclear, and suggest ways to improve context retention for better accuracy in future projects. Your response should be detailed and structured, ideally spanning at least three paragraphs.
Focus on correcting the specific lines where nonexistent imports were introduced.
Correct Import Statements
Identify the lines in the code that contain incorrect import statements. For each incorrect import, provide the correct existing module or function from the project that should be used instead. Ensure that the replacements maintain the functionality of the code and are compatible with the overall structure. Present the corrected import statements in a clear format, indicating the original line and the suggested replacement for easy reference.
Remove Invalid References
Please review the provided code and identify any references to nonexistent modules or functions. Remove these invalid references while ensuring that the remaining code maintains its functionality. After making the necessary adjustments, provide a revised version of the code along with a brief explanation of the changes made and any potential impacts on the overall functionality.
Re-evaluate Context
Please re-evaluate the current project context for [PROJECT NAME] and identify any areas that may lead to incorrect imports. Provide a detailed analysis of the project's structure, including the key components and their interdependencies. Suggest specific changes or improvements to the import statements based on your updated understanding, and outline any potential risks associated with the current setup. Additionally, include recommendations for best practices to avoid similar issues in the future.
Validate Module Paths
Please verify the paths of all imported modules in the project located at [PROJECT_PATH]. Identify any paths that do not lead to existing files and provide a detailed report of these discrepancies. For each incorrect path, suggest the correct path or a potential solution to resolve the issue. Additionally, summarize the overall status of module imports, indicating how many paths were valid and how many required correction.
Synchronize with CLAUDE.md
Please review the CLAUDE.md rules and summarize the key guidelines that must be followed. Provide a clear list of the most important rules, explaining their significance and how they impact the overall process. Additionally, suggest specific actions or adjustments that can be made to ensure strict adherence to these guidelines in future tasks. Format your response as a structured report with headings for each section.
Ensure all import errors are resolved and the project runs without issues.
Run Import Tests
Please execute the project's test suite with a specific focus on verifying the import functionality. I want you to run all relevant tests and provide a detailed output that confirms whether all tests pass successfully without any import errors. Additionally, if there are any failures, please include the specific error messages and the files involved. Summarize the results in a clear format that highlights the overall success rate and any issues that need to be addressed.
Confirm Module Integrity
Please provide a comprehensive list of all modules currently used in the project. For each module, verify its implementation by checking for any errors or issues in the code. Additionally, confirm that each module is functioning as intended, and provide a brief summary of its purpose within the project. If any modules are found to be problematic, include suggestions for resolving the issues.
Reproduce Original Scenario
Please simulate the original scenario that led to the import errors in my code. Describe the specific conditions and code snippets that were present when the errors occurred. After reproducing the scenario, confirm whether the issue persists and provide detailed before-and-after outputs, including any error messages or logs that were generated. Additionally, explain any changes made to resolve the issue and how they impacted the functionality of the code.
Document Changes
Please summarize the changes made to resolve the import issues in the codebase. Include the names of the files where changes were made, along with the specific lines that were altered. Additionally, explain the reason for each change and how it contributes to fixing the import issues. Format the summary in a clear and organized manner, using bullet points for each file and change for easy reference.
Verify CLAUDE.md Compliance
Please verify compliance with the CLAUDE.md rules after implementing the necessary fixes. Review each action taken to ensure it aligns with the documented guidelines. Provide a detailed report that outlines any discrepancies found, suggestions for further adjustments if needed, and confirm whether full compliance has been achieved. Include specific examples from the documentation to support your evaluation and ensure clarity in your findings.
Implement safeguards to avoid future import-related issues.
Create Import Checklist
Please create a comprehensive checklist for verifying the existence of modules before using them in code. The checklist should include specific steps such as how to confirm module paths, methods to check for function availability within the modules, and best practices for handling errors if a module is not found. Additionally, provide examples of common modules and how to validate their presence in a Python environment. Format the checklist in a clear, step-by-step manner that can be easily followed.
Update CLAUDE.md Rules
Please suggest a new rule to add to the CLAUDE.md documentation that addresses recent import errors. The rule should clearly outline the best practices for managing imports in code to prevent similar issues from occurring in the future. Include specific examples of common mistakes and how to avoid them, as well as any relevant guidelines that should be followed. Format the rule in a way that it can be directly added to the existing documentation, ensuring clarity and ease of understanding for developers.
Add Code Comments
Please add comments above the critical import sections in the code to warn about potential pitfalls and constraints. The comments should clearly explain the reasons for caution, including any specific issues that may arise from using certain libraries or modules. Ensure that the comments are concise yet informative, ideally one to two sentences long for each import. Provide the exact text of the comments you suggest for each critical import section.
Session Opening Reminder
Please create a reminder that I can use at the start of each coding session. The reminder should prompt me to verify the existence of all necessary modules and their paths before I begin generating any code. Include specific steps to check for module availability and ensure that the paths are correctly set up. This reminder should be concise yet comprehensive enough to guide me through the verification process effectively.
Establish Naming Conventions
Propose a comprehensive naming convention for modules and functions that will help reduce confusion in our codebase. The convention should include guidelines on naming styles (e.g., camelCase, snake_case), best practices for naming modules versus functions, and examples of good and bad naming choices. Additionally, create a short guide that can be included in the project documentation, outlining the rationale behind the naming conventions and how they contribute to code readability and maintainability. Ensure the guide is clear and concise, ideally no more than one page in length.
Claude Code may lose track of context in large codebases due to its fixed context window. This can lead to incorrect assumptions about available modules. Ensuring CLAUDE.md rules are clear and context is maintained helps mitigate this.
Regularly update and review the CLAUDE.md file to ensure it accurately reflects the project structure. This helps Claude Code maintain context and avoid incorrect imports.
Interrupt the loop and provide specific instructions or corrections. Use prompts to guide Claude Code back on track, ensuring it adheres to project rules.
Clearly define rules in the CLAUDE.md file and regularly verify compliance. Use diagnostic prompts to check adherence during code generation.
CLAUDE.md provides project-specific rules and instructions that guide Claude Code's actions. Keeping it updated ensures the AI operates within the correct parameters, reducing errors.
AI Prompts for Updating Module Imports Consistently
Claude Code changes a module's exports but does not update the files that import from it, leading to broken dependencies and runtime errors.
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 Diagnosing and Correcting Fact Errors
Claude sometimes confidently presents incorrect information, including invented citations and wrong dates, which can mislead users.
See prompts