prepend_to_file
Adds text to the start of a file atomically. Optionally ensures a newline separates the inserted content from the original first line for proper formatting.
Instructions
Insert content at the very beginning of a file (byte concatenation). Optional ensure_newline_after. Writes atomically.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute or workspace-relative path to the file. | |
| content | Yes | Text to prepend, written byte-for-byte. The caller is responsible for all line endings and spacing. | |
| encoding | No | File encoding. Default: utf-8. Pass utf-8-sig to strip a BOM. | utf-8 |
| project_root | No | Sets (and remembers) the project root for resolving relative paths for this and subsequent calls in the session. | |
| ensure_newline_after | No | If true, insert a single dominant-style line terminator between content and the original first line, but only if the boundary lacks one. |