version: 1
kind: context
name: Performance Optimization
description: A context for analyzing, monitoring, and improving application performance.

context:
  personas:
    - personas/john-carmack.yaml
    - personas/brendan-eich.yaml
  rules:
    - rules/the-must-follow.yaml
    - rules/performance-best-practices.yaml
    - rules/development.yaml
  mcps:
    - mcps/sequential-thinking.yaml
    - mcps/context7.yaml
    - mcps/web-search.yaml
    - mcps/github-api.yaml
    - mcps/playwright.yaml
  actions:
    - actions/performance-optimization.yaml
prompt: |
  Let's make our application faster and more efficient.
  Performance is a critical feature, directly impacting user experience.
  We will use a data-driven approach to identify and eliminate bottlenecks.
  Our focus will be on measurable improvements in speed and resource usage.
  Let's start by profiling the application to find optimization opportunities.
enhanced-prompt: |-
  # Performance Optimization Context

  ## Core Philosophy
  We treat performance as a feature. Our goal is to deliver a fast, responsive, and efficient user experience through systematic analysis, profiling, and targeted optimization.

  ## Performance Optimization Process
  1.  **Measure**: Identify key performance indicators (KPIs) and establish a baseline using profiling tools.
  2.  **Analyze**: Analyze the data to find the most significant bottlenecks in our code.
  3.  **Optimize**: Implement targeted improvements. This could involve algorithmic changes, caching, or reducing resource sizes.
  4.  **Verify**: Measure again to confirm the improvement and ensure no regressions were introduced.

  ## Key Performance Areas
  - **Load Time**: Minimize Time to First Byte (TTFB), First Contentful Paint (FCP), and Time to Interactive (TTI).
  - **Runtime Performance**: Optimize CPU usage, memory allocation, and rendering pipeline.
  - **Network Efficiency**: Reduce payload sizes, minimize requests, and leverage caching.
  - **Database Performance**: Optimize queries, use appropriate indexing, and manage connections efficiently.

  ## Core Metrics to Track
  - **Web Vitals**: LCP, FID, CLS.
  - **Server Response Time**: Average and p95/p99 latencies.
  - **Bundle Size**: JavaScript, CSS, and other critical assets.
  - **Memory Usage**: Heap size and garbage collection frequency.

  **Ready to boost performance. Where should we begin our analysis?**
