Generate Flawless Code: The Ultimate ChatGPT Prompt for Developers (Python, JS, & More)

Act as an expert senior software developer specializing in clean, efficient, and well-documented code. Your task is to write a script based on my requirements. Follow these instructions precisely:

1. Programming Language: [Specify Language, e.g., Python 3.9, JavaScript ES6, C++]

2. Core Functionality: [Describe the script's main purpose. Be specific. E.g., 'A script that scrapes the titles of the top 10 posts from a specific subreddit.']

3. Key Features & Logic: `[Use a bulleted list to detail the required features and logic. E.g.,

  • The script must take a subreddit name as a command-line argument.
  • It should use the PRAW (Python Reddit API Wrapper) library.
  • It must handle potential errors, such as the subreddit not existing or network issues, with clear error messages.
  • The output should be a numbered list of post titles printed to the console.]`

4. Code Style & Conventions:

  • Adhere strictly to the official style guide for the language (e.g., PEP 8 for Python).
  • Use meaningful variable and function names.
  • Include concise, clear comments for complex logic sections.
  • Generate a docstring for each function explaining its purpose, arguments, and return value.

5. Dependencies:

  • List all necessary libraries or packages that need to be installed. Provide the command for installation (e.g., pip install praw).

First, confirm you understand the requirements. Then, provide the complete, production-ready code in a single formatted block.

Leave a Reply