Context References - johnpeterman72/CursorRIPER.sigma GitHub Wiki

๐Ÿ“Ž Context Reference System

The Context Reference System helps maintain focus by tracking relevant files, code, and documentation throughout your development workflow. It ensures AI assistance stays targeted and efficient.

๐ŸŽฏ What is Context?

Context in CursorRIPERโ™ฆฮฃ represents the relevant scope of your current work:

  • Files you're working with
  • Code functions you're implementing
  • Documentation you're referencing
  • Folders containing related work

Without context management, AI might:

  • ๐Ÿšซ Reference unrelated files
  • ๐Ÿšซ Suggest changes to wrong components
  • ๐Ÿšซ Lose track of your focus
  • ๐Ÿšซ Provide generic instead of specific help

๐Ÿ“‹ Context Types (ฮ“)

ฮ“โ‚: File References (๐Ÿ“„)

Track specific files in your project

!af src/auth/login.js
!af config/database.json
!af tests/auth.test.js

Use for:

  • Implementation files
  • Configuration files
  • Test files
  • Documentation files

ฮ“โ‚‚: Folder References (๐Ÿ“)

Track entire directories

!ad src/components/
!ad tests/integration/
!ad docs/api/

Use for:

  • Feature folders
  • Module directories
  • Test suites
  • Documentation sections

ฮ“โ‚ƒ: Code References (๐Ÿ’ป)

Track specific code elements

!ac validateUser()
!ac AuthenticationService
!ac DATABASE_CONFIG

Use for:

  • Functions
  • Classes
  • Constants
  • Interfaces

ฮ“โ‚„: Documentation References (๐Ÿ“š)

Track external or internal docs

!adoc "API Design Guide"
!adoc "Security Best Practices"
!adoc README.md

Use for:

  • Technical specifications
  • Best practices
  • API documentation
  • Architecture docs

ฮ“โ‚…: Rules References (๐Ÿ“)

Track Cursor project rules

!ar "Code Style Guide"
!ar "Testing Standards"
!ar RIPERsigma1.0.5.mdc

Use for:

  • Coding standards
  • Project guidelines
  • Framework rules
  • Team conventions

ฮ“โ‚†: Git References (๐Ÿ”„)

Track version control context

!ag feature/authentication
!ag commit:a1b2c3d
!ag PR#42

Use for:

  • Feature branches
  • Specific commits
  • Pull requests
  • Git history

ฮ“โ‚‡: Notepad References (๐Ÿ“)

Track temporary notes and ideas

!an "Authentication Ideas"
!an "Refactoring Notes"
!an "Meeting Notes 2024-01-15"

Use for:

  • Brainstorming
  • Temporary notes
  • Meeting outcomes
  • Quick ideas

ฮ“โ‚ˆ: Pinned Files (๐Ÿ“Œ)

Pin files without direct reference

!pf src/core/engine.js
!pf .env.example
!pf package.json

Use for:

  • Always-relevant files
  • Core dependencies
  • Critical configs
  • Reference files

๐Ÿ”ฎ Active Context Display

Context is displayed in activeContext.md:

## ๐Ÿ“Ž Context References

### ๐Ÿ“„ Active Files
- src/auth/login.controller.js ๐ŸŸข
- src/auth/auth.service.js ๐ŸŸข
- src/middleware/auth.js ๐ŸŸก

### ๐Ÿ’ป Active Code
- validateCredentials() ๐ŸŸข
- generateToken() ๐ŸŸข
- AuthGuard ๐ŸŸฃ

### ๐Ÿ“š Active Docs
- JWT Best Practices ๐ŸŸข
- OAuth2 Specification ๐ŸŸก

## ๐Ÿ“ก Context Status
๐ŸŸข Active - Currently working
๐ŸŸก Partial - May reference
๐ŸŸฃ Essential - Always relevant
๐Ÿ”ด Deprecated - To be removed

๐ŸŽจ Context Status Indicators

๐ŸŸข Active

Currently being worked on

src/auth/login.js ๐ŸŸข

๐ŸŸก Partially Relevant

May be referenced

src/utils/helpers.js ๐ŸŸก

๐ŸŸฃ Essential

Core to current work

src/config/app.js ๐ŸŸฃ

๐Ÿ”ด Deprecated

Marked for removal

src/legacy/old-auth.js ๐Ÿ”ด

๐Ÿ”„ Mode-Specific Context

Each mode automatically loads appropriate context:

Research Mode (ฮฉโ‚)

Mฮ“[ฮฉโ‚] = [ฮ“โ‚„, ฮ“โ‚‚, ฮ“โ‚†] // Docs, Folders, Git
  • Documentation for understanding
  • Folder structure exploration
  • Git history investigation

Innovate Mode (ฮฉโ‚‚)

Mฮ“[ฮฉโ‚‚] = [ฮ“โ‚ƒ, ฮ“โ‚„, ฮ“โ‚‡] // Code, Docs, Notepads
  • Code patterns to consider
  • Best practices docs
  • Brainstorming notes

Plan Mode (ฮฉโ‚ƒ)

Mฮ“[ฮฉโ‚ƒ] = [ฮ“โ‚, ฮ“โ‚‚, ฮ“โ‚…] // Files, Folders, Rules
  • Target files to modify
  • Project structure
  • Coding standards

Execute Mode (ฮฉโ‚„)

Mฮ“[ฮฉโ‚„] = [ฮ“โ‚ƒ, ฮ“โ‚, ฮ“โ‚ˆ] // Code, Files, Pinned
  • Active code elements
  • Implementation files
  • Critical references

Review Mode (ฮฉโ‚…)

Mฮ“[ฮฉโ‚…] = [ฮ“โ‚ƒ, ฮ“โ‚, ฮ“โ‚†] // Code, Files, Git
  • Implemented code
  • Changed files
  • Git comparisons

๐Ÿ“‹ Context Commands

Adding Context

Command Description Example
!af Add file !af src/main.js
!ad Add directory !ad src/services/
!ac Add code !ac processPayment()
!adoc Add documentation !adoc "API Guide"
!ar Add rules !ar "Style Guide"
!ag Add git ref !ag feature/auth
!an Add notepad !an "Ideas"
!pf Pin file !pf config.json

Managing Context

Command Description Example
!cs Set status !cs login.js active
!cr Remove reference !cr old-file.js
!cc Clear all !cc
!cm Mode context !cm

๐Ÿ”„ Context Lifecycle

1. Context Creation

/plan
!af src/feature.js      # Add target file
!ac newFeature()        # Add function to implement
!adoc "Feature Spec"    # Add specification

2. Context Evolution

/execute
!cs src/feature.js essential   # Mark as essential
!ac helperFunction()           # Add new function
!cr "Feature Spec"             # Remove spec (no longer needed)

3. Context Cleanup

/review
!cs src/feature.js partial     # Downgrade relevance
!cr helperFunction()           # Remove temporary function

4. Context Archival

Feature complete - context archived to memory
!cc                            # Clear for next task

๐Ÿ’ก Context Strategies

1. Focused Context

Keep context minimal and relevant:

โŒ Bad: Add entire src/ directory
โœ… Good: Add specific feature folder

2. Progressive Context

Build context as you work:

Research: Broad folders and docs
Plan: Specific files and rules  
Execute: Exact code elements
Review: Changed files and tests

3. Context Rotation

Swap context for different features:

!cc                          # Clear current
!cm                          # Load mode defaults
!af src/new-feature.js       # Add new focus

4. Context Persistence

Important context persists across modes:

!pf src/core/app.js         # Always relevant
!cs database.config essential # Mark critical

๐ŸŽฏ Context Patterns

Feature Development Pattern

# Research Phase
!ad src/features/auth/       # Explore structure
!adoc "Auth Requirements"    # Understand needs

# Plan Phase
!af src/features/auth/login.js   # Target file
!ar "Security Standards"         # Apply standards

# Execute Phase  
!ac loginUser()                  # Implement function
!pf src/features/auth/types.ts   # Reference types

# Review Phase
!ag feature/auth-implementation  # Compare changes
!af tests/auth.test.js          # Verify tests

Bug Fix Pattern

# Research
!ag issue#123                    # Git issue
!af src/problematic-file.js      # Problem file

# Plan
!ac buggyFunction()              # Target function
!adoc "Expected Behavior"        # Correct behavior

# Execute
!cs buggyFunction() essential    # Focus on fix

# Review  
!af tests/regression.test.js     # Verify fix

Refactoring Pattern

# Research
!ad src/legacy/                  # Old code
!adoc "New Architecture"         # Target design

# Plan
!ac oldImplementation()          # Current code
!ac newImplementation()          # Target code

# Execute
!pf src/legacy/interfaces.ts     # Maintain compatibility

# Review
!ag main...refactor-branch       # Full comparison

๐Ÿ“Š Context Operations

Context Intersection

Find common elements:

ฮ“โ‚ โˆฉ ฮ“โ‚ƒ = Files containing active code

Context Union

Combine contexts:

ฮ“โ‚ƒ โˆช ฮ“โ‚ˆ = All code references plus pinned files

Context Filtering

filter(ฮ“โ‚ƒ, "auth") = All auth-related code

Context Ranking

rank(ฮ“โ‚, relevance) = Files by importance

๐Ÿ”— Cross-References with Context

Standard Cross-Reference

[โ†—๏ธฯƒโ‚:Rโ‚ƒ] = Requirement 3

Cross-Reference with Context

[โ†—๏ธฯƒโ‚:Rโ‚ƒ|ฮ“โ‚ƒ:validateUser()] = Requirement 3, specifically validateUser()

Context-Only Reference

[ฮ“โ‚ƒ:AuthService] = Reference to AuthService

Protected Context Reference

[ฮจโ‚+ฮ“โ‚ƒ:secretKey] = Protected code reference

โšก Context Best Practices

1. Start Broad, Narrow Down

Research: !ad src/
Plan: !ad src/auth/
Execute: !af src/auth/login.js

2. Use Status Effectively

๐ŸŸข Active: What you're editing
๐ŸŸก Partial: What you might need
๐ŸŸฃ Essential: What you always need
๐Ÿ”ด Deprecated: What to remove

3. Mode-Appropriate Context

Let mode transitions update context:

!cm  # Automatically sets mode-appropriate context

4. Regular Cleanup

# End of feature
!cc  # Clear all context
# Start of new feature  
!cm  # Fresh context for mode

5. Document Context Decisions

!an "Why auth.service.js is essential"
# This service contains the core business logic
# All auth features depend on it

๐Ÿšจ Common Context Issues

Context Overload

Problem: Too many references Solution: Use status markers and remove irrelevant

Lost Context

Problem: Cleared accidentally
Solution: Check backups in memory-bank

Wrong Context

Problem: Old context still active Solution: !cc then rebuild

Missing Context

Problem: AI not seeing relevant files Solution: Add with appropriate commands

๐ŸŽ“ Context Examples

Example 1: Starting New Feature

/research
!ad src/features/           # Explore features
!adoc "Feature Request #42" # Understand requirements

/plan  
!cc                         # Clear exploration context
!cm                         # Load planning context
!af src/features/search.js  # Target implementation file
!ar "API Design Standards"  # Apply standards

Example 2: Debugging Session

/research
!ag "Error: undefined user" # Search git for error
!af src/auth/middleware.js  # Suspected problem file
!ac checkUserSession()      # Problem function

/execute
!cs checkUserSession() essential  # Focus on this
!pf src/types/user.ts            # Reference for types

Example 3: Code Review

/review
!ag PR#123                      # Pull request context
!af src/changed-file-1.js ๐ŸŸข    # Files to review
!af src/changed-file-2.js ๐ŸŸข
!ac newFeatureImplementation()  # New code to check

๐Ÿ“š Related Topics


โ† Code Protection | Home | Permission System โ†’