DEV Community

Muhammad Saad Ur Rehman
Muhammad Saad Ur Rehman

Posted on

How I Solved the Biggest Problem with AI Coding Assistants

It was just a simple Python script, but it completely changed my daily workflow. Here's the story of why I built it, how it works, and how you can use it for free.

As a full-stack developer, I use AI assistants like Google Gemini and ChatGPT every single day. They're phenomenal for brainstorming, debugging, and getting a head start on new features. But I had one huge, recurring problem that was draining my productivity: the AI's terrible memory.

Every time I'd start a new chat, the AI had no idea about my project. I'd have to manually copy and paste my route files, my controllers, my models, and my Vue components, one by one, just to get it up to speed. It was a constant, tedious process of re-teaching my "assistant" the basics of the very project it was supposed to be helping me with.

I knew there had to be a better way.

My Old Workflow: The Context-Copying Grind

Before I built my solution, a typical task felt like running on a hamster wheel. Let's say I wanted to add a new feature. My workflow would be:

  1. Open a new chat with the AI.
  2. Describe the feature.
  3. The AI would ask for the relevant code.
  4. I'd switch back to my editor, copy the contents of File A, and paste it into the chat.
  5. Then I'd copy File B. Then File C.
  6. The AI would finally give me some code, but it would be missing a detail from File D, which I had forgotten to provide.
  7. I'd sigh, go find File D, paste it in, and ask the AI to try again.

This wasn't just slow; it was creatively draining. It shattered my focus and turned a coding session into a copy-pasting chore.

I looked at amazing tools like GitHub Copilot Workspace and Cursor, which solve this by deeply integrating into the editor. They're fantastic, but they mostly operate on a paid subscription model. I wanted a free, simple solution that would let me use the powerful free-tier chat tools I already loved.

Since one didn't exist for my specific need, I decided to build it myself.

The Solution: A Simple Python Script I Call "Context-Packer"

The idea was simple: What if, instead of manually copying files, I could run a single command that would intelligently grab all my project's code and pack it into a single, clean text file?

So, I wrote a Python script to do just that. I call it Context-Packer.

It's a straightforward tool. It reads a configuration file where I've defined which folders matter (app, routes, resources/js, etc.) and which should be ignored (node_modules, vendor, .env).

When I run it, it scrapes all the code from the specified locations and bundles it into two neat files: backend.txt and frontend.txt. Each piece of code inside is clearly marked with its file path, like this:

File Name: app/Http/Controllers/MyController.php
[...code from MyController.php...]

My New Workflow: Seamless and Instant Context

Now, my workflow is a dream:

  1. Before I start coding, I run python project_scraper.py in my terminal.
  2. I open backend.txt or frontend.txt and copy the entire content.
  3. I start a new chat with Gemini or ChatGPT and paste it all in with a simple instruction: "This is my project's code. Now, let's get to work."

That's it. The AI instantly has a perfect, complete memory of my entire project. The quality of its responses is ten times better, and my productivity has skyrocketed.

What’s even more exciting is how this approach future-proofs my workflow for AI models with massive 1-million-token context windows. Manually filling such a large window is impossible, but with Context-Packer, I can load my entire project and perform large-scale analysis and refactoring that was previously unimaginable.

How You Can Use It Too

I've open-sourced this script because I know other developers are facing the same frustration. You can set it up on your project in just a few minutes.

Give Your AI a Perfect Memory

This simple tool has genuinely changed my daily coding life. It took a major point of friction and automated it away, letting me focus on what actually matters: building great software.

I encourage you to try it out. The full code is available on my GitHub repository. Give it a star if you find it useful, and let me know how it improves your workflow!

Context Packer GitHub Repository

Top comments (0)