# Editing Files with Patch Tool

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

- Skill: `tools-only/editing-files-with-patch-tool` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/editing-files-with-patch-tool`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/editing-files-with-patch-tool/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-29
- Page: https://skillmd.com/skills/tools-only/editing-files-with-patch-tool

---


# 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:

```patch example.py
<<<<<<< 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

