Taro Logo
1

Using AI to increase codebase understanding

Profile picture
Staff Software Engineer [L6] at Google2 days ago

Hi, I am wondering if you have best practices on using Cursor or github copilot to investigate codes / bugs / and ramp up on a certain process.

I have been learning codebase by making and breaking things to understand. But I was wondering if there are better practices using AI to do all these triages / investigations.

Thank you

29
2

Discussion

(2 comments)
  • 2
    Profile picture
    a day ago

    AI is getting increasingly good at understanding codebases now thanks to large context windows. Here are my suggestions:

    1. Do you have MAX mode enabled? this is crucial for large codebases because it uses large context windows. but is more expensive
    2. use reasoning models. This is a must. (gemini 2.5 pro, claude thinking, chatGPT o3). I prefer o3 the most
    3. Use agent mode. This lets the model recursively investigate by running queries, looking at the outputs, and running more queries
    4. Keep resetting the chat. You're better of doing a hard restart instead of keeping on correcting cursor for the 10th time. If it doesnt work once, improve your prompt and do a hard restart
    5. Context is incredibly important. Make sure to spend enough time doing a clear write up on what you know, what you need. What the bug is. What the ideal state should be. Make sure to use @PullRequest to tag the correct branch/PR that did not have the bug. The model cannot read minds and talk to it like its your coworker. I like to use chatGPT's voice dictate mode and brain dump everything in a 5 minute yap session. Itconverts my yap to text. I edit it and then add in any examples that cant be dictated
    6. Before you code, you need to spend enough time priming the chat window with enough context about the problem and codebase. Almost like generating a PRD
    7. Use @Web to let cursor search docs
    8. I'm also fundamentally shifting how I generate docs. I try to make ensure docs I write are searchable by LLMs by making sure if something important is in an image, theres keywords to ensure it can be searched by text

    https://docs.cursor.com/context/@-symbols/@-git

    https://docs.cursor.com/guides/working-with-context (this is gold)

    https://x.com/gdb/status/1878489681702310392 (how to write a prompt)

  • 1
    Profile picture
    Tech Lead @ Robinhood, Meta, Course Hero
    21 hours ago

    Sai gave a bunch of really great tactical advice. Mine is more high-level:

    1. Feed it small pieces - Like humans, I have found that AI is better when the problem space is smaller and more focused. If there's a large component I don't understand, I'll run it by the LLM piece-by-piece, incrementally going over the entire component.
    2. Share your understanding and find the delta - Always try to figure things out yourself first. When asking the LLM to explain the code, tell it what your explanation is and instruct it to call you out where you're wrong. Again, this is similar to interacting with a human engineer mentor. One of the easiest ways to learn what's right is to say something wrong and get corrected.

    Here's another good thread: "How to optimally use GenAI to leverage my coding prowess and become a better software engineer?"