- Home
- Skills
- APIs & Backend
- Safe Agent File Edits
Safe Agent File Edits
Conflict-aware, atomic, and recoverable multi-file editing for AI coding agents.
$12
Safe Agent File Edits
Example session with this skill installed
Apply a refactor to src/auth.ts and src/session.ts. If the files have changed since I last read them, do not overwrite; report the conflict instead.
- Read your context and instructions
- Compiled the safe agent file
I have prepared and executed a workspace-edit plan for the requested refactor. The preflight check verified that the file hashes matched your last read, and the atomic write was completed for both files.
Workspace Edit Result
| File Path | Action | Status | Hash Precondition |
|---|---|---|---|
src/auth.ts | Update | Success | sha256:8f31... |
src/session.ts | Update | Success | sha256:a2b5... |
The changes were applied using the finalize recovery mode. A journal entry was created in .workspace-edit/ and cleared after the successful rename operations. No concurrent edits were detected during the preflight phase.
Next steps
- Verify the refactor by running your local test suite.
- If you notice any unexpected behavior, check the
.workspace-edit/directory for the previous file backups. - Proceed with the next part of the refactor now that the core auth logic is updated.
Connects securely to your tools. The creator never sees your data.
About this skill
Coding agents often read a file, process it, and write back stale data that clobbers intermediate changes from users or other agents. This skill implements conflict-aware file editing to ensure data integrity during multi-file operations and codemods.
What it does
- Conflict detection checks the SHA-256 hash of every file before writing to prevent overwriting concurrent edits.
- All-or-nothing preflight aborts the entire operation if a single file in the change set fails the hash check.
- Atomic writes uses a temp-file and rename pattern to ensure readers never encounter half-written files.
- Crash recovery leverages a journal and backup directory to finalize or rollback interrupted operations.
- Path confinement prevents directory traversal attacks by rejecting absolute paths or escapes outside the root.
How it works
- Plan the edit by defining a list of paths and their new content, which captures current file hashes as preconditions.
- Apply the plan, which triggers a preflight check across all target files before any bytes are written.
- Handle conflicts by re-reading the modified files and generating a fresh patch if the preflight fails.
- Recover the workspace on the next run if a crash occurs mid-write using the local journal.
Frameworks & tools
This skill is built around the workspace-edit pattern, designed for Node.js environments (version 18 or higher) with zero external dependencies. It integrates with any agentic workflow involving file system operations.
Why this beats prompting it yourself
Standard LLM prompts for file writing lack the logic to verify file state between a read and a write call. This skill provides the deterministic infrastructure to detect "stale-read" conflicts that raw prompting cannot handle, preventing silent data loss in active repositories.
Use cases
- Mass refactoring across multiple source files where consistency is critical.
- Codemod execution that must be aborted if the codebase changes during processing.
- Multi-agent collaboration on a shared workspace to prevent clobbering each other's work.
- Long-running agent tasks that require a recovery mechanism if the process is interrupted.
Known limitations
This is not a filesystem-level transaction; files become visible one at a time. The check-then-act window is small but exists. Hashes are byte-exact, so line ending differences will trigger conflicts.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 5 days ago
Permissions
What's inside
Frequently Asked Questions
New in APIs & Backend
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.