📍 Location: ai/docs/ | 🏠 Home: ai/README.md | 📚 Main: README.md
The AI context management system provides structured control over AI assistant context through three sections in the copilot instructions.
- Purpose: Real-time visibility into loaded context and file sizes
- Content: Section breakdown with KB/token counts, active files, management commands
- Updates: Automatically regenerated when context changes
- Benefits: Immediate understanding of current configuration and resource usage
- Purpose: Core AI behavior, response guidelines, and system-wide instructions
- Content: Consistent baseline behavior that never changes
- Includes: Universal principles, memory detection, automation triggers, response guidelines
- Purpose: Single active persona defining specialized role and expertise
- Content: One persona file loaded at a time
- Examples: Developer (technical), Project Manager (strategic), Case Note Analyst (domain expertise)
- Purpose: Flexible context files relevant to current work
- Content: Persona default files + manually added files
- Examples: Project documentation, analysis workflows, methodology files
# Load system
source('ai/scripts/ai-context-management.R')
# Activate personas with their defaults
activate_developer() # Technical focus, minimal context
activate_project_manager() # Strategic oversight + mission/method/glossary
activate_casenote_analyst() # Domain expertise + specialized context
# Check current status
show_context_status()# Add specific context files
add_context_file('./ai/project/mission.md')
add_context_file('./analysis/eda-1/README.md')
# Remove context files
remove_context_file('./ai/project/mission.md')
# Discover available files
list_available_md_files() # All .md files
list_available_md_files('guide') # Files matching pattern
# Remove context files
remove_context_file('philosophy/analysis-templatization.md')
# Check what's loaded
show_context_status()- Focus: Technical implementation, system architecture, reproducible research
- Default Context: None (minimal context for focused technical work)
- Use For: Backend development, R programming, system maintenance
- Activation:
activate_developer()
- Focus: Strategic oversight, project alignment, stakeholder coordination
- Default Context: Project mission, methodology, glossary (full FIDES framework)
- Use For: Planning, requirements analysis, project coordination
- Activation:
activate_project_manager()
- Focus: Domain-specific analysis, social services expertise
- Default Context: AI onboarding guide
- Use For: Case note analysis, domain-specific tasks
- Activation:
activate_casenote_analyst()
project/mission- Project objectives and strategic visionproject/method- Research methodology and analytical approachproject/glossary- Domain terminology and definitionsonboarding-ai- AI system introduction and orientation
philosophy/analysis-templatization.md- Analysis framework and templatesphilosophy/semiology.md- Methodological foundationsphilosophy/causal-inference.md- Causal analysis principles
simulation/implementation.md- System implementation and architecturesimulation/README.md- Synthetic data generation overviewanalysis/*/README.md- Analysis-specific documentation
memory-hub- Central memory coordinationmemory-human- Human project memorymemory-ai- AI learning and insights
# Find all guides
list_available_md_files('guide')
# Find philosophy files
list_available_md_files('philosophy')
# Find analysis documentation
list_available_md_files('analysis')show_context_status()
# Shows:
# - Section 1: Always present (general instructions)
# - Section 2: Current active persona
# - Section 3: All additional context files with paths
# - Total file size and line countEvery copilot-instructions.md file now starts with a Context Configuration Overview that provides:
- Real-time metrics: Total size (KB), line counts, generation timestamp
- Section breakdown: Individual size and status for each section
- File inventory: Detailed listing of all loaded context files with individual sizes
- Quick commands: Ready-to-use R commands for context management
This overview updates automatically every time you change persona or context, giving you immediate visibility into your current configuration without needing to run separate commands.
Each persona defines its default context in get_persona_configs():
"project-manager" = list(
file = "./ai/personas/project-manager.md",
default_context = c("project/mission", "project/method", "project/glossary")
)activate_casenote_analyst() # Domain expertise
add_context_file('philosophy/analysis-templatization.md') # Analysis framework
add_context_file('simulation/implementation.md') # Implementation guidanceactivate_developer() # Technical focus
add_context_file('simulation/README.md') # System overview
# Keep context minimal for focused technical workactivate_project_manager() # Strategic oversight (loads mission/method/glossary automatically)
add_context_file('memory-human') # Project history
add_context_file('philosophy/semiology.md') # Methodological foundation# Strategic planning phase
activate_project_manager()
# Define requirements and priorities
# Implementation phase
activate_developer()
add_context_file('project/mission') # Add just mission for alignment
# Execute with strategic context but technical focusThe system provides clear visibility into context loading:
- Developer: ~12 KB (minimal for technical efficiency)
- Project Manager: ~28+ KB (full strategic context)
- Custom Combinations: Add only what's needed for specific tasks
Monitor context size with show_context_status() to optimize for:
- Performance: Smaller context loads faster
- Relevance: More context provides better domain understanding
- Focus: Right-sized context maintains task focus
- Context changes update
.github/copilot-instructions.mdautomatically - GitHub Copilot reads updated instructions immediately
- No restart required, changes take effect instantly
- All existing
activate_*()functions continue to work - Legacy file aliases maintained (e.g.,
mission→project/mission) - Gradual migration supported without breaking workflows
The system respects the project's organized structure:
ai/
├── personas/ # Section 2 content
├── project/ # FIDES framework for Section 3
└── [memory & other files] # Available for Section 3
philosophy/ # Methodological context for Section 3
simulation/ # Implementation context for Section 3
analysis/ # Analysis workflow context for Section 3
- Experiment with combinations: Try different persona + context combinations for your specific tasks
- Create presets: Consider saving frequently used context combinations
- Monitor performance: Use
show_context_status()to optimize context size for your needs - Extend personas: Create custom personas for specialized workflows
The 3-section system provides the flexibility to craft exactly the right context for any task while maintaining clear structure and efficient performance.