# Reference Patterns # Optimized reference system with flattened hierarchy and automated validation ## Legend @include universal-constants.yml#Universal_Legend ## Note on Reference Shortcuts # Reference shortcuts (@legend, @flags, etc.) were considered but not implemented. # All commands use full @include syntax for clarity and IDE support. # Direct references (e.g., @include universal-constants.yml#Universal_Legend) # provide better maintainability and tool integration. ## Reference Validation System ```yaml Validation_Rules: Reference_Integrity: Check_Targets: "Verify all referenced files and sections exist" Detect_Circular: "Prevent circular reference chains" Validate_Syntax: "Ensure proper @pattern format" Report_Broken: "List all broken references with locations" Auto_Validation: Startup_Check: "Validate all references on system startup" Git_Hook: "Validate before commits via pre-commit hook" File_Watch: "Monitor shared files for changes" Repair_Mode: "Auto-fix simple reference errors" Validation_Report: Location: ".claudedocs/validation/references-{timestamp}.md" Format: "Markdown with severity levels and fix suggestions" Sections: ["Summary", "Broken References", "Recommendations", "Auto-Fixes Applied"] ``` ## File Organization ```yaml Pattern_Files: Universal_Constants: "universal-constants.yml" Command_Patterns: "command-architecture-patterns.yml" Architecture: "architecture-patterns.yml" Security: "security-patterns.yml" Quality: "quality-patterns.yml" Execution: "execution-patterns.yml" Documentation: "docs-patterns.yml" Usage: Direct_Reference: "See shared/[file].yml#[section]" No_Nesting: "Keep references simple and direct" Self_Contained: "Each command has complete information" ``` ## Performance Optimizations ```yaml Reference_Performance: Caching: Strategy: "Cache resolved references for session duration" Invalidation: "Clear cache when shared files change" Memory_Usage: "Limit cache size to prevent memory issues" Lazy_Loading: On_Demand: "Only resolve references when actually needed" Batch_Resolution: "Resolve multiple references in single operation" Prefetch: "Preload commonly used patterns" Token_Efficiency: Direct_Paths: "Use direct file paths instead of aliases where beneficial" Pattern_Inlining: "Inline small patterns instead of referencing" Compression: "Apply UltraCompressed mode to reference content" Monitoring: Reference_Usage: "Track which patterns are used most frequently" Resolution_Time: "Monitor time to resolve references" Cache_Hit_Rate: "Measure caching effectiveness" Error_Frequency: "Track broken reference patterns" Benefits: Token_Reduction: "~30% reduction in reference overhead" Complexity_Reduction: "2-layer max vs 3+ layer indirection" Maintainability: "Easier to trace and update references" Performance: "Faster resolution and lower memory usage" ``` ## Integration Points ```yaml Command_File_Usage: Standard_Commands: "Each command is self-contained" Organization: "Common patterns in shared files" Validation_Required: "All commands follow standard structure" Framework_System: Direct_References: "Use explicit file paths" Error_Handling: "Clear documentation of patterns" Development_Mode: "Easy to understand and maintain" Framework_Integration: Git_Hooks: "Automatic validation on commits and merges" CI_CD: "Reference integrity checks in build pipeline" Editor_Support: "Syntax highlighting and validation" ``` --- *Reference Patterns v2 - Optimized reference system with flattened hierarchy and automated validation*