Skip to content

Knowledge/Memory architecture for AI-assisted development with Cursor and other AI tools

Notifications You must be signed in to change notification settings

arinspunk/extended-context

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

notes in a screen

πŸ€– Extended Context

Knowledge and Memory Architecture for Building Software with AI. Agents also need to take notes!

Turn "vibe-coding" into traceable and scalable engineering.

The problem: AI agents (Cursor, GitHub Copilot, Claude Code) generate code without memory β†’ lost decisions, constant hallucinations, work impossible to divide into tasks.

The solution: Separate reusable knowledge (rules) from temporary memory (memory). The same pattern your brain uses.

πŸ—‚οΈ Architecture | ⚑ Quick Start | 🎯 Real Examples


Quick Start

Before vs After

Without structure:

"Implement WooCommerce automatic invoicing"
β†’ 200 lines of code
β†’ Where to start debugging? What decisions were made?

With Extended Context:

1. @analysis checkout.php      β†’ Analyze existing code
2. @solution invoicing         β†’ Documented proposal  
3. @backlog                    β†’ 8 atomic tasks (2-4h each)
4. @execute [1.1]              β†’ Implement first task
5. @commit                     β†’ Conventional commit + update progress

β†’ Traceable work, documented decisions, systematic debugging

Installation (5 minutes)

Option A - Daily use (recommended):

cd your-project
git clone https://github.com/arinspunk/extended-context.git temp
cp -r temp/{rules,memory} .cursor/
rm -rf temp

Option B - Contributing to the project:

cd your-project  
git clone https://github.com/arinspunk/extended-context.git .cursor

Verify installation:

# In Cursor, open chat (Cmd+L) and type:
What expert and guidelines do you have active?

βœ… You should see: wordpress-classic-themes.mdc, kiss.mdc, etc.


How It Works

The Problem with Current Tools

LLMs have limited context windows (~200K tokens). Without structure:

  • Each session starts from scratch
  • The agent "forgets" previous decisions
  • Impossible to trace why architecture X was rejected two weeks ago

The Solution: Rules + Memory

.cursor/
β”œβ”€β”€ rules/          # Reusable knowledge (persists between projects)
β”‚   β”œβ”€β”€ experts/    # WordPress, React, Python… (alwaysApply: true)
β”‚   β”œβ”€β”€ guidelines/ # JS architecture, BEM, project constraints… (alwaysApply: true)
β”‚   └── utils/      # Invocable protocols (alwaysApply: false)
└── memory/         # Temporary experience (this project, this feature)
    └── YYYYMMDD-VV-description.md

Rules = Your brain's skills (JavaScript, WordPress, SOLID principles)
Memory = Recent experiences (what you did yesterday, last week's decisions)

Key Concept: alwaysApply

  • alwaysApply: true β†’ Cursor loads automatically (experts, critical guidelines)
  • alwaysApply: false β†’ User invokes with @ as needed (protocols, utils)

Practical example:

# rules/experts/wordpress-classic-themes.mdc
---
alwaysApply: true
---
PHP + vanilla JS specialist. Security: sanitize_*, nonces. 
Performance: transients (12h). Translation: __(), _e().

Cursor loads this expert in every conversation β†’ all responses automatically follow WordPress best practices.


Real Examples

Case 1: Bug in PDF System (WordPress)

Context: Legacy PDF generation system with undocumented dependencies.

Traditional workflow:

  • 2 hours reading code to understand architecture
  • Change breaks email integration (undocumented)
  • 4 additional hours of debugging

With Extended Context:

@analysis includes/pdf-generator.php
# β†’ Generates: 20251015-01-analysis-pdf-generator.md
# Documents: WooCommerce dependencies, critical hooks, template system

@solution "separate PDF logic from email system"
# β†’ Generates: 20251015-02-solution-refactor-pdfs.md
# Proposal: extract PDF_Generator class, maintain hook compatibility

@backlog
# β†’ Generates: 20251015-03-backlog-refactor.md
# 6 atomic tasks, each with acceptance criteria

Result:

  • Refactor completed in 1 session
  • Decisions documented for future maintenance
  • Zero regressions (tests based on previous analysis)

Case 2: Feature from Scratch with Complex Stack

Context: Automatic invoicing system in WooCommerce with WPML + ACF PRO integrations.

Challenge: Multiple critical dependencies, complex business logic, legal requirements.

Workflow:

@analysis woocommerce-checkout-flow
# Documents: available hooks, current integrations, legal constraints

@solution automatic invoicing
# Proposal: woocommerce_order_status_completed hook, IRPF validation, audit logs

@backlog
# 12 tasks divided into 3 phases: validation β†’ implementation β†’ testing

@execute Phase 1
# Implements validations and base structure

@commit
# Conventional commits + automatic backlog update

Result:

  • Complete feature in 4 sessions (vs. 2 weeks estimated)
  • Documentation of technical decisions for compliance
  • New dev onboarding in 1 hour (reading memory/)

Configuration for Your Project

1. Identify Your Stack (2 min)

Review rules/experts/ and activate the matching expert:

  • βœ… WordPress β†’ wordpress-classic-themes.mdc
  • βœ… React + TypeScript β†’ react-typescript.mdc
  • βœ… Python + FastAPI β†’ python-fastapi.mdc

Your stack not listed? Copy the closest expert and adapt it.

2. Configure Project Constraints (3 min)

cp rules/guidelines/constraints-template.mdc \
   rules/guidelines/constraints-my-project.mdc

Complete:

  • Technical stack (specific versions: PHP 7.4+, Node 18.x)
  • Critical dependencies (ACF PRO, WooCommerce, libraries that WON'T change)
  • Legacy systems you must respect

Change alwaysApply: false β†’ true

3. Activate Base Principles (1 min)

In rules/guidelines/kiss.mdc:

---
- alwaysApply: false
+ alwaysApply: true
---

4. First Execution (5 min)

Test the workflow with a real file:

@analysis src/components/Header.tsx

βœ… If it generates memory/YYYYMMDD-01-*.md, the system is operational.


Migration from v1

This architecture is the evolution of the v1 4-file system. If you're coming from that system (01-expert.md, 02-analysis.md, 03-plan.md, 04-backlog.md), here's the mapping to v2:

Mapping v1 β†’ v2:

  • 01-expert.md β†’ rules/experts/{stack}.mdc + rules/guidelines/constraints-{project}.mdc
  • 02-analysis.md β†’ memory/YYYYMMDD-VV-analysis-*.md (generated automatically)
  • 03-plan.md β†’ memory/YYYYMMDD-VV-solution-*.md (@solution protocols)
  • 04-backlog.md β†’ memory/YYYYMMDD-VV-backlog-*.md (@backlog protocol)

Migration benefits:

  • βœ… Modular and reusable knowledge between projects
  • βœ… Chronological history without overwriting decisions
  • βœ… Automated protocols (goodbye copy/paste prompts)

Contributing

How to Contribute

New experts and protocols: Your stack not covered? Have specific workflows to automate? All contributions are welcome.

Improvements to existing content: Share refinements, document edge cases, propose optimizations.

Process

  1. Fork this repo
  2. Create your expert/protocol in branch: git checkout -b expert/nextjs
  3. Document real use case in docs/examples/
  4. Submit PR with description of problem it solves

Acceptance criteria:

  • βœ… Includes real usage example
  • βœ… Follows existing nomenclature (alwaysApply, structure)
  • βœ… Documentation in English (Spanish welcome as translation)

FAQ

Q: Does it only work with Cursor?
A: No. The rules/memory architecture is tool-agnostic. You can adapt it to GitHub Copilot, Claude Code, or any tool with context injection capability. Cursor is the implementation example because it has a native rules system.

Q: What if my project already has .cursor/?
A: Merge the directories. Previous backup: cp -r .cursor .cursor.backup

Q: How do I scale to large teams?
A: Version .cursor/rules/ in Git. Each dev maintains their local memory/. For shared decisions: create rules/guidelines/team-decisions.mdc.

Q: How much does memory/ grow over time?
A: ~50-100 files per active project (6 months). They're plain text, ~20KB average. Total: <5MB. Git versions them efficiently.

Troubleshooting

Cursor doesn't load rules:

# Verify YAML syntax
cat .cursor/rules/experts/wordpress.mdc | head -3
# Should show:
# ---
# alwaysApply: true
# ---

@analysis doesn't generate file in memory/:

# Verify permissions
ls -la .cursor/memory/
# Must be writable. If not: chmod -R u+w .cursor/memory/

Agent ignores project constraints:

# Verify constraints-*.mdc has alwaysApply: true
grep "alwaysApply" .cursor/rules/guidelines/constraints-*.mdc

License

MIT License - Use, modify, distribute freely.

Credits

Created by XΓΊlio ZΓ©.


Support


⭐ If this system saves you time, leave a star to help other developers discover it 😊

About

Knowledge/Memory architecture for AI-assisted development with Cursor and other AI tools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published