AI Prompts for Preventing Duplicate Function Creation

20 of the best prompts for preventing duplicate function creation, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

AI Prompts for Preventing Duplicate Function Creation

20 of the best prompts for preventing duplicate function creation, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

Scroll to explore

Published June 28, 2026

Most people try to use AI for Preventing Duplicate Function Creation with a single vague prompt and get generic results. This guide takes a different approach: 4 targeted stages, from Diagnose the Wall through Prevent Recurrence, each with a prompt that gives the AI exactly the context it needs. Windsurf sometimes creates a new function that already exists elsewhere in the codebase under a different name, leading to confusion and potential errors. This duplication can cause inconsistencies and unexpected behavior in the application. These prompts help developers identify and resolve duplicate functions efficiently, ensuring code integrity. Works with ChatGPT, Claude, and Gemini.

Diagnose the Wall

Identify existing functions and their usage across the codebase.

List All Functions

Please provide a comprehensive list of all functions present in the codebase, including their respective file locations. Additionally, identify and highlight any functions that exhibit similar or identical functionality, providing a brief explanation of their similarities. Format the output in a clear table with columns for the function name, file location, and a description of the functionality. This will help in diagnosing potential duplicates and optimizing the codebase.

Diagnose the Wall

Check Function Usage

Analyze the usage of [FUNCTION_NAME] across the entire project. Provide a detailed summary that includes the specific files or modules where this function is called, the frequency of its usage, and any parameters or arguments passed to it. Additionally, identify any potential duplicate functions that may exist and suggest ways to consolidate them for better efficiency. Format the summary in a clear and organized manner, highlighting key insights and recommendations.

Diagnose the Wall

Identify Function Conflicts

Analyze the new function [NEW_FUNCTION_NAME] and identify any potential conflicts with existing functions. Please provide a detailed comparison that highlights similarities in functionality, including any overlapping features or parameters. Additionally, outline the implications of these conflicts on the overall system performance and suggest possible resolutions or adjustments that could be made to avoid issues. Format your response in a clear, structured manner.

Diagnose the Wall

Review Function Definitions

Please review the following function definition: [PASTE FUNCTION]. Compare it with the existing functions in the codebase and identify any duplicates. For each duplicate, provide the name of the existing function, its definition, and explain how it overlaps with the new function. Additionally, suggest any potential improvements or modifications that could be made to avoid redundancy and enhance code efficiency.

Diagnose the Wall

Scan for Naming Patterns

Please scan the codebase for naming patterns that could potentially lead to duplicate functions. Identify any inconsistencies in naming conventions, such as variations in capitalization, prefixes, or suffixes that may cause confusion. Provide a detailed report highlighting specific instances of these patterns, along with recommendations for standardizing names to improve clarity and maintainability. Include examples of both consistent and inconsistent naming practices, and suggest a naming convention that could be adopted across the codebase.

Diagnose the Wall

Isolate and Fix

Focus on resolving the identified duplicate functions.

Rename New Function

Please suggest a unique name for the new function currently labeled as [NEW_FUNCTION_NAME] to avoid any conflicts with the existing function named [EXISTING_FUNCTION_NAME]. Provide at least three alternative names, ensuring that they are descriptive and relevant to the function's purpose. Additionally, explain briefly why each suggested name would be suitable, considering best practices for naming conventions in programming.

Isolate and Fix

Merge Duplicate Functions

Please merge the functionality of [NEW_FUNCTION_NAME] with [EXISTING_FUNCTION_NAME]. Make sure to retain all existing features and behaviors from both functions, and provide a detailed explanation of how the merged function operates. Include any necessary adjustments to parameters and return values to ensure seamless integration. Additionally, outline any potential issues that may arise from this merge and how they can be addressed.

Isolate and Fix

Remove Redundant Function

Please check the code for any instances of the function [NEW_FUNCTION_NAME] and determine if it duplicates the functionality of [EXISTING_FUNCTION_NAME]. If it is indeed redundant, provide a confirmation of its removal and explain briefly why it was deemed unnecessary. Additionally, ensure that the overall functionality of the code remains intact after this change.

Isolate and Fix

Refactor for Clarity

Refactor the following code to ensure that each function has a clear and distinct purpose. Identify any functions that are performing multiple tasks and suggest how to break them down into smaller, more focused functions. Additionally, provide comments explaining the purpose of each function and any improvements that could enhance readability and maintainability. The final output should include the refactored code along with a summary of the changes made and the rationale behind them.

Isolate and Fix

Update Function Calls

Please review the codebase and identify all instances where [NEW_FUNCTION_NAME] is called. Replace each occurrence with [EXISTING_FUNCTION_NAME] and ensure that the functionality remains intact. After making the updates, provide a summary of the changes made, including the number of instances updated and any potential impacts on the overall code performance or functionality. Additionally, confirm that all relevant tests pass successfully after the modifications.

Isolate and Fix

Verify the Resolution

Ensure the duplicate function issue is resolved and the codebase is consistent.

Confirm Function Uniqueness

Please analyze the codebase and confirm that all functions are unique and serve distinct purposes. Provide a detailed report that includes the names of the functions, their definitions, and a brief description of their intended functionality. If any functions are found to be duplicates or serve similar purposes, highlight them and suggest how they can be refactored or consolidated for clarity and efficiency. Additionally, include any recommendations for maintaining function uniqueness in future code development.

Verify the Resolution

Run Code Consistency Check

Please perform a thorough consistency check on the codebase for [PROJECT NAME] to identify and eliminate any duplicate functions. Provide a detailed report that includes the names of any duplicate functions found, their locations within the code, and suggestions for how to refactor or consolidate them. Additionally, summarize the overall health of the codebase regarding function duplication and any potential impacts on performance or maintainability. The report should be structured clearly, with sections for findings, recommendations, and a conclusion.

Verify the Resolution

Validate Function Calls

Please review the function calls in my codebase to ensure that each call is correctly pointing to the intended function. Provide a detailed report that includes: a list of all function calls, the corresponding functions they are supposed to invoke, and any discrepancies or errors found. Additionally, suggest corrections for any incorrect function calls and explain why each correction is necessary. Format the report in a clear, organized manner for easy reference.

Verify the Resolution

Test Application Behavior

Please test the application to verify that the recent changes implemented have not introduced any new issues or bugs. Focus on the key functionalities that were modified, and ensure that they perform as expected. Additionally, check for any unintended side effects in related areas of the application. Document any issues you encounter, including steps to reproduce them, and provide suggestions for resolution if applicable.

Verify the Resolution

Generate Function Report

Please generate a comprehensive report that lists all functions within the project, detailing their names, purposes, and usage frequency. Ensure that the report highlights any potential duplicates by comparing the function names and descriptions. Include a summary section that outlines the total number of unique functions and any identified duplicates, along with recommendations for resolving any issues found. Format the report in a clear, organized manner, suitable for review by the development team.

Verify the Resolution

Prevent Recurrence

Create safeguards to prevent future duplicate function creation.

Create Naming Convention Rule

Please create a detailed naming convention rule for the file CLAUDE.md that aims to prevent the occurrence of duplicate functions. The rule should include specific guidelines on how to structure function names, such as incorporating unique identifiers, descriptive prefixes, or versioning. Additionally, outline examples of both correct and incorrect naming practices to illustrate the conventions clearly. Ensure the rule is comprehensive enough to be easily understood and followed by all developers working on the project.

Prevent Recurrence

Add Function Check Rule

Please create a rule for CLAUDE.md that mandates a check for existing functions prior to the addition of any new functions. The rule should specify the process for verifying whether a function already exists, including the criteria for determining duplicates. Additionally, outline the consequences of failing to adhere to this rule, and provide examples of how to document the findings of the check. Ensure the rule is clear, concise, and easy to follow for all team members.

Prevent Recurrence

Develop Function Usage Comment

Help me develop a standard comment template for function definitions that clearly documents their purpose and usage. The template should include sections for the function name, a brief description of what the function does, parameters with types and descriptions, return values with types, and any exceptions that may be raised. Additionally, provide an example of how to use the function in practice. Format this template in a way that is easy to read and implement in code.

Prevent Recurrence

Draft Session-Opener Checklist

Create a comprehensive checklist for session openers that will help prevent the creation of duplicate functions during the development process. The checklist should include key items such as reviewing existing functions for similarities, verifying naming conventions, and ensuring proper documentation is in place. Additionally, include steps for team communication to confirm that all members are aware of current functions and their purposes. Format the checklist in a clear, organized manner with bullet points for easy reference.

Prevent Recurrence

Implement Project Guard

Propose a project guard mechanism that can automatically detect and alert on potential duplicate functions within a codebase. Describe the criteria that the system should use to identify duplicates, such as function names, parameters, and return types. Additionally, outline how the alerts should be communicated to the development team, including the format of the notifications and any recommended actions to resolve the duplicates. Provide examples of how this mechanism could improve code quality and maintainability.

Prevent Recurrence

Frequently asked questions

How can I stop Windsurf from creating duplicate functions?+

Use the custom rules feature in Windsurf to enforce naming conventions and check for existing functions before creating new ones. This helps maintain a clean and efficient codebase.

What should I do if Windsurf creates a function that already exists?+

First, identify the duplicate using Windsurf's diagnostic tools. Then, either rename or merge the functions as needed to resolve the duplication.

Why does Windsurf create duplicate functions?+

Windsurf may create duplicates if the naming conventions are not clear or if it lacks context about existing functions. Implementing clear rules in CLAUDE.md can help mitigate this.

How do I verify that all functions are unique?+

Use Windsurf to run a code consistency check and generate a report of all functions and their usage to ensure uniqueness.

Can I automate checks for duplicate functions in Windsurf?+

Yes, you can automate checks by setting up project guards and using CLAUDE.md rules to alert you to potential duplicates during development.