edit_file

Replace the first occurrence of a string in a file in place.

8|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/OpenAuthority/clawthority --skill edit-file-openauthority
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: edit_file
Source: https://github.com/OpenAuthority/clawthority/tree/main/examples/skills/edit_file
Command: npx skills add https://github.com/OpenAuthority/clawthority --skill edit-file-openauthority

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Replaces the first occurrence of a specified string in a file, enabling precise, in-place edits without manual file manipulation.

Core Features & Use Cases

  • Targeted string replacement in text files to fix a single instance without altering subsequent matches.
  • Supports UTF-8 text and writes changes back to the same path.
  • Useful for code, configuration, or documentation edits where only the first match should be changed.

Quick Start

Provide the file path, the old_string, and the new_string to perform the targeted replacement.

Frequently Asked Questions about edit_file

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace only the first occurrence of a string in a text file?

To replace the first occurrence of a string in a text file, provide the file path, old_string, and new_string. The tool locates the initial match and performs an in-place edit, returning the modified file path.

What's the best way to make a targeted code edit without altering multiple matches?

The best way to make a targeted code edit without altering multiple matches is using a first-match string replacement function. It modifies only the initial occurrence in your code or configuration file and saves the changes in-place.

How do I update a single configuration value in place using string replacement?

You can update a single configuration value by specifying the file path, the exact old_string, and the new_string. This performs an in-place modification on your UTF-8 configuration file, changing only the first match found.

Does in-place file editing work with UTF-8 encoded documents?

Yes, in-place file editing works with UTF-8 encoded documents. The string replacement process reads the UTF-8 text, replaces the first occurrence of the specified string, and writes the updated content back to the same file path.

Why does my string replacement only change the first match and not the rest of the file?

Your string replacement only changes the first match because the tool is designed for targeted edits where only the initial occurrence should change. This prevents unintended modifications to subsequent identical strings in the file.

What inputs do I need to perform a targeted text replacement in a file?

To perform a targeted text replacement, you need three inputs: the file path, the old_string to locate, and the new_string to substitute. The tool uses these to execute the first-match replacement and return the modified path.