The Smarter Way of Using AI in Programming
avoid the outdated methods of integrating AI into your coding workflow by going beyond ChatGPT
Since ChatGPT’s launch in 2022, developers have split into two camps: those who ban AI in coding and those who embrace it. Many programmers, especially the more seasoned ones, not only don’t use AI-generated code but also prohibit their teams from doing so. Their argument against using AI for programming is understandable, “AI-generated code is unreliable.”
Now even if you don’t approve of this anti-AI-code stance, you must have faced challenges, hurdles, or hiccups when using AI for programming. The key is to find strategies to use AI to your advantage the right way.
Many of us are using a simple, but outdated AI strategy that was only good two years ago. We are cutting a tree down with kitchen knives.
I will begin this article with two major issues when we talk about AI for developers, and I will propose four reliable AI solutions that will separate you from the average programmer when it comes to using LLMs, no matter what kind of developer you are.
Table of Contents
· the wrong way you may be using AI…
∘ you’re not using the right interface
∘ you have unrealistic expectations of AI
· Cursor: AI-first IDE
· Micro Agent: Code + Test Case
· SWE-agent: AI against Github Issues
· AI Commits: git commit -m
· Let’s Connect!
· Further Reads
the wrong way you may be using AI…
… can be divided in two:
you’re not using the right interface
When ChatGPT was released, for months, the mainstream method of working with AI was to go to the website and chat with gpt-3.5
in the browser. The AI scenery was simple.
You wanted ChatGPT to write docstrings and comment on your function?
You would copy that piece of code from your IDE,
give it to ChatGPT, while writing a lazy prompt, like“add comments”,
it would spit back a new code,
then, you would make sure it didn’t make the code faulty,
and if everything was fine, you would paste the new code into your IDE.
Many are still using AI to code the same way. I’m seeing this in students, programmers, and especially beginners. As the AI landscape has changed in the last two years, our methods for using AI have not adjusted. We haven’t caught up to its full potential.
you have unrealistic expectations of AI
The second pitfall of using AI is how we tend to use it. Typically we would ask the LLM to code something, we test if it works, and if it doesn’t, we go back and forth manually to fix the issue. If we’re lucky, we don’t fall into an endless loop of hallucinations when we try to have the LLM understand what’s wrong with the code and it doesn't.
We know it doesn’t work, but for a lack of a better solution, we push and push it. It’s easy to get frustrated this way.
Having said this, I will share four tools that can boost your programming productivity with AI.
Cursor: AI-first IDE
🔎 Best For: Absolutely Everyone
When I was first suggested to use Cursor, I didn’t really know what it was. It was only after some testing that I figured it was a game-changer. Cursor is an AI-first IDE, well… it’s actually VScode, but on steroids.
Cursor allows you to use your chatbot API to use AI as an assistant in writing code. Some of the features that can practically uplift your coding workflow that I love about Cursor:
Ctrl K: the primary feature, allowing you to select multiple lines, and prompt the chatbot about it. You can use this feature to have the LLM write you complete functions from scratch, to add documentation, or to modify parts of the code. It’s slick, easy to use, and it shows you parts of the code that are modified so you get to see the before/after.
Tab: a powerful auto-complete feature that helps you write one line or a full function.
Chat: you can talk with your AI about your full codebase. On top of that, you can provide context by providing documentation files, images, or webpage URLs (Ask the Web feature).
The good thing about Cursor is that it is VScode with extra AI features, meaning, it’s not a whole new IDE that you need to get comfortable with. So if you are already working with VScode, the transition will be effortless.
You can provide your API of the model of your choice, GPT-4
, GPT-4o
, Claude 3.5 Sonnet
, and the built-in free cursor-small
. I have seen many people praise the Cursor + Sonnet 3.5 combo. Claude 3.5 Sonnet is a very smart model in coding, and you can get fantastic results once you plug it into Cursor.
Cursor is a big improvement over copy-pasting code back and forth from the ChatGPT website (honestly, at this point this looks somewhat unprofessional).
Micro Agent: Code + Test Case
🔎 Best For: Reliable Code Generation
When it comes to generating code with AI, every tool is unreliable. As mentioned earlier, LLMs tend to fall into painful loops of hallucination.
Micro Agent is honest and reliable in what it promises. Instead of generating full chunks of code to be tested and reviewed by the user, Micro Agent starts by creating test cases for your prompt. It will then iteratively write code that passes the generated test cases.
The idea is that LLMs are better at generating test cases for a problem than creating code to solve it. I haven’t found much research to support this idea, but it’s trivial that a tested code is more reliable than not, which is what Micro Agent achieves.
If you want to create functions that are not super-complex, but at the same time are tricky to get right, Micro Agent generates code that is more tested and grounded than out-of-the-box LLM output.
Make sure to check out their blog and GitHub page.
SWE-agent: AI against Github Issues
🔎 Best For: GitHub Geeks
On the list of Agentic tools that actually work, sits SWE-agent, developed by the Princeton Language and Intelligence. SWE-agent is specialized in resolving real-world GitHub repository issues and then submitting a pull request for review.
It’s a lifesaver for big repositories, organizations, or even small-scale projects. The reason it works well is the particular tools created by the developers that focus on reviewing codebases, identifying the issue, and then making the necessary changes.
SWE-agent is an open-source project with already 13.1K stars on GitHub.
AI Commits: git commit -m
🔎 Best For: Those Who Commit
If you have a hard time coming up with the right commit messages, you are not alone. There must be a better way to write meaningful commit messages than adding dates or simply including “minor changes”, right?
AI Commits is a simple solution to this problem. It is easy to install and easy to use. Based on your git diff
, aicommits returns an AI-generated commit message. It uses gpt-3.5, which is a great choice as it is cheap and the task is not heavyweight too.
At the end of the day, what matters is that you use tools that help you in productivity and achieving your goal. AI landscape is changing shapes fast, and the right tools change with it as well. If you want to get all the necessary updates on AI and its new technologies, I have written an article on how you could do this for only a few minutes a day.
We cannot get rid of AI hallucinations or its limitations. But we can take measures to mitigate it. Simple, manual interactions with AI, such as using ChatGPT for generating code or comments, can be frustrating and inefficient. By choosing the right tools, you can avoid the common pitfalls and be more confident in your practice.
Thank you for reading through the article! I have tried my best to provide an accurate article, however, please share your opinions and suggestions if you think any modifications are required.
Let’s Connect!
Subscribe for FREE to be notified of new articles! You can also find me on LinkedIn and Twitter.