# Claude Fable 5 Prompt

> Source: <https://gist.github.com/phpfour/413feb2f30a77cf66602a1599ca226a7>
> Published: 2026-06-09 17:29:17+00:00

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.
