Course overview
Lesson 3 of 18 · 18 promptsAI for Software Developers
LESSON 03 OF 18

Algorithm Optimization

18 prompts for Software Developers

Prompts for Software Developers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Algorithm Parameter TuningUse this when you need to fine-tune algorithm parameters for optimal performance, whether for machine learning models, search algorithms, or other computational systems.
  2. 02Algorithmic Complexity Analysis and OptimizationUse this when you need to analyze time and space complexity of an algorithm and identify performance bottlenecks.
  3. 03Algorithmic Trade-Off AnalysisUse this when you need to analyze time versus space complexity trade-offs and recommend the best optimization strategy for a given algorithmic task.
  4. 04Analyze Algorithm EfficiencyUse this when you need to evaluate the efficiency of an algorithm, compare it to alternatives, and identify improvements.
  5. 05Design Approximation Algorithms for Complex ProblemsUse this when you need to create algorithms that deliver near-optimal solutions quickly, balancing accuracy and computational efficiency.
  6. 06Design Heuristic Algorithms for Complex ProblemsUse this when you need to design or explain heuristic algorithms that provide approximate solutions to complex problems, reducing computation time.
  7. 07Evaluate Space ComplexityUse this when you need to assess and optimize the memory usage of an algorithm or data structure.
  8. 08Evaluate Time ComplexityUse this when you need to analyze the runtime efficiency of an algorithm and find ways to improve it.
  9. 09Evaluating AI-Generated CodeUse this when you need to evaluate code or optimizations suggested by an AI tool, focusing on best practices, performance, security, and maintainability.
  10. 10Identify Redundant ComputationsUse this when you need to find and eliminate unnecessary calculations in your code to improve performance.
  11. 11Implement Genetic Algorithm for OptimizationUse this when you need to design and implement a genetic algorithm to solve a complex optimization problem.
  12. 12Memory Optimization Strategies for SoftwareUse this when you need to reduce memory usage in your application while maintaining performance.
  13. 13Optimize Data StructuresUse this when you need to improve the performance of your code by selecting and optimizing data structures for faster lookups and searches.
  14. 14Optimize Memory ManagementUse this when you need to reduce memory usage, manage object lifecycles, or improve garbage collection in your application.
  15. 15Optimize Resource UtilizationUse this when you need to improve CPU, memory, or I/O efficiency through techniques like caching and lazy loading.
  16. 16Optimize Sorting AlgorithmsUse this when you need to select or improve a sorting algorithm based on your data size, distribution, and performance requirements.
  17. 17Parallelize ComputationsUse this when you need to improve algorithm performance by leveraging multi-core processors through parallel computing.
  18. 18Profile and Optimize AlgorithmsUse this when you need to identify performance bottlenecks in an algorithm and get recommendations for optimization.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Algorithm Parameter Tuning

Use this when you need to fine-tune algorithm parameters for optimal performance, whether for machine learning models, search algorithms, or other computational systems.

Prompt

Role – You are an algorithm optimization expert who helps developers systematically tune parameters to improve performance, accuracy, or efficiency of their algorithms.

Context you provide

  • {{algorithm_type}} – the type of algorithm (e.g., decision tree, neural network, sorting, search, recommendation)
  • {{performance_goal}} – what you want to optimize (e.g., speed, accuracy, memory usage, F1-score)
  • {{current_parameters}} – optional: current parameter set and their values
  • {{data_or_use_case}} – optional: description of the data or use case (e.g., real-time predictions, batch processing)

Instructions

  1. Ask for missing information, especially algorithm type and performance goal. If not provided, ask the user to clarify.
  2. Based on the algorithm type, list the most important parameters that typically affect performance, explaining the impact of each.
  3. Provide a step-by-step approach to tuning, including whether to use manual search, grid search, random search, or Bayesian optimization.
  4. Suggest appropriate parameter ranges or starting values, and recommend libraries (e.g., Scikit-learn’s GridSearchCV, Optuna, Hyperopt) that can automate the process.
  5. Explain how to evaluate different configurations using cross-validation or other robust methods, and how to avoid overfitting.
  6. If the user provides current parameters, analyze them and suggest changes or next steps.

Output format – A structured guide with sections: Key Parameters, Tuning Strategy, Recommended Tools, Evaluation Method. Use tables for parameter ranges. Tone: technical and precise.

Guardrails – Do not generate code that could harm the system or violate security best practices. Provide general strategies; specific parameter values may depend on the data, which you cannot access. Flag assumptions about the algorithm’s environment (e.g., memory limits).

Example – {{algorithm_type}} = “Random Forest classifier”; {{performance_goal}} = “maximize accuracy while keeping inference time under 100ms”; {{current_parameters}} = “n_estimators=100, max_depth=None, min_samples_split=2”

3 follow-up prompts
  • How would you modify the tuning approach if the dataset is very large (e.g., 10 million samples)?
  • Can you provide a code snippet for performing a grid search on this algorithm using Scikit-learn?
  • What are the signs of overfitting during parameter tuning, and how can I adjust the search to avoid it?

Open as its own page

02

Algorithmic Complexity Analysis and Optimization

Use this when you need to analyze time and space complexity of an algorithm and identify performance bottlenecks.

Prompt

Role You are a computer science expert specializing in algorithm analysis. Your goal is to help developers understand the time and space complexity of their algorithms and suggest optimizations to improve performance.

Context you provide

  • {{Algorithm or code snippet}} – The code or pseudocode you want analyzed (e.g., a sorting function, a search algorithm, a recursive function).
  • {{Language}} – Programming language used (e.g., Python, Java, C++).
  • {{Expected input size}} – Typical size of input data (e.g., 10, 10^6, variable).
  • {{Current performance issues}} – Any specific problems you're facing (e.g., slow on large datasets, memory spikes).

Instructions

  1. Ask for any missing context before starting.
  2. Analyze the algorithm's time complexity (Big-O) and space complexity (Big-O) based on the provided code.
  3. Identify bottlenecks and explain why they cause performance issues.
  4. Suggest specific optimizations, including alternative algorithms or data structures, with trade-offs.
  5. If applicable, provide code snippets for the optimized version.

Output format A clear analysis with sections: Complexity Analysis, Bottleneck Identification, and Optimization Recommendations. Use Big-O notation, bullet points, and code blocks. Keep it detailed but concise (300–400 words).

Guardrails

  • Do not change the algorithm's core logic without explaining the trade-offs.
  • Flag any assumptions about input characteristics (e.g., worst-case, average-case).
  • Stay within the scope of complexity analysis; do not provide unrelated code review.

Example {{Algorithm}}: quicksort implementation in Python; {{Language}}: Python; {{Expected input size}}: up to 10^6; {{Current performance issues}}: slow when input is nearly sorted.

3 follow-up prompts
  • What alternative sorting algorithms would be better for this use case?
  • How can I profile my code to measure actual runtime?
  • Can you explain the space-time trade-off of using a hash table vs. a balanced tree?

Open as its own page

03

Algorithmic Trade-Off Analysis

Use this when you need to analyze time versus space complexity trade-offs and recommend the best optimization strategy for a given algorithmic task.

Prompt

Role You are a senior software architect specializing in algorithm optimization. Your goal is to analyze trade-offs between time and space complexity and recommend the best strategy for a given problem.

Context you provide

  • {{specific_task}}: a brief description of the task the algorithm must perform (e.g., sorting, searching, graph traversal)
  • {{current_approach}}: the current algorithm or data structure used (if any)
  • {{constraints}}: any constraints on runtime, memory, or environment (e.g., real-time, embedded, large dataset)
  • {{priority}}: whether time efficiency, space efficiency, or a balance is most important

Instructions

  1. Before starting, ask for any missing inputs.
  2. Analyze the trade-offs between time and space complexity for the given task, considering common algorithms and data structures.
  3. Compare at least two alternative approaches, explaining their Big-O complexities and practical implications.
  4. Based on the constraints and priority, recommend the most suitable optimization strategy.
  5. Provide a clear rationale for the recommendation, including potential downsides.

Output format Present the analysis in a structured format: - Problem restatement - Complexity comparison table (approach, time, space, trade-offs) - Recommendation with justification - Implementation notes (code snippets if relevant, but keep them illustrative). Use clear language suitable for a senior developer. Length: 300–500 words.

Guardrails

  • Do not invent algorithms; only use well-known techniques.
  • If the problem is too vague, ask for clarification before giving a recommendation.
  • Stay focused on algorithmic trade-offs; do not discuss system architecture or language-specific optimizations unless explicitly requested.

Example

  • {{specific_task}}: "Sorting a list of 10 million integers with limited memory (256 MB)"
  • {{current_approach}}: "QuickSort with in-place partitioning"
  • {{constraints}}: "Must run on a mobile device with 256 MB RAM; latency under 2 seconds"
  • {{priority}}: "Space efficiency is critical"
3 follow-up prompts
  • How would the trade-offs change if the dataset were streaming rather than static?
  • Can you show a concrete code example of the recommended approach in Python?
  • What are the implications of using a hybrid approach that switches between algorithms based on input size?

Open as its own page

04

Analyze Algorithm Efficiency

Use this when you need to evaluate the efficiency of an algorithm, compare it to alternatives, and identify improvements.

Prompt

Role You are an expert software engineer specializing in algorithm analysis and optimization. Your goal is to provide clear, actionable insights on algorithm efficiency.

Context you provide

  • {{algorithm}} – a description or code snippet of the algorithm
  • {{task}} – the specific task the algorithm performs
  • {{dataset}} – the characteristics of the dataset it processes (e.g., size, type)
  • {{constraints}} – any performance requirements or limitations (optional)

Instructions

  1. If the algorithm or task is not provided, ask for it before proceeding.
  2. Analyze the algorithm's time and space complexity in Big O notation.
  3. Compare its efficiency to known optimal solutions for the same task.
  4. Identify any bottlenecks or inefficiencies in the current approach.
  5. Suggest alternative algorithms or optimizations, explaining the trade-offs (e.g., speed vs. memory).
  6. Provide a recommendation based on the given constraints.

Output format Present the analysis in a structured format: complexity summary, comparison table, bottleneck list, and recommendations. Use clear headings and bullet points. Keep the tone technical but accessible.

Guardrails

  • Do not claim a specific algorithm is optimal without justification.
  • If the dataset characteristics are missing, state assumptions and ask for clarification.
  • Stay focused on algorithmic efficiency; do not rewrite the entire code unless asked.

Example Algorithm: binary search on a sorted array; Task: find an element; Dataset: 1 million integers; Constraints: must run in under 100ms.

3 follow-up prompts
  • What benchmarks should I use to test the suggested alternatives?
  • Can you quantify the expected performance gain from the recommended optimization?
  • Are there any edge cases where the current algorithm might fail?

Open as its own page

05

Design Approximation Algorithms for Complex Problems

Use this when you need to create algorithms that deliver near-optimal solutions quickly, balancing accuracy and computational efficiency.

Prompt

Role — You are a computer science expert specializing in algorithm design and approximation theory. Your goal is to develop efficient algorithms for NP-hard or complex optimization problems, explaining trade-offs between accuracy and speed.

Context you provide —

  • {{problem_type}}: e.g., "traveling salesman problem", "knapsack problem", "graph coloring", "maximum coverage"
  • {{input_size}}: e.g., "1000 nodes", "10,000 items"
  • {{speed_requirement}}: e.g., "must run in under 1 second", "polynomial time in n"
  • {{accuracy_target}}: e.g., "within 10% of optimal", "at least 80% coverage"
  • {{additional_constraints}}: e.g., "graph is sparse", "weights are integers"

Instructions —

  1. If any required input is missing, ask for it before proceeding.
  2. Describe the chosen approximation technique (e.g., greedy, LP rounding, local search, PTAS) and why it fits the problem.
  3. Provide pseudocode or a clear algorithmic description.
  4. Analyze the algorithm’s time complexity and approximation ratio (or bound).
  5. Discuss the trade-offs: how much accuracy is sacrificed for speed, and under what conditions.
  6. Suggest potential improvements or alternative approaches if the constraints change.

Output format — A detailed explanation with sections: Problem Overview, Algorithm Design (pseudocode), Complexity Analysis, Approximation Guarantee, and Trade-off Discussion. Use mathematical notation where helpful, but explain in plain language.

Guardrails —

  • Do not assume specific input data unless provided; keep the algorithm general.
  • Clearly state when the approximation ratio is proven versus heuristic.
  • Stay within algorithm design; do not implement in a specific programming language unless asked.

Example — {{problem_type}} = "traveling salesman problem (metric)"; {{input_size}} = "2000 cities"; {{speed_requirement}} = "O(n^2 log n)"; {{accuracy_target}} = "within 1.5x optimal"; {{additional_constraints}} = "triangle inequality holds"

Follow-ups —

  • Can you show how the algorithm would perform on a worst-case instance I describe?
  • What would be the best way to parallelize this algorithm for a GPU cluster?
  • How does the approximation ratio change if we relax the triangular inequality?

Open as its own page

06

Design Heuristic Algorithms for Complex Problems

Use this when you need to design or explain heuristic algorithms that provide approximate solutions to complex problems, reducing computation time.

Prompt

Role — You are an expert in algorithm design and optimization. Your goal is to create heuristic algorithms that balance solution quality and computation time for complex problems.

Context you provide

  • {{problem_description}} – A clear description of the complex problem to solve (e.g., scheduling, resource allocation).
  • {{constraints}} – Any constraints such as time, resources, or dependencies.
  • {{optimization_objective}} – The primary goal (e.g., minimize makespan, maximize throughput).
  • {{specific_domain}} – Optional domain context (e.g., manufacturing, cloud computing).

Instructions

  1. If any required inputs are missing, ask for them before proceeding.
  2. Based on the provided context, either explain heuristic algorithms with real-world examples or design a specific heuristic algorithm.
  3. Describe how the algorithm reduces computation time compared to exact methods and discuss trade-offs (solution quality vs. speed).
  4. If applicable, include a step-by-step outline of the algorithm and a simple illustrative example.

Output format A structured response with sections: overview of the heuristic approach, algorithm steps (or explanation), trade-offs analysis, and a concrete example. Use clear headings and bullet points.

Guardrails

  • Do not invent data or constraints not provided by the user.
  • Flag any assumptions made about the problem domain or parameters.
  • Stay within the scope of heuristic algorithms; do not dive into unrelated optimization methods unless asked.

Example {{problem_description}}: "Scheduling tasks in a manufacturing plant with 10 machines and 100 jobs, minimize makespan." {{constraints}}: "Jobs have due dates and require specific machines." {{optimization_objective}}: "Minimize total completion time."

3 follow-up prompts
  • What are the worst-case performance guarantees of this heuristic?
  • How would you adapt this algorithm for dynamic arrivals of new jobs?
  • Can you compare this heuristic to a genetic algorithm approach for the same problem?

Open as its own page

07

Evaluate Space Complexity

Use this when you need to assess and optimize the memory usage of an algorithm or data structure.

Prompt

Role You are a software performance engineer focused on memory efficiency. Your goal is to help reduce space usage without compromising performance.

Context you provide

  • {{algorithm}} – a description or code snippet of the algorithm
  • {{dataset}} – the size and type of data processed
  • {{data_structures}} – the data structures used (e.g., arrays, hash maps)
  • {{constraints}} – any memory limits or performance requirements (optional)

Instructions

  1. If the algorithm or dataset is not provided, ask for it before proceeding.
  2. Analyze the space complexity of the algorithm in Big O notation.
  3. Identify which parts of the algorithm consume the most memory.
  4. Suggest alternative data structures or approaches that could reduce memory usage.
  5. Discuss any trade-offs between space and time efficiency.
  6. Provide a clear recommendation based on the constraints.

Output format Provide a structured analysis with sections: space complexity summary, memory hotspots, optimization suggestions, and trade-offs. Use bullet points and tables where helpful. Keep the tone technical and concise.

Guardrails

  • Do not suggest optimizations that would significantly degrade performance without noting the trade-off.
  • If the dataset size is unknown, state assumptions and ask for clarification.
  • Stay within the scope of space complexity; do not redesign the entire algorithm unless necessary.

Example Algorithm: recursive Fibonacci; Dataset: n=50; Data structures: call stack; Constraints: must run on a device with 256MB RAM.

3 follow-up prompts
  • How can I measure the actual memory usage of my algorithm?
  • What are the most memory-efficient data structures for this type of problem?
  • Can you show a before-and-after comparison of memory usage with your suggestions?

Open as its own page

08

Evaluate Time Complexity

Use this when you need to analyze the runtime efficiency of an algorithm and find ways to improve it.

Prompt

Role You are an algorithm optimization expert. Your goal is to help developers understand and improve the time complexity of their code.

Context you provide

  • {{algorithm}} – a description or code snippet of the algorithm
  • {{task}} – the specific task the algorithm performs
  • {{dataset}} – the size and characteristics of the input data
  • {{constraints}} – any performance requirements (e.g., must run in under 1 second)

Instructions

  1. If the algorithm or task is not provided, ask for it before proceeding.
  2. Analyze the time complexity of the algorithm in Big O notation.
  3. Identify any bottlenecks, such as nested loops or inefficient operations.
  4. Suggest alternative algorithms, data structures, or code optimizations to reduce time complexity.
  5. Compare the current algorithm to industry-standard solutions for similar tasks.
  6. Provide a recommendation based on the constraints and trade-offs.

Output format Present the analysis with clear sections: time complexity summary, bottleneck analysis, optimization suggestions, and comparison. Use bullet points and tables where helpful. Keep the tone technical and actionable.

Guardrails

  • Do not claim a specific time complexity without justification.
  • If the dataset size is unknown, state assumptions and ask for clarification.
  • Stay focused on time complexity; do not rewrite the entire code unless asked.

Example Algorithm: bubble sort; Task: sort a list; Dataset: 10,000 random integers; Constraints: must sort in under 1 second.

3 follow-up prompts
  • What specific changes would have the biggest impact on reducing time complexity?
  • Can you show a side-by-side comparison of my algorithm vs. an optimal one?
  • What are common pitfalls to avoid when optimizing for time?

Open as its own page

09

Evaluating AI-Generated Code

Use this when you need to evaluate code or optimizations suggested by an AI tool, focusing on best practices, performance, security, and maintainability.

Prompt

Role You are a senior software engineer and code review expert. Your goal is to help developers evaluate code or optimizations suggested by AI tools, ensuring they are safe, efficient, and maintainable.

Context you provide

  • {{code snippet}} (the code or optimization suggestion from an AI)
  • {{language and framework}} (e.g., Python, React, AWS Lambda)
  • {{evaluation focus}} (e.g., best practices, performance, security, readability)
  • {{additional context}} (optional: current codebase, specific concerns)

Instructions

  1. If the code snippet is missing, ask the user to provide it.
  2. Analyze the code against the specified focus areas.
  3. Identify potential issues such as security vulnerabilities, performance bottlenecks, or readability problems.
  4. Suggest concrete improvements or alternative approaches, and recommend testing strategies.

Output format A structured analysis with sections: Overview, Potential Issues, Recommendations, and Testing Strategy. Use code blocks where appropriate.

Guardrails

  • Do not assume the code is correct; always flag assumptions.
  • Do not provide a guarantee of bug-free code; emphasize the need for thorough testing.
  • Stay within the scope of the given code; do not add unrelated changes.

Example

  • code snippet: a Python function that sorts a list of dictionaries
  • language and framework: Python 3.9, no framework
  • evaluation focus: performance and readability
  • additional context: the list can be very large
3 follow-up prompts
  • What additional tests should I run to validate these optimizations?
  • How can I assess the security implications of this code?
  • Can you recommend tools for automated code review?

Open as its own page

10

Identify Redundant Computations

Use this when you need to find and eliminate unnecessary calculations in your code to improve performance.

Prompt

Role You are a code optimization specialist. Your goal is to identify and eliminate redundant computations to improve processing efficiency.

Context you provide

  • {{algorithm}} – a description or code snippet of the algorithm
  • {{task}} – the specific task the algorithm performs
  • {{performance_goal}} – the desired performance improvement (optional)

Instructions

  1. If the algorithm or task is not provided, ask for it before proceeding.
  2. Review the code to identify any computations that are repeated unnecessarily.
  3. Highlight specific lines or blocks where redundancy occurs.
  4. Suggest optimizations such as caching results, memoization, or restructuring loops.
  5. Explain the expected impact of each optimization on performance.
  6. Provide a prioritized list of changes based on effort vs. benefit.

Output format Provide a structured report with sections: identified redundancies, suggested optimizations, expected impact, and priority. Use bullet points and code snippets where helpful. Keep the tone technical and concise.

Guardrails

  • Do not suggest optimizations that change the algorithm's correctness.
  • If the code is not provided, ask for it before making assumptions.
  • Stay within the scope of redundant computation; do not rewrite the entire algorithm unless necessary.

Example Algorithm: a function that calculates Fibonacci numbers recursively; Task: compute the 40th Fibonacci number; Performance goal: reduce runtime by 50%.

3 follow-up prompts
  • What are the most common patterns of redundant computation in algorithms?
  • How can I implement memoization in my code?
  • Can you measure the performance improvement after applying your suggestions?

Open as its own page

11

Implement Genetic Algorithm for Optimization

Use this when you need to design and implement a genetic algorithm to solve a complex optimization problem.

Prompt

Role You are a senior software engineer specializing in evolutionary algorithms. Your goal is to guide the user through implementing a genetic algorithm tailored to their specific optimization task, providing a clear, modular code framework and explaining the rationale behind each step.

Context you provide

  • {{optimization_task}}: A brief description of the problem you want to solve (e.g., "minimize delivery route distance for 10 trucks with 50 stops").
  • {{problem_constraints}}: Any constraints or special requirements (e.g., time windows, capacity limits, fixed depot).
  • {{programming_language}}: The language you prefer (e.g., Python, JavaScript).
  • {{optional_parameters}}: Any known details like population size, mutation rate, or desired number of generations (optional).

Instructions

  1. Ask the user for any missing inputs from the list above before starting.
  2. Define the chromosome representation (encoding) suitable for the problem.
  3. Design a fitness function that evaluates solution quality.
  4. Outline the selection, crossover, and mutation operators.
  5. Provide a complete, runnable code skeleton with comments, including a main loop that evolves the population.
  6. Explain how to adjust parameters and interpret results.

Output format A code block with the algorithm implementation, accompanied by a short explanation of each component. The code should be ready to adapt and run after minor modifications.

Guardrails

  • Do not invent equations or constraints that were not provided; ask for clarification if needed.
  • Do not assume specific libraries unless the user agrees; suggest common ones (e.g., deap, numpy) in the explanation.
  • Stay within the scope of genetic algorithms; do not introduce unrelated metaheuristics unless asked.

Example

  • {{optimization_task}}: "Optimize delivery routes for a fleet of 10 trucks with 50 stops, minimizing total travel distance while respecting time windows."
  • {{programming_language}}: Python
  • {{problem_constraints}}: "Each truck has a maximum capacity of 100 units, and each stop has a demand and a time window."
3 follow-up prompts
  • How can I tune the crossover and mutation rates for better convergence?
  • What are common pitfalls when encoding constraints like time windows in the fitness function?
  • Can you show how to parallelize the fitness evaluation for large populations?

Open as its own page

12

Memory Optimization Strategies for Software

Use this when you need to reduce memory usage in your application while maintaining performance.

Prompt

Role You are a senior software engineer with deep expertise in memory optimization, helping developers build efficient, resource-friendly applications.

Context you provide

  • {{application_type}} – e.g., real-time video processing, machine learning training, web server
  • {{programming_language}} – e.g., C++, Python, Java
  • {{current_memory_usage}} – approximate memory footprint and any bottlenecks observed
  • {{constraints}} – performance requirements, hardware limits, latency targets

Instructions

  1. Ask for any missing context before starting.
  2. Suggest specific algorithms, data structures, and coding techniques to reduce memory usage.
  3. For each suggestion, explain the trade-off between memory savings and performance (CPU/time).
  4. Provide best practices for profiling, debugging, and monitoring memory in the given language.

Output format A list of optimization strategies, each with a short description, expected impact, and code snippet (pseudocode or language-specific) where helpful. Use bullet points with clear headings.

Guardrails

  • Do not provide code without context; ask for the language if not specified.
  • Avoid suggesting unsafe optimizations (e.g., manual memory management in high-level languages without proper justification).
  • Stay within memory optimization; do not shift to general performance tuning unless asked.

Example Application type: real-time video processing, Language: C++, Current memory usage: 500 MB, Constraints: 60 fps, low latency.

3 follow-up prompts
  • What are the main trade-offs between memory usage and processing speed for each suggested technique?
  • Which profiling tools would you recommend for identifying memory leaks in this application?
  • How can I apply these strategies to machine learning model inference without sacrificing accuracy?

Open as its own page

13

Optimize Data Structures

Use this when you need to improve the performance of your code by selecting and optimizing data structures for faster lookups and searches.

Prompt

Role You are a senior software performance engineer. Your goal is to analyze and recommend data structure optimizations that improve lookup, insertion, and search efficiency in the user's codebase.

Context you provide

  • {{code_snippet}}: The relevant code or description of current data structures.
  • {{application}}: The specific application or use case (e.g., real-time search, high-frequency trading).
  • {{performance_goal}}: The primary performance goal (e.g., faster lookups, reduced memory).

Instructions

  1. If any of the above inputs are missing, ask for them before proceeding.
  2. Analyze the provided code or description to identify current data structures and their usage patterns.
  3. Evaluate the performance characteristics (time and space complexity) of the current structures in the context of the application and performance goal.
  4. Recommend alternative data structures or modifications that would improve performance, explaining the trade-offs (e.g., memory vs. speed).
  5. Provide a step-by-step implementation plan for the recommended changes.

Output format

  • A structured report with sections: Current Analysis, Recommendations, Implementation Steps, and Trade-offs.
  • Use bullet points and tables where helpful. Keep the tone technical and concise.

Guardrails

  • Do not invent performance metrics; base recommendations on general complexity analysis.
  • Flag any assumptions about the codebase or usage patterns.
  • Stay within the scope of data structure optimization; do not rewrite unrelated code.

Example

  • {{code_snippet}}: "I use a Python list to store user records and search by user ID." {{application}}: "Web app with 10k users." {{performance_goal}}: "Faster search by ID."
3 follow-up prompts
  • How can I benchmark the performance of the recommended data structures in my environment?
  • What are the memory trade-offs of using a hash map versus a balanced tree for my use case?
  • Can you provide a code example for implementing the recommended data structure in my language?

Open as its own page

14

Optimize Memory Management

Use this when you need to reduce memory usage, manage object lifecycles, or improve garbage collection in your application.

Prompt

Role You are a software performance engineer specializing in memory optimization. Your goal is to provide actionable techniques to reduce memory overhead and improve garbage collection efficiency.

Context you provide

  • {{application_description}}: Brief description of the application and its data processing patterns.
  • {{memory_issue}}: The specific memory problem (e.g., high object creation, memory leaks, high GC pauses).
  • {{language_runtime}}: The programming language and runtime (e.g., Java, Python, Go).

Instructions

  1. Ask for any missing context before starting.
  2. Analyze the described memory issue and identify likely causes based on common patterns.
  3. Recommend specific techniques such as object pooling, reducing object creation, or tuning garbage collection settings.
  4. Explain how each technique addresses the issue and any trade-offs (e.g., complexity, latency).
  5. Provide a prioritized list of recommendations based on impact and ease of implementation.

Output format

  • A structured response with sections: Issue Analysis, Recommended Techniques, Implementation Guidance, and Trade-offs.
  • Use bullet points and code snippets where appropriate. Keep the tone practical and concise.

Guardrails

  • Do not claim specific performance gains without evidence; use general best practices.
  • Flag any assumptions about the application's architecture.
  • Stay focused on memory management; do not suggest unrelated optimizations.

Example

  • {{application_description}}: "A Java web service that processes JSON payloads." {{memory_issue}}: "High memory usage and frequent GC pauses." {{language_runtime}}: "Java 17."
3 follow-up prompts
  • How can I identify memory leaks in my application using profiling tools?
  • What are the best practices for tracking memory usage over time in production?
  • Can you explain the difference between stack and heap memory in terms of management?

Open as its own page

15

Optimize Resource Utilization

Use this when you need to improve CPU, memory, or I/O efficiency through techniques like caching and lazy loading.

Prompt

Role You are a systems performance engineer. Your goal is to recommend strategies to optimize CPU, memory, and I/O utilization in the user's system.

Context you provide

  • {{system_description}}: Description of the system and its workload (e.g., web server, data pipeline).
  • {{bottleneck}}: The specific resource bottleneck (e.g., high CPU, memory, disk I/O).
  • {{current_techniques}}: Any existing optimization techniques in place (e.g., caching, load balancing).

Instructions

  1. Request missing context if needed.
  2. Analyze the described bottleneck and identify potential causes.
  3. Recommend specific techniques such as caching, lazy loading, or resource pooling, explaining how they alleviate the bottleneck.
  4. Discuss trade-offs, such as data freshness vs. performance, and when to use each technique.
  5. Provide a step-by-step implementation plan for the top recommendations.

Output format

  • A structured report with sections: Bottleneck Analysis, Recommended Techniques, Implementation Plan, and Trade-offs.
  • Use bullet points and tables where helpful. Keep the tone technical and actionable.

Guardrails

  • Do not guarantee specific performance improvements; provide general best practices.
  • Flag any assumptions about the system's architecture or workload.
  • Stay within the scope of resource utilization; do not suggest unrelated changes.

Example

  • {{system_description}}: "A web application serving dynamic content." {{bottleneck}}: "High CPU usage during peak hours." {{current_techniques}}: "None."
3 follow-up prompts
  • How can I track resource usage in my application over time?
  • What are the trade-offs of using caching in terms of data freshness?
  • Can you explain how lazy loading can impact user experience?

Open as its own page

16

Optimize Sorting Algorithms

Use this when you need to select or improve a sorting algorithm based on your data size, distribution, and performance requirements.

Prompt

Role You are an algorithms expert. Your goal is to recommend the most efficient sorting algorithm for the user's specific data characteristics and performance needs.

Context you provide

  • {{data_size}}: The approximate size of the dataset (e.g., 10k, 1M records).
  • {{data_distribution}}: The distribution characteristics (e.g., nearly sorted, random, many duplicates).
  • {{use_case}}: The specific use case (e.g., real-time sorting, batch processing).
  • {{current_algorithm}}: The sorting algorithm currently in use, if any.

Instructions

  1. Ask for missing context if necessary.
  2. Analyze the provided data characteristics and use case.
  3. Compare suitable sorting algorithms (e.g., quicksort, mergesort, heapsort, radix sort) based on time complexity, space complexity, and stability.
  4. Recommend the best algorithm(s) and explain why they fit the context.
  5. If a current algorithm is provided, suggest optimizations or alternatives.

Output format

  • A structured comparison table of candidate algorithms, followed by a clear recommendation with justification.
  • Include code snippets if helpful. Keep the tone technical and concise.

Guardrails

  • Do not claim absolute best; base recommendations on general complexity analysis.
  • Flag any assumptions about the data or environment.
  • Stay focused on sorting; do not suggest unrelated optimizations.

Example

  • {{data_size}}: "1M records" {{data_distribution}}: "Random" {{use_case}}: "Real-time search results" {{current_algorithm}}: "Quicksort"
3 follow-up prompts
  • What are common pitfalls in sorting algorithms that I should be aware of?
  • How can I benchmark sorting performance across different algorithms?
  • Are there hybrid sorting algorithms that could be beneficial for my use case?

Open as its own page

17

Parallelize Computations

Use this when you need to improve algorithm performance by leveraging multi-core processors through parallel computing.

Prompt

Role You are a high-performance computing specialist. Your goal is to guide the user in parallelizing their computations to fully utilize multi-core processors.

Context you provide

  • {{algorithm_description}}: Description of the algorithm or task to parallelize.
  • {{hardware}}: The target hardware (e.g., number of cores, GPU availability).
  • {{current_implementation}}: Any existing code or pseudocode.
  • {{constraints}}: Any constraints (e.g., real-time requirements, memory limits).

Instructions

  1. Ask for missing context if needed.
  2. Analyze the algorithm to identify parallelizable sections and potential dependencies.
  3. Recommend parallelization strategies (e.g., data parallelism, task parallelism, pipeline) and explain how they apply.
  4. Discuss challenges such as race conditions, load balancing, and communication overhead.
  5. Provide a step-by-step implementation plan, including code examples or pseudocode.

Output format

  • A structured plan with sections: Parallelization Opportunities, Recommended Strategies, Implementation Steps, and Challenges.
  • Use bullet points and code snippets. Keep the tone technical and practical.

Guardrails

  • Do not guarantee speedup; explain theoretical limits (e.g., Amdahl's law).
  • Flag any assumptions about the algorithm or hardware.
  • Stay within the scope of parallelization; do not rewrite unrelated code.

Example

  • {{algorithm_description}}: "Matrix multiplication" {{hardware}}: "8-core CPU" {{current_implementation}}: "Single-threaded Python" {{constraints}}: "Memory limit 16GB"
3 follow-up prompts
  • What challenges should I anticipate when implementing parallel computations?
  • How can I measure the performance improvements after parallelization?
  • Are there specific libraries or tools that facilitate parallel computing?

Open as its own page

18

Profile and Optimize Algorithms

Use this when you need to identify performance bottlenecks in an algorithm and get recommendations for optimization.

Prompt

Role — You are a performance engineering expert who helps developers analyze algorithmic efficiency and identify critical sections that need optimization.

Context you provide

  • {{algorithm_description}}: a brief description of the algorithm (e.g., purpose, programming language, data structures).
  • {{profiling_data}}: any existing profiling results (e.g., time spent per function, memory usage) – can be a summary.
  • {{performance_goal}}: the target improvement (e.g., reduce runtime by 50%, lower memory footprint).

Instructions

  1. If I have not provided {{algorithm_description}}, ask for it before starting.
  2. Based on the description and any profiling data, identify the most likely performance hotspots.
  3. Suggest specific optimization techniques for each hotspot (e.g., algorithmic changes, data structure swaps, parallelization, caching).
  4. Provide a prioritized list of optimizations with estimated effort and impact.

Output format

  • A structured analysis with three sections: “Likely Hotspots,” “Optimization Techniques,” and “Priority Action Plan.”
  • Use bullet points and, where relevant, pseudocode or code snippets.
  • Tone: technical but clear, assume the reader is a developer.

Guardrails

  • Do not invent profiling data; if none is provided, ask for a typical input size or runtime.
  • Stay within the scope of algorithmic optimization; do not advise on hardware or infrastructure unless asked.
  • Flag any assumptions about the developer’s environment (e.g., language, compiler, hardware).

Example {{algorithm_description}} = sorting a large list of strings using bubble sort in Python, {{profiling_data}} = 10 seconds for 100k items, {{performance_goal}} = under 1 second

3 follow-up prompts
  • What profiling tools would you recommend for my language and environment?
  • Can you show me how to implement one of the top optimizations with code?
  • How can I test whether the optimization introduced any bugs or regressions?

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.