---
tags:
- Documentation
- Bookstack
- Notes
---
# AI Development
# AI Development Prompt Templates
Here is a clean, professional, and well-structured markdown template based on your provided prompts. I have eliminated redundancies (like the duplicated review points), organized the sections into logical modules, and formatted it so you can quickly copy-paste it whenever you need AI-assisted development.
# AI Development Prompt Templates
## 1. Code Generation
Use this prompt when you need to build a new class, module, or specific functionality from scratch.
```
Act as an expert software engineer. I need to implement the following functionality:
- **Task:** [e.g., Create a class/module for a rate-limiter]
- **Language/Framework:** [programming language/framework]
### Key Requirements
1. [Requirement 1]
2. [Requirement 2]
3. [Requirement 3]
### Implementation Guidelines
- Include a proper constructor/initialization method.
- Implement main public methods with clear docstrings.
- Break down complex logic into private helper methods where appropriate.
- Ensure proper encapsulation and strict adherence to OOP principles.
- Implement thorough error handling and guard against edge cases.
- Optimize for performance and follow best practices for [language/framework].
- Do not unnecessarily remove any context. Include clear inline comments explaining the core logic.
```
## 2. Code Review & Explanation
Use this prompt when you want to deeply understand an existing piece of code and identify potential vulnerabilities or flaws.
```
Act as a senior code reviewer. Please review and explain the following code snippet in detail:
---
[PASTE CODE HERE]
---
### Analysis Requested
1. **Purpose:** What is the primary objective of this code section?
2. **Step-by-Step Walkthrough:** How does it execute line-by-line?
3. **Evaluation:** Are there any potential issues or limitations with this approach?
### Evaluation Criteria
Please evaluate the code against the following lenses:
- **Code Quality:** Readability, maintainability, and adherence to clean code standards.
- **Robustness:** Potential bugs, unhandled edge cases, or missing error states.
- **Performance:** Execution bottlenecks or optimization opportunities.
- **Security:** Any vulnerabilities or safety concerns.
Provide specific suggestions for improvement and explain the reasoning behind each recommendation.
```
## 3. Code Refactoring & Rewriting
Use this prompt when you have working code but want to elevate it to production-grade quality.
```
Act as a principal engineer. Please review and rewrite the following code to make it production-ready, highly optimized, and maintainable.
---
[PASTE CODE HERE]
---
### Refactoring Requirements
Please refactor the code while prioritizing the following:
- **Robustness:** Add comprehensive error handling and address edge cases.
- **Performance:** Optimize execution time and memory footprint where applicable.
- **Security:** Fix any potential security vulnerabilities.
- **Clean Code:** Improve readability, maintainability, and alignment with modern language best practices.
Please provide the final refactored code with clear comments, accompanied by a brief summary of the key improvements made and why they were necessary.
```