004_auto_context

004_auto_context is a cursor rule for Cursor from forsonny/Enhanced-Cursor-Memory-Bank-System. It costs 0 tokens per session (1,100 once invoked), scanned A, original, MIT.

Rules for choosing which saved memory files to load based on the files and folders involved in the current coding task.

In plain words
What is it for?
Use them to select guidance for programming languages, tests, documentation, configuration, databases, and other project areas.
Why use it?
They help an agent use relevant project context without loading unrelated memories.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use them to select guidance for programming languages, tests, documentation, configuration, databases, and other project areas.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/forsonny/enhanced-cursor-memory-bank-system/004_auto_context
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/forsonny/Enhanced-Cursor-Memory-Bank-System

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 004_auto_context

README.md
[![agentmods](https://agentmods.dev/badge/rules/forsonny/enhanced-cursor-memory-bank-system/004_auto_context.svg)](https://agentmods.dev/rules/forsonny/enhanced-cursor-memory-bank-system/004_auto_context)
Your own site
<a href="https://agentmods.dev/rules/forsonny/enhanced-cursor-memory-bank-system/004_auto_context"><img src="https://agentmods.dev/badge/rules/forsonny/enhanced-cursor-memory-bank-system/004_auto_context.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,100 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.01100
Opus 5 $0.00000 $0.00550
Sonnet 5 $0.00000 $0.00220
Haiku 4.5 $0.00000 $0.00110

Measured 8d ago against content hash 6c8ffb17faf5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

004_auto_context 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 8d 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.

example/cursor/rules/004_auto_context.mdc · 137 lines

How it starts

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

Context Loading System

This rule defines how I should request and load relevant memory files into my context based on file types, locations, current activity, and project complexity.

Context Loading Principles

  • Request access to the most relevant memory files for the current task
  • Prioritize recently updated memory files over older ones
  • Include both short-term and long-term memory as appropriate
  • Adapt context requests based on current operational mode
  • Scale context depth with project complexity

File Type Associations

When working with specific file types, I should request access to these memory contexts:

*.ts, *.tsx, *.js, *.jsx → patterns.md (TypeScript/JavaScript patterns)
*.py → patterns.md (Python patterns)
*.go → patterns.md (Go patterns)
*.rs → patterns.md (Rust patterns)
*.java, *.kt → patterns.md (Java/Kotlin patterns)
*.rb → patterns.md (Ruby patterns)
*.php → patterns.md (PHP patterns)
*.cs → patterns.md (C# patterns)
*.cpp, *.c, *.h → patterns.md (C/C++ patterns)
**/test/**, **/tests/**, **/*.test.*, **/*.spec.* → patterns.md (Testing patterns)
**/docs/**, **/*.md → documentation.md
**/config/**, **/*.config.* → configuration.md
**/db/**, **/database/**, **/*db*.* → database.md
**/api/**, **/*api*.* → api.md
**/ui/**, **/components/**, **/*component*.* → ui.md
**/auth/**, **/*auth*.* → auth.md

Location-Based Context

The file's location in the project structure indicates I should request these additional contexts:

/ (root) → project_brief.md
/src/ → architecture.md
/src/components/ → ui.md
/src/api/ → api.md
/src/utils/ → utilities.md
/src/hooks/ → hooks.md
/src/contexts/ → contexts.md
/src/reducers/ → state.md
/src/db/ → database.md
/src/auth/ → auth.md
/src/types/ → types.md
/tests/ → testing.md
/docs/ → documentation.md
/config/ → configuration.md
/scripts/ → build.md

Activity-Based Context

Recent user activity suggests I should request these memory files:

Recently discussed test files → testing.md
Recently discussed build commands → build.md
Recently discussed documentation → documentation.md
Recently discussed API endpoints → api.md
Recently discussed database files → database.md
Recently discussed configuration → configuration.md
Recently discussed UI components → ui.md

Read the full file on GitHub · 137 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. 8d ago First seen · 137 lines · 1,100 tokens per session scan A 6c8ffb17faf5

Subscribe to this mod's changes

004_auto_context is a cursor rule published in the GitHub repository forsonny/Enhanced-Cursor-Memory-Bank-System (36 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,100 tokens. 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-30.

Related

Other cursor rules, from other repositories

compression-safety

Cursor rule "compression-safety" from yvgude/lean-ctx, covering compression safety — prevent lean-ctx marker corruption, the problem, rules for all agents, never write compressed content to files and file restoration commands.

yvgude/lean-ctx · 399 tokens

honcho_rules

Honcho persistent memory — capture every conversation, recall past context, and build a growing model of the user. Activates on every conversation.

matthewdcage/llm-swarm-router · 1,412 tokens

nauro-adopt

Seeds Nauro's project store from an existing repo. Use after nauro adopt has run locally. On filesystem-capable surfaces, reads docs (README, manifests, ADRs, Memory-Bank) for rationale and inspects code, config, tests, lockfiles, and recent git history for evidence, then surfaces targeted probes that turn evidence…

Nauro-AI/nauro · 89 tokens

nauro-context

Writes durable shared context into Nauro's project store so other agents (a later session or a parallel one) can discover and pull it, finds and reads context another agent left, or captures a resumable brief so your own next session in this environment picks up cleanly. Three modes. Author writes a shared brief for…

Nauro-AI/nauro · 272 tokens

memforge-auto-recall

Rules that make an AI assistant automatically retrieve and save team memories during conversations.

zql0805/memforge · 7,463 tokens

compendium

Prefer the Compendium MCP gateway to shrink noisy/large context before pasting it into the conversation.

hocestnonsatis/Compendium · 564 tokens