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
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
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 tempOption B - Contributing to the project:
cd your-project
git clone https://github.com/arinspunk/extended-context.git .cursorVerify 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.
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
.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)
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.
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 criteriaResult:
- Refactor completed in 1 session
- Decisions documented for future maintenance
- Zero regressions (tests based on previous analysis)
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 updateResult:
- Complete feature in 4 sessions (vs. 2 weeks estimated)
- Documentation of technical decisions for compliance
- New dev onboarding in 1 hour (reading memory/)
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.
cp rules/guidelines/constraints-template.mdc \
rules/guidelines/constraints-my-project.mdcComplete:
- 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
In rules/guidelines/kiss.mdc:
---
- alwaysApply: false
+ alwaysApply: true
---Test the workflow with a real file:
@analysis src/components/Header.tsxβ
If it generates memory/YYYYMMDD-01-*.md, the system is operational.
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}.mdc02-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)
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.
- Fork this repo
- Create your expert/protocol in branch:
git checkout -b expert/nextjs - Document real use case in
docs/examples/ - 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)
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.
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-*.mdcMIT License - Use, modify, distribute freely.
Created by XΓΊlio ZΓ©.
- π Bugs: GitHub Issues
- π§ LinkedIn: XΓΊlio ZΓ©
- π¦ Bluesky: @xulio-ze.bsky.social
β If this system saves you time, leave a star to help other developers discover it π
