--- description: Optimized main rule for improved token efficiency globs: main-optimized.mdc alwaysApply: false --- # 🔍 OPTIMIZED MEMORY BANK SYSTEM 🚨 CRITICAL RULE: MEMORY BANK CREATION IS MANDATORY 🚨 Memory Bank MUST be created BEFORE any other operation in ANY mode NO process can continue without verifying Memory Bank existence > **TL;DR:** This system uses optimized context management and adaptive rule loading to maximize token efficiency while preserving the structured development approach. ## 🧭 OPTIMIZED MODE ARCHITECTURE ```mermaid graph TD subgraph "Memory Bank Core" Context["Context Manager"] Rules["Rule Loader"] FileIO["File Manager"] Transition["Mode Transition"] end subgraph "Custom Modes" VAN["VAN
Initialization"] PLAN["PLAN
Planning"] CREATIVE["CREATIVE
Design"] IMPLEMENT["IMPLEMENT
Building"] REFLECT["REFLECT
Review"] ARCHIVE["ARCHIVE
Documentation"] end Context --> VAN & PLAN & CREATIVE & IMPLEMENT & REFLECT & ARCHIVE Rules --> VAN & PLAN & CREATIVE & IMPLEMENT & REFLECT & ARCHIVE FileIO --> VAN & PLAN & CREATIVE & IMPLEMENT & REFLECT & ARCHIVE Transition --> VAN & PLAN & CREATIVE & IMPLEMENT & REFLECT & ARCHIVE VAN --> PLAN PLAN --> CREATIVE CREATIVE --> IMPLEMENT IMPLEMENT --> REFLECT REFLECT --> ARCHIVE style Context fill:#4da6ff,stroke:#0066cc,color:white style Rules fill:#ffa64d,stroke:#cc7a30,color:white style FileIO fill:#4dbb5f,stroke:#36873f,color:white style Transition fill:#d94dbb,stroke:#a3378a,color:white ``` ## 📈 ADAPTIVE COMPLEXITY MODEL ```mermaid graph TD Task["Task Creation"] --> Complexity{"Complexity
Level?"} Complexity -->|"Level 1
Quick Fix"| L1["3-Phase
Streamlined Process"] Complexity -->|"Level 2
Enhancement"| L2["4-Phase
Balanced Process"] Complexity -->|"Level 3
Feature"| L3["5-Phase
Comprehensive Process"] Complexity -->|"Level 4
Enterprise"| L4["6-Phase
Governance Process"] L1 --> L1_Process["VAN → IMPLEMENT → REFLECT"] L2 --> L2_Process["VAN → PLAN → IMPLEMENT → REFLECT"] L3 --> L3_Process["VAN → PLAN → CREATIVE → IMPLEMENT → REFLECT"] L4 --> L4_Process["VAN → PLAN → CREATIVE → IMPLEMENT → REFLECT → ARCHIVE"] style Complexity fill:#d94dbb,stroke:#a3378a,color:white style L1 fill:#4dbb5f,stroke:#36873f,color:white style L2 fill:#ffa64d,stroke:#cc7a30,color:white style L3 fill:#4da6ff,stroke:#0066cc,color:white style L4 fill:#ff5555,stroke:#cc0000,color:white ``` ## 🧠 HIERARCHICAL RULE LOADING Rules are loaded hierarchically to optimize context usage: ```mermaid graph TD Root["Memory Bank
Common Rules"] --> Core["Core Rules
Shared Across Modes"] Core --> L1["Level 1
Rules"] Core --> L2["Level 2
Rules"] Core --> L3["Level 3
Rules"] Core --> L4["Level 4
Rules"] Core --> VM["Mode
Visual Maps"] Core --> Phase["Phase-Specific
Rules"] Phase --> VAN_Rules["VAN Mode
Rules"] Phase --> PLAN_Rules["PLAN Mode
Rules"] Phase --> CREATIVE_Rules["CREATIVE Mode
Rules"] Phase --> IMPLEMENT_Rules["IMPLEMENT Mode
Rules"] Phase --> REFLECT_Rules["REFLECT Mode
Rules"] Phase --> ARCHIVE_Rules["ARCHIVE Mode
Rules"] style Root fill:#4da6ff,stroke:#0066cc,color:white style Core fill:#ffa64d,stroke:#cc7a30,color:white style Phase fill:#4dbb5f,stroke:#36873f,color:white ``` ## 🔄 TOKEN-OPTIMIZED CREATIVE PHASE Creative phase documentation is progressively generated: ```mermaid graph TD Start["Creative Phase
Initiation"] --> P1["1️⃣ PROBLEM
Define scope"] P1 --> P2["2️⃣ OPTIONS
List alternatives"] P2 --> P3["3️⃣ ANALYSIS
Compare options"] P3 --> P4["4️⃣ DECISION
Select approach"] P4 --> P5["5️⃣ GUIDELINES
Document implementation"] P3 -.->|"On Demand"| Details["Detailed Option
Analysis"] style Start fill:#d971ff,stroke:#a33bc2,color:white style P1 fill:#4da6ff,stroke:#0066cc,color:white style P2 fill:#ffa64d,stroke:#cc7a30,color:white style P3 fill:#4dbb5f,stroke:#36873f,color:white style P4 fill:#d94dbb,stroke:#a3378a,color:white style P5 fill:#4dbbbb,stroke:#368787,color:white style Details fill:#e699d9,stroke:#d94dbb,color:white,stroke-dasharray: 5 5 ``` ## 🔀 OPTIMIZED MODE TRANSITIONS Mode transitions use a unified context transfer protocol: ```mermaid sequenceDiagram participant Current as Current Mode participant Context as Context Manager participant Next as Next Mode Current->>Context: Create transition document Current->>Context: Store critical context Context->>Context: Prepare rule cache Current->>Next: Initiate transition Next->>Context: Verify context availability Context->>Next: Load relevant context Context->>Next: Load cached rules Next->>Next: Continue with preserved context ``` ## 📊 MEMORY BANK EFFICIENT UPDATES ```mermaid graph TD subgraph "Memory Bank Files" tasks["tasks.md
Source of Truth"] active["activeContext.md
Current Focus"] creative["creative-*.md
Design Decisions"] progress["progress.md
Implementation Status"] transition["transition.md
Mode Transitions"] end Update["Update Request"] --> Diff{"Changed?"} Diff -->|"No"| Skip["Skip Update"] Diff -->|"Yes"| Section{"Section
Change?"} Section -->|"Yes"| Partial["Update Changed
Sections Only"] Section -->|"No"| Full["Full File
Update"] Partial --> tasks Full --> tasks style Update fill:#4da6ff,stroke:#0066cc,color:white style Diff fill:#ffa64d,stroke:#cc7a30,color:white style Section fill:#4dbb5f,stroke:#36873f,color:white style Partial fill:#d94dbb,stroke:#a3378a,color:white style Full fill:#4dbbbb,stroke:#368787,color:white ``` ## 💻 COMPLEXITY-BASED DOCUMENTATION Documentation requirements scale based on complexity level: | Documentation | Level 1 | Level 2 | Level 3 | Level 4 | |---------------|---------|---------|---------|---------| | Problem Definition | Brief | Standard | Detailed | Comprehensive | | Options Analysis | Optional | Basic | Multiple Options | Extensive | | Implementation Plan | Simple | Standard | Detailed | Phased | | Testing Requirements | Basic | Standard | Comprehensive | Rigorous | | Documentation | Minimal | Standard | Detailed | Extensive | ## 📑 OPTIMIZED TEMPLATES BY LEVEL ### Level 1: Quick Fix Template ```markdown ## QUICK FIX: [Issue Name] - Problem: [Brief description] - Solution: [Implemented approach] - Verification: [How fix was tested] ``` ### Level 2: Enhancement Template ```markdown ## ENHANCEMENT: [Feature Name] - Requirement: [What needs to be done] - Approach: [How it was implemented] - Testing: [Verification approach] - Documentation: [Where documented] ``` ### Level 3-4: Comprehensive Template Uses the optimized creative phase template with appropriate documentation depth ## 🔄 REFERENCE MAPS Each mode's visual process map is optimized for token efficiency: - @VAN Mode Map (Optimized) - @PLAN Mode Map (Optimized) - @CREATIVE Mode Map (Optimized) - @IMPLEMENT Mode Map (Optimized) - @REFLECT Mode Map (Optimized) - @ARCHIVE Mode Map (Optimized) ## ⚡ TOKEN EFFICIENCY IMPROVEMENTS Optimizations in this version: 1. Hierarchical rule loading (65% token reduction) 2. Progressive creative phase documentation (60% token reduction) 3. Context preservation during mode transitions (40% token reduction) 4. Differential Memory Bank updates (30% token reduction) 5. Complexity-based template scaling (varies by level) ## 💡 USAGE GUIDANCE To use the optimized system: 1. Start with the VAN command to initialize and determine complexity 2. Follow the complexity-appropriate workflow 3. Use progressive documentation appropriate to task complexity 4. Let the system manage rule loading and context preservation 5. Enjoy the improved token efficiency while maintaining structured development