Editing Files with Patch Tool

When modifying existing files, use the patch tool to make incremental changes.

tools-only Updated 7 repo stars

File contents

Editing Files with Patch Tool

When modifying existing files, use the patch tool to make incremental changes.

Best Practices

  1. Keep patches focused: Each patch should make one logical change
  2. Preserve context: Include enough surrounding lines for clarity
  3. Avoid placeholders: Don't use comments like // ... rest of code ...
  4. Test after patching: Verify the changes work as expected

Example

To add a new method to a class:

<<<<<<< ORIGINAL
class MyClass:
    def existing_method(self):
        pass
=======
class MyClass:
    def existing_method(self):
        pass

    def new_method(self, arg):
        return arg * 2
>>>>>>> UPDATED

When to Use Patch vs Save

  • Use patch for: Small targeted changes, adding/modifying functions
  • Use save for: New files, complete rewrites, when patch format conflicts with content

tools-only/X-Skills/tree/main/content-creation/1878-patch_f8ca9443 commit 5308208bf8

Frequently asked questions

npx skillmds@latest add tools-only/editing-files-with-patch-tool