proactive-edge-case-handling

proactive-edge-case-handling is a cursor rule for Cursor from SeanLF/weather-mcp. It costs 1,027 tokens per session, scanned A, original, MIT.

A rule that looks for likely failure points during code implementation and adds handling for them. It checks code patterns for error handling and missing-value checks in several programming languages.

In plain words
What is it for?
Use it while implementing functions, methods, classes, or components to identify edge cases, document remaining risks, and check for basic defensive code.
Why use it?
It encourages the agent to consider invalid, missing, or unexpected inputs instead of stopping at the normal case.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it while implementing functions, methods, classes, or components to identify edge cases, document remaining risks, and check for basic defensive code.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/seanlf/weather-mcp/proactive-edge-case-handling
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.

Clone the repo
git clone --depth 1 https://github.com/SeanLF/weather-mcp

Made for: Cursor.

Wrote 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.

agentmods badge for proactive-edge-case-handling

README.md
[![agentmods](https://agentmods.dev/badge/rules/seanlf/weather-mcp/proactive-edge-case-handling.svg)](https://agentmods.dev/rules/seanlf/weather-mcp/proactive-edge-case-handling)
Your own site
<a href="https://agentmods.dev/rules/seanlf/weather-mcp/proactive-edge-case-handling"><img src="https://agentmods.dev/badge/rules/seanlf/weather-mcp/proactive-edge-case-handling.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,027 This file is loaded in full into every session.
When invoked 1,027 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.01027 $0.01027
Opus 5 $0.00513 $0.00513
Sonnet 5 $0.00205 $0.00205
Haiku 4.5 $0.00103 $0.00103

Measured 7d ago against content hash 2bd2d816ea55, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

proactive-edge-case-handling 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 7d 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/proactive-edge-case-handling.mdc · 154 lines

How it starts

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

filters:

  • type: event pattern: "code_implementation"
  • type: content pattern: "(?i)(function|method|class|component)"

actions:

  • type: transform pattern: "^([a-z]*\n)?.*?()?$" replacement: |

    Implementation with Edge Case Handling

    Potential Failure Points

    {list_of_identified_edge_cases}

    Handling Strategy

    {edge_case_handling_approach}

    ${2}
    

    Remaining Risks

    {unhandled_edge_cases_and_rationale}

  • type: validate conditions:

    • pattern: ".*" validationScript: | // Check for error handling patterns based on language const language = detectedLanguage; let requiredPatterns = [];

      if (language === "javascript" || language === "typescript") { requiredPatterns = [ /try\s*{.?}\scatch/s, /if\s*([^)]?null|undefined[^)]?)/, /?./ ]; } else if (language === "python") { requiredPatterns = [ /try:(?:\s.?)?except/s, /if\s+[\w\s.]+\s+is\s+None/, /if\s+not\s+[\w\s.]+:?/ ]; } else if (language === "java" || language === "kotlin") { requiredPatterns = [ /try\s{.?}\scatch/s, /if\s*([^)]?null[^)]?)/, /Optional<.*?>/ ]; }

      // Check if code has appropriate error handling const missingPatterns = requiredPatterns.filter(pattern => !pattern.test(code));

      if (missingPatterns.length > 0 && code.length > 100) { return { valid: false, message: "Code appears to be missing error handling for common edge cases." }; }

      return { valid: true };

  • type: suggest message: | When implementing any functionality, remember to:

    1. Identify all possible edge cases before coding
    2. Handle null/undefined/empty values explicitly
    3. Consider resource availability (network, disk, memory)
    4. Add appropriate error logging for debugging
    5. Use defensive programming techniques consistently

examples:

  • input: |

    function getUserData(userId) {
      const userData = database.fetchUser(userId);
      return {
        name: userData.name,
        email: userData.email,
        permissions: userData.permissions
      };
    }
    

    output: |

    Implementation with Edge Case Handling

    Potential Failure Points

    1. userId could be null, undefined, or invalid format
    2. Database operation could fail (connection issues, timeouts)
    3. User might not exist in the database
    4. User data might be incomplete (missing required fields)
    5. Database might return unexpected data types

    Handling Strategy

    • Input validation for userId
    • Explicit error handling for database operations
    • Null/undefined checks for user data
    • Default values for missing properties
    • Type checking/conversion for data safety
    function getUserData(userId) {
      // Input validation
      if (!userId || typeof userId !== 'string') {
        throw new Error('Invalid user ID provided');
      }
      
      try {
        // Handle potential database failures
        const userData = database.fetchUser(userId);
        
        // Handle missing user
        if (!userData) {
          return null;
        }
        
        // Handle potentially missing data with defaults and type safety
        return {
          name: userData.name || 'Unknown User',
          email: userData.email || '',
          permissions: Array.isArray(userData.permissions) ? userData.permissions : []
        };
      } catch (error) {
        // Log error for debugging
        console.error(`Failed to fetch user data for ID ${userId}:`, error);
        throw new Error(`Unable to retrieve user data: ${error.message}`);
      }
    }
    

Read the full file on GitHub · 154 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. 7d ago First seen · 154 lines · 1,027 tokens per session scan A 2bd2d816ea55

Subscribe to this mod's changes

proactive-edge-case-handling is a cursor rule published in the GitHub repository SeanLF/weather-mcp (2 stars, last pushed 1y ago), licensed MIT. It adds 1,027 tokens to every session, about $0.0051 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-31.