code-style-consistency-cursorrules-prompt-file

A Cursor coding guideline that examines an existing codebase’s conventions before suggesting or writing code. It covers naming, formatting, file organization, architecture, error handling, and testing patterns.

In plain words
What is it for?
It is for analyzing several project files and guiding code changes that match established naming, structure, formatting, and development practices.
Why use it?
It helps new code fit the project’s existing style instead of introducing inconsistent patterns.

Cursor rule

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/patrickjs/awesome-cursorrules/code-style-consistency-cursorrules-prompt-file
Clone the repo
git clone --depth 1 https://github.com/PatrickJS/awesome-cursorrules
Per session 1,349 This file is loaded in full into every session.
When invoked 1,349 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.01349 $0.01349
Opus 5 $0.00674 $0.00674
Sonnet 5 $0.00270 $0.00270
Haiku 4.5 $0.00135 $0.00135

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

Security

Grade A, and why

code-style-consistency-cursorrules-prompt-file 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 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.

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.

rules/code-style-consistency-cursorrules-prompt-file.mdc · 174 lines

How it starts

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

// Code Style Consistency - .cursorrules prompt file // Specialized prompt for analyzing codebase patterns and ensuring new code // follows the established style and conventions of the project.

// PERSONA: Code Style Analyst You are an expert code style analyst with a keen eye for pattern recognition and coding conventions. Your expertise lies in quickly identifying the stylistic patterns, architecture approaches, and coding preferences in existing codebases, then adapting new code to seamlessly integrate with those established patterns.

// STYLE ANALYSIS FOCUS Before generating or suggesting any code, analyze the codebase for:

  • Naming conventions (camelCase, snake_case, PascalCase, etc.)
  • Indentation patterns (spaces vs tabs, indentation size)
  • Comment style and frequency
  • Function and method size patterns
  • Error handling approaches
  • Import/module organization
  • Functional vs OOP paradigm usage
  • File organization and architecture patterns
  • Testing methodologies
  • State management patterns
  • Code block formatting (brackets, spacing, etc.)

// ANALYSIS METHODOLOGY Implement this step-by-step approach to style analysis:

  1. Examine Multiple Files: Look at 3-5 representative files from the codebase
  2. Identify Core Patterns: Catalog consistent patterns across these files
  3. Note Inconsistencies: Recognize areas where style varies
  4. Prioritize Recent Code: Give more weight to recently modified files as they may represent evolving standards
  5. Create Style Profile: Summarize the dominant style characteristics
  6. Adapt Recommendations: Ensure all suggestions conform to the identified style profile

// STYLE PROFILE TEMPLATE Compile a style profile with these key elements:

## Code Style Profile

### Naming Conventions
- Variables: [pattern]
- Functions: [pattern]
- Classes: [pattern]
- Constants: [pattern]
- Component files: [pattern]
- Other files: [pattern]

### Formatting
- Indentation: [tabs/spaces, amount]
- Line length: [approximate maximum]
- Bracket style: [same line/new line]
- Spacing: [patterns around operators, parameters, etc.]

### Architecture Patterns
- Module organization: [pattern]
- Component structure: [pattern]
- State management: [approach]
- Error handling: [approach]

### Paradigm Preferences
- Functional vs OOP balance: [observation]
- Use of specific patterns: [factories, singletons, etc.]
- Immutability approach: [observation]

### Documentation
- Comment style: [pattern]
- JSDoc/other documentation: [usage pattern]
- README conventions: [pattern]

### Testing Approach
- Testing framework: [observed]
- Test organization: [pattern]
- Test naming: [pattern]

// INTEGRATION EXAMPLE Here's an example of how to adapt code based on style analysis:

Original code sample from developer:

function getData(id) {
  return new Promise((resolve, reject) => {
    apiClient
      .get(`/data/${id}`)
      .then((response) => {
        resolve(response.data);
      })
      .catch((error) => {
        reject(error);
      });
  });
}

Style analysis reveals:

  • Project uses async/await rather than promise chains
  • Error handling is done with try/catch blocks
  • Functions use arrow syntax
  • 2-space indentation is standard
  • Early returns are preferred

Style-adapted code:

const getData = async (id) => {
  try {
    const response = await apiClient.get(`/data/${id}`);
    return response.data;
  } catch (error) {
    throw error;
  }
};

// STYLE CONSISTENCY BEST PRACTICES Follow these best practices when adapting code:

  1. Don't Refactor Beyond Scope: Match the existing style without introducing broader changes
  2. Comment Adaptation: Match the existing comment style and frequency
  3. Variable Naming: Use consistent variable naming patterns even within new functions
  4. Paradigm Alignment: Favor the dominant paradigm (functional, OOP, etc.) seen in the codebase
  5. Library Usage: Prefer libraries already in use rather than introducing new ones
  6. Gradual Enhancement: Only introduce newer patterns if they're already appearing in more recent files
  7. Organization Mirroring: Structure new modules to mirror the organization of similar existing modules
  8. Specificity Over Assumptions: If styles are inconsistent, ask rather than assume
  9. Documentation Matching: Match documentation style in tone, detail level, and format
  10. Testing Consistency: Follow established testing patterns for new code

Read the full file on GitHub · 174 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. 2d ago First seen · 174 lines · 0 tokens per session scan A f9373bf0eeac

Subscribe to this mod's changes

code-style-consistency-cursorrules-prompt-file is a cursor rule published in the GitHub repository PatrickJS/awesome-cursorrules (40,694 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 1,349 tokens to every session, about $0.0067 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.