Skip to main content
command

optimize-api-performance — Claude Code command: what it does

A slash command that walks an API through bottlenecks: slow endpoints, database queries, caching, rate limits. Useful when responses drag under load.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --command performance/optimize-api-performance
Open on GitHub

What optimize-api-performance does

The command runs fifteen passes over your API. It starts by measuring response times and throughput, then hunts for the slowest endpoints and the patterns behind them. From there it moves to request parsing, response serialization and compression.

Database work comes next: slow queries, indexes, connection pooling, plus multi-level caching across memory, Redis and CDN. Rate limiting, throttling, queues and circuit breakers follow, along with async I/O and parallel execution for independent calls.

Later sections cover gateways and load balancing, monitoring with distributed tracing, auth and JWT validation, CDN delivery, endpoint design with pagination and filtering, load testing, and a scaling plan. External services get retries, timeouts and fallbacks.

Pass the API type as [api-type] or with --rest, --graphql, --grpc. The tool list is read-only — Read, Bash, Grep, Glob — so the command proposes changes instead of editing code. Cache and rate-limit settings in production configs you apply and verify yourself.

What it helps with

  • find which endpoints are slowest under real traffic
  • trace slow database queries and add missing indexes
  • set up multi-level caching with sensible TTLs
  • add rate limits and queues for traffic spikes
  • prepare load tests and a horizontal scaling plan

Example prompts for the agent

  • Analyze API performance and list the slowest endpoints
  • Optimize this REST API: caching, rate limits and connection pooling
  • Review the GraphQL queries and draft a scaling plan

How to install optimize-api-performance

1claude-code-templates

npx claude-code-templates@latest --command performance/optimize-api-performance

2Manually: put the files in place

.claude/commands/optimize-api-performance.md

Call it with /optimize-api-performance. For all projects use ~/.claude/commands/

Questions about optimize-api-performance

How do I install optimize-api-performance in Claude Code?

Run npx claude-code-templates@latest --command performance/optimize-api-performance. It lands in .claude/commands/optimize-api-performance.md.

What does optimize-api-performance do?

It reviews an API across fifteen areas: metrics, database queries, caching, rate limits, concurrency, gateways, monitoring, security, CDN, endpoint design, load testing and scaling. You get a prioritized list of changes ranked by impact on response time.

Which tools can the command use?

Only Read, Bash, Grep and Glob. It does not edit code — it suggests changes for you to apply.

Source text

optimize-api-performance.md · MIT
---
allowed-tools: Read, Bash, Grep, Glob
argument-hint: "[api-type] | --rest | --graphql | --grpc"
description: Comprehensive API performance optimization with response time reduction, throughput improvement, and scalability enhancements
---

# Optimize API Performance

Analyze and optimize API performance for faster response times, higher throughput, and better scalability: **$ARGUMENTS**

## Instructions

1. **API Performance Analysis**
   - Analyze current API response times and throughput metrics
   - Identify slowest endpoints and bottleneck patterns
   - Profile API request/response lifecycle and processing time
   - Document baseline performance metrics across different load scenarios
   - Map API dependency chains and external service calls

2. **Request/Response Optimization**
   - Optimize request parsing and validation logic
   - Implement efficient response serialization and compression
   - Minimize payload sizes through selective field inclusion
   - Configure appropriate HTTP headers and caching directives
   - Optimize request routing and middleware processing

3. **Database Query Optimization**
   - Identify and optimize slow database queries
   - Implement query result caching strategies
   - Add appropriate database indexes for API queries
   - Optimize database connection pooling and management
   - Implement query batching and aggregation where applicable

4. **Caching Strategy Implementation**
   - Implement multi-level caching (in-memory, Redis, CDN)
   - Configure cache invalidation strategies
   - Set up API response caching with appropriate TTL values
   - Implement cache warming and preloading strategies
   - Monitor cache hit ratios and effectiveness

5. **Rate Limiting and Throttling**
   - Implement intelligent rate limiting based on usage patterns
   - Configure adaptive throttling for different user tiers
   - Set up queue management for handling traffic spikes
   - Implement circuit breaker patterns for external services
   - Monitor and adjust rate limits based on performance metrics

6. **Concurrency and Parallelization**
   - Implement proper async/await patterns for I/O operations
   - Optimize thread pool configuration and management
   - Implement parallel processing for independent operations
   - Configure connection pooling for optimal concurrency
   - Use streaming for large data transfers

7. **API Gateway and Load Balancing**
   - Configure API gateway for optimal routing and load distribution
   - Implement health checks and automatic failover
   - Set up load balancing algorithms for even traffic distribution
   - Configure request/response transformation at gateway level
   - Implement API versioning and traffic splitting

8. **Monitoring and Observability**
   - Set up comprehensive API performance monitoring
   - Implement distributed tracing for request lifecycle visibility
   - Configure performance metrics collection and alerting
   - Monitor API error rates and response time percentiles
   - Set up real-time performance dashboards

9. **Security Performance Optimization**
   - Optimize authentication and authorization processes
   - Implement efficient JWT validation and caching
   - Configure SSL/TLS termination for optimal performance
   - Optimize API key validation and rate limiting
   - Implement security middleware performance tuning

10. **Content Delivery Optimization**
    - Configure CDN for static API responses and assets
    - Implement geographic load balancing and edge caching
    - Optimize API endpoint geographical distribution
    - Set up content compression and optimization
    - Configure cache headers for optimal CDN performance

11. **API Design Optimization**
    - Review and optimize API endpoint design patterns
    - Implement efficient pagination and filtering strategies
    - Optimize API versioning and backward compatibility
    - Design APIs for optimal client-side caching
    - Implement GraphQL query optimization (if applicable)

12. **Load Testing and Performance Validation**
    - Implement comprehensive load testing scenarios
    - Configure performance regression testing in CI/CD
    - Set up chaos engineering tests for resilience validation
    - Monitor API performance under various load conditions
    - Validate performance optimizations with realistic test data

13. **Scalability Planning**
    - Design API architecture for horizontal scaling
    - Implement auto-scaling policies based on performance metrics
    - Configure database scaling strategies (read replicas, sharding)
    - Plan for traffic growth and capacity requirements
    - Implement graceful degradation strategies

14. **Third-Party Service Optimization**
    - Optimize external API calls and integrations
    - Implement retry policies and exponential backoff
    - Configure timeout settings for external services
    - Set up fallback mechanisms for service unavailability
    - Monitor third-party service performance impact

15. **Performance Testing Automation**
    - Set up automated performance testing pipelines
    - Configure performance benchmarking and comparison
    - Implement performance regression detection
    - Set up load testing in staging environments
    - Create performance test data management strategies

Focus on optimizations that provide the highest impact on response times and throughput. Prioritize changes that improve user experience and system scalability while maintaining reliability.

© davila7 · MIT · davila7/claude-code-templates

Similar slash commands

All slash commands for Backend and APIs →

From the same set361

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor