Developers how do you efficiently modify any code using gpt4 or gpt4o?

Hi everyone,

I’ve been using GPT-4 and GPT-4o lately for generating and modifying code, but I often encounter inefficiencies, especially when the model regenerates large sections of code for minor changes.

I’m looking for tips on:

  1. Prompting ChatGPT to make specific changes without rewriting the entire file.
  2. Best practices for iterative development with ChatGPT.
  3. Tools or plugins that enhance code modification efficiency with ChatGPT.
  4. General advice to improve workflow efficiency.

Any suggestions would be greatly appreciated!


1 Like

here’s some thoughts:

  1. specify what exactly it needs to rewrite, and let it know that you can do the code insertion for it, it just needs to tell you where to put it.
  2. generate spec before tests before code
  3. use github copilot
  4. use github copilot, and guide it with comments



I wrote a project refactoring agent called Quanta Agent, based on Langchain and with a Streamlit chat interface.

It uses a feature called Named Blocks for solving this. It lets you identify sections in your code which you can then ask questions about, or ask the AI to even make updates to and it edits those named blocks in your project.

The agent can also directly edit stuff not in any named blocks too if you want.

1 Like

Thank you for your answer but I knew this already :smile:

I was looking more for a specific approach people are using and their experience in general with the above questions.

Thank you Clay! Much appreciated, this is what I was looking for.

I am definitely going to go through your project. Don’t mind me spamming your inbox in the next few days if I have any questions.

Great, I’m happy to answer questions about the project or collaborate to improve the project, or discuss other approaches.

One improvement I think I will make eventually is to use XML Tags in the templates to enclose various chunks of instructions, but the way I have it now does work well afaik.

1 Like

As for tools and plugins for code modification, I can offer two open source solutions.

The Co-Developer GPT engine is a local server + a GPT which you can create in ChatGPT that gives ChatGPT functions to list, search, read and modify files in the directory the local server is started, and run local actions you configure, such as running a build. Thus you can employ it as an interesting mixture of junior and senior developer, read and discuss your code and have it change it by it self, even tell it to run the build and fix things until it works. That has limits, of course, but can be quite helpful and relieves you from copy and pasting code into ChatGPT.

Then I developed AI based code generation pipeline to systematically employ AI code generation in my projects. It’s a command line tool (or alternatively a Java framework) where you give prompt files, input files and an output file on each invocation, and the AI is run to (re-)generate the output file only if a prompt or input file has changed since the last run.

Under the hood: the GPT engine has functions to overwrite a file or do a multi line search and replace in the file. (I experimented with other operations a while ago, but didn’t have much success.) The aigenpipeline has the AI overwrite the output file in one go; if you want to have it incrementially changed the output file is also given as input to the AI (normally the ChatGPT chat completion API) and the AI is instructed to make only minor modifications, which seems to work quite well. I use a conversation pattern I call “put it into the AI’s mouth” that nicely separates data and instructions and seems to work very well.

Best regards,

1 Like

Here’s another high level overview of what other devs have been doing:

1 Like