agentleFS
byronwadebyronwade/memoria/.cursor/rules/memoria.mdc

memoria / rules

Cursor rule1 starsChanged 12 months agoMITView on GitHub

Memoria MCP integration - provides AI with senior developer intuition through git forensics

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 4,373 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

Show its rules and text

We split this memoria.mdc into the rules it gives an agent

24 rules. About 0 are common, 21 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈21

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before editing ANY code file

    line 18
  2. Distinctive:

    When asked to modify, refactor, or fix a file

    line 19
  3. Distinctive:

    Before deleting or moving files

    line 20
  4. Distinctive:

    CRITICAL: Always use the ABSOLUTE path, not relative.

    line 32
  5. Distinctive:

    Read the coupled files if risk is HIGH or CRITICAL

    line 45
  6. Distinctive:

    Verify all files in the pre-flight checklist

    line 47
  7. Distinctive:

    Purpose: Search git history to understand WHY code was written a certain way.

    line 53
  8. Distinctive:

    IMPORTANT: Use SHORT, SPECIFIC KEYWORDS (1-3 words).

    line 55
  9. Distinctive:

    When you see "weird" or confusing code

    line 58
  10. Distinctive:

    Before removing code that looks unnecessary

    line 59
  11. Distinctive:

    When user asks "why is this here?"

    line 60
  12. Distinctive:

    When investigating a bug's origin

    line 61
  13. Distinctive:

    When you need context about a setTimeout, try/catch, or workaround

    line 62
  14. Distinctive:

    When investigating specific lines of code:

    line 88
  15. Distinctive:

    Commit hashes, dates, and authors

    line 104
  16. Very specific:

    Call: ask_history with query "setTimeout" and the file path

    line 111
  17. Very specific:

    ALWAYS call analyze_file before modifying any code file: - no exceptions

    line 119
  18. Distinctive:

    NEVER create workaround scripts: - use the MCP tools directly

    line 120
  19. Distinctive:

    If risk is CRITICAL (75+): Stop and ask the user before proceeding

    line 121
  20. Distinctive:

    If risk is HIGH (50-74): Read all coupled files before making changes

    line 122
  21. Very specific:

    Before removing "unnecessary" code: Call ask_history to check if it's a bug fix

    line 123
  22. Distinctive:

    If the tool returns an error:

    line 142
  23. Distinctive:

    "File not found": Check the path is absolute and correct

    line 144
  24. Distinctive:

    Never fall back to creating scripts - report the error to the user instead.

    line 147

≈ “Common” is an estimate: at least 1 in 5 of the 7,324 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
memoria.mdc
---
description: Memoria MCP integration - provides AI with senior developer intuition through git forensics
globs: ["**/*.{ts,tsx,js,jsx,py,go,rs,java,rb,php,swift,kt,c,cpp,h,hpp,cs}"]
alwaysApply: true
---
<!-- MEMORIA:START -->


# Memoria MCP Tools

Memoria gives you memory of what broke before. ALWAYS use these tools - never create workaround scripts.

## Tool 1: `analyze_file`

**Purpose:** Analyze a file BEFORE modifying it to understand hidden dependencies, risk level, and coupled files.

**When to use:**
- Before editing ANY code file
- When asked to modify, refactor, or fix a file
- Before deleting or moving files

**How to call:**
```json
{
  "tool": "analyze_file",
  "arguments": {
    "path": "/absolute/path/to/file.ts"
  }
}
```

**CRITICAL:** Always use the ABSOLUTE path, not relative.

**What you get back:**
- **Risk Score (0-100):** LOW (0-24), MEDIUM (25-49), HIGH (50-74), CRITICAL (75+)
- **Coupled Files:** Files that historically change together - check these before committing
- **Static Dependents:** Files that import this file - will break if you change the API
- **Volatility:** How "buggy" this file has been historically
- **Pre-flight Checklist:** Files to verify before your change is complete

**Example workflow:**
1. User asks: "Fix the bug in UserService.ts"
2. FIRST call: `analyze_file` with `/project/src/services/UserService.ts`
3. Review the coupled files and risk score
4. Read the coupled files if risk is HIGH or CRITICAL
5. Make your changes
6. Verify all files in the pre-flight checklist

---

## Tool 2: `ask_history`

**Purpose:** Search git history to understand WHY code was written a certain way. Solves Chesterton's Fence - understand before changing.

**IMPORTANT:** Use SHORT, SPECIFIC KEYWORDS (1-3 words). Do NOT use full sentences - git grep requires exact matches.

**When to use:**
- When you see "weird" or confusing code
- Before removing code that looks unnecessary
- When user asks "why is this here?"
- When investigating a bug's origin
- When you need context about a setTimeout, try/catch, or workaround

**How to call:**
```json
{
  "tool": "ask_history",
  "arguments": {
    "query": "setTimeout",
    "path": "/optional/path/to/scope/search.ts",
    "searchType": "both",
    "limit": 20
  }
}
```

**Parameters:**
| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| `query` | Yes | - | Short keyword (e.g., "setTimeout", "Safari", "race condition") |
| `path` | No | repo root | Scope search to specific file or directory |
| `searchType` | No | "both" | Where to search: "message", "diff", or "both" |
| `limit` | No | 20 | Max results to return |
| `startLine` | No | - | Start line for Sherlock Mode (line-range search) |
| `endLine` | No | - | End line for Sherlock Mode (line-range search) |

**Sherlock Mode (Line-Range Search):**
When investigating specific lines of code:
```json
{
  "tool": "ask_history",
  "arguments": {
    "query": "",
    "path": "/project/src/utils.ts",
    "searchType": "diff",
    "startLine": 100,
    "endLine": 150
  }
}
```
This finds ALL commits that ever touched lines 100-150, showing the full evolution of that code block.

**What you get back:**
- Commit hashes, dates, and authors
- Full commit messages explaining WHY changes were made
- Files changed in each commit
- Warnings if bug fixes are detected (don't remove that code!)

**Example workflow:**
1. You see: `setTimeout(() => resolve(), 0)` and think "this is useless"
2. Call: `ask_history` with query "setTimeout" and the file path
3. Find: Commit from 2 years ago - "Fix race condition in Safari where API returns before DOM ready"
4. Decision: Keep the setTimeout, it's a critical Safari fix

---

## MANDATORY RULES

1. **ALWAYS call `analyze_file` before modifying any code file** - no exceptions
2. **NEVER create workaround scripts** - use the MCP tools directly
3. **If risk is CRITICAL (75+):** Stop and ask the user before proceeding
4. **If risk is HIGH (50-74):** Read all coupled files before making changes
5. **Before removing "unnecessary" code:** Call `ask_history` to check if it's a bug fix
6. **Use absolute paths** - the tools require full paths like `/Users/name/project/src/file.ts`

---

## Quick Reference

| Situation | Tool | Example |
|-----------|------|---------|
| About to edit a file | `analyze_file` | `{"path": "/abs/path/to/file.ts"}` |
| See confusing code | `ask_history` | `{"query": "workaround", "path": "/abs/path/to/file.ts"}` |
| User asks "why is X here?" | `ask_history` | `{"query": "X", "searchType": "both"}` |
| Investigating specific lines | `ask_history` | `{"query": "", "startLine": 50, "endLine": 75}` |
| Before deleting code | `ask_history` | `{"query": "deleted_function_name"}` |

---

## Error Handling

If the tool returns an error:
- **"Not a git repository":** The path is outside a git repo
- **"File not found":** Check the path is absolute and correct
- **"No results":** Try broader search terms or remove the path filter

Never fall back to creating scripts - report the error to the user instead.

<!-- MEMORIA:END -->


# Memoria MCP Tools

Memoria gives you memory of what broke before. ALWAYS use these tools - never create workaround scripts.

## Tool 1: `analyze_file`

**Purpose:** Analyze a file BEFORE modifying it to understand hidden dependencies, risk level, and coupled files.

**When to use:**
- Before editing ANY code file
- When asked to modify, refactor, or fix a file
- Before deleting or moving files

**How to call:**
```json
{
  "tool": "analyze_file",
  "arguments": {
    "path": "/absolute/path/to/file.ts"
  }
}
```

**CRITICAL:** Always use the ABSOLUTE path, not relative.

**What you get back:**
- **Risk Score (0-100):** LOW (0-24), MEDIUM (25-49), HIGH (50-74), CRITICAL (75+)
- **Coupled Files:** Files that historically change together - check these before committing
- **Static Dependents:** Files that import this file - will break if you change the API
- **Volatility:** How "buggy" this file has been historically
- **Pre-flight Checklist:** Files to verify before your change is complete

**Example workflow:**
1. User asks: "Fix the bug in UserService.ts"
2. FIRST call: `analyze_file` with `/project/src/services/UserService.ts`
3. Review the coupled files and risk score
4. Read the coupled files if risk is HIGH or CRITICAL
5. Make your changes
6. Verify all files in the pre-flight checklist

---

## Tool 2: `ask_history`

**Purpose:** Search git history to understand WHY code was written a certain way. Solves Chesterton's Fence - understand before changing.

**When to use:**
- When you see "weird" or confusing code
- Before removing code that looks unnecessary
- When user asks "why is this here?"
- When investigating a bug's origin
- When you need context about a setTimeout, try/catch, or workaround

**How to call:**
```json
{
  "tool": "ask_history",
  "arguments": {
    "query": "setTimeout",
    "path": "/optional/path/to/scope/search.ts",
    "searchType": "both",
    "limit": 20
  }
}
```

**Parameters:**
| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| `query` | Yes | - | Keyword to search (e.g., "setTimeout", "workaround", "Safari") |
| `path` | No | repo root | Scope search to specific file or directory |
| `searchType` | No | "both" | Where to search: "message", "diff", or "both" |
| `limit` | No | 20 | Max results to return |
| `startLine` | No | - | Start line for Sherlock Mode (line-range search) |
| `endLine` | No | - | End line for Sherlock Mode (line-range search) |

**Sherlock Mode (Line-Range Search):**
When investigating specific lines of code:
```json
{
  "tool": "ask_history",
  "arguments": {
    "query": "",
    "path": "/project/src/utils.ts",
    "searchType": "diff",
    "startLine": 100,
    "endLine": 150
  }
}
```
This finds ALL commits that ever touched lines 100-150, showing the full evolution of that code block.

**What you get back:**
- Commit hashes, dates, and authors
- Full commit messages explaining WHY changes were made
- Files changed in each commit
- Warnings if bug fixes are detected (don't remove that code!)

**Example workflow:**
1. You see: `setTimeout(() => resolve(), 0)` and think "this is useless"
2. Call: `ask_history` with query "setTimeout" and the file path
3. Find: Commit from 2 years ago - "Fix race condition in Safari where API returns before DOM ready"
4. Decision: Keep the setTimeout, it's a critical Safari fix

---

## MANDATORY RULES

1. **ALWAYS call `analyze_file` before modifying any code file** - no exceptions
2. **NEVER create workaround scripts** - use the MCP tools directly
3. **If risk is CRITICAL (75+):** Stop and ask the user before proceeding
4. **If risk is HIGH (50-74):** Read all coupled files before making changes
5. **Before removing "unnecessary" code:** Call `ask_history` to check if it's a bug fix
6. **Use absolute paths** - the tools require full paths like `/Users/name/project/src/file.ts`

---

## Quick Reference

| Situation | Tool | Example |
|-----------|------|---------|
| About to edit a file | `analyze_file` | `{"path": "/abs/path/to/file.ts"}` |
| See confusing code | `ask_history` | `{"query": "workaround", "path": "/abs/path/to/file.ts"}` |
| User asks "why is X here?" | `ask_history` | `{"query": "X", "searchType": "both"}` |
| Investigating specific lines | `ask_history` | `{"query": "", "startLine": 50, "endLine": 75}` |
| Before deleting code | `ask_history` | `{"query": "deleted_function_name"}` |

---

## Error Handling

If the tool returns an error:
- **"Not a git repository":** The path is outside a git repo
- **"File not found":** Check the path is absolute and correct
- **"No results":** Try broader search terms or remove the path filter

Never fall back to creating scripts - report the error to the user instead.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.