← Latest papers
🤖 AI

LLM Code Smells: A Taxonomy and Detection Approach

This paper presents a refined taxonomy of nine LLM code smells and introduces SpecDetect4LLM, a static analysis tool that demonstrates high precision and recall in detecting these integration issues across 73.5% of 692 analyzed open-source projects.

Original authors: Zacharie Chenail-Larcher, Brahim Mahmoudi, Naouel Moha, Quentin Stiévenart, Florent Avellaneda

Published 2026-05-25
📖 5 min read🧠 Deep dive

Original authors: Zacharie Chenail-Larcher, Brahim Mahmoudi, Naouel Moha, Quentin Stiévenart, Florent Avellaneda

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are building a house, but instead of hiring a human architect, you are hiring a super-smart, incredibly fast, but slightly unpredictable robot to help you design rooms and pick furniture. This robot is a Large Language Model (LLM). It's amazing, but if you don't give it clear instructions or check its work, it might build a door where a window should be, or use materials that fall apart in the rain.

This paper is about the "bad habits" (or "code smells") that happen when human developers try to use these robots inside their software. The researchers found that just like a messy kitchen can lead to burnt food, messy code when talking to an AI can lead to software that crashes, costs too much money, or gives wrong answers.

Here is a breakdown of their findings using simple analogies:

1. The Problem: "The Robot's Bad Habits"

The researchers identified 9 specific bad habits developers make when talking to these AI robots. They grouped them into three categories, like sorting tools into a toolbox:

  • The "Structural" Habits (How you ask the question):

    • Analogy: Imagine asking a chef, "Make me dinner," without telling them if you want vegetarian, spicy, or if you have a nut allergy.
    • The Smell: No System Message. Developers often forget to give the AI a "job description" (a system message) telling it who it is supposed to be (e.g., "You are a helpful math tutor"). Without this, the robot acts like a generic chatty bot instead of a specialist.
    • The Smell: Anonymous Calls. Imagine calling a restaurant but not giving your name. If the food is bad, the restaurant doesn't know who to call back. Developers often forget to attach a "user ID" to the AI request, making it impossible to track who caused a problem later.
  • The "Data" Habits (What you send and get back):

    • Analogy: Asking a robot to sort your mail, but sending it a giant, unopened box of junk mail instead of just the letters.
    • The Smell: No Structured Output. You ask the AI for a list of ingredients in a specific format (like a JSON list), but you don't force it to follow that format. It might give you a paragraph of text instead. Your software then tries to read that paragraph as a list and crashes.
    • The Smell: Raw Vision Payload. If you ask the AI to look at a photo of a bug in your code, sending the entire 4K screenshot of your monitor is wasteful. It's like mailing a whole library to ask about one book. You should crop the image to just the bug first.
  • The "Protocol" Habits (The rules of the game):

    • Analogy: Driving a car without setting a speed limit or checking which model of car you are driving, assuming it will always be the same.
    • The Smell: No Model Version Pinning. You tell the robot, "Use the 'GPT-4' model." But the company might update "GPT-4" tomorrow to be a different robot entirely. Your code breaks because the robot changed its personality. You need to pin it to a specific version (like "GPT-4 from November 2024").
    • The Smell: Unbounded Max Metrics. You ask the robot to write a story, but you don't tell it to stop after 500 words. It might keep writing forever, eating up all your money and time.
    • The Smell: Temperature Not Set. This controls how "creative" or "random" the robot is. If you don't set it, the robot uses a default setting that might change tomorrow, making your software act differently on different days.

2. The Solution: The "Sniffer Dog" (SpecDetect4LLM)

The researchers built a tool called SpecDetect4LLM. Think of this as a sniffer dog that walks through your code.

  • It doesn't run the code; it just looks at the instructions (the "static analysis").
  • It sniffs around to see if you made any of those 9 bad habits.
  • If it finds a bad habit, it barks (flags it) so the developer can fix it before the software goes live.

3. The Results: How Good is the Dog?

The researchers tested this sniffer dog on 692 different software projects (over 171,000 files of code). Here is what they found:

  • How often do these bad habits happen?

    • 73.5% of the projects had at least one of these bad habits. It's like walking into a house and finding that 3 out of 4 have a leaky faucet. It's very common.
    • The most common bad habit was not pinning the model version (using a generic name instead of a specific one).
  • How good is the sniffer dog at finding them?

    • Precision (Accuracy): When the dog barks, it is right 91.3% of the time. It rarely cries wolf.
    • Recall (Completeness): The dog finds about 71.8% of the actual bad habits. It misses some, but it catches the majority.

4. Why Does This Matter?

The paper argues that while these bad habits don't always cause the software to crash immediately, they are like rust on a car.

  • They make the car harder to fix later (Maintainability).
  • They make the car run slower or cost more gas (Performance).
  • They make the car behave unpredictably on rainy days (Reliability).
  • They make the car unsafe if the road conditions change (Robustness).

Summary

The researchers created a "menu" of 9 common mistakes developers make when using AI, built a tool to automatically find these mistakes, and proved that these mistakes are everywhere in the software world. Their tool is very good at spotting them, helping developers build software that is safer, cheaper, and more reliable when it uses AI.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →