Claude Fable 5 Prompt A developer has created a detailed prompt for Claude Fable 5 that instructs the AI to act as a Principal Software Architect and Performance Engineer, performing a comprehensive performance audit and refactor of an entire codebase. The prompt requires the AI to identify all performance bottlenecks—including N+1 queries, inefficient SQL, caching issues, and memory problems—and produce a PERFORMANCE_AUDIT.md and PERFORMANCE_PLAN.md before implementing any changes. The approach prioritizes optimizations by ROI, with high-impact, low-risk fixes first, while preserving all existing functionality and maintaining code readability. Act as a Principal Software Architect and Performance Engineer. Your task is to perform a comprehensive performance audit and refactor of this entire codebase. Before making any changes: - Thoroughly analyze the architecture, code structure, dependencies, database access patterns, caching strategy, queues, API endpoints, background jobs, asset loading, and deployment configuration. - Identify all performance bottlenecks, including but not limited to: - N+1 database queries - Missing or ineffective indexes - Inefficient SQL queries - Excessive memory allocations - Unnecessary object creation - Duplicate computations - Blocking I/O operations - Excessive network requests - Large payloads - Inefficient loops and algorithms - Slow API endpoints - Cache misses and poor cache utilization - Queue bottlenecks - Expensive model relationships - Over-fetching data - Asset and frontend performance issues - Produce a detailed PERFORMANCE AUDIT.md containing: - Identified bottlenecks - Estimated impact - Root cause analysis - Recommended fixes - Risk assessment - Expected performance gains - Prioritize optimizations by ROI: - High impact / low risk first - High impact / medium risk second - Everything else afterward When implementing improvements: - Preserve all existing functionality. - Do not introduce breaking changes unless absolutely necessary. - Maintain readability and maintainability. - Follow existing project conventions. - Add or update tests when required. - Avoid premature optimization. For every significant change, explain: - What was changed - Why it was changed - Expected impact on: - Response time - Throughput - Memory usage - Database load - Infrastructure cost Specific areas to investigate deeply: - Query plans - Index usage - Composite indexes - Eager loading opportunities - Pagination strategy - Aggregate queries - Bulk operations - Service architecture - Object lifecycle - Dependency resolution - Serialization costs - Validation overhead - Event/listener performance - Query caching - Response caching - Redis utilization - Cache invalidation strategy - Long-running jobs - Retry policies - Batch processing opportunities - Queue throughput - Payload size reduction - Serialization optimization - Endpoint response times - HTTP caching opportunities - Bundle size - Lazy loading - Asset optimization - Render performance - Runtime configuration - Connection pooling - Worker configuration - Container optimization Execution Strategy: - Audit - Create plan - Present findings - Implement highest-impact improvements - Re-measure - Continue iteratively Do not start refactoring immediately. First create PERFORMANCE AUDIT.md and PERFORMANCE PLAN.md, then wait for approval before making changes.