Smart AI

This blog specializes in smart usages of Generative AI for professional use.

Cursor AI - The Beginning
Published 4.10.2024 by Christian Gintenreiter
Last updated 10.10.2024
Categories: ai-toolsuse-cases

Cursor AI - The Beginning

I am a big fan of Cursor AI by now and use it for a lot of my coding and even for writing tasks like this article.

How things started off with using Code-Assistants

First I got experience with GitHub Copilot in IntelliJ and was very impressed how good it mimics the coding style and often proposed code I can use immediately. But soon I realized that the automatic proposals while I am writing is not the right interface for me. It often reminded me of a colleague who is randomly talking more or less useful things from the side while I am thinking and typing. So I went on to add comments and then expected from Copilot to get my point and add the code with TAB-Enter-TAB-Enter-...

I found out that I prefer to state my intent and then let the AI propose the code. So i moved on and tried the integration in VSCode and was very happy with the chat-like interface that you could also use there already before it was added to the IntelliJ-Plugin.

Still the tool made me do things I would not naturally do and I therefore was not a 100% happy with it. Also I wanted to enable my colleagues to use it more effectively but I found that if it was hard for me to use it effectively it would be even harder to make them do.

I thought I got now what is possible right now and where the limitations of such Code-Assistants are.

Other Code-Assistants i used from time to time

Aider

Aider is a wonderful command line tool that informs iteself well about the code base it is working in and can propose and apply changes to the code. When I first saw it creating files and running tests after changes it did I was very impressed and wanted more of that.

The command line style of interaction was tricky to get at first. But using markdown files to describe my idea of a whole code baseand smaller ones to describe the changes I want to make was a great help.

Now there is even a Browser-UI for Aider (experimental I think) that adds another take to it. In the end it depends a lot on your personal preferences if you prefer the command line or a chat-like interface.

I also found the aider python-package to be very interesting where you can specify files and a prompt to instruct aider with your change request. This definitely sounds interesting for CI/CD pipelines, automated merge requests and bug-fixing.

ChatGPT, Gemini, Claude, Local OpenSource Models, ...

I will keep this one short as due to the lack of proper integration into the coding workflow I did not investigate a lot in that. Also I wanted to get things done and moving forward and therefore did not spend more time on that topic.

But I collected some challenges to see how these models evolve over time and was impressed how good they got over time. Additional challenges like creating requirements.txt, Dockerfile, ... were hard for 'them' at first (2023) but now are also no problem at all even with one inital prompt.

Then came Cursor AI

Then I stumbled upon Cursor.sh and was very happy to see that all the things I liked from different Code-Assistants were now in one place and practically integrated. First I watched some videos on YouTube how Cursor AI worked and was very impressed that it looked much more fluently integrating into the coding process.

My first attempts with it showed me very quickly that this is a whole new level of fluency and integration. Funnily it was hard to showcase to colleagues because Cursor AI seems to take so much from former changes and apply to the suggestions that made up examples with back and forth changes or show-casing just did not tell the same story than using it in a normal workflow.

Usage example for Aider-Chat or Cursor AI

Create new simple POC for text translation
Existing file for general project information

I added some basic files to the project to give some context about the project and the conventions I want to follow.

CONVENTIONS.md
# Software Engineering Conventions

## Current Conventions for the specific state of this project 
The idea here is to create a Proof of Concept for a simple mini application.

So there is no need for a complex structure.
There is no need for databases and things that might be interesting later when this stays and grows.

pyproject.toml contains "^3.11" as version for python and "*" as version for all dependencies.
IDEA.md
# Voice Correction POC

## Main thoughts

I would like to create a POC based on the following description. I need an HTML page that has two text areas.
In the first text area, the user can type text, and then this text is regularly sent to a backend service, and getting a response that is then put into the second text area. The overall idea is to have a kind of a live text correction, and if the text, for example, is spoken into the first text area by the user's Android voice-to-text feature, I would like to have a corrected version of punctuations and stuff that usually goes wrong in the second text area. And the backend basically takes the text, sends it to an LLM provider service like Google Gemini, and asks it to correct the text, and returns the corrected text via the API to the HTML page.

## Detailed ideas for the POC

Let's start with an extremely simple approach. Please create the HTML page and a very simple Python endpoint. Also provide me with pyproject.tomr with Python 3.11 and all the necessary libraries in the most up-to-date recent versions.
ChatGPT said:
ChatGPT
Great! Here's a simple setup to get you started. Below is the HTML page, a simple Python backend using FastAPI, and a pyproject.toml file to manage the project dependencies.
The task to implement as first step
Create all the necessary files for a first version to try out with mocked
code for LLM provider like Google Gemini for text correction.
File index.html is served under / route.
Kicking things off and see how Cursor AI does it

Handing this over to Aider-Chat or Cursor AI will create the whole files. Ideally it works out of the box. But as these LLMs are none-deterministic it might work on the first attempt or you have to keep iterating.

The nice thing is that the information you added to the context are taken into account on followup requests. So the steps to get to a running first version is not far away as the tools helps you getting there

Here you can see what happens ideally when you use this method to create a first version:

Appendix: Resources