MDC Simple Example

A practical guide to understanding and implementing MDC rules

What are MDC Rules?

MDC rules are Markdown files (typically with a .mdc extension) that combine:

Born in the Cursor IDE's .cursor/rules directory, MDC rules are now envisioned as a flexible, tool-agnostic standard for RAG contexts, where AI models retrieve and apply relevant information dynamically.

Why Use MDC Rules?

Example MDC File

Here's an example of a simple .mdc file:

---
description: Guidelines for handling Python utility functions
patterns:
  - "**/utils/*.py"
  - "**/helpers/*.py"
---

# Python Utility Functions Guide

This document provides instructions for working with utility functions in Python files located in `utils` or `helpers` directories.

## Key Guidelines

1. **Naming**: 
   - Use snake_case for function names
   - Prefix with `util_` for general-purpose utilities

2. **Documentation**:
   - Include a docstring for every function
   - Use Google-style Python docstrings

3. **Structure**:
   - Keep functions short and focused (under 50 lines)
   - Group related utilities in the same file

## Example

```python
def util_format_name(first: str, last: str) -> str:
    """Format a full name from first and last name components.
      
    Args:
        first: The first name
        last: The last name
      
    Returns:
        A formatted full name string
    """
    return f"{first.title()} {last.title()}"

This .mdc file includes:

The file would typically be saved with a .mdc extension, like python_utils.mdc.