I've found the best way to pair program with ChatGPT is with GPT4 API through a VSCode extension by @jakear [1] that uses the Notebook interface. Instead of setting a language for each cell, you set roles like "system", "user", or "assistant" and when you run a cell it sends the cells as chat messages.<p>A huge benefit of this format is that you can delete cells, edit the responses from GPT4 to incorporate changes from future queries, and even rearrange or add mock assistant messages to prime the conversation. As ChatGPT suggests changes, I incorporate them into the main code cells and replace the old queries/feedback with new queries feedback. Since the old changes are incorporated into the parent cells, it loses track a lot less and I can also touch it up to use the right file paths, APIs, etc when it messes up.<p>You can go a step further and monitor the llm file with inotify and extract assistant messages, infer the file path from the responses, and automatically write them to file as you update the notebook. That eliminates the back and forth copy pasting.<p>It'd be nice to extend that interface to include Jupyter notebook cells so we can use ChatGPT to generate notebook cells that can be parsed and executed in the interface directly.<p>Edit to add another tip: I use a variation of the below system prompt for working on larger sessions. Each user message begins with a file path and contains a code block with the contents of the file. After each user message containing a file, I manually add an assistant message that just says "continue", which allows adding several files at different paths. The last user message, the one I actually execute, contains the <request> tokens and the description of the modifications I want in the code. I incorporate the suggested changes into the messages then rinse and repeat. Prompt (sadly I forgot to record where I found it):<p><pre><code> You are a Rust AI programming assistant. The user will send you the relevant code over several requests. Please reply "continue" until you receive a message from the user starting with the tokens "<request>". Upon receiving a message from the user starting with the tokens "<request>" please carry out the request with reference to the code that the user previously sent. Assume the user is a senior software engineer who needs minimal instruction. Limit your commentary as much as possible. Under ideal circumstances, your response should just be code with no commentary. In some cases, commentary may be necessary: for example, to correct a faulty assumption of the user or to indicate into which file the code should be placed.
</code></pre>
[1] <a href="https://news.ycombinator.com/item?id=35605159" rel="nofollow">https://news.ycombinator.com/item?id=35605159</a>