Welcome to the Deep Medicine Digest! My name is Dr. Robert Toth and I run Theta Tech AI, a healthcare AI consulting firm.
Has someone forwarded this article to you? Click here to subscribe to this newsletter for free and get AI content sent directly to your inbox:
What is Cursor and why you need to be using it today
With the recent advent of large language models (“LLM’s”) like OpenAI’s ChatGPT, Anthropic’s Claude, Google’s Gemini, or Meta’s Llama, more and more people are using them to write code. Both novices and experienced developers alike are often asking the LLM’s what they want instead of typing the code themselves. That’s what “coding in English” is all about.
But when it comes to using these new AI code generation tools most efficiently, copy and pasting from a web browser is not the way. There’s far too much friction.
Enter Cursor.
The first day I tried it circa August 2023, I knew I would never go back to coding by hand. It’s a fork of the popular VSCode software, but modified to be AI-first. Everything about the user experience is optimized for ease of using regarding using LLM to generate code. From seamless and intelligent tab completions across different lines of code, to inline editing, to prioritizing which chunks of code will provide the best context, to a full chat interface, coding with Cursor accelerates development.
It may feel awkward at first, but like any new skill it takes practice. In my healthcare AI business, all our coders are encouraged to use Cursor.
Inline Editing: Ctrl+K / Cmd+K
The Ctrl+K editor tool is your bread and butter for daily coding work. A coder highlights a few lines of text, or even a whole file, and asks the LLM to fix, add, remove, modify, or modularize that code block. You can also choose your LLM backend (right now, 2024-10-08, we like Claude-3.5-Sonnet best).
We at Theta Tech use Ctrl+K all the time to generate boilerplate code, make edits to a function, or in constructing IAC backend architecture yaml code for instance.
And by regularly using Ctrl+K to write our code in English, we collectively get more skilled at prompt engineering. From conscious competence to unconscious competence, we are Cursor whisperers, subtly directing the LLM’s to generate the code we want.
Our basic infrastructure gets spun up faster, our clients’ applications get features developed more rapidly, and bugs are squashed quicker, than ever before.
In this screenshot, I highlight a function and ask Cursor to modularize it:
Afterwards, it shows the diff (red means code was deleted, green means added) and ask if you want to provide follow-up instructions or accept the change.
With the inline editor, coding is no more about typing lines of code yourself (no matter how tempted you may be) and instead using the editor to generate boilerplate code and then modify that code repeatedly, in a granular manner.
This experience provides its own unique flow state.
Chat with Your Code: Ctrl+L / Cmd+L
While Cursor’s inline editor is used for actively generating code, sometimes engineers are analyzing code, brainstorming ways to improve the code, exploring various new libraries to use to make their lives easier, or trying to understand an elusive bug.
For these situations, Cursor’s chat window provides a web-like interface for, well, chatting with your code. By pressing Ctrl+Enter / Cmd+Enter, instead of just Enter, every single file of code is included as context in your query. Cursor has an intelligent RAG (“Retrieval-Augmented Generate”) system which only plucks out the blocks of code needed to directly answer your question.
If you look at this screenshot here, after the prompt is submitted, Cursor comes up with a few different search queries, looks at all the files in the code base, plucks out relevant chunks of code, and then answers the question.
It also contains buttons to “Apply” the suggested changes in your code directly from the chat window.
Moreover, if you type the “@” symbol in the chat window, you can include online documentation, blog posts, web pages, outside files, or specific pieces of code in your repository to prioritize as context. If properly utilized, a coder is always getting their coding prompts answered with the most up-to-date information from the online documentation, regardless of the cutoff date of the underlying LLM backbone. Using @ to pull in online information is a powerful feature that is criminally underused.
Using Composer to Edit Multiple Files Simultaneously: Ctrl+I / Cmd+I
Cursor’s latest feature, this power-tool lets you edit several files at once. First, you select which files to edit as a group and then ask your queries in a chat-like interface.
It will then edit all (or a subset) of the files you selected in its chat window.
You can look at the diffs, save the files and run the code, and then choose whether to accept or reject the suggested changes. Or you can continue the chat with a followup query.
Afterwards, subsequent queries in the composer chat window can include additional files if you want, or you can remove files that are no longer needed. In this way, you are simply directing the LLM’s to build your app all at once. It can consider both frontend and backend in one prompt, it can edit both your architecture and endpoints, or it can use information from a readme file or other scripts when editing some files. Finally, you can organize your Composer contexts into different projects, to reuse the same context in sets of edits.
Conclusion: Mastering The AI Tools
Think of learning any new AI tool, Cursor included, like learning a new musical instrument. It may feel uncomfortable at first (“But I can just type the for loop myself!”) or even unnecessary (“I know how to spin up an API endpoint, using AI for that is overkill!”). Yet it’s about becoming a better craftsperson; it’s about mastering a new tool. Go slowly, do it properly, and learn every subtle usage pattern and power tool component.
Because really, it’s about getting your code produced in minutes not hours.
This is a new AI driven world, and those who fall behind get left behind.