# Continue.dev Complexity Optimizer
# Add to .continue/config.yaml in your project or ~/.continue/config.yaml globally

customCommands:
  - name: complexity-report
    description: Analyze codebase for algorithmic complexity hotspots
    prompt: |
      Analyze this codebase for algorithmic complexity and performance hotspots.

      Run the scanner first:
      ```bash
      python3 ~/.continue/complexity-optimizer/analyze_complexity.py . --format markdown
      ```

      Then produce a report with:
      - Scope analyzed, stack/test commands detected
      - Top findings ranked by impact
      - Findings as a table, mandatory columns (never drop one): Location | Current pattern | Current (Cost) | Future | Impact | Risk | Recommended change
      - Tests/benchmarks needed

      Follow these rules:
      - Only edit files if I explicitly ask to implement/fix/optimize
      - Prefer maps/sets for lookups, indexing for nested scans, memoization for renders, bulk fetch for N+1
      - Verify: tests + lint/build, benchmark if non-obvious
      - Safety: preserve ordering, identity, auth/tenant constraints

      After implementing optimizations, benchmark the changes:
      - Generate a temp script measuring original vs optimized function (timeit+tracemalloc for Python, performance.now+process.memoryUsage for JS/TS)
      - Use project fixtures first, synthetic data as fallback
      - Report results in a Performance Benchmark table: Function | Metric | Before | After | Delta | Change%
      - Auto-scale units (μs/ms/s, KB/MB/GB), include data source and dev-machine disclaimer
      - Skip with reason if environment is restricted
