file-guard

file-guard is a cursor rule for Cursor from tecnomanu/pampa. It costs 250 tokens per session, scanned A, original, ISC.

Rules for changing files without accidentally replacing existing content.

In plain words
What is it for?
They are for checking files before creation and merging additions into existing code, configuration, or documentation unless overwriting was explicitly requested.
Why use it?
They help preserve comments, imports, configuration, documentation, and other work already present in a file.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit They are for checking files before creation and merging additions into existing…

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/tecnomanu/pampa/file-guard
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.

Clone the repo
git clone --depth 1 https://github.com/tecnomanu/pampa

Made for: Cursor.

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-guard

README.md
[![agentmods](https://agentmods.dev/badge/rules/tecnomanu/pampa/file-guard.svg)](https://agentmods.dev/rules/tecnomanu/pampa/file-guard)
Your own site
<a href="https://agentmods.dev/rules/tecnomanu/pampa/file-guard"><img src="https://agentmods.dev/badge/rules/tecnomanu/pampa/file-guard.svg" alt="Measured on agentmods" height="20"></a>
Per session 250 This file is loaded in full into every session.
When invoked 250 The same file — it is already loaded in full.
Security scan A 0 findings. 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.00250 $0.00250
Opus 5 $0.00125 $0.00125
Sonnet 5 $0.00050 $0.00050
Haiku 4.5 $0.00025 $0.00025

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

Security

Grade A, and why

file-guard scanned grade A with 0 findings 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 7d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/rules-kit/global/file-guard.mdc · 36 lines

What it actually says

File Management Guard

Before creating a file, check if it already exists. If it exists and there is no explicit instruction to overwrite, merge content instead of replacing.

Best Practices for File Operations

  1. Check Existence: Always verify if a file exists before creating it.

  2. Preserve Content: When a file exists, preserve important elements:

    • Comments and documentation
    • Existing imports
    • License headers
    • Configuration settings
  3. Merge Strategies:

    • For code files: Add new functions, classes, or methods without removing existing ones
    • For configuration files: Add new settings while preserving existing ones
    • For documentation: Append new information or integrate it with existing content
  4. Communicate Changes: When modifying existing files, document the nature of the changes.

When to Overwrite

Only overwrite files when:

  1. Explicitly instructed to do so
  2. The file is known to be a generated file that should be recreated
  3. The entire purpose of the file is being changed
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. 7d ago First seen · 36 lines · 250 tokens per session scan A 5d0a252a7908

Subscribe to this mod's changes

file-guard is a cursor rule published in the GitHub repository tecnomanu/pampa (30 stars, last pushed 11mo ago), licensed ISC. It adds 250 tokens to every session, about $0.0013 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.