54.18 AI Code assistant tips

This article contains code assistant tips and tricks that have helped me write better code. It is currently a direct copy of the suggestions provided by SomeOddCodeGuy, and I will refine it as I progress.

Rules

Keep context low

Tell them another AI (not you) wrote it

Create Workflows

AI is a junior dev

2 is better than 1

Phase 1: Architecture

AI is terrible at architecture, so this is mostly you. You don't have to deep dive down to, say, the inner/helper method level, but at a minimum you want to document the following:

1. About the project

2. Scope

3. Mental model

4. Basic code architecture

During this phase, you can present the answers to #1 and #2 to your AI and ask it for an architectural breakdown but don't just use its answer. This is just to help you overcome mental blocks, give you something to think about, etc.
Write your own architecture. A big reason is that you, above all, need to know this project's structure inside and out. It will be harder for you to keep track of your project if you don't write your own architecture.

Phase 2: The Coding

Below is the workflow I use. I understand that for many people, this will feel like an unnecessary number of steps, but for me, it has resulted in the highest quality that I've found so far and has sped my development up massively, especially when working in a language I'm not intimately familiar with (like Python—I'm a C# dev, lol).

Yes, you can get code from AI far faster than what I'm about to say by simply asking for it and moving on, but the goal for me here is quality, developer understanding of the code, and adherence to the developer's style of coding. I want to write code that is clean, maintainable, and scalable, and other developers at least won't want to set fire to it if they look at it lol

Note: When I send the AI my first coding prompt of a conversation, I almost always include the answer to #1 from Architecture above—the breakdown of requirements for the full project. That context can sometimes help the AI better understand what you're trying to achieve.

Step 1: Pick a feature

Step 2: Present requirements

Step 3: Requirement and Response

Review Prompt

This wasn't written by me, by you, or by anyone with feelings, so no one will be made sad if you rip it to pieces

Step 4: 2nd AI comes to picture

Step 5: Manual code review

Step 6: Restart

While this may seem like it would be exceptionally time-consuming, I can tell you that this workflow has worked amazingly for me in saving both time and energy. I'm usually dead tired at the end of a workday, and I simply don't have the mental energy to write code for another 4 to 5 hours straight. Because of this, I put off personal projects for YEARS. But by doing this, it allows me to get roughly similar quality to my own work when I'm fresh, while pawning off the labor portion of the dev to the AI.

I do the thinking, it does the effort.

I would expect that steps 2, 3 and 4 will take around 5 minutes total. Step 5 will take 10-20 minutes depending on how much code is involved. Another loop will take another 15-25 minutes. So 1 feature will take around 20-60 minutes or so to produce. But the key here is how much mental energy you, as the developer, conserved while still maintaining tight control over the code.

Caution

Also, note that this workflow won't work for EVERYTHING. Context limits can make it simply infeasible to engage the AI in some tasks. Say you've got 6 classes that are all working together on a function, and you realize there's an odd bug that you can't figure out where it is in that workflow. More than likely, you won't find an AI capable of handing that amount of context without degraded quality. In those cases, you're on your own.

Anyhow, I know this is lengthy, but I wanted to share this. This workflow has worked amazingly for me, and I intend to continue refining it as time goes on.

Source

Thoughts 🤔 by Soumendra Kumar Sahoo is licensed under CC BY 4.0