Safe Agent File Edits

    by Khristian Kopachelli

    1

    Conflict-aware, atomic, and recoverable multi-file editing for AI coding agents.

    $12

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    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 PathActionStatusHash Precondition
    src/auth.tsUpdateSuccesssha256:8f31...
    src/session.tsUpdateSuccesssha256: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

    1. Plan the edit by defining a list of paths and their new content, which captures current file hashes as preconditions.
    2. Apply the plan, which triggers a preflight check across all target files before any bytes are written.
    3. Handle conflicts by re-reading the modified files and generating a fresh patch if the preflight fails.
    4. 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Write Files
    Read Files
    Listed5 days ago

    What's inside

    Frequently Asked Questions

    This skill prevents 'stale-read' errors where an agent overwrites a file that was changed by a human or another process while the agent was 'thinking.' It ensures that if any part of a multi-file edit fails a hash check, the entire operation is halted to prevent codebase corruption.

    Upon purchase, you receive the full skill logic, documentation for the 'Plan' and 'Apply' patterns, and the journaling system for crash recovery. It is a 'zero-dependency' package, meaning you won't need to manage a complex tree of external libraries to get it running.

    While the tool uses a 'check-then-act' pattern with SHA-256 hashes to minimize risks, it is not a kernel-level database transaction. It provides atomic file-level writes, but files in a multi-file set become visible to the system one by one in rapid succession.

    The skill includes a built-in recovery mechanism that uses a local journal and backup directory. If your agent crashes mid-operation, the skill can detect the interrupted state on the next run and either finalize the pending writes or rollback to the original state.

    Because the skill uses byte-exact SHA-256 hashing, even a change in line endings (LF vs CRLF) will trigger a conflict. We recommend ensuring your workspace has a consistent `.gitattributes` or `editorconfig` to prevent unnecessary preflight failures.

    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.