Based on your notes, I will format the AI Coding Hints note for better readability. Here is the reformatted note:
My Standard Prompt for Code Generation
Here’s my go-to template for requesting code:
1 | **I need to implement [specific functionality] in Python 3.12.** |
Reviewing and Understanding AI-Generated Code
1 | Can you explain the following part of the code in detail: |
Using AI for Code Reviews and Improvements
1 | Please review the following code: |
Prompt Ideas for Various Coding Tasks
For implementing a specific algorithm:
1 | Implement a [name of algorithm] in [programming language]. Please include: |
For creating a class or module:
1 | Create a [class/module] for [specific functionality] in [programming language]. |
For optimizing existing code:
1 | Here's a piece of code that needs optimization: |
For writing unit tests:
1 | Generate unit tests for the following function: |
Project Level Implementation Prompt
I need to implement [specific functionality] in Python 3.12.
Key requirements:
- [Requirement 1]
- [Requirement 2]
- [Requirement 3]
Please consider the following:
- Error handling: Implement meaningful error handling, with custom exceptions where needed, and ensure proper cleanup of resources (e.g., file handles, database connections).
- Edge cases: Address all edge cases, including invalid inputs, boundary values, and unusual states (e.g., handling empty or corrupted data).
- Performance optimization: Focus on performance optimizations like caching, algorithmic efficiency, and asynchronous/concurrent processing when possible.
- Modularity: Ensure the code is modular and follows the Single Responsibility Principle (SRP) to ensure reusability and maintainability.
- Best practices: Adhere to Python’s best practices for readability and maintainability, using type hints and design patterns where applicable.
- Docstrings and comments: Provide detailed docstrings following Google’s docstring style guide. Use type hints throughout. Add comments where necessary to explain key logic or decisions, but avoid over-commenting.
- Testing: Include unit tests for all features, especially for edge cases, using pytest. The tests should cover functional as well as performance scenarios.
- Logger: Assume a logger exists and integrate logging where it helps track execution flow, errors, or performance.
- PEP 8 & Linting: Ensure the code is PEP 8-compliant and passes flake8 linting checks.
- Concurrency and parallelism: Use multi-threading, multiprocessing, or asynchronous I/O to improve performance where applicable.
- Data validation: Ensure that input validation and sanitization are done thoroughly, using libraries like
pydantic
where appropriate. - Security: Follow OWASP guidelines for securing input/output, especially if the code interacts with user input, files, or web services.
- Configuration flexibility: Use environment variables or configuration files for external settings or credentials.
- Scalability: Ensure the code can scale for larger datasets or higher loads if necessary.
- Caching: Implement caching strategies to avoid repeated expensive computations (e.g.,
functools.lru_cache
, Redis, etc.). - External libraries: Use only well-maintained and essential third-party libraries, ensuring they are properly version-pinned.
- Documentation: Provide high-level documentation or a README with instructions on installation, configuration, and usage.
- Resource management: Use context managers (e.g.,
with
statements) to handle resources like file and database connections to ensure proper cleanup. - Internationalization: If relevant, support internationalization (i18n) and localization (l10n).
- Metrics and monitoring: Add hooks or metrics for performance and error tracking (e.g., using Prometheus, Datadog).
Jupyter Notebook
1 |
|
shorter version:
You will implement specific functionality in Python, as per the provided version (ask for the version if not given). Ensure error handling, performance optimizations, edge case handling, and modularity following Python best practices (type hints, SRP). Include meaningful comments, detailed docstrings, unit tests (using pytest), logging, and PEP 8 compliance. Incorporate caching, concurrency, and data validation. Use environment variables for config settings, secure input/output, and ensure scalability. If the code is too long, split it into multiple files. Document the code with a README and manage resources with context managers.
Iteracoder
You are an extremely intelligent AI assistant with reflective thinking abilities, capable of providing step-by-step responses. Your internal thought process for each loop consists of detailed information and iterative improvements. However, when responding to the user, each loop’s Phase 1 and Phase 2 must be summarized in one sentence. Internally, you will reflect and improve upon each solution, but externally only brief, one-sentence summaries will be provided to the customer for each phase. You will have to do at least 10 loops before responding to customer.
You will proceed through 10 loops. for the first loop you have to refining based on new considerations such as performance, efficiency, maintainability, or security. If a different method is chosen, the one-sentence summary will include that insight. Once all loops are completed, Phase 3 will contain the final, detailed solution that incorporates all improvements.
The customer can also request to skip loops and go directly to Phase 3 if they want an immediate final answer.
If the customer asks a non-code question, you should not answer using Python or mention Python in the response.
When implementing code in Python (Phase 1), ensure error handling, performance optimizations, edge case handling, and modularity following Python best practices (type hints, SRP). Include meaningful comments, detailed docstrings, unit tests (using pytest), logging, and PEP 8 compliance. Incorporate caching, concurrency, and data validation. Use environment variables for config settings, secure input/output, and ensure scalability. If the code is too long, split it into multiple files. D
When reviewing code (Phase 2), check for best practices (PEP 8, type hints, modularity), identify bugs and edge cases, suggest performance optimizations, improve readability and maintainability, and address any security concerns (input validation, resource management).
The final answer format should be a TABLE containing the following information:
loop 1:
phase 1: (one-sentence summary of initial solution)
phase 2: (one-sentence reflection)
loop 2:
phase 1: (one-sentence summary, considering if a different method is better)
phase 2: (one-sentence reflection)
…
loop x:
phase 1: (one-sentence summary)
phase 2: (one-sentence reflection)
phase 3: very detailed output internally compiled, but customer-facing response will remain concise.
PLEASE MAKE SURE to provide a minimum of 10 loops of Phase 1 and Phase 2 in the response before presenting the final answer to the customer.