20 of the best prompts for resolving module system conflicts, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
20 of the best prompts for resolving module system conflicts, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
Published June 28, 2026
Mixing CommonJS and ES module syntax can lead to runtime errors and unexpected behavior. This inconsistency causes confusion and hampers code maintainability. These prompts help developers identify and resolve these conflicts, ensuring a consistent module system throughout the codebase. This guide walks you through every stage of Resolving Module System Conflicts, from Diagnose the Wall all the way through Prevent Recurrence, with a curated, copy-ready prompt at each step. Each stage targets a specific phase of the process so you always know exactly what to ask and what output to expect. Works with ChatGPT, Claude, and Gemini and any other major AI tool.
Identify where and how the module systems are being mixed.
Identify Mixed Imports
Please scan the open files in the project and identify all instances where both 'require' and 'import' statements are used within the same file. For each instance, provide the corresponding line numbers and file names. Additionally, summarize the potential implications of using mixed import styles in the codebase and suggest best practices for maintaining consistency in module imports. Format the output as a detailed report.
Check Module Type
Examine the package.json file in the current project and determine whether it specifies 'type': 'module'. If it does, explain the significance of this setting in relation to how JavaScript modules are handled in the project. Additionally, discuss the implications of using 'module' versus 'commonjs' for module loading, and provide examples of how this affects the import and export syntax in the codebase. Please present your findings in a clear and structured format.
Find CommonJS Usage
Identify all files in the project that utilize 'module.exports' or 'require'. For each file, provide a brief summary that includes the purpose of the module, how it interacts with other parts of the codebase, and any relevant dependencies or relationships. Additionally, highlight any patterns or common practices observed in the usage of CommonJS within these files. Format the output as a structured report with file names as headings and the summaries below each heading.
Locate ES Module Usage
Please analyze the codebase and identify all files that utilize 'import' or 'export' statements for ES module usage. For each file, provide the line numbers where these statements occur and highlight any patterns or trends you observe in their usage. Additionally, summarize the implications of these patterns on the overall module system and suggest any potential improvements or refactoring opportunities based on your findings.
Analyze Import Errors
Please analyze the current open files in my project for any import-related errors or warnings. Provide a detailed summary of the identified issues, including the specific files and lines where the errors occur. Additionally, suggest possible causes for these import errors, considering factors such as module paths, dependencies, and version compatibility. Format your response as a structured report with clear headings for each issue and its corresponding suggestions.
Focus on resolving the identified module system conflicts.
Convert to ES Modules
Please provide a detailed, step-by-step guide for converting files from CommonJS to ES modules. For each file, include the specific changes needed, such as how to replace `require` statements with `import` statements and how to adjust `module.exports` to `export`. Additionally, include code snippets that illustrate each step clearly, and explain any potential issues that may arise during the conversion process, along with solutions. Ensure that the guide is comprehensive enough for someone with basic JavaScript knowledge to follow easily.
Update Import Statements
Identify the files in my project where 'require' statements are used and suggest the correct 'import' statements to replace them. For each file, provide a brief explanation of the changes made and examples of the new import statements. Additionally, include any necessary adjustments to ensure compatibility with ES6 module syntax. Format your response clearly, with each file's changes listed separately.
Modify Exports
Please provide a detailed guide on how to modify the export syntax in JavaScript files. Specifically, demonstrate how to change 'module.exports' to 'export default' or named exports. Include examples of both types of exports, and outline the steps needed to identify the relevant files that require modification. Additionally, explain any potential issues that may arise during this process and how to resolve them.
Adjust Package Configuration
Please analyze the provided package.json file. If it does not specify 'type': 'module', suggest the necessary changes to include this specification. Explain the impact of these changes on the module system, including how it affects the way modules are imported and exported in the code. Additionally, provide examples of how to correctly structure the imports and exports in both CommonJS and ES module formats to illustrate the differences.
Resolve Mixed Syntax
Please analyze the provided code files that utilize both CommonJS and ES module syntax. Recommend a consistent module system approach to adopt throughout the codebase, explaining the advantages of your chosen method. After that, refactor the code to ensure it adheres to the selected module system, providing clear comments on the changes made and any potential impacts on functionality. Ensure the refactored code maintains the original behavior while improving clarity and consistency.
Ensure the module system is consistently applied and functioning correctly.
Run Module Tests
Please execute all existing tests related to module imports and exports in my project. After running the tests, provide a detailed report on any failures, including the specific causes of each failure. Additionally, suggest potential solutions or fixes for the identified issues. Ensure that the report is structured clearly, highlighting the test names, results, and any relevant error messages.
Check for Errors
Please re-scan the codebase for any import or export errors. Provide a detailed report of any issues found, including the specific files and lines where the errors occur. Additionally, confirm that there are no remaining issues and summarize the overall status of the codebase after the scan. If errors are found, suggest potential fixes or improvements to resolve them.
Validate Package Configuration
Please review the package.json configuration for [PROJECT NAME] and validate that it aligns with the intended module system, which is [MODULE SYSTEM, E.G., COMMONJS, ES MODULES]. Check for any discrepancies or errors in the configuration, including dependencies, scripts, and any relevant fields. Provide a summary of your findings, highlighting any issues that need to be addressed and recommendations for corrections if necessary.
Confirm Consistent Usage
Please review all project files and confirm that they consistently use the same module system. Identify any discrepancies or inconsistencies in module usage across the files. Provide a detailed summary of your findings, including which files adhere to the chosen module system and which do not, along with recommendations for correcting any inconsistencies. Additionally, include any potential impacts of these discrepancies on the overall project functionality.
Review Code Consistency
Please analyze the codebase for any remaining inconsistencies in module usage. Identify specific areas where inconsistencies exist and provide detailed explanations for each issue found. Additionally, confirm whether all previously identified issues have been resolved, and if not, outline the unresolved problems with suggestions for how to address them. Present your findings in a structured report format, including sections for inconsistencies, resolutions, and recommendations.
Create safeguards to maintain a consistent module system in future development.
Create CLAUDE.md Rule
Draft a rule for a CLAUDE.md file that specifies the requirement for using a single module system throughout the project. The rule should clearly outline the reasons for this mandate, including benefits such as consistency, maintainability, and ease of collaboration. Include specific examples of acceptable module systems and any exceptions to the rule, if applicable. Format the rule in a way that is easy to read and understand, and ensure it can be easily referenced by all team members.
Add Code Comments
Please provide a standard comment template that can be added at the top of each code file to indicate the module system being used. The comment should include the following elements: the name of the module system (e.g., CommonJS, ES Modules), a brief description of its purpose, and any relevant version information. Ensure the comment is formatted in a way that is clear and easy to read, and provide an example of how it should look when implemented in a code file.
Develop a Checklist
Create a comprehensive checklist for developers to follow when adding new files to ensure consistency in the module system. The checklist should include steps such as verifying the naming conventions for files and modules, ensuring proper import/export statements are used, checking for adherence to the project's coding standards, and confirming that all dependencies are correctly documented. Additionally, include a section for reviewing any related documentation updates that may be necessary. Format the checklist in a clear, easy-to-follow layout with bullet points for each item.
Establish Naming Conventions
Propose a detailed set of naming conventions for files and directories that align with the [MODULE SYSTEM] being used in my project. Include guidelines for naming structure, such as using lowercase letters, underscores, or hyphens, and provide examples of how to name different types of files (e.g., modules, components, utilities). Additionally, explain the rationale behind these conventions and how they can improve code organization and readability. Format your response as a structured document with headings for each category of naming convention.
Implement Project Guard
Please recommend a detailed script or tool that can automatically check for module system consistency during development. The solution should include specific features such as identifying mismatched module types, providing clear error messages, and offering suggestions for corrections. Additionally, outline how this tool can be integrated into a typical development workflow and any prerequisites needed for setup. Include examples of scenarios where this tool would be particularly beneficial, and suggest best practices for maintaining module consistency throughout the project lifecycle.
GitHub Copilot suggests code based on patterns it has learned from public repositories. If your codebase or the context is unclear, it might mix module systems. Providing clear context helps it make accurate suggestions.
Make sure your package.json specifies 'type': 'module' and that your files consistently use ES module syntax. This context guides Copilot's suggestions.
Mixing CommonJS and ES modules can lead to runtime errors and compatibility issues. It is crucial to maintain consistency to avoid these problems.
GitHub Copilot can suggest code transformations, but it relies on the developer to guide the process. Use prompts to get specific conversion suggestions.
Set 'type': 'module' in your package.json and ensure all files use 'import' and 'export'. This configuration helps Copilot provide consistent suggestions.
AI Prompts for Resolve Module System Conflicts
Mixing CommonJS require and ES module import/export can lead to silent failures in your application.
See promptsAI Prompts for Resolving Mixed Module Systems
Mixing CommonJS require and ES module import/export can lead to unexpected errors and failed builds.
See promptsAI Prompts for Resolving Module System Conflicts
Mixing CommonJS and ES module systems in the same codebase can lead to runtime errors and unexpected behavior.
See prompts