Aim: Understanding code reuse and divergence in open-source microservice projects is crucial to assessing software evolution and community-driven software development. As repositories are forked and modified, it becomes difficult to trace how much of the original code persists and whether or not these forks create a unique project or retain the same functionality as the original. In this study, we leveraged Large Language Models to identify code clones and analyzed code clone distribution in open-source microservice projects. Method: We used a RAG framework based on LLMs to semantically compare code at the service level. This allowed us to detect not only direct clones, but also functionally equivalent segments that have been refactored. In order to identify a feasible LLM pipeline for analyzing clone types and distribution, we tested three candidate LLMs and four prompt techniques on the IBM CodeNet dataset of Type-4 clones. We then used the best-performing pipeline to identify the code clones in pairs of primary and forked open-source microservices projects. Results: We found the code-specific Codestral-22B LLM with a few-shot continuous prompting technique to be the most accurate in detecting Type-4 code clones, with a precision of 0.74 but a recall of only 0.60. Our analysis of 22 microservice repositories with this technique showed that Type-1 clones are most prevalent, followed by Type-3 clones. Semantic comparison revealed patterns of reuse and divergence not captured by syntax-based tools. Conclusion: Semantic code analysis using LLMs provides deeper understanding of code evolution in forks of microservice projects. Code-specific LLMs significantly outperformed multimodal models but remain unsuitable for production use due to high false negative rates.
No takes yet. Share an insight, caveat, or question.
Kemman et al. (2026) studied this question.
Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context: