safety

safety is a cursor rule for Cursor from Pranav-Karra-3301/tuck. It costs 0 tokens per session (415 once invoked), scanned A, original, MIT.

A set of safety rules for coding agents, covering file changes, backups, secrets, and input validation. Zod is a TypeScript library used here to check that external data has the expected shape.

In plain words
What is it for?
Use it when an agent deletes or overwrites files, changes configuration, handles API keys or passwords, or processes data from outside the program.
Why use it?
It reduces the risk of losing user files, exposing credentials, or accepting malformed input. Destructive actions require confirmation, and modified files must be backed up first.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { ConfigSchema } from '../schemas/config.schema.js';.

Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/Pranav-Karra-3301/tuck
agentmods
npx agentmods add rules/pranav-karra-3301/tuck/safety

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 safety

README.md
[![agentmods](https://agentmods.dev/badge/rules/pranav-karra-3301/tuck/safety.svg)](https://agentmods.dev/rules/pranav-karra-3301/tuck/safety)
Your own site
<a href="https://agentmods.dev/rules/pranav-karra-3301/tuck/safety"><img src="https://agentmods.dev/badge/rules/pranav-karra-3301/tuck/safety.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 415 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00000 $0.00415
Opus 5 $0.00000 $0.00208
Sonnet 5 $0.00000 $0.00083
Haiku 4.5 $0.00000 $0.00042

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

Security

Grade A, and why

safety 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 6d 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/safety.mdc · 88 lines

What it actually says

Safety Rules

Core Safety Principles

  1. Never lose user data - This is the most important rule
  2. Confirm destructive actions - Always ask before deleting/overwriting
  3. Create backups - Before any file modification
  4. Validate all input - Use Zod schemas

Destructive Operations

ALWAYS confirm before:

  • Deleting files
  • Overwriting files
  • Removing tracked files
  • Resetting configuration
// Required pattern
const confirmed = await prompts.confirm(
  'This will delete all backups. Continue?',
  false  // Default to safe option
);

if (!confirmed) {
  prompts.cancel('Operation cancelled');
  return;
}

Backup Requirements

Before modifying any user file:

  1. Create a backup copy
  2. Store backup location
  3. Provide restore path in error messages
// Create backup before modification
const backupPath = await createBackup(originalPath);

try {
  await modifyFile(originalPath);
} catch (error) {
  throw new Error(`Failed. Restore from: ${backupPath}`);
}

Secrets and Credentials

NEVER:

  • Store API keys in tracked files
  • Track SSH private keys
  • Include passwords in config
  • Log sensitive data

Input Validation

Use Zod for ALL external data:

  • Config file contents
  • Manifest file contents
  • User-provided paths
  • Environment variables
import { ConfigSchema } from '../schemas/config.schema.js';

const data = JSON.parse(fileContent);
const config = ConfigSchema.parse(data); // Throws if invalid

Path Handling

ALWAYS use path utilities:

  • expandPath() - Expand ~ to full path
  • collapsePath() - Collapse home to ~
  • pathExists() - Check existence safely

NEVER:

  • Assume path format
  • Use raw ~ in fs operations
  • Hardcode paths
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. 6d ago First seen · 88 lines · 0 tokens per session scan A 8aa85fca330e

Subscribe to this mod's changes

safety is a cursor rule published in the GitHub repository Pranav-Karra-3301/tuck (15 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 415 tokens. 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.

Related

Other cursor rules, from other repositories

rule-generating-agent

This rule is essential for maintaining consistency and quality in rule creation across the codebase. It must be followed whenever: (1) A user requests a new rule to be created, (2) An existing rule needs modification, (3) The user asks to remember certain behaviors or patterns, or (4) Future behavior changes are…

appboypov/pew-pew-cli · 1,197 tokens

testing-mocks-spies-stubs-agent

Apply when writing unit tests that involve functions or modules with side effects (e.g., file system access, network requests, database interactions, timers, complex dependencies). Guides the use of test doubles like mocks, spies, and stubs (using frameworks like Jest) to isolate the unit under test and control its…

appboypov/pew-pew-cli · 71 tokens

cli-configuration-management-agent

Apply when implementing or discussing configuration management strategy for any CLI tool. Ensures a clear order of precedence (args > env > project config > user config > system config), use of standard config file locations (e.g., XDG Base Directory spec), support for environment variables, and secure persistence of…

appboypov/pew-pew-cli · 67 tokens

testing-isolation-logic-agent

Apply when designing or refactoring CLI command implementations or writing unit tests for them. Promotes separating the core business logic of a command from I/O operations (argument parsing, console output, file system access, network requests) to enhance testability. Encourages testing the isolated logic functions…

appboypov/pew-pew-cli · 58 tokens

npm-cli-packaging-agent

Apply when preparing a TypeScript CLI tool for distribution via npm, specifically when configuring package.json, handling executables, and considering cross-platform compatibility. Covers the bin field, shebang line (#!/usr/bin/env node), pre-publish checks, installation instructions, and Node engine compatibility.

appboypov/pew-pew-cli · 61 tokens

ts-dependency-management-agent

Apply when adding, removing, or managing dependencies, or when structuring code modules in a TypeScript project, especially for CLIs. Promotes minimizing external dependencies, using lockfiles (package-lock.json), vetting dependencies, following SOLID principles for modular code, and using dependency injection for…

appboypov/pew-pew-cli · 62 tokens