davepoon/buildwithclaude/reapply-patches
Claude Code and agent skill by davepoon/buildwithclaude
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Reapply local modifications after a GSD update
Install
npx vskill@latest install davepoon/buildwithclaude/reapply-patchesSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as davepoon/buildwithclaude/reapply-patches.
<purpose> After a GSD update wipes and reinstalls files, this command merges user's previously saved local modifications back into the new version. Uses three-way comparison (pristine baseline, user-modified backup, newly installed version) to reliably distinguish user customizations from version drift.
Critical invariant: Every file in gsd-local-patches/ was backed up because the installer's hash comparison detected it was modified. The workflow must NEVER conclude "no custom content" for any backed-up file — that is a logical contradiction. When in doubt, classify as CONFLICT requiring user review, not SKIP. </purpose>
<process>
Step 1: Detect backed-up patches
Check for local patches directory:
Read backup-meta.json from the patches directory.
If no patches found:
Exit.
Step 2: Determine baseline for three-way comparison
The quality of the merge depends on having a pristine baseline — the original unmodified version of each file from the pre-update GSD release. This enables three-way comparison:
- Pristine baseline (original GSD file before any user edits)
- User's version (backed up in
gsd-local-patches/) - New version (freshly installed after update)
Check for baseline sources in priority order:
Option A: Git history (most reliable)
If the config directory is a git repository:
When HAS_GIT=true, use git log to find the commit where GSD was originally installed (before user edits). For each file, the pristine baseline can be extracted with:
This gives the commit that first added the file (the install commit). Extract the pristine version:
Option B: Pristine snapshot directory
Check if a gsd-pristine/ directory exists alongside gsd-local-patches/:
If it exists, the installer saved pristine copies at install time. Use these as the baseline.
Option C: No baseline available (two-way fallback)
If neither git history nor pristine snapshots are available, fall back to two-way comparison — but with strengthened heuristics (see Step 3).
Step 3: Show patch summary
Step 4: Merge each file
For each file in backup-meta.json:
- Read the backed-up version (user's modified copy from
gsd-local-patches/) - Read the newly installed version (current file after update)
- If available, read the pristine baseline (from git history or
gsd-pristine/)
Three-way merge (when baseline is available)
Compare the three versions to isolate changes:
- User changes = diff(pristine → user's version) — these are the customizations to preserve
- Upstream changes = diff(pristine → new version) — these are version updates to accept
Merge rules:
- Sections changed only by user → apply user's version
- Sections changed only by upstream → accept upstream version
- Sections changed by both → flag as CONFLICT, show both, ask user
- Sections unchanged by either → use new version (identical to all three)
Two-way merge (fallback when no baseline)
When no pristine baseline is available, use these strengthened heuristics:
CRITICAL RULE: Every file in this backup directory was explicitly detected as modified by the installer's SHA-256 hash comparison. "No custom content" is never a valid conclusion.
For each file: a. Read both versions completely b. Identify ALL differences, then classify each as:
- Mechanical drift — path substitutions (e.g.
/Users/xxx/.claude/→$HOME/.claude/), variable additions (${GSD_WS},${AGENT_SKILLS_*}), error handling additions (|| true) - User customization — added steps/sections, removed sections, reordered content, changed behavior, added frontmatter fields, modified instructions
c. If ANY differences remain after filtering out mechanical drift → those are user customizations. Merge them. d. If ALL differences appear to be mechanical drift → still flag as CONFLICT. The installer's hash check already proved this file was modified. Ask the user: "This file appears to only have path/variable differences. Were there intentional customizations?" Do NOT silently skip.
Git-enhanced two-way merge
When the config directory is a git repo but the pristine install commit can't be found, use commit history to identify user changes:
Each matching commit represents an intentional user modification. Use the commit messages and diffs to understand what was changed and why.
- Write merged result to the installed location
Post-merge verification
After writing each merged file, verify that user modifications survived the merge:
- Line-count check: Count lines in the backup and the merged result. If the merged result has fewer lines than the backup minus the expected upstream removals, flag for review.
- Hunk presence check: For each user-added section identified during diff analysis, search the merged output for at least the first significant line (non-blank, non-comment) of each addition. Missing signature lines indicate a dropped hunk.
- Report warnings inline (do not block):
``` ⚠ Potential dropped content in {file_path}:
- Missing hunk near line {N}: "{first_line_preview}..." ({line_count} lines)
- Backup available: {patches_dir}/{file_path}
```
- Produce a Hunk Verification Table — one row per hunk per file. This table is mandatory output and must be produced before Step 5 can proceed. Format:
| file | hunk_id | signature_line | line_count | verified | |
|---|---|---|---|---|---|
| {file_path} | {N} | {first_significant_line} | {count} | yes | |
| {file_path} | {N} | {first_significant_line} | {count} | no |
hunk_id— sequential integer per file (1, 2, 3…)signature_line— first non-blank, non-comment line of the user-added sectionline_count— total lines in the hunkverified—yesif the signature_line is present in the merged output,nootherwise
- Track verification status — add to per-file report:
Merged (verified)vsMerged (⚠ {N} hunks may be missing)
- Report status per file:
Merged— user modifications applied cleanly (show summary of what was preserved)Conflict— user reviewed and chose resolutionIncorporated— user's modification was already adopted upstream (only valid when pristine baseline confirms this)
Never report `Skipped — no custom content`. If a file is in the backup, it has custom content.
Step 5: Hunk Verification Gate
Before proceeding to cleanup, evaluate the Hunk Verification Table produced in Step 4.
If the Hunk Verification Table is absent (Step 4 did not produce it), STOP immediately and report to the user:
If any row in the Hunk Verification Table shows `verified: no`, STOP and report to the user:
Do not proceed to cleanup until the user confirms they have resolved all unverified hunks.
Only when all rows show `verified: yes` (or when all files had zero user-added hunks) may execution continue to Step 6.
Step 6: Cleanup option
Ask user:
- "Keep patch backups for reference?" → preserve
gsd-local-patches/ - "Clean up patch backups?" → remove
gsd-local-patches/directory
Step 7: Report
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/gsd/skills/reapply-patches/SKILL.md
Popularity
- Repository stars
- 3,193
- Repository forks
- 432
- 7-day trend score
- 40
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/davepoon/buildwithclaude/reapply-patches)