Icon
Icon

Blog Details

AI Programming Assistants: Common Pitfalls and How to Avoid Them

July 10, 2025

By

Everawe Labs

"It wrote the code, passed the compilation, and ran smoothly, until we discovered it had quietly stored all users' plaintext passwords in the database..." — A programmer's blood and tears lament.


If you're enjoying the "vibe coding" joy, watching AI programming assistants like Kiro, Cursor, or Claude Code spit out whole blocks of code like magic, you might not realize that your AI teammate might be "digging a hole" for you. In the world of programming, AI programming assistants have quietly become our "coding buddies." These intelligent tools greatly enhance our productivity by providing autocomplete, code suggestions, or even generating entire blocks of code. However, these AI assistants can sometimes seem like they've been possessed by a demon—generating code that drives us crazy, full of errors, and unusable in production environments.

Large sinkhole in a city street surrounded by orange safety barriers and a prominent 'Danger' warning sign, with tall buildings in the background, representing the hidden pitfalls and potential dangers that can emerge unexpectedly in AI programming projects despite warning systems and safety measures
Large sinkhole in a city street surrounded by orange safety barriers and a prominent 'Danger' warning sign, with tall buildings in the background, representing the hidden pitfalls and potential dangers that can emerge unexpectedly in AI programming projects despite warning systems and safety measures
Large sinkhole in a city street surrounded by orange safety barriers and a prominent 'Danger' warning sign, with tall buildings in the background, representing the hidden pitfalls and potential dangers that can emerge unexpectedly in AI programming projects despite warning systems and safety measures

Here are some examples of AI programming assistants "falling flat":

Case 1: A programmer asked the AI assistant to generate a regular expression for "validating complex passwords." The AI quickly output:
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$.
Looks perfect, right? Until the security team screamed: the AI didn't set a maximum password length (like 64 characters), which could lead to database storage errors or performance issues.

Case 2: A programmer used the AI programming assistant to generate AWS S3 file upload code. The AI confidently recommended:
boto3.client('s3').upload_file(Bucket="My-Bucket", Key="file.txt", Body=data)
But the code kept throwing an error: ClientError: Bucket name must follow DNS rules!
The cause was simple. The bucket name cannot contain uppercase letters, as per AWS's rules.

Case 3: A request was made for the AI to generate a Python program to parse JSON data and extract specific fields. The AI provided a solution that successfully read the JSON, but it used the eval() function to parse the data. The eval() function in Python is a dangerous function that can execute arbitrary strings and poses significant security risks. The developer only realized this after reviewing the code and made necessary changes.

There are many more such examples, big and small. These examples remind me that while AI programming assistants generate code quickly and efficiently, they can also make small mistakes, especially when lacking context. Therefore, when using AI tools, we need to establish strict rules to ensure the quality of generated code. Here, I recommend a core principle: AI-generated code should be treated with caution, especially when it involves security or core logic, and it must undergo rigorous review!

Rulebook:

1. No vague names.
Let’s start with the basics—naming. Good naming allows others to understand the purpose of the code at a glance. For example, variable names like ‘data’, ‘temp’, or ‘thing’ are too vague and should be avoided. Whether it’s an AI-generated function name, variable name, or class name, they should all follow the team’s style guide, including indentation, naming conventions, and so on.

2. Keep the code clean.
Good code is like a clean desk—neat, organized, and modular. AI-generated code may attempt to handle multiple tasks at once, but this is not best practice. Each function or module should fulfill a single responsibility, following the Single Responsibility Principle (SRP). Suppose you ask the AI to write an API interface for handling user information, and it does not only the user authentication but also performs database queries, logging, and more. Upon review, you’ll realize it violates the modularity principle. You can break this code into several functions: one for authentication, one for database operations, and one for logging.

3. Don’t overlook potential "landmines."
A common issue with AI programming assistants is that they may be lax in exception handling. Sometimes, they might catch all exceptions instead of specific exception types, which could swallow critical errors.

4. Security checks, rigorous testing.
AI might overlook security considerations when generating code, such as SQL injection, XSS attacks, etc. As developers, we need to ensure that every line of code accounts for security. Avoid AI generating core encryption or permission code unless using validated models with expert review, as AI might neglect the latest encryption standards (e.g., using deprecated MD5 algorithms). Furthermore, complex AI-generated code should be publicly available for review. No black-box code.

5. Make the code more maintainable.
AI-generated code often lacks adequate testing and documentation. Code without documentation is like a maze without a guide; it’s hard for others (or even your future self) to understand. Testing and documentation are both essential for improving code readability.

6. Review, Review, Review
All AI-generated code must be manually reviewed line by line. Key logic should undergo cross-review by two developers.

———

Final Thoughts:

The secret to human-AI collaboration is: “The best programmer is not the one who doesn’t use AI, but the one who knows when AI is full of nonsense.” Treat AI like that talented but careless assistant: it can deliver results in 10 minutes, but might also burn down the entire building. And you—the designer who holds the rules—are the one who decides whether the world burns or not.

As long as we give it the right framework and rules, it will become our “secret weapon” on the development road, helping us move toward a more efficient, secure, and maintainable code world. And you, are you ready to code with AI?

Fast Take

AI programming assistants can boost productivity, but they may also come with hidden risks. Discover common "pitfalls" to avoid and ensure your AI-generated code is safe and reliable. Want to learn how to keep your projects on track? Keep reading!

Share Now
Facebook
Twitter
Linkdin