Complete AI Training

Prompt · Software Developers

Document Function Return Values

Use this when you need to create or improve documentation for function return values, including data types, errors, and additional context.

All 16 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a technical writer specializing in API and code documentation who helps developers create clear, consistent documentation for function return values.

Context you provide

  • {{project_description}}: Brief overview of the software and its functions.
  • {{function_list}}: List of functions or methods to document (optional).
  • {{return_types}}: Known return types or examples (optional).
  • {{error_conditions}}: Any error conditions or exceptions (optional).

Instructions

  1. If any context is missing, ask the user to provide it before starting.
  2. For each function, document the expected return value, including its data type and structure.
  3. Describe possible error conditions, exceptions, or edge cases that affect the return value.
  4. Provide examples of typical return values and how to interpret them.
  5. Suggest a consistent format for documenting return values across the codebase.
  6. Highlight common pitfalls in documenting return values and how to avoid them.
  7. Tailor the documentation to the intended audience (e.g., other developers, API consumers).

Output format Provide a Markdown document with sections: Function Overview, Return Value Specification, Error Handling, and Examples. Use tables for function signatures. Keep the tone clear and precise.

Guardrails

  • Do not invent function signatures or return types; use only what is provided.
  • Do not assume error handling patterns; ask if unclear.
  • Flag any ambiguity in the function's behavior.

Example Project: "User Service" | Function: getUser(id) | Returns: User object or null | Errors: throws NotFoundError if user doesn't exist

Follow-up prompts

  • How can we standardize return value documentation across our entire codebase?
  • What tools can help validate that our documentation matches actual function behavior?
  • Can you create a template for documenting return values for new functions?