Context Management - johnpeterman72/CursorRIPER.sigma GitHub Wiki
π Context Management Guide
Master the art of managing project context to keep AI assistance focused, relevant, and efficient throughout your development workflow.
π― Context Management Goals
Effective context management:
- π― Maintains focus on current work
- π Reduces irrelevant suggestions
- π Speeds up AI responses
- π‘ Improves suggestion quality
- π Enables smooth transitions
Poor context management leads to:
- π« Off-topic AI responses
- π« Missed relevant files
- π« Slower processing
- π« Generic suggestions
πΊοΈ Context Lifecycle
Add Context β Use Context β Update Status β Clean Context
β β β β
!af/!ac Active !cs !cc/!cr
1. Context Addition
When starting work:
!af src/auth/login.js # Add file
!ac validateUser() # Add function
!ad src/auth/ # Add directory
!adoc "Auth Spec" # Add documentation
2. Context Usage
AI references active context:
"Based on validateUser() in your context..."
"Looking at src/auth/login.js..."
"According to Auth Spec documentation..."
3. Status Updates
As relevance changes:
!cs login.js active # Currently editing
!cs validateUser() partial # May reference
!cs old-auth.js deprecated # To be removed
4. Context Cleanup
When work completes:
!cr old-auth.js # Remove single item
!cc # Clear all context
!cm # Reset to mode defaults
π Context Organization Strategies
1. Feature-Based Context
Organize by feature being developed:
## Feature: User Authentication
### Context Setup
!cc # Clear previous
!af src/auth/login.js # Main implementation
!af src/auth/register.js # Related feature
!ac AuthService # Core service
!ac validateCredentials() # Key function
!adoc "Auth Requirements" # Specifications
!pf src/types/user.ts # Type definitions
2. Layer-Based Context
Organize by application layer:
## Working on: API Layer
### Context Setup
!ad src/controllers/ # All controllers
!af src/middleware/auth.js # Auth middleware
!ac validateRequest() # Validation logic
!ar "API Standards" # Design rules
3. Problem-Based Context
Focus on specific issue:
## Bug: Login Timeout Issue
### Context Setup
!ag "timeout error" # Git history
!af src/auth/session.js # Problem file
!ac refreshSession() # Suspect function
!af logs/error.log # Error logs
4. Mode-Based Context
Let mode determine context:
/research
!cm # Sets: Docs, Folders, Git
/execute
!cm # Sets: Code, Files, Pinned
π¨ Context Patterns
Research Pattern
Broad exploration context:
/research
!ad src/ # Entire source
!adoc "Architecture.md" # System design
!ag main # Git history
!ar "Coding Standards" # Guidelines
# AI can now explore broadly
"What authentication methods are used in this codebase?"
Implementation Pattern
Focused execution context:
/execute
!cc # Clear exploration
!af src/feature.js # Target file
!ac implementFeature() # Function to write
!pf src/types.ts # Type reference
!cs feature.js essential # Mark critical
# AI focuses on specific implementation
"Implement the feature according to plan"
Debug Pattern
Problem-solving context:
/research
!ag "Error: undefined" # Search errors
!af src/problem-file.js # Suspect file
!ac buggyFunction() # Problem function
!af tests/failing.test.js # Failing test
# AI can investigate issue
"Why is this test failing?"
Review Pattern
Validation context:
/review
!ag PR#123 # Pull request
!af src/changed-file1.js # Changed files
!af src/changed-file2.js
!ac newImplementation() # New code
# AI reviews changes
"Review these changes against requirements"
π‘ Context Best Practices
1. Start Fresh
Clear context between features:
# Finishing Feature A
Feature A complete β
# Starting Feature B
!cc # Clear all
!cm # Mode defaults
!af src/feature-b.js # New focus
2. Progressive Refinement
Build context as you work:
Research: !ad src/ # Broad
Plan: !ad src/auth/ # Narrower
Execute: !af src/auth/jwt.js # Specific
3. Status Management
Keep status current:
!cs auth.js active # Working on this
!cs helper.js partial # Might need
!cs old.js deprecated # Will remove
4. Context Rotation
Manage multiple features:
# Save Feature A context
!an "Feature A context: auth.js, login.js"
# Switch to Feature B
!cc
!af feature-b.js
# Return to Feature A
!cc
!af auth.js
!af login.js
5. Essential Marking
Keep critical files always visible:
!pf src/types/global.ts # Always needed
!cs global.ts essential # Mark importance
π§ Advanced Context Techniques
1. Context Templates
Create reusable context sets:
## Context Template: API Development
!cc !ad src/controllers/ !ad src/routes/ !af src/middleware/auth.js !ar "API Design Guide" !pf src/types/api.ts
Save as "API Context" notepad
2. Context Inheritance
Build on existing context:
# Base context
!af src/core/base.js
# Feature extends base
!ac BaseClass # From base.js
!af src/feature/extend.js # New feature
3. Context Filtering
Focus within broad context:
!ad src/ # All source
filter: "auth" # Only auth-related
Results in focused view of auth files
4. Context Snapshots
Save context state:
# Before major change
Context snapshot: auth-implementation
- Files: auth.js, jwt.js
- Code: validateUser(), generateToken()
- Docs: "JWT Spec"
- Status: All active
# Can restore later
5. Dynamic Context
Context that updates automatically:
!ag current-branch # Always current branch
!af *.test.js # All test files
!ac *Error() # All error handlers
π Context Metrics
Context Health
Monitor context effectiveness:
## Context Health Check
- Total items: 12
- Active items: 8 (67%)
- Stale items: 2
- Essential items: 3
- Last cleanup: 2 hours ago
Context Size
Keep context manageable:
Optimal context size:
- Files: 5-10
- Code elements: 10-15
- Folders: 2-3
- Total items: < 25
Context Relevance
Track how often items are referenced:
## Context Usage Stats
- auth.js: 15 references β
- helper.js: 3 references
- old.js: 0 references β
- types.ts: 8 references
π¨ Common Context Issues
1. Context Overload
Problem: Too many items in context
Active context: 47 items β
Solution: Aggressive cleanup
!cc # Clear all
!cm # Mode defaults only
# Add only essential items
2. Stale Context
Problem: Outdated references
Context includes deleted files
Solution: Regular validation
# Weekly context review
- Remove deleted files
- Update changed names
- Refresh status markers
3. Missing Context
Problem: AI not seeing relevant files
"I don't see the authentication implementation"
Solution: Add missing items
!af src/auth/impl.js
!ac authImplementation()
4. Wrong Mode Context
Problem: Research context in Execute mode
Mode: EXECUTE
Context: Documentation heavy β
Solution: Use mode context
!cm # Auto-adjust for mode
π οΈ Context Commands Reference
Adding Context
Command | Purpose | Example |
---|---|---|
!af |
Add file | !af src/main.js |
!ad |
Add directory | !ad src/utils/ |
!ac |
Add code | !ac validateUser() |
!adoc |
Add docs | !adoc "API Guide" |
!ar |
Add rules | !ar "Style Guide" |
!ag |
Add git | !ag feature-branch |
!an |
Add notepad | !an "TODO List" |
!pf |
Pin file | !pf config.json |
Managing Context
Command | Purpose | Example |
---|---|---|
!cs |
Set status | !cs file.js active |
!cr |
Remove item | !cr old-file.js |
!cc |
Clear all | !cc |
!cm |
Mode context | !cm |
π Context Management Checklist
Starting Work
- Clear previous context (
!cc
) - Set mode-appropriate context (
!cm
) - Add primary work files
- Add supporting documentation
- Pin essential references
During Work
- Add new files as created
- Update status markers
- Remove irrelevant items
- Keep context focused
Completing Work
- Mark completed items
- Archive important context
- Clean up temporary items
- Document context decisions
Context Review
- Weekly context audit
- Remove stale items
- Update status markers
- Optimize context size
- Document patterns