cursorrules / rules
Cursor rule88 starsChanged 13 months agoMITView on GitHub
This rule helps identify potential secrets, credentials, and sensitive data in code files to prevent accidental exposure or leakage. It provides warnings when secrets are detected and suggests best practices for secure secret management. actions: - type: enforce conditions: # Generic API Keys, Tokens, and Credentials - pattern: "(?i)(api[-]?key|apikey|api[-]?secret|apisecret|app[-]?key|appkey|app[-]?secret|access[-]?key|accesskey|access[-]?token|auth[-]?key|authkey|client[-]?secret|consumer[-]?key|consumer[-]?secret|oauth[_-]?token|token)[\\s][=:]\\s'\\\"{16,}['\\\"]" message: "Potential API key or secret detected. Consider using environment variables or a secure secrets manager instead of hardcoding sensitive values."
- Reads credentials
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository70 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/accessibility-standards.mdcCursor rule
- .cursor/rules/api-standards.mdcCursor rule
- .cursor/rules/behat-ai-guide.mdcCursor rule
- .cursor/rules/behat-steps.mdcCursor rule
- .cursor/rules/build-optimization.mdcCursor rule
- .cursor/rules/code-generation-standards.mdcCursor rule
- .cursor/rules/confluence-editing-standards.mdcCursor rule
- .cursor/rules/cursor-rules.mdcCursor rule
- .cursor/rules/debugging-standards.mdcCursor rule
- .cursor/rules/docker-compose-standards.mdcCursor rule
- .cursor/rules/drupal-authentication-failures.mdcCursor rule
- .cursor/rules/drupal-broken-access-control.mdcCursor rule
- .cursor/rules/drupal-cryptographic-failures.mdcCursor rule
- .cursor/rules/drupal-database-standards.mdcCursor rule
- .cursor/rules/drupal-file-permissions.mdcCursor rule
- .cursor/rules/drupal-injection.mdcCursor rule
- .cursor/rules/drupal-insecure-design.mdcCursor rule
- .cursor/rules/drupal-integrity-failures.mdcCursor rule
- .cursor/rules/drupal-logging-failures.mdcCursor rule
- .cursor/rules/drupal-security-misconfiguration.mdcCursor rule
- .cursor/rules/drupal-ssrf.mdcCursor rule
- .cursor/rules/drupal-vulnerable-components.mdcCursor rule
- .cursor/rules/generic_bash_style.mdcCursor rule
- .cursor/rules/git-commit-standards.mdcCursor rule
- .cursor/rules/github-actions-standards.mdcCursor rule
- .cursor/rules/improve-cursorrules-efficiency.mdcCursor rule
- .cursor/rules/javascript-broken-access-control.mdcCursor rule
- .cursor/rules/javascript-cryptographic-failures.mdcCursor rule
- .cursor/rules/javascript-identification-authentication-failures.mdcCursor rule
- .cursor/rules/javascript-injection.mdcCursor rule
- .cursor/rules/javascript-insecure-design.mdcCursor rule
- .cursor/rules/javascript-performance.mdcCursor rule
- .cursor/rules/javascript-security-logging-monitoring-failures.mdcCursor rule
- .cursor/rules/javascript-security-misconfiguration.mdcCursor rule
- .cursor/rules/javascript-server-side-request-forgery.mdcCursor rule
- .cursor/rules/javascript-software-data-integrity-failures.mdcCursor rule
- .cursor/rules/javascript-standards.mdcCursor rule
- .cursor/rules/javascript-vulnerable-outdated-components.mdcCursor rule
- .cursor/rules/lagoon-docker-compose-standards.mdcCursor rule
- .cursor/rules/lagoon-yml-standards.mdcCursor rule
- .cursor/rules/multi-agent-coordination.mdcCursor rule
- .cursor/rules/new-pull-request.mdcCursor rule
- .cursor/rules/node-dependencies.mdcCursor rule
- .cursor/rules/php-drupal-best-practices.mdcCursor rule
- .cursor/rules/php-drupal-development-standards.mdcCursor rule
- .cursor/rules/php-memory-optimisation.mdcCursor rule
- .cursor/rules/project-definition-template.mdcCursor rule
- .cursor/rules/pull-request-changelist-instructions.mdcCursor rule
- .cursor/rules/python-authentication-failures.mdcCursor rule
- .cursor/rules/python-broken-access-control.mdcCursor rule
- .cursor/rules/python-cryptographic-failures.mdcCursor rule
- .cursor/rules/python-injection.mdcCursor rule
- .cursor/rules/python-insecure-design.mdcCursor rule
- .cursor/rules/python-integrity-failures.mdcCursor rule
- .cursor/rules/python-logging-monitoring-failures.mdcCursor rule
- .cursor/rules/python-security-misconfiguration.mdcCursor rule
- .cursor/rules/python-ssrf.mdcCursor rule
- .cursor/rules/python-vulnerable-outdated-components.mdcCursor rule
- The first 60 shown.
The file
We split this secret-detection.mdc into the rules it gives an agent
8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 96
Use libraries like dotenv, but ensure .env files are in .gitignore
- Distinctive: line 101
Use short-lived tokens when possible
- Distinctive: line 111
Use the principle of least privilege
- Distinctive: line 115
Add patterns for files that might contain secrets
- Distinctive: line 117
Verify these files are not committed to version control
- Distinctive: line 125
Use pre-commit hooks to prevent secret leakage
- Distinctive: line 127
Consider tools like git-secrets, trufflehog, or detect-secrets
- Distinctive: line 137
Create a response plan for leaked credentials
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
# Secret Detection and Warning Rule
This rule helps identify potential secrets, credentials, and sensitive data in code files to prevent accidental exposure or leakage. It provides warnings when secrets are detected and suggests best practices for secure secret management.
<rule>
name: secret_detection_warning
description: Detect and warn about potential secrets and sensitive data in code files
filters:
- type: file_extension
pattern: "\\.(php|js|py|ts|jsx|tsx|java|rb|go|cs|c|cpp|h|hpp|ini|conf|yaml|yml|json|xml|properties|env|config|sh|bash|zsh)$"
- type: file_path
pattern: ".*"
exclude: "(node_modules|vendor|bower_components|.git|.yarn|dist|build|out|\\.bundle|cache)"
actions:
- type: enforce
conditions:
# Generic API Keys, Tokens, and Credentials
- pattern: "(?i)(api[_-]?key|apikey|api[_-]?secret|apisecret|app[_-]?key|appkey|app[_-]?secret|access[_-]?key|accesskey|access[_-]?token|auth[_-]?key|authkey|client[_-]?secret|consumer[_-]?key|consumer[_-]?secret|oauth[_-]?token|token)[\\s]*[=:]\\s*['\\\"](\\w|[\\-]){16,}['\\\"]"
message: "Potential API key or secret detected. Consider using environment variables or a secure secrets manager instead of hardcoding sensitive values."
# AWS Keys and Tokens
- pattern: "(?i)(aws[_-]?access[_-]?key|aws[_-]?secret[_-]?key|aws[_-]?account[_-]?id)[\\s]*[=:]\\s*['\\\"](\\w|[\\-]){16,}['\\\"]"
message: "Potential AWS key detected. AWS credentials should be stored securely using AWS SDK credential providers, environment variables, or a secrets manager."
# Google Cloud and Firebase
- pattern: "(?i)(google[_-]?api[_-]?key|google[_-]?cloud[_-]?key|firebase[_-]?api[_-]?key)[\\s]*[=:]\\s*['\\\"](\\w|[\\-]){16,}['\\\"]"
message: "Potential Google Cloud or Firebase key detected. Use environment variables or a secure secrets manager to store these credentials."
# Azure and Microsoft
- pattern: "(?i)(azure[_-]?key|azure[_-]?connection[_-]?string|microsoft[_-]?key)[\\s]*[=:]\\s*['\\\"](\\w|[\\-]){16,}['\\\"]"
message: "Potential Azure or Microsoft key detected. Use Azure Key Vault, environment variables, or a secure secrets manager instead of hardcoding credentials."
# Database Connection Strings and Credentials
- pattern: "(?i)(jdbc:|mongodb[\\+]?://|postgres://|mysql://|database[_-]?url|connection[_-]?string)[^\\n]{10,}(password|pwd)[^\\n]{3,}"
message: "Potential database connection string with credentials detected. Use environment variables or a secure configuration manager for database connections."
# Database Credentials
- pattern: "(?i)(db[_-]?password|mysql[_-]?password|postgres[_-]?password|mongo[_-]?password|database[_-]?password)[\\s]*[=:]\\s*['\\\"][^\\s]{3,}['\\\"]"
message: "Potential database password detected. Store database credentials in environment variables or use a secure configuration manager."
# Private Keys and Certificates
- pattern: "(?i)-----(BEGIN|END) (RSA |DSA |EC )?(PRIVATE KEY|CERTIFICATE)-----"
message: "Private key or certificate material detected. Never include these directly in code - store them securely and reference them from protected locations."
# SSH Keys
- pattern: "(?i)ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}"
message: "SSH key detected. SSH keys should be managed securely and never included directly in code files."
# Passwords
- pattern: "(?i)(password|passwd|pwd|secret)[\\s]*[=:]\\s*['\\\"][^\\s]{3,}['\\\"]"
message: "Potential password detected. Never hardcode passwords in code files. Use environment variables or a secure secrets manager."
# OAuth Tokens
- pattern: "(?i)(bearer|oauth|access[_-]?token)[\\s]*[=:]\\s*['\\\"][\\w\\d\\-_.]{30,}['\\\"]"
message: "Potential OAuth token detected. Store tokens securely and consider implementing proper token rotation."
# JWT Tokens
- pattern: "(?i)ey[a-zA-Z0-9]{20,}\\.ey[a-zA-Z0-9\\-_]{20,}\\.[a-zA-Z0-9\\-_]{20,}"
message: "JWT token detected. Never hardcode JWT tokens directly in your code."
# GitHub Tokens
- pattern: "(?i)gh[pousr]_[a-zA-Z0-9]{20,}"
message: "GitHub token detected. GitHub tokens should be stored securely in environment variables or a secrets manager."
# Slack Tokens
- pattern: "(?i)(xox[pbar]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})"
message: "Slack token detected. Store Slack tokens securely using environment variables or a secrets manager."
# Stripe API Keys
- pattern: "(?i)(sk|pk)_(test|live)_[0-9a-zA-Z]{24,}"
message: "Stripe API key detected. Store Stripe keys securely in environment variables or a secrets manager."
# Generic Encryption Keys
- pattern: "(?i)(encryption[_-]?key|cipher[_-]?key|aes[_-]?key)[\\s]*[=:]\\s*['\\\"][\\w\\d\\-_.]{16,}['\\\"]"
message: "Potential encryption key detected. Encryption keys should be managed securely and never hardcoded."
# .env or config files with credentials
- pattern: "(?i)(DB_PASSWORD|API_KEY|SECRET_KEY|ADMIN_PASSWORD)[\\s]*=[\\s]*['\"]?[\\w\\d\\-_.]{3,}['\"]?"
message: "Environment variable with credential detected. Make sure .env files are included in .gitignore and .cursorignore."
# IP Addresses (if they appear with credentials)
- pattern: "(?i)(username|password|login|credential)[^\\n]{3,}(?:\\d{1,3}\\.){3}\\d{1,3}"
message: "IP address detected near potential credentials. Consider using DNS names and storing connection details securely."
- type: suggest
message: |
**Secure Secret Management Best Practices:**
1. **Never hardcode secrets in source code**
- Secrets in code can be exposed via version control, logs, or screenshots
- Code is often shared, backed up, and stored in multiple locations
2. **Use environment variables for configuration**
- Load secrets from environment variables at runtime
- Use libraries like dotenv, but ensure .env files are in .gitignore
- Example: `API_KEY=os.environ.get("API_KEY")`
3. **Implement secret rotation**
- Regularly rotate credentials and keys
- Use short-lived tokens when possible
- Implement proper secret lifecycle management
4. **Use secrets management solutions**
- AWS Secrets Manager, Azure Key Vault, HashiCorp Vault
- Platform-specific solutions like Kubernetes Secrets
- These provide encryption, access control, and audit trails
5. **Implement access controls**
- Limit who can access secrets
- Use the principle of least privilege
- Implement proper authentication for secret access
6. **Use .gitignore and .cursorignore**
- Add patterns for files that might contain secrets
- Example patterns: `.env`, `*.key`, `*secret*`, `*.pem`
- Verify these files are not committed to version control
7. **Consider using secure by default libraries**
- Libraries that separate configuration from code
- Frameworks with built-in secrets management
- Encryption libraries with secure defaults
8. **Implement detection tools**
- Use pre-commit hooks to prevent secret leakage
- Implement scanning in CI/CD pipelines
- Consider tools like git-secrets, trufflehog, or detect-secrets
9. **Audit and monitor**
- Regularly audit code for leaked secrets
- Monitor for unauthorized access to secrets
- Implement alerts for potential compromises
10. **Educate your team**
- Train developers on secure secret management
- Establish clear procedures for handling secrets
- Create a response plan for leaked credentials
- type: validate
conditions:
- pattern: "(?i)import\\s+os\\s*;?\\s*.*\\s+os\\.environ(\\.get)?"
message: "Environment variable usage detected, which is a good practice for managing secrets."
- pattern: "(?i)process\\.env\\."
message: "Environment variable usage in JavaScript detected, which is a good practice for managing secrets."
- pattern: "(?i)dotenv"
message: "Dotenv library usage detected, which can help with environment variable management."
- pattern: "(?i)(secret[s]?[_-]?manager|key[_-]?vault|hashicorp|vault)"
message: "Secret management solution reference detected, which is a best practice for handling secrets."
metadata:
priority: high
version: 1.0
tags:
- category:security
- subcategory:secrets
- subcategory:sensitive-data
- language:all
- priority:critical
references:
- "https://owasp.org/www-community/vulnerabilities/Hardcoded_credentials"
- "https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html"
- "https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning"
- "https://cloud.google.com/secret-manager/docs/best-practices"
- "https://aws.amazon.com/blogs/security/how-to-use-aws-secrets-manager-securely-store-rotate-deploy-database-credentials/"
</rule>Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

