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.
npx agentmods add rules/srajangpt1/agent-rule-sync/bestpracticesgit clone --depth 1 https://github.com/Srajangpt1/agent-rule-syncWrote 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.
[](https://agentmods.dev/rules/srajangpt1/agent-rule-sync/bestpractices)<a href="https://agentmods.dev/rules/srajangpt1/agent-rule-sync/bestpractices"><img src="https://agentmods.dev/badge/rules/srajangpt1/agent-rule-sync/bestpractices.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.02242 | $0.02242 |
| Opus 5 | $0.01121 | $0.01121 |
| Sonnet 5 | $0.00448 | $0.00448 |
| Haiku 4.5 | $0.00224 | $0.00224 |
Grade B, and why
bestpractices scanned grade B with 2 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 4d 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.
Downloads and executes remote codemediumSupply chain
curl | sh runs whatever the server returns today, which is not necessarily what it returned when this was reviewed.
console.log(chalk.white(' curl https://cursor.com/install -fsS | bash\n')); Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.
Makes network callslowCapability
Not a fault in itself. Listed so you know the mod talks to something, and to what.
console.log(chalk.white(' curl https://cursor.com/install -fsS | bash\n')); How it starts
The opening of the file, as written. The whole thing — 186 lines — stays where its author put it; the contents beside it link to each section on GitHub.
-
Security - Environment Variables: Never hardcode API keys or sensitive credentials. Always use environment variables for sensitive data (CURSOR_API_KEY). Inherit environment variables when spawning processes. Never pass sensitive data as command-line arguments.
- env: { ...process.env, // Inherit all environment variables (includes CURSOR_API_KEY) PATH: process.env.PATH || '', }
- // Security Note: Always use environment variables for API keys. Never pass them as command-line arguments.
-
Security - Process Execution: Use spawn for executing external commands rather than eval or exec with user input. Validate inputs before passing to external processes. Handle process errors and timeouts appropriately.
- const childProcess = spawn('cursor-agent', args, { stdio: ['ignore', 'pipe', 'pipe'], env: { ...process.env }, });
- const timeoutId = setTimeout(() => { childProcess.kill(); // handle timeout }, timeout);
-
Performance - Timeout Handling: Set reasonable timeouts for long-running operations (default 5 minutes). Always clear timeouts when operations complete. Kill processes that exceed timeout to prevent resource leaks.
- const timeout = 300000; // 5 minute default timeout
- const timeoutId = setTimeout(() => {
childProcess.kill();
resolve({ success: false, error:
Analysis timeout...}); }, timeout); - childProcess.on('close', (code) => { clearTimeout(timeoutId); // ... });
-
Performance - File Operations: Use synchronous file operations (readFileSync, writeFileSync) when appropriate for CLI tools. Check file existence before reading. Use recursive directory creation when needed. Normalize paths for comparison operations.
- if (!fs.existsSync(rulesDir)) { fs.mkdirSync(rulesDir, { recursive: true }); }
- const normalize = (s: string) => s.trim().replace(/\s+/g, ' '); return normalize(existingContent) !== normalize(newContent);
-
Code Reusability - Helper Functions: Extract reusable logic into helper functions. Create utility functions for common operations (filename generation, content comparison, directory management). Keep functions pure when possible (no side effects).
- export function generateFilename(categoryName: string): string
- export function needsUpdate(existingContent: string, newContent: string): boolean
- export function ensureRulesDirectory(rulesDir: string): void
-
DRY Principle - Data Structures: Define shared data structures in types.ts to avoid duplication. Use consistent result object patterns across functions. Reuse type definitions rather than redefining similar structures.
- // Define once in types.ts export interface AnalysisResult { ... }
- // Reuse across modules import { AnalysisResult, RulesManagerResult } from './types';
-
DRY Principle - Conversion Logic: Centralize format conversion logic in single functions. Reuse conversion functions rather than duplicating logic. Create utility functions for repeated transformations.
- export function convertToMDC(categoryName: string, category: RuleCategory): string { ... }
- export function parseRawOutput(rawOutput: string): AnalysisData | null { ... }
-
Error Recovery - Fallback Parsing: Provide fallback mechanisms when primary operations fail. Attempt alternative parsing methods when primary method fails. Provide meaningful error messages that guide users toward solutions.
- // Try to parse raw output as fallback if (analysisResult.rawOutput) { const parsedData = parseRawOutput(analysisResult.rawOutput); if (parsedData) { analysisResult.data = parsedData; analysisResult.success = true; } }
- const jsonMatch = stdout.match(/{[\s\S]*}/); if (!jsonMatch) { // fallback logic }
-
User Experience - Clear Messaging: Provide clear, actionable error messages. Include installation instructions in error messages when tools are missing. Use color coding in CLI output for better UX. Show progress for long-running operations.
- console.error(chalk.red('\nError: cursor-agent is not installed or not in PATH')); console.log(chalk.yellow('\nTo install cursor-agent, run:')); console.log(chalk.white(' curl https://cursor.com/install -fsS | bash\n'));
- console.log(chalk.gray('Analyzing codebase with cursor-agent...')); console.log(chalk.gray('This may take a few minutes...\n'));
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.
- 4d ago First seen · 186 lines · 2,242 tokens per session scan B b133f02241a6
bestpractices is a cursor rule published in the GitHub repository Srajangpt1/agent-rule-sync (12 stars, last pushed 5mo ago), licensed MIT. It adds 2,242 tokens to every session, about $0.0112 per session on Opus 5. A static security scan graded it B with 2 findings (downloads and executes remote code, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.