conventions

A set of project coding conventions for errors, asynchronous work, function structure, and types. Asynchronous work means operations that finish later, such as file access or network calls.

In plain words
What is it for?
Use it when adding TypeScript functions, handling failures, writing async code, or organizing exported modules.
Why use it?
It gives contributors consistent patterns, making code easier to read and reducing mistakes in error handling and asynchronous functions.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/srajangpt1/agent-rule-sync/conventions
Clone the repo
git clone --depth 1 https://github.com/Srajangpt1/agent-rule-sync

Made for: Cursor.

Per session 1,446 This file is loaded in full into every session.
When invoked 1,446 The same file — it is already loaded in full.
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 $0.01446 $0.01446
Opus 5 $0.00723 $0.00723
Sonnet 5 $0.00289 $0.00289
Haiku 4.5 $0.00145 $0.00145

Measured 3d ago against content hash 77a819cadc75, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

conventions 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 3d 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/conventions.mdc · 139 lines

How it starts

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

  • Error Handling: Always check for errors using instanceof Error before accessing error properties. Use instanceof Error before accessing .message. Return error objects with success: false and error message string. Log errors appropriately based on context (console.error for CLI, return error for library API).

    • catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Unknown error occurred', }; }
    • process.on('error', (err) => { resolve({ installed: false, error: err.message, }); });
  • Async/Await Usage: Always use async/await for asynchronous operations, never Promise chains (.then/.catch). Make async functions return Promise with explicit type. Use try-catch blocks for error handling in async functions. Wrap callback-based APIs (like spawn) in Promise constructors.

    • export async function generateRules(config: GenerateRulesConfig = {}): Promise { try { const result = await analyzeCodebase({ verbose }); // ... } catch (error) { // handle error } }
    • export async function checkCursorAgent(): Promise { return new Promise((resolve) => { // callback-based logic }); }
  • Function Organization: Export functions at module level. Group related functions together. Use helper functions to break down complex logic. Keep functions focused on a single responsibility. Document exported functions with JSDoc comments.

    • export async function generateRules(...) { }
    • export async function checkAgent() { }
    • export async function analyze(...) { }
    • function createAnalysisPrompt(): string { }
    • function parseRawOutput(rawOutput: string): AnalysisData | null { }
  • TypeScript Type Usage: Define interfaces for all data structures. Use optional properties (?) for values that may be undefined. Use explicit return types on all exported functions. Use union types for literal value sets. Avoid any type, use unknown if type is truly unknown.

    • export interface AnalysisResult { success: boolean; data?: AnalysisData; error?: string; rawOutput?: string; }
    • ruleType?: 'always' | 'auto-attached' | 'agent-requested' | 'manual';
    • export async function generateRules(config: GenerateRulesConfig = {}): Promise
  • Default Parameters: Use default parameters for optional configuration options. Provide sensible defaults. Use object destructuring with defaults in function parameters.

    • export async function generateRules(config: GenerateRulesConfig = {}): Promise
    • export async function analyzeCodebase(options: AnalyzeOptions = {}): Promise { const { timeout = 300000, verbose = false } = options; }
    • export async function analyze(verbose: boolean = false): Promise
  • Result Objects: Use result objects with success boolean and additional data/error fields for function returns. This pattern allows for consistent error handling and data extraction. Include arrays for operation results (created, updated, unchanged).

    • interface RulesManagerResult { success: boolean; created: string[]; updated: string[]; unchanged: string[]; error?: string; }
    • return { success: true, created: ['file1.mdc'], updated: [], unchanged: [], };
  • Verbose Logging Pattern: Accept verbose boolean parameter for detailed logging. Check verbose flag before logging detailed information. Use console.log for verbose output, console.error for errors. Provide helpful progress messages during long operations. For large outputs, truncate and show length/preview.

    • if (verbose) { console.log(Using cursor-agent: ${agentCheck.version}); }
    • if (verbose && analysisResult.success && analysisResult.data) { console.log('Analysis successful, data received'); }
    • if (analysisResult.rawOutput.length < 500) { console.log('Raw output:', analysisResult.rawOutput); } else { console.log('Raw output (first 500 chars):', analysisResult.rawOutput.substring(0, 500)); }

Read the full file on GitHub · 139 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. 3d ago First seen · 139 lines · 1,446 tokens per session scan A 77a819cadc75

Subscribe to this mod's changes

conventions is a cursor rule published in the GitHub repository Srajangpt1/agent-rule-sync (12 stars, last pushed 5mo ago), licensed MIT. It adds 1,446 tokens to every session, about $0.0072 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.