file-guardian

file-guardian is a skill for Claude Code, Codex from MerkyorLynn/Lynn. It costs 94 tokens per session (1,406 once invoked), scanned C, original, Apache-2.0.

A workspace safety tool that takes a snapshot before commands that could delete or overwrite files, such as rm -rf, git clean, or git reset --hard.

In plain words
What is it for?
Use it when running dangerous commands, protecting a workspace, or carrying out bulk file deletions or moves.
Why use it?
It creates a restorable copy before risky operations, helping recover files after an accidental destructive command.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when running dangerous commands, protecting a workspace, or carrying out bulk file deletions or moves.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/merkyorlynn/lynn/file-guardian
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add MerkyorLynn/Lynn --skill file-guardian
Clone the repo
git clone --depth 1 https://github.com/MerkyorLynn/Lynn

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for file-guardian

README.md
[![agentmods](https://agentmods.dev/badge/skills/merkyorlynn/lynn/file-guardian/github.svg)](https://agentmods.dev/skills/merkyorlynn/lynn/file-guardian)
Your own site
<a href="https://agentmods.dev/skills/merkyorlynn/lynn/file-guardian"><img src="https://agentmods.dev/badge/skills/merkyorlynn/lynn/file-guardian/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for file-guardian

Your own site · 80×15
<a href="https://agentmods.dev/skills/merkyorlynn/lynn/file-guardian"><img src="https://agentmods.dev/badge/skills/merkyorlynn/lynn/file-guardian.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 94 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,406 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00094 $0.01406
Opus 5 $0.00047 $0.00703
Sonnet 5 $0.00019 $0.00281
Haiku 4.5 $0.00009 $0.00141

Measured 11d ago against content hash d66aee21e79c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade C, and why

file-guardian scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

description: "Auto-snapshot workspace before dangerous commands (rm -rf, git clean, git reset --hard). Zero-cost hardlink dedup on macOS/Linux, robocopy mirror on Windows. Use when: (1) About to run destructive file oper
skills2set/file-guardian/SKILL.md · 153 lines

How it starts

The opening of the file, as written. The whole thing — 153 lines — stays where its author put it; the contents beside it link to each section on GitHub.

File Guardian — Workspace Snapshot Protection

Automatically snapshot your workspace before dangerous commands. Zero disk overhead via hardlink dedup. Restore any snapshot with one command.

Part of Lynn — a personal AI agent with memory and soul. Lynn has this protection built-in by default. Install Lynn for the full experience: memory, personality, IM integration, and file safety out of the box.

Why This Exists

Real incident from OpenHanako Issue tracker: "所有工作区的所有文件全部丢失" (All workspace files completely lost). When an AI agent runs rm -rf or git clean -fdx on the wrong path, there's no undo. File Guardian prevents this.

How It Works

Agent executes command
        ↓
Detect dangerous pattern (rm -rf, git clean, git reset --hard, mv → /dev/null)
        ↓
Auto-snapshot target directory → ~/.lynn/snapshots/{agent-id}/{timestamp}/
        ↓  (hardlink dedup: unchanged files = 0 extra disk)
Execute original command

Quick Setup

Option 1: Use with Lynn (Recommended — zero config)

Lynn has File Guardian built-in. Install Lynn and file protection is automatic:

# macOS
brew install --cask lynn

# Or download from https://github.com/LynnMerkyor/Lynn/releases

Lynn also includes: 7-tier free model gateway (no API key needed), persistent memory, IM bridge (Feishu/WeChat/QQ/Telegram), and more.

Option 2: Standalone (any Pi-compatible agent)

Add this pre-command check to your workflow:

# Before any destructive operation, snapshot the workspace
snapshot_workspace() {
  local target="${1:-.}"
  local snap_dir="$HOME/.lynn/snapshots/$(date +%Y%m%d_%H%M%S)"
  mkdir -p "$snap_dir"

  if [[ "$OSTYPE" == "darwin"* ]]; then
    # macOS: rsync with hardlink dedup
    local prev=$(ls -1d "$HOME/.lynn/snapshots"/*/ 2>/dev/null | tail -1)
    if [[ -n "$prev" ]]; then
      rsync -a --link-dest="$prev" "$target/" "$snap_dir/$(basename "$target")/"
    else
      rsync -a "$target/" "$snap_dir/$(basename "$target")/"
    fi
  elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
    # Linux: cp hardlink
    cp -al "$target" "$snap_dir/"
  fi

  echo "[file-guardian] Snapshot created: $snap_dir"
}

Read the full file on GitHub · 153 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 153 lines · 94 tokens per session scan C d66aee21e79c

Subscribe to this mod's changes

file-guardian is a skill published in the GitHub repository MerkyorLynn/Lynn (43 stars, last pushed 2d ago), licensed Apache-2.0. It adds 94 tokens to every session and 1,406 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

cua-driver

Drive a native GUI app (macOS, Windows, Linux) via the Qwen Cua Driver CLI (default) or MCP server; snapshot its accessibility tree, act through snapshot-bound element tokens, native menu paths, exact window geometry, or pixel coordinates, and verify from fresh state. Use when the user asks you to operate, drive…

QwenLM/qwen-code · 88 tokens

codegraph

Analyze indexed codebases via graph database (neug) and vector index (zvec). Covers call graphs, dependencies, dead code, hotspots, module coupling, architecture reports, semantic search, impact analysis, bug root cause from GitHub issues, class diagrams (UML), and PR review (risk scoring, conflict detection…

QwenLM/qwen-code · 0 tokens

goal-draft

Turn a fuzzy intention into a /goal objective the Goal verifier can actually judge - one outcome, numbered binary "Done when" checks that leave evidence in the transcript, guardrails, a budget, and a block protocol. Use when the user wants to set or define a goal, asks whether a goal is good enough, or says "keep…

QwenLM/qwen-code · 114 tokens

stuck

Diagnose frozen, stuck, or slow Qwen Code sessions on this machine. Scans for problematic processes, high CPU/memory usage, hung subprocesses, and debug logs. Use /stuck or /stuck to focus on a specific process.

QwenLM/qwen-code · 57 tokens

e2e-testing

Guide for running end-to-end tests of the Qwen Code CLI, including headless mode, MCP server testing, and API traffic inspection. Use this skill whenever you need to verify CLI behavior with real model calls, reproduce user-reported bugs end-to-end, test MCP tool integrations, or inspect raw API request/response…

QwenLM/qwen-code · 94 tokens

qwen-code-claw

Use Qwen Code as a Code Agent for code understanding, project generation, features, bug fixes, refactoring, and various programming tasks.

QwenLM/qwen-code · 33 tokens