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/codepatternsgit clone --depth 1 https://github.com/Srajangpt1/agent-rule-syncWhat 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.00000 | $0.01380 |
| Opus 5 | $0.00000 | $0.00690 |
| Sonnet 5 | $0.00000 | $0.00276 |
| Haiku 4.5 | $0.00000 | $0.00138 |
Grade A, and why
codepatterns scanned grade A with 1 finding 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 2d 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.
Runs shell commandslowCapability
Expected in a hook, worth knowing in a rule or an instructions file.
- import { spawn } from 'child_process'; How it starts
The opening of the file, as written. The whole thing — 114 lines — stays where its author put it; the contents beside it link to each section on GitHub.
-
Indentation Style: Use 2 spaces for indentation, never tabs. All code files consistently use 2-space indentation.
- function example() { const value = 1; return value; }
- if (condition) { doSomething(); }
-
Naming Conventions: Use camelCase for functions, variables, and method names. Use PascalCase for interfaces, types, classes, and exported types. Use descriptive, clear names that indicate purpose.
- camelCase: generateRules, checkCursorAgent, readExistingRules
- PascalCase: GenerateRulesConfig, AnalysisResult, CursorAgentCheck, RuleCategory
-
Function Documentation: All exported functions must have JSDoc-style comments with /** */ syntax. Include a brief description of what the function does. Document parameters and return types in TypeScript types, not JSDoc tags.
- /**
- Check if cursor-agent is installed and accessible */ export async function checkCursorAgent(): Promise
- /**
- Main function to generate cursor rules */ export async function generateRules(config: GenerateRulesConfig = {}): Promise
-
Import Organization: Group imports logically: Node.js built-ins first (if any), then external dependencies, then local imports. Use named imports for clarity. Keep import statements at the top of the file.
- import { spawn } from 'child_process'; import chalk from 'chalk'; import { Command } from 'commander'; import { generateRules } from './index';
- import * as fs from 'fs'; import * as path from 'path'; import { AnalysisData, RulesManagerResult } from './types';
-
Export Patterns: Use named exports (export function, export const) rather than default exports. Export types and interfaces explicitly using export interface/export type. Re-export related items from index.ts using export *.
- export async function generateRules(...) { }
- export interface GenerateRulesConfig { }
- export * from './types';
-
File Organization: One major concern per file. Related functions grouped together. Files named with kebab-case for multi-word names (e.g., rules-manager.ts), single words can use camelCase. Each file should have a clear, singular responsibility.
- src/analyzer.ts - handles cursor-agent integration
- src/rules-manager.ts - handles file system operations for rules
- src/cli.ts - handles CLI interface
-
Code Formatting: Use consistent spacing around operators, after commas, and in object literals. Use trailing commas in multiline arrays and objects. Use semicolons at end of statements.
- const config: GenerateRulesConfig = { outputDir: options.output, verbose: options.verbose, dryRun: options.dryRun, };
- const files = ['file1', 'file2', 'file3'];
-
String Literals: Use single quotes for string literals throughout the codebase. Use template literals (backticks) for multi-line strings and string interpolation.
- const message = 'Simple string';
- const path = path.join(baseDir, '.cursor', 'rules');
- const prompt =
Analyze this entire codebase...;
-
Conditional Logic: Prefer early returns for error conditions. Use explicit boolean checks (=== true, === false) when clarity is needed. Use optional chaining and nullish coalescing where appropriate.
- if (!agentCheck.installed) { return { success: false, error: '...' }; }
- const alwaysApply = category.alwaysApply !== undefined ? category.alwaysApply : category.ruleType === 'always' ? true : false;
-
CLI Error Handling: In CLI entry points (cli.ts), use process.exit() with appropriate exit codes (1 for errors, 0 for success) after displaying error messages. Library functions should return error objects instead of exiting.
- if (!agentCheck.installed) { console.error(chalk.red('Error: ...')); process.exit(1); }
- // In library functions, return errors instead: return { success: false, error: '...' };
-
Filename Comparison: When comparing filenames for existence checks, use case-insensitive comparison by converting to lowercase. This prevents issues with case-sensitive file systems while maintaining compatibility.
- const existingFilenames = new Set(existingRules.map((r) => r.filename.toLowerCase()));
- const existingFile = existingRules.find((r) => r.filename.toLowerCase() === filename.toLowerCase());
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.
- 2d ago First seen · 114 lines · 0 tokens per session scan A cdcc0513f9b2
codepatterns is a cursor rule published in the GitHub repository Srajangpt1/agent-rule-sync (12 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,380 tokens. A static security scan graded it A with 1 finding (runs shell commands). 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
as-contract-cast-smell
// ❌ WRONG — bypasses the family ContractSerializer seam const contract = JSON.parse(raw) as Contract; const contract = JSON.parse(raw) as Contract .
no-barrel-files
Avoid barrel files and unnecessary re-exports.
vue-typescript-patterns
Cursor rule "vue-typescript-patterns" from soaring-xiongkulu/easyaiot, covering vue3 + typescript 开发规范, vue 组件规范, vue sfc 组件规范, typescript 规范 and 状态管理.
project-overview
这是一个基于 uniapp + Vue3 + TypeScript + Vite5 + UnoCSS 的跨平台开发框架。.
compose-resource-lifecycles-with-layermerge
Cursor rule "compose-resource-lifecycles-with-layermerge" from PaulJPhilp/EffectPatterns, covering compose resource lifecycles with layer.merge and example.
frontend-patterns
React/TypeScript patterns for src/ code.