Giving an AI chat your whole codebase, and getting the changes back without losing your own
I use the Claude and ChatGPT web chats on my own projects. Sending the code was never the hard part. Copying the AI's edits back, file by file, without breaking something, was. Here's what I learned doing it safely.
I use the Claude and ChatGPT web chats on my own projects. Sending the code was never the hard part. Copying the AI's edits back, file by file, without breaking something, was.
Here's what I learned doing it safely.
1. Send files, not snippets
A model that sees your folder structure guesses less. It finds the files you already have instead of inventing new ones. A ZIP also keeps the paths, so you know where every file in the reply belongs.
2. Leave out the noise
Skip dependencies, build output, caches, lockfiles and media. On one of my Next.js projects that's 37,887 of 37,949 files. The 62 left are what a new teammate would actually read.
3. Never send secrets
That means .env, private keys, .npmrc, cloud credentials and Terraform state. If the model needs to know which settings exist, send the keys with the values blanked:
DATABASE_URL=[REDACTED]
API_KEY=[REDACTED]
4. Ask for a reply you can apply
- Complete files, never "rest unchanged"
- The same paths you sent
- A list of anything moved or deleted
5. Merge three ways, not two
Copying the reply back goes wrong in three ways:
-
Flattened paths: the reply has
page.tsx. Which one? -
Cut-off files:
// ... rest unchangeddeletes half your file. - Your own edits: you fixed a typo while waiting, and the reply overwrites it.
The fix is to compare three versions: what you sent, what's on disk now, and what came back. If only the AI changed a file, write it. If you both changed it in different places, merge. If you both changed the same lines, a human decides. That's a three-way merge, and it only works if you kept a copy of what you sent.
Doing it in one command
I built contextzip to do all of this:
pip install contextzip
cz # zip the right files to your clipboard
cz apply # merge the AI's reply back
It knows 62 stacks, never sends secrets, and keeps a snapshot of every ZIP for the merge. Nothing to install? contextzipcli.com does it in your browser, and your files never leave your machine.
Which stack does it get wrong for you? And how do you get AI edits back into your code today? I'd like to hear in the comments.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.