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/starch-uk/sca-extra/importantgit clone --depth 1 https://github.com/starch-uk/sca-extraWhat 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.04052 | $0.04052 |
| Opus 5 | $0.02026 | $0.02026 |
| Sonnet 5 | $0.00810 | $0.00810 |
| Haiku 4.5 | $0.00405 | $0.00405 |
Grade A, and why
IMPORTANT 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.
- **Shell Command Execution**: Use `execFileSync` instead of `execSync` when How it starts
The opening of the file, as written. The whole thing — 296 lines — stays where its author put it; the contents beside it link to each section on GitHub.
When working with PMD rules, XPath expressions, Apex AST structure, testing, or code analysis, always reference these documentation files:
Core PMD & Rule Development:
- @docs/PMD.md - PMD (source code analyzer) quick reference and essentials for Salesforce Code Analyzer integration (includes Apex AST reference)
- @docs/XPATH31.md - XPath 3.1 syntax, functions, and expressions reference
- @docs/CODEANALYZER.md - Quick reference for configuring
code-analyzer.ymlwith all engines and properties (includes Regex engine configuration)
Documentation & Suppression:
- @docs/APEXDOC.md - ApexDoc syntax, tags, and documentation format for Apex code
- @docs/PMD.md - How to suppress PMD rule violations using annotations, comments, and rule properties (see Suppressing Warnings section)
Testing & Development:
- @docs/JEST.md - Jest 30.0 API reference for writing and running tests
- @docs/PNPM.md - pnpm package manager reference for dependency management and workspace configuration
- @docs/HUSKY.md - Husky reference for Git hooks management and configuration
Additional Code Analyzer Engines:
- @docs/PMD.md - Copy/Paste Detector (CPD) engine for duplicate code detection across multiple languages (see CPD section)
- @docs/ESLINT.md - ESLint engine configuration for JavaScript, TypeScript, and LWC static analysis
Graph Engine Documentation:
- @docs/GRAPHENGINE.md - Salesforce Graph Engine configuration and usage
- @docs/GREMLIN.md - Gremlin query language reference for graph traversal
- @docs/TINKERPOP.md - Apache TinkerPop framework reference for graph computing
- @docs/GRAPHML.md - GraphML format for graph serialization
- @docs/GRAPHSON.md - GraphSON format for graph serialization
- @docs/GRYO.md - Gryo binary format for graph serialization
- @docs/GRAPHBINARY.md - GraphBinary format for graph serialization
Use these documents to:
- Understand PMD fundamentals and how it integrates with Salesforce Code Analyzer
- Understand how Apex code is represented in the PMD AST (see PMD.md Apex AST Reference section)
- Write correct XPath expressions that match AST nodes
- Reference XPath 3.1 syntax and functions when writing rule queries
- Ensure XPath expressions correctly traverse the AST structure
- Access rule examples, violations, valid code patterns, and configuration properties
- Configure
code-analyzer.ymlwith proper engines and properties - Write and maintain Jest tests using the Jest 30.0 API
- Manage dependencies and workspaces using pnpm
- Configure Git hooks using Husky
- Understand ApexDoc syntax and documentation requirements
- Suppress rule violations when necessary (see PMD.md Suppressing Warnings section)
- Configure additional Code Analyzer engines (CPD, ESLint, Regex)
- Understand graph engine configuration and usage (Graph Engine, Gremlin, TinkerPop)
- Reference graph serialization formats (GraphML, GraphSON, Gryo, GraphBinary)
When creating or modifying PMD rules:
- Reference @docs/PMD.md for PMD fundamentals and integration details
- Check @docs/PMD.md Apex AST Reference section for the correct AST node types and patterns
- Use @docs/XPATH31.md for XPath 3.1 syntax and function reference
- Use @docs/CODEANALYZER.md for configuring
code-analyzer.ymlwith engines and properties - Use @docs/CODEANALYZER.md Regex Engine section for creating pattern-based Regex rules
- Reference @docs/PMD.md Suppressing Warnings section when implementing suppression mechanisms
- When fixing rules to comply with unit tests, always start by dumping the
AST - Use
pnpm ast-dump <apex-file>to inspect the actual AST structure of test fixtures before modifying XPath expressions. This ensures you understand the exact node structure and relationships before making changes. - XML Schema Location: The
xsi:schemaLocationattribute in ruleset XML files must usehttp://pmd.sourceforge.net/ruleset/2.0.0(with dots) for the namespace andhttps://pmd.sourceforge.io/ruleset_2_0_0.xsd(with underscores) for the schema URL. Do not use2_0_0.xsdin the namespace. - Apex File Structure: Apex files can only contain one top-level class. Test fixtures must use a single class with multiple methods or fields to test different scenarios, not multiple top-level classes.
- Single-Line Comments in AST: PMD's Apex parser does not include
single-line comments (
//) in the AST. Only block comments (/* */) and ApexDoc comments (/** */) are included asFormalCommentnodes. For rules that need to detect single-line comments (e.g.,// prettier-ignore,// NOPMD), use regex-based rules instead of PMD XPath rules. See@docs/CODEANALYZER.mdRegex Engine section for creating regex-based rules. - Regex Rules Must Be Added to code-analyzer.yml: When creating regex
rules, you must add them to
code-analyzer.ymlunderengines.regex.custom_rules. Unlike PMD rules (which are XML files inrulesets/), regex rules are defined directly incode-analyzer.yml. Always add new regex rules to the repository'scode-analyzer.ymlfile, not just in test files. SeeCONTRIBUTING.mdfor complete instructions. - Every rule should use properties for things that should be configurable - Add configurable properties (thresholds, lists, etc.) instead of hardcoding values
- New subfolders can be created under rulesets/ - Make sure they follow PMD's 8 standard categories (bestpractices, codestyle, design, documentation, errorprone, multithreading, performance, security)
- Every rule must have both positive and negative test cases - Create test
fixtures in
tests/fixtures/positive/andtests/fixtures/negative/covering all parts of the XPath expression - XML element order must be correct - PMD ruleset XML files must follow
the PMD Ruleset XML Schema.
Elements within
<rule>must appear in this order:description→priority→properties→exclude→example. Usepnpm check-xml-orderto verify order, orpnpm fix-xml-orderto automatically fix it. These scripts use XML libraries (xmldom) to properly parse and manipulate XML, ensuring all elements (including multiple examples) are preserved. - All code should be linted and formatted following any changes - Run
pnpm formatandpnpm lint(orpnpm lint:fix). CRITICAL: Always run lint commands with full permissions - Userequired_permissions: ['all']when running lint commands. ESLint will fail withEPERM: operation not permittederrors when run without full permissions due to pnpm's module resolution requiring full filesystem access to read files fromnode_modules/.pnpm/. - All tests should be run and regressions checked following any changes -
Run
pnpm testand verify no test regressions. CRITICAL: Always runpnpm testwith full permissions the first time - Userequired_permissions: ['all']when running test commands. Jest will fail with module resolution errors (e.g., "Cannot find module '@jest/test-sequencer'") when run without full permissions due to pnpm's module resolution requiring full filesystem access. After the first successful run, subsequent runs may work without full permissions, but always use full permissions for initial test runs. Reference @docs/JEST.md for Jest API usage when writing or modifying tests. - README.md should be updated with any pertinent changes - Document new
rules, rule changes, or significant updates in the README. When adding a new
rule:
- Add a short description in the rule categories section (e.g., under "Documentation Quality")
- Add a comprehensive rule documentation section with priority, source link, description, violations, and valid code examples
- Update the rule count in the "Rule Categories" section
- Add the rule to the comprehensive
code-analyzer.ymlexample in README.md
- PLAN.md is a planning document - PLAN.md should be written as if the
project has not yet been created. It details what needs to happen to create
the project, not the current state of the project. PLAN.md should:
- Use future tense ("will be", "should be", "needs to", "must be")
- Describe implementation steps and phases
- Include requirements and prerequisites
- Focus on what needs to be done to create the project
- NOT describe current project state, what already exists, or how things currently work
- NOT include historical context or references to past states
- The current state of the project is documented in README.md and other documentation files, not in PLAN.md
- Test XPath expressions against both positive and negative test cases
- Benchmark stress tests must be kept up to date - When adding or
modifying rules, update the benchmark fixtures:
- New rules: Add violations to
benchmarks/fixtures/stress-test-all-rules.clsand the appropriate category-specific fixture (e.g.,stress-code-style.cls,stress-design.cls,stress-best-practices.cls) - Rule modifications: Update existing violations in stress test fixtures to reflect rule changes
- Target 10-20 violations per rule in stress tests to properly benchmark performance
- Use realistic code patterns that developers might actually write
- Update
benchmarks/FIXTURES.mdwith new violation counts and rule coverage - Run benchmarks after updates:
pnpm benchmarkto verify performance - Regenerate baseline if needed:
pnpm benchmark -- --baselineafter significant changes
- New rules: Add violations to
- Stress test fixtures location:
benchmarks/fixtures/contains comprehensive stress-test files:stress-test-all-rules.cls- Comprehensive fixture with violations across all 43 PMD rulesstress-code-style.cls- Code style rules (21 rules, 300+ violations, includes naming)stress-design.cls- Design rules (15 rules, 130+ violations, includes structure and method signatures)stress-best-practices.cls- Best practices rules (5 rules, 100+ violations, includes modifiers)stress-documentation.cls- Documentation rules (2 rules, 30+ violations)- Note: Regex rules (NoConsecutiveBlankLines, ProhibitPrettierIgnore, ProhibitSuppressWarnings, NoLongLines) are not included in PMD benchmark fixtures as they use a different engine.
- Running specific tests: When debugging or working on a specific rule,
use Jest's
--testNamePatternflag to run only matching tests instead of the full test suite. This saves time and focuses output. Reference @docs/JEST.md for Jest CLI options and API. The pattern matches test names using regex:- Run all tests for a specific rule:
pnpm test -- --testNamePattern="RuleName"(matches any test containing "RuleName") - Run only detection tests:
pnpm test -- --testNamePattern="should detect"(matches tests with "should detect" in the name) - Run a specific test for a rule:
pnpm test -- --testNamePattern="RuleName.*should detect"(matches tests starting with "RuleName" and containing "should detect") - Concrete examples:
pnpm test -- --testNamePattern="AnnotationBeforeComment"- Runs all AnnotationBeforeComment tests (both positive and negative cases)pnpm test -- --testNamePattern="ProhibitSuppressWarnings.*should detect"- Runs only the "should detect" test for ProhibitSuppressWarnings rulepnpm test -- --testNamePattern="should not flag"- Runs all tests that verify rules don't produce false positives
- Run all tests for a specific rule:
- Using PMD AST dump tool: Use the AST dump script to inspect the actual
AST structure of Apex files:
pnpm ast-dump <apex-file>- Dump AST for a file (text format)pmd ast-dump --file=<apex-file> -l apex -f xml- Dump AST in XML formatpmd ast-dump --file=<apex-file> -l apex -f xml > output.ast.xml- Save AST to file- Examples:
pnpm ast-dump tests/fixtures/negative/codestyle/ProhibitSuppressWarnings.clspmd ast-dump --file=tests/fixtures/positive/documentation/AnnotationBeforeComment.cls -l apex -f xml | grep -E "Method|FormalComment|Annotation"
- Note: Files with syntax errors cannot be parsed. Fix syntax errors first or use valid test files for AST inspection.
- Tip: Use AST dump to understand node relationships, attributes, and structure before writing XPath expressions.
- PMD command execution: Always use the
-r <file>flag when running PMD commands to avoid progressbar rendering conflicts with STDOUT. PMD will show a warning:[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r <file> to output the report to a file instead.To prevent this warning, always redirect PMD output to a file using the-rflag:- Correct:
pmd check --no-cache -d "${file}" -R "${ruleset}" -f xml -r "${outputFile}" - Incorrect:
pmd check --no-cache -d "${file}" -R "${ruleset}" -f xml(outputs to STDOUT, causes warning) - The
tests/helpers/pmd-helper.jsfile already implements this correctly - any new PMD invocations should follow the same pattern - When running PMD manually or in scripts, always use
-r <file>to write output to a file, then read the file contents
- Correct:
- Version bumping: Always run
pnpm bump-rule-versionsafter making rule changes - This script automatically bumps rule versions based on changes:- Major bump (X.0.0): Rules with failing existing tests (tests that existed at HEAD) - indicates breaking changes
- Minor bump (0.X.0): Rules with new tests - indicates new features
- Patch bump (0.0.X): Other changed rules - indicates bug fixes/improvements
- The script runs tests, detects failures, checks git history, and bumps versions accordingly
- Run this before committing rule changes to ensure proper versioning
- Script security: Scripts must implement security best practices -
When creating or modifying scripts in
scripts/, follow these security guidelines:- File System Operations: Use file descriptors instead of file paths to
prevent time-of-check to time-of-use (TOCTOU) race conditions:
- Never use
fs.existsSync()before opening files - This creates a race condition. Instead, open files directly and handle errors if they don't exist - Use
fs.openSync()with appropriate flags (O_RDWRfor read-write,O_CREAT | O_WRONLY | O_TRUNCfor write-only,O_RDONLYfor read-only) - Wrap file open operations in try-catch to handle cases where files don't exist
- Use the same file descriptor for both read and write operations when possible
- Always close file descriptors in
finallyblocks to ensure cleanup - Use
fs.readFileSync(fd, ...)andfs.writeFileSync(fd, ...)with file descriptors instead of paths - Use
fs.ftruncateSync(fd, 0)before writing when overwriting files - Example pattern: Open file directly, catch errors if it doesn't exist, then read/write using the file descriptor
- Never use
- Shell Command Execution: Use
execFileSyncinstead ofexecSyncwhen passing dynamic paths or arguments:- Pass command and arguments separately:
execFileSync('git', ['show', path], {...}) - Avoid constructing shell commands with string interpolation
- This prevents shell command injection vulnerabilities
- Pass command and arguments separately:
- Path Validation (for user input): Scripts accepting file paths from
user input (e.g., from
process.argvor command line arguments) must:- Use the
sanitize-filenamepackage to sanitize file paths, eliminating dangerous characters - Validate paths to prevent path traversal attacks (reject paths
containing
..sequences) - Reject absolute paths when relative paths are expected (use
path.isAbsolute()) - Use
fs.realpathSync()to resolve symbolic links and validate that resolved paths are within expected directories - Implement defense in depth with multiple validation layers
- Use the
- See
scripts/benchmark.js,scripts/bump-rule-versions.js,scripts/check-performance-regressions.js, andscripts/ast-dump.shfor reference implementations - For more details, see SECURITY.md and CONTRIBUTING.md (Security Best Practices for Scripts section)
- File System Operations: Use file descriptors instead of file paths to
prevent time-of-check to time-of-use (TOCTOU) race conditions:
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 · 296 lines · 4,052 tokens per session scan A 87e12a1b3629
IMPORTANT is a cursor rule published in the GitHub repository starch-uk/sca-extra (7 stars, last pushed 3mo ago), licensed MIT. It adds 4,052 tokens to every session, about $0.0203 per session on Opus 5. 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-31.
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.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.