Apply ChatGPT and Claude changes to your code
Ask the AI for complete files at their full paths, put them in place on a clean git branch, and read the diff before you keep anything. By hand that works for a few files. Past that, cz apply-zip writes the AI's ZIP into the right folders and merges around edits you made in the meantime.
Apply ChatGPT changes to code by hand
The two things that go wrong are files landing in the wrong place and your own edits being overwritten. Asking for full paths fixes the first. Working on a branch makes the second recoverable.
Then tell the AI how to answer. Most of the pain comes later, when changed files come back as bare names and you have to work out where each one goes. Ask for full paths up front:
For every file you change or create, give the complete file, not a snippet.Put its full path from the project root on the first line,for example: // src/lib/auth.tsKeep the same folder structure. Don't move files to the root.When the reply comes back as a ZIP, commit or stash your work, then unpack it over the project on a new branch:
git switch -c ai-changesunzip -o ~/Downloads/reply.zip -d .git statusgit diffgit switch -c ai-changestar -xf $HOME\Downloads\reply.zipgit statusgit diffIf the reply is text, paste each file over its path by hand. Either way, git diff shows exactly what the AI changed. Then check git status for three problems:
- New files in the project root that belong in a subfolder: the AI flattened the paths. Move them.
- A whole folder wrapped in an extra top-level folder, like
my-app-fixed/. Move its contents up. - Files that shrank to a few lines with
// ... rest unchanged. Restore them withgit restoreand copy in only the changed part.
Unzipping overwrites
unzip -o and tar -xf replace files without asking. Anything you changed after sending the code to the AI is lost unless it was committed first.The faster way: contextzip
cz apply-zip runs the checks above on every file, and nothing is written until every file has been matched and compared. It works best on a ZIP that contextzip made, because it keeps a local snapshot of what you sent.
1. Install it once. With Python 3.9 or newer, use pip (pipx and uv work too). Without Python, npm install -g @contextzip/cli, Homebrew or Scoop install the same tool.
pip install contextzip2. Package the project. Run cz from the project root. It detects your stack, leaves out dependencies, build output, caches, binaries and secret files, and puts the ZIP on your clipboard as a real file.
cz3. Paste it into ChatGPT or Claude. Click the message box and press Ctrl+V (⌘V on a Mac). The ZIP attaches like any file you copied in your file manager. It also carries a short CONTEXTZIP.md that tells the AI how to reply: complete files, the same paths, secrets left as [REDACTED].
4. Write the answer back. Ask for the changed files as a ZIP, download it, and point cz apply-zip at it. Or drop it in .contextzip/inbox/ and run cz apply-zip with no arguments.
cz apply-zip ~/Downloads/reply.zipAI replies rarely come back in the shape you sent. A ZIP can arrive wrapped in an extra folder, relative to a subfolder (src/… for frontend/src/…), or flattened to bare file names. apply-zip matches each file to your project by the longest stretch of its path that agrees, and new files follow their siblings. A name that fits several files, like three different page.tsx, is settled by comparing contents. If it's still unclear, you choose. Nothing is written on a guess.
It also compares three versions of every file: what you sent, what's on disk now and what came back. Edits you made in the meantime are merged, not overwritten, and anything that clashes waits for you. How apply-zip works
~/projects/my-app
$ contextzip apply-zip
✓ Resolved · .contextzip/inbox/fix.zip
✓ Compared with snapshot #14 (k3f9a2) · named in the reply's CONTEXTZIP.md
Paths in the zip were remapped: my-app-fixed/… → …
✓ Classified 6 files · 1 modified, 1 merged, 1 new, 1 unchanged
! 1 conflict, 1 partial — needs your call
| When the AI… | apply-zip |
|---|---|
| changed a file you didn't touch | writes it |
| changed a file you also changed, in different places | merges both |
| changed the same lines you did | marks a conflict for you to resolve |
| returned a cut-down file | marks it partial, writes nothing |
| moved or renamed a file | writes the new path, keeps the old file unless you say otherwise |
Preview with cz apply-zip --dry-run. Decide on conflicts side by side with --review, or in VS Code's merge editor with --editor. Line endings never count as a change, and redacted secrets are never written over your real values. All options
FAQ
- Can ChatGPT or Claude edit files in my project directly?
- Not from the web chat. The chat works on the copies you upload and hands back files to download. Getting them into your project is up to you, which is the step cz apply-zip does.
- What if the AI puts every file in the root of the ZIP?
- Unzipping it by hand drops them all in your project root. cz apply-zip matches each file to its real place by the longest part of its path that agrees, settles duplicate names like page.tsx by comparing contents, and asks you when it still can't tell.
- What if I changed the same file after sending it?
- apply-zip compares what you sent, what's on disk now and what came back. Changes in different places are merged. Changes to the same or neighbouring lines are a conflict, which waits for you to resolve in your browser or in VS Code.
- What if the AI returns only part of a file?
- A cut-down file with a line like "// ... rest unchanged" is marked partial and isn't written unless you say so, so it can't wipe out the rest of your file.
- Will apply-zip delete files?
- Only with your explicit OK. A moved file's old copy, or a file the AI asked to delete, is removed only when you say yes, never by --yes alone, and never if you've changed it since.