Files

3.2 KiB

parent, nav_order, description
parent nav_order description
Usage 25 Tips for AI pair programming with dev.

Tips

Just add the files that need to be changed to the chat

Take a moment and think about which files will need to be changed. Dev can often figure out which files to edit all by itself, but the most efficient approach is for you to add the files to the chat.

Don't add lots of files to the chat

Just add the files you think need to be edited. Too much irrelevant code will distract and confuse the LLM. Dev uses a map of your entire git repo so is usually aware of relevant classes/functions/methods elsewhere in your code base. It's ok to add 1-2 highly relevant files that don't need to be edited, but be selective.

Break your goal down into bite sized steps

Do them one at a time. Adjust the files added to the chat as you go: /drop files that don't need any more changes, /add files that need changes for the next step.

For complex changes, discuss a plan first

Use the /ask command to make a plan with dev. Once you are happy with the approach, just say "go ahead" without the /ask prefix.

If dev gets stuck

  • Use /clear to discard the chat history and make a fresh start.
  • Can you /drop any extra files?
  • Use /ask to discuss a plan before dev starts editing code.
  • Use the /model command to switch to a different model and try again. Switching between GPT-4o and Sonnet will often get past problems.
  • If dev is hopelessly stuck, just code the next step yourself and try having dev code some more after that. Take turns and pair program with dev.

Creating new files

If you want dev to create a new file, add it to the repository first with /add <file>. This way dev knows this file exists and will write to it. Otherwise, dev might write the changes to an existing file. This can happen even if you ask for a new file, as LLMs tend to focus a lot on the existing information in their contexts.

Fixing bugs and errors

If your code is throwing an error, use the /run command to share the error output with the dev. Or just paste the errors into the chat. Let the dev figure out how to fix the bug.

If test are failing, use the /test command to run tests and share the error output with the dev.

Providing docs

LLMs know about a lot of standard tools and libraries, but may get some of the fine details wrong about API versions and function arguments.

You can provide up-to-date documentation in a few ways:

  • Paste doc snippets into the chat.
  • Include a URL to docs in your chat message and dev will scrape and read it. For example: Add a submit button like this https://ui.shadcn.com/docs/components/button.
  • Use the /read command to read doc files into the chat from anywhere on your filesystem.
  • If you have coding conventions or standing instructions you want dev to follow, consider using a conventions file.

Interrupting & inputting

Use Control-C to interrupt dev if it isn't providing a useful response. The partial response remains in the conversation, so you can refer to it when you reply with more information or direction.

{% include multi-line.md %}