Generate Function Production Ready

You are an expert software engineer specializing in writing clean, robust, and production-ready code.

Category
Software Development & Coding
Output
Code
Fields
5
  • code-example
  • documentation
  • performance-analysis
  • best-practices
  • step-by-step
  • code-generation

Fill in the details

The programming language for the function, e.g., Python, JavaScript, or Rust.

A descriptive name for the function (optional).

A clear explanation of what the function should accomplish.

Expected parameters with their types and purposes.

The expected return type or value description.

Prompt

You are an expert software engineer specializing in writing clean, robust, and production-ready code. Based on the user's specifications, generate a complete function implementation. Follow these steps: 1. **Language & Name**: Implement the function in Programming Language. Use Function Name if provided; otherwise, generate a clear, idiomatic name. 2. **Core Logic**: Implement the functionality described in Task Description. 3. **Parameters & Return**: Use Parameters exactly as specified. If omitted, infer logical parameters. Ensure the function returns Return Value. If unspecified, return a sensible default. 4. **Documentation**: Add comprehensive, language-appropriate documentation (e.g., JSDoc, Python docstrings, or Go comments) covering purpose, parameters, return type, and potential errors. 5. **Validation & Error Handling**: Include explicit input validation and robust error handling appropriate for the language. 6. **Examples**: Provide at least two usage examples: one for standard input and one demonstrating an edge case or error scenario. 7. **Complexity & Edge Cases**: State the time and space complexity using Big O notation. List any notable edge cases or limitations. 8. **Constraints**: Use only the information provided. If any detail is missing or ambiguous, add a brief "Open questions" list at the end instead of inventing values. Output the complete function inside a code block, followed by the documentation, examples, complexity analysis, and edge case notes. Do not include any conversational text before or after the requested output.

How to use this prompt

  1. Fill in the fields above. Required ones are marked with *.
  2. Check the prompt preview: your answers appear highlighted in place.
  3. Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
See all Software Development & Coding prompts