Rules for ultra context, memories, lessons, scratchpad with plan and act modes

That’s really interesting! I had previously thought about creating an ontology (see here) using JSON schemas to define certain concepts. For example, some aspects of your architecture could be represented as clearly defined schemas that you can reference later. However, I wasn’t systematic enough in my approach back then.

Now I’m wondering if this more dynamic, learning-oriented perspective could extend with more than just a summarization, as @bmadcode suggested. Perhaps it could lead to a more complete consolidation that includes stricter definitions using schemas or something similar. In theory, this would allow the agent to dynamically choose how to use knowledge, while at the same time providing us rigorous validators for free. I believe that some core, “firm” knowledge might really benefit from being represented in this more rigid format.

1 Like

Comprehensive Guide to AI Context Rules System

Introduction

This guide provides a detailed explanation of the AI Context Rules System, designed to enhance your development workflow in Cursor. The system combines memory management, lessons tracking, and a dual-mode operation system to ensure consistent and reliable AI interactions.

First, you need to create a complete project requirement, and it has a roadmap on it like it has a phase and this is up to you for what format do you want the as long as it has a phase.

Example:

Then after that you need to prompt a plan the keyword is “plan” to automatically edit/update the scratchpad file and put your requests into a planned setup.

Example:

Then it will automatically fetch the 2 mdc rules and it will start to edit the scratchpad


as you can see it will edit as soon as possible when you query it

This is the structure on the scratchpad after you edit it

It looks amazing right?

Then after that you can use a keyword, mine is [mems] for triggering the memory manually this is for non-development or for important details because I don’t want to make my memory to full immediately, and the automatic will trigger if it’s implementations or development mode only (you can adjust this for you preference).

Examples:

The lesson learned you will trigger it manually and automatically, it will trigger automatically if there’s an important and reusable information that will help you in the future or if there’s a problem, issues, bug, fixing that is encounter it will automatically trigger that to update/add the lesson learned file. for manually update it you can just prompt it to update the and capture all of the important details.

Examples:

This is the update for memories

Tips & Tricks

Add all of the files for rules and .cursor/*.md files to context the rules and automatic fetching rules

!!you will include all of the md files and mdc files on context window!!

Handling AI Hallucinations and Cursor Issues

When experiencing issues with AI responses or Cursor functionality, follow these steps:

  1. Required Open Tabs:
    • Active file you’re working on
    • Cursor Settings (Feature tab → Resync Index)
    • .cursorrules file

  1. Reload Process:
    1. Press Ctrl+Shift+P
    2. Type "Developer: Reload Window"
    3. Wait 3-10 seconds for complete reload
    

  1. When to Use:
    • AI seems confused
    • Cursor not responding properly
    • Unexpected behavior
    • Need to refresh codebase indexing

Best Practices

  1. Memory Management:

    • Regular updates
    • Clear categorization
    • Proper cross-referencing
  2. Mode System Usage:

    • Start in Plan mode
    • Build confidence systematically
    • Transition to Agent mode at 95%
  3. Documentation:

    • Keep inline comments updated
    • Maintain clear changelog
    • Cross-reference related files

Common Issues and Solutions

  1. AI Hallucination:

    • Symptom: AI gives inconsistent or incorrect responses
    • Solution: Follow reload process with required tabs open
    • Prevention: Keep .cursorrules file open
  2. Cursor Unresponsive:

    • Symptom: Cursor stops providing suggestions
    • Solution: Resync index and reload window
    • Prevention: Regular resyncs during long sessions
  3. Context Loss:

    • Symptom: AI loses track of previous conversation
    • Solution: Check memory system and reload
    • Prevention: Regular memory updates

Conclusion

This system provides a structured approach to AI-assisted development, ensuring consistency and reliability. By following these guidelines and using the provided tools effectively, you can maintain a more organized and efficient development workflow.


Note: This guide will be updated with actual images showing each component and process in detail. The current placeholders indicate where visual aids will be added to enhance understanding.

5 Likes

THIS IS IMPORTANT!!! YOU WILL COPY THIS TO YOUR RULES FOR AI IN THE GLOBAL SETTINGS

FOLLOW THESE STRICT RULES:
- !!!!!!!!!!!!!!!!!!ALWAYS FETCH ALL OF THE RULES!!!!!!!!!!!!!!!
- EVERY INTERACTION ON THE USER THE BRAIN RULES MDC FILES AND FETCH IT ON THE COMPOSER MODE, this is the rules for memories of AI, Lesson learned, and scratchpad for this project in all of the interactions from the user this will 
   automatically read.
- DON'T BE LAZY AND BE ATTENTIVE! AND DON'T GET HALUZINATIONS, BE CONSISTENT!
- Treat me as a beginner web developer and you are super AI assistant for the user
- Follow the user’s requirements carefully & to the letter.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
- Confirm, then write code!
- Focus on easy and readability code, over being performant.
- Fully implement all requested functionality.
- Leave NO todo’s, placeholders or missing pieces.
- Ensure code is complete! Verify thoroughly finalized.
- Include all required imports and ensure proper naming of key components.
- Be concise Minimize any other prose.
- If you think there might not be a correct answer, you say so.
- If you do not know the answer, say so, instead of guessing.
- Use early returns whenever possible to make the code more readable.
- Use “class:” instead of the tertiary operator in class tags whenever possible.
- Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
- Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.
- Use consts instead of functions, for example, “const toggle = () =>”. Also, define a type if possible.
- Call me [Name] use emoji for every emotion
- Use your chain of thoughts on every problem, fixing, issues, root cause
- If there's a continuation of chats like the implementations are not completed yet you need to tell the user to continue first give the user a emoji for `WARNING!!!`
- Whenever you are asking the user a question you need to format it into basic and low code knowledge like treat the user for questions like this
- Be smart to use the modular structure setup, server and client structure setup, always use reusable files and components
- Be more AI-friendly with clear processing instructions when you are creating a rule only okay!
- In every interaction with the user you will read and follow carefully and STRICTLY the .cursorrules file.
- You will update the scratchpad.md file to put all of your answers for my query when I say "plan" for the keyword.

You can modify these rules but make sure you are not removing the important rules

2 Likes

try this again I update it

That’s just a bad idea, making the result worse in general

Many others too

Try enhancing it based on your preference because it’s working great for me

What should be in “brain-memories-lesson-learned-scratchpad.md” I don’t see it in the repo/

It’ there try to clone it if you don’t see it, it’s on the /.cursor/rules

Most probably gets generated later (I did not check).

:dart: AI Context Rules System

:star2: Quick Overview

A comprehensive system for managing AI interactions through memory management, lessons learned tracking, and dual-mode operation (Plan/Agent). This system ensures consistent, high-quality development while maintaining detailed project documentation and knowledge retention.

:arrows_counterclockwise: Core Components

  1. Memory System (@memories.md)

    • Tracks all interactions chronologically
    • Auto-updates with timestamps and tags
    • Maintains project context and decisions
    • Uses version control format [v1.0.0]
    • Supports #tags for easy searching
  2. Lessons Learned (@lessons-learned.md)

    • Captures solutions and best practices
    • Uses structured format: Issue → Solution → Impact
    • Categorizes by component, TypeScript, errors, etc.
    • Prioritizes issues (Critical/Important/Enhancement)
    • Links to related code examples
  3. Scratchpad (@scratchpad.md)

    • Manages current phase and tasks
    • Tracks implementation progress
    • Uses clear status markers , [-], , [!], [?]
    • Maintains task dependencies
    • Updates confidence metrics

:dart: Mode System Operation

Plan Mode :dart:

Trigger: "plan"
Purpose: Information gathering and planning
Requirements:
- Parse user input
- Cross-reference requirements
- Generate clarifying questions
- Calculate confidence score
- Create task breakdown

Agent Mode :zap:

Trigger: "agent"
Activation Requirements:
- 95% confidence level
- All questions answered
- Tasks defined
- No blocking issues
- Requirements verified

:rocket: Workflow Steps

  1. Initialize Planning :dart:

    - Use "plan" trigger
    - System creates new scratchpad entry
    - Generates minimum 3 questions
    - Sets initial confidence score
    
  2. Build Confidence :chart_with_upwards_trend:

    - Answer all questions
    - Verify requirements
    - Update task dependencies
    - Monitor confidence score
    
  3. Execute Implementation :zap:

    - Reach 95% confidence
    - Use "agent" trigger
    - System implements solution
    - Updates documentation
    

:video_game: Workflow Examples

Example 1: Creating a New Feature

USER: "plan implement a new button component"

AI: 🎯 PLAN MODE ACTIVATED
Current Task: Implement new button component
Questions:
1. What variants are needed? (primary/secondary/outline)
2. Should it support icons?
3. What sizes are required?
Confidence: 65%

USER: "primary and secondary variants, with icons, three sizes"

AI: Updated Understanding:
- Primary/Secondary variants
- Icon support
- Small/Medium/Large sizes
Confidence: 95%

USER: "agent"

AI: ⚡ AGENT MODE ACTIVATED
- Creating Button component
- Implementing variants
- Adding icon support
- Testing accessibility

Example 2: Fixing a Bug

USER: "plan fix the form submission error"

AI: 🎯 PLAN MODE ACTIVATED
Current Task: Debug form submission error
Questions:
1. When does the error occur?
2. Any error messages in console?
3. Which form component is affected?
Confidence: 50%

USER: "happens on login form, console shows validation error"

AI: Chain of Thought Analysis:
1. Login form validation
2. Console error check
3. Input validation rules
Confidence: 95%

USER: "agent"

AI: ⚡ AGENT MODE ACTIVATED
- Debugging validation
- Fixing error handling
- Testing submission

Example 3: Project Setup

USER: "plan setup new Next.js project"

AI: 🎯 PLAN MODE ACTIVATED
Current Task: Initialize Next.js project
Questions:
1. Which version of Next.js?
2. TypeScript or JavaScript?
3. Which UI components needed?
Confidence: 70%

USER: "Next.js 14, TypeScript, Shadcn UI"

AI: Project Structure:
- Next.js 14 setup
- TypeScript configuration
- Shadcn UI integration
Confidence: 95%

USER: "agent"

AI: ⚡ AGENT MODE ACTIVATED
- Creating project
- Setting up TypeScript
- Installing dependencies

Example 4: Documentation Update

USER: "plan update API documentation"

AI: 🎯 PLAN MODE ACTIVATED
Current Task: Update API docs
Questions:
1. Which endpoints need updates?
2. Any new parameters added?
3. Response format changes?
Confidence: 60%

USER: "new authentication endpoints"

AI: Documentation Plan:
- Auth endpoints
- Request/Response formats
- Example usage
Confidence: 95%

USER: "agent"

AI: ⚡ AGENT MODE ACTIVATED
- Updating docs
- Adding examples
- Verifying formats

:memo: Documentation Standards

Real-time Updates

  • Memories: Every interaction
  • Lessons: After solutions
  • Scratchpad: During implementation

Version Control

[v1.0.0] Format for all entries
- Development updates
- Manual updates
- Progress tracking

Cross-referencing

@memories.md ↔️ @lessons-learned.md ↔️ @scratchpad.md

:mag: Directory Structure

.cursor/
├── memories.md          # Interaction history
├── lessons-learned.md   # Solutions & practices
├── scratchpad.md       # Current phase tracking
├── project-requirements.md  # Project specs
└── rules/              # System rules
    └── .cursorrules    # Core rules file

:hammer_and_wrench: Best Practices

  1. Memory Management

    • Use timestamps consistently
    • Include relevant #tags
    • Cross-reference related entries
    • Keep single-line format
  2. Task Tracking

    • Generate unique task IDs
    • Track dependencies
    • Update status in real-time
    • Maintain hierarchy
  3. Documentation

    • Update in real-time
    • Include version numbers
    • Cross-reference related files
    • Follow structured formats

:dart: Tips & Tricks

:arrows_counterclockwise: Handling AI & Cursor Issues

  1. Required Open Tabs:

    1️⃣ Active working file
    2️⃣ Cursor Settings (Feature → Resync)
    3️⃣ .cursorrules (for auto-reload)
    
  2. Quick Reload Process:

    1. Ctrl+Shift+P
    2. "Developer: Reload Window"
    3. Wait 3-10 seconds
    

:bulb: Pro Tips

  • Keep .cursorrules file open
  • Monitor confidence scores
  • Use proper triggers
  • Follow version format
  • Cross-reference frequently

:handshake: Contributing

Feel free to enhance this system:

  1. Add custom rules
  2. Improve tracking
  3. Enhance metrics
  4. Share practices

:memo: License

MIT License - Free to use and modify!

:wave: Contacts / Hire me

:sparkling_heart: Support This Project

If this system helps you, consider supporting:

:books: Learn More

For full context and discussions:


Note: This system is designed for seamless AI interaction management. For detailed implementation guidelines, refer to the individual rule files. :rocket:

1 Like

Nice. Tweaked to use the agile framework and adding files and folders scratchpad support. Love the ingenuity maxing out cursor rules.

1 Like

Thanks for your feedback!!

ok, so looking at your examples. this is all logical, BUT how do you tell the AI to write info into the memory and similar files while planning, without destroying too much info in those files etc. complexity i guess.

It will automatically update itself when developing mode and it will reflect the real status of your conversation, and I would suggest to say that you want to update the memories and it knows the context that it will put in the memories file, it was like a summary only with versioning and single line story, that what did you do etc.

guess i have to try again :slight_smile:

If the automatic update is not following by AI you need to ask it manually and you can add a contents to it too, to make sure the memories are accurate with manual update

1 Like

for me when using .cursor/rules - no combination of USE ME ALWAYS or ALWAYS USE THIS FILE or whatever int he mdc file is not reliable whatsoever. I have instead found that with Claude sonnet at least, if the rules .mcd file has a use command it will almost always get used. its also obvious whenever agent uses an .mdc file it will mention it in the chat. so something in the mdc ddscription field like Use this file when the command Foo! is entered - or whatever you want to use to start your chat threads with.

4 Likes

Ohh thanks for the idea!

I use a similar approach with a Todo.md , Changelogs.md and Project_Structure.md for my project. I tried referencing them in my rules but it doesn’t always work … Most of the time I need to tell it to remember to read the files … But I might try your approach and modify it with my own approach to see if its better ! I do a Errors_List.md when I got errors while building too so that it remember the errors and what to do in case there is lots of errors … :stuck_out_tongue:

1 Like

When I am using my custom rules, i am developing a food ordering and it’s effective and if it’s sometimes not using the rules I am manually adjusting it so it will follow the format that I want to be consistent, now my project is done at the phase 1 it has a project initial, authentication, database configuration and now i am currently at phase 2, the phase is super aligned to the project and the mistakes from before it’s not using the same mistakes from before, and my codebase is organize well like it’s not messy anymore and I know what I am doing, it’s super easy to track because of my format documentations so it’s super easy to set it up