SAThinkwithClaude
AI Q&A

How do I get an AI coding assistant to reuse shared code instead of duplicating it?

Answered by Shantanu Anand, AI Trainer & Consultant · 6 November 2026

AI assistants tend to write fresh code for each task because they only see what is in their context. Fix that by making the shared code visible and by stating your rules.

Create a short project instructions file (many tools read one automatically) saying where shared utilities live, how they are named, and that new logic should reuse them. Point the assistant at the specific shared files in your prompt. Ask it to search the codebase for an existing function before writing a new one. For larger changes, ask for a plan first and check it for reuse. Afterwards, request a review pass that looks only for duplicated logic and proposes moving it into a shared module.

Want your team doing this hands-on? See Shantanu's AI training →

More AI questions, answered

← All AI questions

Want your team to use AI like this?

Hands-on AI training for professionals and teams, online or in person anywhere in India. Get the training details on WhatsApp, or book a free 20-minute call.

Get training detailsBook a free call
© 2026 ThinkwithClaude · Shantanu Anand, AI Trainer & Consultant