# Command Result Sharing & Context Mgmt ## Enhanced Result Storage ```yaml Cache Duration: Current session+persistent patterns Storage Format: analyze: {issues[], metrics{}, hotspots[], patterns[]} build: {artifacts[], errors[], warnings[], perf{}} test: {passed[], failed[], coverage%, flaky[]} scan: {vulns[], risks{}, fixes[], compliance{}} design: {arch{}, patterns[], decisions[]} troubleshoot: {findings[], root_causes[], solutions[]} Reuse Rules: Same target+flags: Use cache | Modified files: Invalidate Chained commands: Auto-pass results | Time limit: 30min Persistent patterns: Store successful workflows across sessions Context sharing: Pass relevant subset→next command ``` ## Advanced Context Chaining ```yaml Intelligent Workflows: analyze→improve: Use found issues as targets + priority ranking build→test: Focus on changed modules + integration points scan→fix: Prioritize critical vulnerabilities + context design→build: Apply architectural patterns + decisions troubleshoot→improve: Use root cause analysis for targeted fixes any→deploy: Verify all checks passed + readiness assessment Context Enrichment: File Change Detection: Track modifications since last analysis Dependency Mapping: Understand component relationships Performance Baseline: Compare against historical metrics Quality Trends: Track improvement over time User Patterns: Learn from successful workflows ``` ## Smart Context Optimization ```yaml Memory Management: Essential Context: Keep critical information accessible Token Optimization: Compress verbose results for efficiency Selective Loading: Load only needed context per command Background Processing: Precompute likely needed context Pattern Learning: Workflow Recognition: Identify common command sequences Success Patterns: Learn from effective approaches Error Prevention: Remember failure patterns to avoid User Preferences: Adapt to individual working styles ```