ThisCalculator

Everyday

Stop Coding Agents From Making Duplicate Internal Tools

Updated · Standard formula, shown below

This guide helps engineering and platform teams prevent AI coding agents from automatically creating duplicate internal tools. By setting up clear discovery, naming, and review practices, you can reduce redundant code, save maintenance time, and keep your internal tool ecosystem healthy.

What You’ll Need

  • Access to your code repository and CI/CD pipeline.
  • An internal developer portal or a simple wiki (e.g., Backstage, Notion, or a Markdown folder in your repo).
  • Permissions to modify your agent’s instructions or system prompts (e.g., for GitHub Copilot, Cursor, or an internal agent).
  • A code search tool (e.g., GitHub code search, ripgrep, or an IDE’s global search).

Step-by-Step

  1. Create a central tool registry. Maintain a single file (e.g., tools.yaml) or a wiki page that lists every internal tool, its purpose, owner, and repository location. This is the source of truth that agents can read.
  2. Add a discovery step to your agent’s workflow. Modify your agent’s system prompt to require a search of the registry and codebase before generating a new tool. For example: “Before writing any new internal tool, search tools.yaml and the codebase for existing tools with similar functionality.”
  3. Define a clear naming convention. Establish a pattern like tool-{purpose}-{language} (e.g., csv-to-json-python). Enforce this in your agent’s instructions and in code review checks.
  4. Use a linter or CI check to enforce uniqueness. Add a CI step that parses your registry and fails the build if a new tool’s name or purpose matches an existing entry. Tools like yamllint or a simple Python script can do this.
  5. Implement a ‘search before create’ prompt in your agent. For agents that accept natural language commands, require them to output a list of potentially related tools and ask the user to confirm before proceeding. Example: “I found these existing tools that might do what you need: … Do you still want me to create a new one?”
  6. Set up a review process for new tools. Require a human review for any new tool that passes the CI check. This could be a pull request rule that only certain team members can approve new tool additions.
  7. Regularly audit and deduplicate. Schedule a monthly or quarterly review of the registry. Use a script to detect overlapping tools by comparing descriptions or keywords. Merge or archive duplicates.
  8. Educate your team and agents. Document the process in your developer onboarding and in the agent’s knowledge base. Include examples of good and bad tool requests.

Common Mistakes

  • Only relying on human memory. Without a registry, developers and agents will naturally forget what exists.
  • Too strict a naming convention. If the convention is overly rigid, agents may deviate or create vague names that don’t match the purpose.
  • Ignoring the registry for existing tools. The registry must be kept up to date; otherwise agents will trust it and create duplicates when the registry is outdated.
  • Not updating the agent’s instructions after changes. If you change the registry location or naming, update the agent’s prompt immediately.
  • Forgetting to search for similar code. A tool may exist but not be in the registry if it was created ad hoc. Always search the codebase, not just the registry.

Tips

  • Use semantic search. If your registry is large, implement a simple keyword or vector search so agents can find tools by functionality, not just name.
  • Include a ‘deprecated’ status. Mark old tools as deprecated so agents don’t use them, but they still appear in search results to prevent re-creation.
  • Automate registry updates. When a new tool is merged, have a bot update the registry automatically with the tool’s name, path, and description.
  • Make the registry easy to read. Use a simple format like YAML or Markdown tables. Avoid complex nested structures that agents might parse incorrectly.
  • Test your agent’s behavior. Run a test prompt like “Create a tool to convert CSV to JSON” and see if it finds the existing one. Adjust instructions if it doesn’t.

Troubleshooting

  • The agent still creates duplicates. Check if the agent is actually reading the registry. You may need to explicitly include the registry content in the prompt or use a tool that the agent can query.
  • The CI check fails for legitimate new tools. Your duplicate detection may be too aggressive. Refine the matching logic to compare purpose keywords, not just names.
  • The registry becomes outdated. Assign a dedicated owner or add a reminder in your team’s workflow. Consider automating updates via a post-merge GitHub Action.
  • Agents don’t follow the naming convention. Add a validation step in the CI that checks the name format and rejects non-compliant names.
  • Team members bypass the process. Make the registry a required part of the pull request template. If a new tool is added without a registry entry, the PR should be blocked.

Frequently Asked Questions

Q: Can I rely on the coding agent to search for duplicates automatically?

A: Not without explicit instructions. You must configure the agent’s system prompt or use a tool that integrates with your registry. Otherwise, agents typically generate code based on the immediate prompt without checking existing code.

Q: What if my team has many tools and no registry yet?

A: Start by creating a simple inventory from your codebase. Use a script to scan for files that look like internal tools (e.g., scripts in a tools/ folder) and list them in a new registry. Then enforce the process going forward.

Q: How do I handle tools that are similar but not exact duplicates?

A: Define a ‘purpose’ field in the registry. If two tools have the same purpose, consider merging them. If they differ significantly in functionality, keep both but document the distinction.

Q: Should I block agents from creating any new tools without human approval?

A: That’s a good approach for high-risk or critical systems. For low-risk tools, you can allow automatic creation but require a post-merge review. The key is to have a review step before the tool is widely used.

Q: What if an agent creates a duplicate because it didn’t find the existing tool due to different naming?

A: Improve the search step by including keyword synonyms in the registry. For example, if the existing tool is ‘csv-to-json’, add tags like ‘convert’, ‘csv’, ‘json’ so a search for ‘convert csv to json’ will match.

Q: How often should I audit for duplicates?

A: At least quarterly. You can also run a script that compares tool descriptions and flags potential overlaps. The more frequently you audit, the less likely duplicates will accumulate.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.