generating-patcheslisted
Install: claude install-skill oaustegard/claude-skills
# Generating Patches
Generate portable git patch files from codebase modifications, enabling users to apply Claude's edits to their local repositories.
## When to Use
Activate after modifying files in an uploaded codebase when the user needs to transfer changes back to their local environment. Typical workflow: user uploads zip → Claude edits files → this skill exports changes as a patch.
## Prerequisites
Verify git is available and the working directory is a git repository (or can be initialized as one):
```bash
git status 2>/dev/null || git init
```
If working with an uploaded codebase that lacks git history, initialize and create a baseline commit before making edits:
```bash
git init
git add -A
git commit -m "Baseline: original uploaded state"
```
## Generating the Patch
After completing edits, generate a unified diff:
```bash
# For uncommitted changes (working tree modifications)
git diff > /mnt/user-data/outputs/changes.patch
# If changes are staged but not committed
git diff --cached > /mnt/user-data/outputs/changes.patch
# For both staged and unstaged
git diff HEAD > /mnt/user-data/outputs/changes.patch
```
For committed changes (preserves commit messages and metadata):
```bash
# All commits since baseline
git format-patch --stdout baseline..HEAD > /mnt/user-data/outputs/changes.patch
# Or specify number of commits
git format-patch --stdout -n 3 > /mnt/user-data/outputs/changes.patch
```
## Handling Edge Cases
**Binary files**: Git diff excludes bina