memoria / rules
Cursor rule2 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 1,533 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.
- .claude/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
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
- Distinctive: line 18
Before editing ANY code file
- Distinctive: line 19
When asked to modify, refactor, or fix a file
- Distinctive: line 20
Before deleting or moving files
- Distinctive: line 32
CRITICAL: Always use the ABSOLUTE path, not relative.
- Distinctive: line 45
Read the coupled files if risk is HIGH or CRITICAL
- Distinctive: line 47
Verify all files in the pre-flight checklist
- Distinctive: line 53
Purpose: Search git history to understand WHY code was written a certain way.
- Distinctive: line 55
IMPORTANT: Use SHORT, SPECIFIC KEYWORDS (1-3 words).
- Distinctive: line 58
When you see "weird" or confusing code
- Distinctive: line 59
Before removing code that looks unnecessary
- Distinctive: line 60
When user asks "why is this here?"
- Distinctive: line 61
When investigating a bug's origin
- Distinctive: line 62
When you need context about a setTimeout, try/catch, or workaround
- Distinctive: line 88
When investigating specific lines of code:
- Distinctive: line 104
Commit hashes, dates, and authors
- Very specific: line 111
Call: ask_history with query "setTimeout" and the file path
- Very specific: line 119
ALWAYS call
analyze_filebefore modifying any code file: - no exceptions - Distinctive: line 120
NEVER create workaround scripts: - use the MCP tools directly
- Distinctive: line 121
If risk is CRITICAL (75+): Stop and ask the user before proceeding
- Distinctive: line 122
If risk is HIGH (50-74): Read all coupled files before making changes
- Very specific: line 123
Before removing "unnecessary" code: Call ask_history to check if it's a bug fix
- Distinctive: line 142
If the tool returns an error:
- Distinctive: line 144
"File not found": Check the path is absolute and correct
- Distinctive: line 147
Never fall back to creating scripts - report the error to the user instead.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 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.
Files
---
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.
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
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.

