What if the chat with my AI assistant is too long?

Yazmin T. Montana
3 min readJul 24, 2024

--

You may have started using an AI assistant like Claude or ChatGPT to help you manage the entire codebase for your projects.

As you’re aware, context windows can grow too large, causing AI assistants to potentially hallucinate or lose track of your coding progress and project goals. In the following steps, I will provide you with some tips on what to do if your AI assistant loses sight of your project’s objectives, begins giving repetitive answers, or simply forgets what you’re working on. These techniques will help you reorient the AI and maintain productive collaboration throughout your development process.

Tips and tricks:

  • Honestly… There isn’t really a great way. While there’s no perfect solution, one approach is to create a script that concatenates all your project files into a single document. However, it’s important to note that a fundamental aspect of managing large-scale projects is the art of decomposition — breaking down complex problems into smaller, more manageable components. This practice not only aids in organization but also facilitates easier collaboration with AI assistants by allowing you to focus on specific parts of your project at a time.
  • This is not a solved problem. devin and other platforms are working on solving the problem of too large context windows for codebases. Until today, Claude is great for prototyping small apps, but struggles past that.
  • If you’re in Visual Studio Code, then Cody AI works great for this.
  • Create a Python script that combines all your code files in a specific folder, adding the filename (e.g., Credentials.php) at the beginning of each line. Then include the code, followed by a separator line like ‘ — — — ,’ and so on. When you combine your projects, you can upload the text to Claude providing a structured prompt and specify what you need. It works and will remember everything in your project. The downside of doing this is that it keeps getting bigger and bigger unless you provide specific files and the database structure. You need to know how to read and understand code to manage this effectively.
  • Use a project file flattener: Place it in API console(workbench) and not the chat. Github link to the tool: https://github.com/colestriler/flatfile
  • If your context window gets too long you will need a RAG setup. If your code is well structured then you could put each function as a document into a vector database.
  • Write a script that takes all of your files and puts them in a single .txt document with delineations to tell which file is which, then upload it to your next chat. You should just make sure to not get many config files that would get pulled in as well. Paste the following code into your terminal:
bashCopy codeoutput_file="repository_contents.txt"
> $output_filefiles_to_include=(
"http://main.py"
"http://app.py"
"config.yaml"
"requirements.txt"
"http://README.md"
)
for file in "${files_to_include[@]}"; do
if [ -f "$file" ]; then
echo "File: $file" >> $output_file
cat "$file" >> $output_file
echo -e "\n\n==================================================\n\n" >> $output_file
else
echo "File not found: $file" >> $output_file
fi
done
echo "Contents written to $output_file"

Then:

  1. Modify the files_to_include list to specify the files you need to incorporate.
  2. Execute the script by copying the code into your terminal and pressing Enter.
  3. Verify the output: A file named repository_contents.txt will be generated in your current directory.
  4. You can then share the repository_contents.txt file with Claude in a single step, providing a comprehensive overview of your project’s contents.
  • You can join the waitlist for beluga an AI coding navigator for “non-coders”.
  • Use Cursor: Cursor’s Cmd-K lets you write code using instructions. Update entire classes or functions with a simple prompt, and Cursor’s Copilot++ lets you breeze through changes by predicting your next edit.

Happy coding!

--

--

Yazmin T. Montana

Industrial and Systems Engineer, MS Artificial Intelligence '25, Lean Six Sigma background. Elevating Machines, Engineering, and Thought: My Journey.