secrets-rules

secrets-rules is a cursor rule for Cursor from girijashankarj/cursor-handbook. It costs 515 tokens per session, scanned A, original, MIT.

A rulebook for storing and using passwords, API keys, and other secret settings. It requires secrets to come from environment variables or a dedicated secrets manager.

In plain words
What is it for?
It helps developers load, validate, mask, and rotate sensitive configuration values.
Why use it?
It prevents credentials from being exposed in source code, logs, or documentation. It also makes production configuration safer to manage.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It helps developers load, validate, mask, and rotate sensitive configuration values.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/girijashankarj/cursor-handbook/secrets-rules
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/girijashankarj/cursor-handbook

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 secrets-rules

README.md
[![agentmods](https://agentmods.dev/badge/rules/girijashankarj/cursor-handbook/secrets-rules/github.svg)](https://agentmods.dev/rules/girijashankarj/cursor-handbook/secrets-rules)
Your own site
<a href="https://agentmods.dev/rules/girijashankarj/cursor-handbook/secrets-rules"><img src="https://agentmods.dev/badge/rules/girijashankarj/cursor-handbook/secrets-rules/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 secrets-rules

Your own site · 80×15
<a href="https://agentmods.dev/rules/girijashankarj/cursor-handbook/secrets-rules"><img src="https://agentmods.dev/badge/rules/girijashankarj/cursor-handbook/secrets-rules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 515 This file is loaded in full into every session.
When invoked 515 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.00515 $0.00515
Opus 5 $0.00258 $0.00258
Sonnet 5 $0.00103 $0.00103
Haiku 4.5 $0.00052 $0.00052

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

Security

Grade A, and why

secrets-rules 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/security/secrets-rules.mdc · 72 lines

How it starts

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

Secrets Handling Rules

Environment Variable Patterns

Required Environment Variables

All secrets MUST be loaded from environment variables or a secrets manager.

// CORRECT - Environment variable
const dbPassword = process.env.DB_PASSWORD;
const apiKey = process.env.API_KEY;

// WRONG - Hardcoded (NEVER do this)
const dbPassword = "my-secret-password";
const apiKey = "sk-1234567890abcdef";

Configuration Loading Pattern

// config/index.ts
export const config = {
  database: {
    host: process.env.DB_HOST || 'localhost',
    port: parseInt(process.env.DB_PORT || '5432'),
    name: process.env.DB_NAME || '{{CONFIG.project.name}}',
    // Secrets - NO defaults for production
    password: process.env.DB_PASSWORD,
    username: process.env.DB_USERNAME,
  },
  auth: {
    jwtSecret: process.env.JWT_SECRET,
    jwtExpiry: process.env.JWT_EXPIRY || '15m',
  },
  cloud: {
    region: process.env.CLOUD_REGION || 'us-east-1',
    // Never log these values
    accessKey: process.env.CLOUD_ACCESS_KEY,
    secretKey: process.env.CLOUD_SECRET_KEY,
  }
};

// Validate required secrets at startup
const requiredSecrets = ['DB_PASSWORD', 'JWT_SECRET'];
for (const secret of requiredSecrets) {
  if (!process.env[secret]) {
    throw new Error(`Missing required environment variable: ${secret}`);
  }
}

.env File Rules

  • .env files MUST be in .gitignore
  • Provide .env.example with placeholder values (no real secrets)
  • Never commit .env files to version control
  • Use different .env files per environment: .env.development, .env.staging, .env.production

Secret Rotation

  • All secrets should support rotation without deployment
  • Use secrets manager with automatic rotation when possible
  • Log secret access (but never the secret value) for audit trails

What to Look For in Code Reviews

  • grep for patterns: password, secret, key, token, credential
  • Check for base64-encoded strings that might be obfuscated secrets
  • Verify .env files are in .gitignore
  • Check that test fixtures don't contain real credentials

Read the full file on GitHub · 72 lines

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 · 72 lines · 515 tokens per session scan A 71a1f38d912c

Subscribe to this mod's changes

secrets-rules is a cursor rule published in the GitHub repository girijashankarj/cursor-handbook (30 stars, last pushed 10d ago), licensed MIT. It adds 515 tokens to every session, about $0.0026 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-09-03.