Skip to content

Instantly share code, notes, and snippets.

@architjn
Created June 9, 2025 06:52
Show Gist options
  • Save architjn/918791fa22560e626a160be602ac0d8f to your computer and use it in GitHub Desktop.
Save architjn/918791fa22560e626a160be602ac0d8f to your computer and use it in GitHub Desktop.

Revisions

  1. architjn created this gist Jun 9, 2025.
    52 changes: 52 additions & 0 deletions debugging-process.mdc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    ---
    description:
    globs:
    alwaysApply: true
    ---
    # Debugging Rule for Bug-Fixing Requests

    This rule ensures that when a user request involves solving a bug, Cursor adds minimal debug logs, leverages browser-based debugging tools, removes logs after resolution, and makes only the minimal changes necessary.

    ## Rule Instructions

    1. **Identify Bug-Fixing Requests**:
    - MUST check for keywords like "bug," "fix," "issue," "error," "debug," or "problem."
    - Example prompts: "Fix the login button crash," "Debug the API call failure," "Resolve the null pointer issue."

    2. **Add Minimal Debug Logs**:
    - MUST insert minimal console logs or debugging statements (e.g., `console.log`, `debugger`) only at critical points, such as:
    - Function entry/exit points directly related to the bug.
    - Key variable assignments tied to the issue.
    - Suspected error-prone areas (e.g., API calls, DOM manipulations).
    - Use concise, descriptive log messages, e.g., `console.log('LoginButton: userId:', userId)`.
    - Avoid excessive or redundant logs to minimize code changes.

    3. **Use Browser Debugging Tools**:
    - MUST simulate browser-based debugging:
    - Open browser developer tools (e.g., Chrome DevTools).
    - Check console for errors or logs.
    - Inspect network requests for failed API calls.
    - Use breakpoints or watch expressions for dynamic analysis.
    - For UI bugs, inspect only relevant DOM elements and CSS styles.

    4. **Resolve the Bug with Minimal Changes**:
    - MUST analyze logs and browser tool outputs to pinpoint the root cause.
    - Apply the smallest possible code changes to fix the bug.
    - Test the fix in the browser to confirm resolution.

    5. **Remove Debug Logs**:
    - After confirming the bug is fixed, MUST remove all added debug logs and statements.
    - Ensure no residual debugging code remains in the codebase.

    ## Example Workflow
    For a prompt like "Fix the login button crash":
    - Add `console.log('LoginButton: state:', state)` in the button’s event handler.
    - Open browser, check console for errors.
    - Identify the issue (e.g., missing user authentication token).
    - Fix with minimal change (e.g., add token validation).
    - Remove the `console.log` statement after verification.

    ## Constraints
    - Make only the minimal code changes necessary to resolve the bug.
    - Avoid modifying unrelated code sections.
    - Ensure browser-based debugging is relevant (e.g., skip for backend-only bugs).