Skip to content
Back to skills

Spgr Write File

ASecurity

Create or overwrite a repository file safely, with read-before-write enforcement, parent-directory creation, backup, and post-write checksum verification. Use when an agent needs to write source, config, or artifact files to disk, since the artifact-write skills call this as their write side.

  • 2 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 11, 2026
ai-agentsgit

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add z4gunn/springer --skill spgr-write-file --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Spgr Write File?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Spgr Write File
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/z4gunn-spgr-write-file/badge)](https://www.skillsdirectory.com/skills/z4gunn-spgr-write-file)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: spgr-write-file
description: Create or overwrite a repository file safely, with read-before-write enforcement, parent-directory creation, backup, and post-write checksum verification. Use when an agent needs to write source, config, or artifact files to disk, since the artifact-write skills call this as their write side.
disable-model-invocation: true
---

# write-file

## Purpose

Give every agent one safe write interface so file production does not cause missing directories, blind overwrites of unread files, or partial writes on crash. This skill does not generate content. The caller assembles the full content string, and this skill writes it atomically and confirms the result.

## Inputs

| Field | Description |
|-------|-------------|
| `file_path` | Absolute or repo-relative path to write |
| `content` | Full file content as a string |
| `mode` | `create` (fail if exists), `overwrite` (replace unconditionally), or `safe` (fail if not read this session). Defaults to `safe` |
| `create_parents` | Create missing parent directories. Defaults to true |
| `encoding` | Defaults to utf-8 |

## Outputs

| Artifact | Description |
|----------|-------------|
| `write_result` | Object: `write_confirmed`, `file_path`, `bytes_written`, `created_dirs`, `backup_path`, `checksum` |

## Procedure

1. Resolve `file_path` and confirm it stays within the repository root. The root is the main worktree's root, the parent of `git rev-parse --git-common-dir`, so a unit in a linked worktree under `.worktrees/` may write to the run store in the main worktree. Refuse writes outside that boundary.
2. In `safe` mode, confirm the file was read this session with `spgr-read-file`. If it was not, escalate with `spgr-escalate` rather than writing blindly.
3. In `create` mode, fail with a clear error if the file already exists. Do not silently overwrite.
4. When overwriting an existing file, copy it to a `.bak` in a temp directory and record the path in `backup_path`.
5. Write to a temp file in the same directory, then move it to the target path so a crash cannot leave a partial write. Create parent directories first when `create_parents` is true and record them in `created_dirs`.
6. Verify the write by re-reading the first and last five lines and comparing a checksum. Return `write_confirmed` with the checksum.

## Notes

- Write LF line endings by default. Respect an explicit `create_line_ending` of CRLF only for Windows-targeted config files.
- When several agents may write the same shared file, take a file lock around the write to prevent a race.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.