Managing Code Reuse and Dependencies in LLM Projects

Explore top LinkedIn content from expert professionals.

Summary

Managing code reuse and dependencies in LLM projects means organizing how different parts of code and libraries are shared and connected within large language model workflows. This ensures that projects run smoothly, stay maintainable, and avoid problems caused by tangled or unnecessary dependencies.

  • Streamline dependencies: Regularly check and remove unnecessary packages, and only add new libraries when there’s a clear need to keep your project stable and easy to manage.
  • Modularize your code: Break your code into smaller, focused pieces so each part does one thing, making it easier for both humans and LLMs to understand and reuse.
  • Document and clarify: Keep clear documentation and use descriptive names so anyone—or any coding assistant—can trace how features, libraries, and APIs connect within your project.
Summarized by AI based on LinkedIn member posts
  • View profile for Brij Kishore Pandey
    Brij Kishore Pandey Brij Kishore Pandey is an Influencer

    AI Architect & AI Engineer | Building Agentic Systems & Scalable AI Solutions

    727,414 followers

    What if your LLM could reuse work and respond 5-10× faster? That’s exactly what LMCache delivers. What is LMCache? It’s the open-source “KV cache layer” for LLMs — designed to store and reuse key/value caches across queries, sessions and even engines. Built for high-volume, long-context systems. Evaluations show up to 15× throughput improvements when paired with engines like vLLM. Why This Matters Right Now Latency kills UX. Every extra millisecond waits hit adoption. LMCache slashes response time by re-using caches. GPU cycles cost money. Re-computation means wasted resources. LMCache allows reuse across workloads, reducing GPU load. Context & multi-round workflows are exploding. RAG systems, agent pipelines, conversational contexts — LMCache fits them all. It’s production-ready and open-source. No black-box: you can inspect, integrate, extend. Typical Use Cases: -Agentic systems that make multi-turn decisions -RAG pipelines that reuse retrievalable contexts -Long-form applications (document processing + summarization) -Multi-engine inference clusters / cloud-scale deployments Plug into your engine and enable KV-cache reuse across queries & threads. If you’re building LLM-based systems for scale, this isn’t one more library — it’s a fundamental architecture upgrade. Mark this: The future of LLM inference isn’t just bigger models — it’s smarter reuse.

  • View profile for Mayank A.

    Follow for Your Daily Dose of AI, Software Development & System Design Tips | Exploring AI SaaS - Tinkering, Testing, Learning | Everything I write reflects my personal thoughts and has nothing to do with my employer. 👍

    176,176 followers

    Best Practices for Writing Modular and Reusable Code ➊ Design ➟ Single Responsibility Each module/class/function should do one thing. This is the core of the Single Responsibility Principle (SRP), a pillar of SOLID design. ➟ Loose Coupling Modules should have minimal dependencies. This ensures easier reuse and lower maintenance cost. ➟ High Cohesion Related functionality should be grouped together for better clarity and maintainability. ➋ Structure ➟ Small Functions Functions should do one thing and do it well. This improves readability and testability. ➟ Clear Interfaces Well-defined APIs/interfaces enable easy integration and replacement. ➟ Consistent Naming Using consistent, descriptive names helps other developers understand the code quickly. ➌ Reuse ➟ Libraries Common functionality should be abstracted into libraries/modules. ➟ Generic Code Use parameterization/generics/templates where appropriate to maximize reuse. ➟ Configuration Avoid hardcoding values, use configs for flexibility. ➍ Testing ➟ Unit Tests Essential for verifying small, isolated pieces of code. ➟ Mocking Facilitates testing in isolation, independent of dependencies. ➟ Coverage Strive for high test coverage to ensure reliability. ➎ Documentation ➟ Comments Explain why (not just what) in the code. ➟ Readme Every module/library should have clear usage instructions. ➟ Examples Usage examples are extremely helpful for onboarding and adoption. ➏ Maintainability ➟ Refactor Regularly Tackle technical debt before it grows. ➟ Code Reviews Peer reviews catch issues and spread knowledge. ➟ Follow Standards Consistency (via code style guides and conventions) prevents confusion.

  • View profile for Esco Obong

    Sr SWE @ Airbnb | Follow for LLMs, LeetCode + System Design & Career Growth (ex-Uber)

    40,184 followers

    I work at Airbnb where I use LLMs to add features to huge codebases with custom libraries and APIs. LLMs aren't only for new projects. Here is my workflow: Treat the LLM like a new developer that needs to ramp up on the project 𝟭. 𝗦𝘁𝗮𝗿𝘁 𝘄𝗶𝘁𝗵 𝗮 𝘀𝗽𝗲𝗰𝗶𝗳𝗶𝗰 𝗲𝗻𝘁𝗿𝘆 𝗽𝗼𝗶𝗻𝘁 I ask my coding agent to start at the root directory and read a specific file path related to the feature or area I’m working on. From there, I have it trace the code and its dependencies so it can understand how the system fits together. 𝟮. 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗲 𝗶𝗻𝘁𝗲𝗿𝗻𝗮𝗹 𝗱𝗼𝗰𝘂𝗺𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻 I ask the agent to crawl through the codebase and draft documentation explaining how that feature or area works. It looks at imported libraries, API schemas, shared utilities, common patterns, endpoints, and related functions. Basically, it does what a human engineer would do when ramping up on an unfamiliar part of the codebase without much documentation. 𝟯. 𝗪𝗿𝗶𝘁𝗲 𝘁𝗵𝗲 𝗱𝗼𝗰𝘂𝗺𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻 𝘁𝗼 𝗱𝗶𝘀𝗸 I have the agent save the output into a docs/ folder. This can include written explanations, implementation notes, and Mermaid diagrams that show how components relate to each other. That documentation becomes reusable context for the rest of the task. 𝟰. 𝗥𝗲𝘃𝗶𝘀𝗲 𝘁𝗵𝗲 𝗱𝗼𝗰𝘀 𝗮𝘀 𝗻𝗲𝗲𝗱𝗲𝗱 The first version is rarely perfect, so I review and refine it. Once it’s accurate, I can ask the LLM to read those docs before implementing the feature. From that point on, it has much better context for the codebase. 𝟱. 𝗔𝗱𝗱 𝘁𝗵𝗶𝗿𝗱-𝗽𝗮𝗿𝘁𝘆 𝗹𝗶𝗯𝗿𝗮𝗿𝘆 𝗰𝗼𝗻𝘁𝗲𝘅𝘁 When I’m using an external library, I point the agent to the relevant external documentation pages. Then I ask it to summarize the important methods, APIs, return values, examples, and best practices into another file in the docs/ folder. This helps the agent understand not just our codebase, but also the tools it needs to use correctly. 𝟲. 𝗨𝘀𝗲 𝗰𝗵𝗮𝘁 𝗽𝗿𝗼𝗱𝘂𝗰𝘁𝘀 𝘄𝗵𝗲𝗻 𝗻𝗲𝘁𝘄𝗼𝗿𝗸 𝗮𝗰𝗰𝗲𝘀𝘀 𝗶𝘀 𝗹𝗶𝗺𝗶𝘁𝗲𝗱 If the coding agent doesn’t have network access, I do this step manually with ChatGPT, Gemini, or Claude. I drop in the relevant docs link and ask for a concise summary focused on the APIs and patterns I’ll need. For this kind of deep documentation and codebase-understanding work, I’ve found GPT-5 Pro, Gemini 3 Pro, and Opus 4.7 with extended thinking especially useful.

  • View profile for Martin Ravichandran

    No.1 Branding Expert in Nagercoil & Tamil Nadu | SEO Analyst | Graphic Designer | Video Editor | Content Strategist | Business Analyst | Schema Markup Expert | Helping Brands Grow & Generate Leads

    26,167 followers

    Every new dependency is a future problem waiting to happen , unless you manage it now 👉 Use minimal dependencies Only add libraries when truly necessary. Every new package increases risk, size, and tech debt. 👉 Prefer standard libraries Most modern languages offer powerful built-ins. Using them boosts portability and reduces external complexity. 👉 Audit dependencies regularly Check for outdated, insecure, or bloated packages. Clean up what’s no longer needed. 👉 Avoid large libraries for small tasks Don’t bring in a whole framework to use a single function. Native tools like map, filter, or pandas methods often do the job. 👉 Modularize your code Break projects into small, testable components. Less coupling = fewer hidden dependencies. 👉 Pin versions to ensure stability Lock versions to avoid surprise breaking changes in production or when collaborating. 👉 Clean up unused packages Use pip uninstall or npm prune to remove unused cruft. Less clutter, fewer security holes. 👉 Review each new dependency Ask: Do I really need this? Consider long-term cost in complexity, size, and maintainability. 👉 Automate updates carefully Tools like Dependabot help, but always review and test before merging. Automation ≠ mindless trust.

  • Can we talk about separation of concerns and cognitive load? One thing about LLM coding assistants that's very interesting is how they tend to crap out on code that has poor separation of concerns. Despite some pretty darn big advertised maximum context sizes (e.g., GPT-5 has 400K tokens), the *effective* maximum context size - beyond which accuracy degrades rapidly - is orders of magnitude smaller. Studies have found it to be in the order of 100 - 1000 tokens, even for the hyperscale "frontier" models. Coding assistants like Claude Code and Codex use static dependency analysis to determine what source files need to be added to the context for a particular task. If you ask it to make a change to a 1,000-line source file that has 20 direct dependencies on other source files, that's a *lot* of context. If you ask it to make a change to a 100-line source file with 2 direct dependencies on other files, the context is much smaller. I think of LLM context as being analogous to cognitive load: in order to understand Module A, what else do I need to understand? Higher modularity tends to reduce cognitive load when it's done effectively. If I can understand the contents of Module A, I don't need to understand the contents of any of its dependencies. To reverse an old marketing slogan, each dependency "Says what it does on the tin", so to speak. A useful test of code comprehensibility is to ask people to predict what a method or function will do in a specific test case *without* letting them see the implementations of any other methods or functions it uses. What these dependencies are doing should be obvious from the outside, and the details of how they do it should be irrelevant if that's not going to change. And it turns out that's good advice when working with LLMs, too. Signposting dependencies clearly (e.g., with intent-revealing names and/or type information) helps models pattern-match more accurately - they don't need to "guess". And from experiment I've seen it reduce context size - "cognitive load" - on many occasions, producing fewer "hallucinations" in the output. In languages like C# and Java, we don't get much of a choice over whether we provide type information (though watch out for those implied types!) In dynamically-typed languages, I've found I need to be more careful. If, for example, a dependency name doesn't correspond to its type in my Python code, I'll add a type hint to give the model more to go on. One final thought: LLMs are famously good at generating code they're bad at modifying. I routinely see larger source files with lots of dependencies being spat out by Claude, GPT-5, Llama etc. So you need to keep on top of your modular design. (I see some folks posting that they get the model to review and break modules down once a day. IME, generated code can be tripping the model up before lunch, so I'd recommend refactoring more often than that. Indeed, I recommend refactoring *continuously*.)

Explore categories