From Laziness to git2prompt: The tool I built just to stop Copy-Pasting Files into ChatGPT
If you've ever groaned at the thought of copying multiple files into ChatGPT just to ask a question — this story is for you. This is how one minor annoyance became a real-world tool.
Just Another Day in Dev Life
I was debugging what seemed like a simple logic bug. But as always, it unraveled into a web of components: a custom hook, a utility function, a config file, and a suspiciously vague type definition.
I opened a new ChatGPT tab to ask what’s wrong.
Then came the part I hate most: hunting down and copying files.
First useFetch.ts
, then api.ts
, then types.ts
, then config.ts
. By the fourth file, I paused and thought:
"Why am I doing what a script could do better?"
It Wasn’t a Code Problem — It Was a Context Problem
Working with AI tools like ChatGPT or Claude is incredibly effective — only if you give them the right context.
And the painful truth is: these models can’t access your codebase. Everything depends on what you paste into the chat window.
That’s where the problems begin:
- If you paste just one function, it doesn’t know its dependencies.
- If you forget to paste a
type
, the model's output derails. - If you don’t format markdown properly, syntax parsing goes wrong.
And worst of all — if you send multiple files across multiple turns, ChatGPT eventually forgets the earlier ones.
Your context is gone. Your answer? Probably wrong.
The Idea Hit Me
I stared at my terminal and thought: "What if I could just point to a folder, and the AI magically understands everything inside?"
That led to this imaginary command:
npx @nolanx/git2prompt <repoPath> [options]
What I wanted was simple:
- Read each file
- Detect the file type (
.ts
,.json
,.md
, etc.) - Format it in markdown
- Print everything into one clean, copy-pastable block
I didn’t need to send code to any server. I just needed a way to quickly gather and format context — once.
So I Built It (In One Night)
No framework. No fancy UI. Just a tiny Node.js script.
- I used
globby
to gather paths fs.promises.readFile
to read file contents- Guessed language mode from file extension
- Printed everything in markdown format
I called it git2prompt
— originally I thought about using git diff
, but even simple folders worked well.
First time I ran:
npx @nolanx/git2prompt /path/to/repo -o output.md
I smiled.
Because I had just saved myself 10 minutes — not just today, but every time I needed AI help in the future.
Reuse Was the Real Win
I didn’t build this for other people. I built it for me — to use again and again.
After a few days, I noticed something powerful:
- I could paste full context into a single AI thread
- Ask 5–7 different questions — and the model still remembered all dependencies
- When a teammate asked me about a bug, I just forwarded the same markdown
It wasn’t just a time-saver — it made my conversations with AI more accurate and helped my team move faster.
What I Learned from One Evening of Tooling
-
Laziness is a creative superpower
If you’re repeating something annoying, chances are there’s a script waiting to be born. -
Small tools make a big difference
You don’t need to wait for a “big idea” — something that saves you 5 minutes every day is already worth it. -
Build for yourself first
If a tool makes your life easier, you’ll maintain it. Others using it? That’s a bonus.
A Few Important Notes
-
✅ Only use this tool on small folders or tiny projects (under ~30 files)
Don’t dump your entire codebase into ChatGPT — it’s inefficient and a potential security risk. -
Don’t use it on sensitive code (secrets, tokens, user data, internal IPs)
Even though the tool just reads local files, it’s your responsibility to review what you share. -
Requires a Git repository
git2prompt
uses.gitignore
to avoid including unnecessary files (likenode_modules
,dist/
, etc.)
Final Thoughts
The code snippets above are illustrative examples to help you understand the approach.
You can explore and clone the real tool here:
github.com/dongnguyenvie/git2prompt