About Prompt
- Prompt Type – Dynamic
- Prompt Platform – ChatGPT, Grok, Deepseek, Gemini, Copilot, Midjourney, Meta AI and more
- Niche – Code Generation
- Language – English
- Category – Education & Training
- Prompt Title – Code Generation Prompt with Copilot
Prompt Details
This prompt is designed to be used with AI code generation tools like GitHub Copilot, Codex, and similar models across various platforms for educational and training purposes. It emphasizes a dynamic structure allowing users to tailor the prompt based on their learning objectives.
**Prompt Structure:**
“`
## Code Generation Request (Education & Training)
**1. Learning Objective:** [Clearly state the specific concept or skill you aim to learn or practice. Be precise and avoid ambiguity. Example: “Understanding recursion in Python,” “Implementing a binary search tree in Java,” “Building a responsive navigation bar with HTML and CSS.”]
**2. Programming Language:** [Specify the desired programming language. Example: “Python,” “Java,” “JavaScript,” “C++.”]
**3. Task Description:** [Describe the specific coding task you want the AI to generate. Be detailed and include expected inputs, outputs, and any specific functionalities. Example: “Write a Python function that calculates the factorial of a given non-negative integer using recursion,” “Implement a Java class for a binary search tree with methods for insertion, deletion, and search,” “Create a responsive navigation bar using HTML and CSS that collapses into a hamburger menu on smaller screens.”]
**4. Code Style and Constraints (Optional):** [Specify any preferred coding style guidelines (e.g., PEP 8 for Python) or constraints (e.g., maximum code complexity, specific libraries to use or avoid, memory usage limitations). Example: “Follow PEP 8 style guidelines,” “Use only standard libraries,” “Minimize memory usage,” “Do not use any external libraries.”]
**5. Test Cases (Optional but Recommended):** [Provide example input and expected output pairs to help the AI generate accurate and robust code. This also serves as a learning tool for understanding how the code should behave. Example: “Input: 5, Output: 120 (for factorial calculation),” “Input: [10, 5, 15, 2, 7], Operations: insert(12), delete(5), search(7), Output: True (for search(7) after operations).”]
**6. Level of Detail (Optional):** [Specify the desired level of code detail. Options include: “Concise,” “Detailed,” “Explanatory.” “Concise” will generate minimal code without comments. “Detailed” includes necessary comments to explain the logic. “Explanatory” provides comprehensive comments and explanations of the code’s functionality, suitable for educational purposes. Default is “Detailed.”]
**7. Pedagogical Focus (Optional):** [For educational purposes, specify any particular concepts or principles you want the generated code to emphasize. Example: “Demonstrate the use of recursion base case and recursive step,” “Illustrate the principles of object-oriented programming,” “Showcase best practices for responsive web design.”]
**8. Specific Libraries or Frameworks (Optional):** [If you want the code to utilize specific libraries or frameworks, mention them here. Example: “Use React for the front-end,” “Use NumPy for array manipulation.”]
**9. Error Handling (Optional):** [Specify whether the code should include error handling and the type of error handling required. Example: “Include basic input validation,” “Implement try-except blocks for potential exceptions.”]
**10. Output Format (Optional):** [Specify the desired output format for the code. Example: “Provide the code in a single file,” “Separate the code into multiple files based on functionality,” “Include a README file explaining how to run the code.”]
“`
**Example Usage:**
“`
## Code Generation Request (Education & Training)
**1. Learning Objective:** Understanding recursion in Python
**2. Programming Language:** Python
**3. Task Description:** Write a Python function that calculates the factorial of a given non-negative integer using recursion.
**4. Code Style and Constraints:** Follow PEP 8 style guidelines.
**5. Test Cases:**
Input: 5, Output: 120
Input: 0, Output: 1
Input: -1, Output: Raise a ValueError for negative input.
**6. Level of Detail:** Explanatory
**7. Pedagogical Focus:** Demonstrate the use of recursion base case and recursive step.
**8. Specific Libraries or Frameworks:** None
**9. Error Handling:** Include input validation for non-negative integers.
**10. Output Format:** Provide the code in a single file with a docstring explaining the function.
“`
**Benefits of this Dynamic Prompt:**
* **Clarity and Specificity:** Ensures the AI understands the desired code functionality and learning goals.
* **Flexibility:** Allows for customization based on individual learning needs and project requirements.
* **Comprehensive Learning:** Encourages best practices like testing, documentation, and error handling.
* **Cross-Platform Compatibility:** Designed to work with various AI code generation tools.
* **Educational Focus:** Promotes understanding of underlying concepts and principles.
This structured and detailed prompt provides a robust framework for generating code tailored to educational and training purposes, maximizing the effectiveness of AI-powered learning experiences. By adjusting the parameters, users can progressively challenge themselves and deepen their understanding of programming concepts.