What this prompt does
This prompt instructs ChatGPT to produce a full documentation pass on a specific target — a class, module, API surface, or entire codebase — in one structured request. It works because the template forces six distinct documentation layers simultaneously: inline comments, type-annotated parameters, return value specs, usage examples, an architecture overview, and any additional doc type you define. That last slot ([additional_docs]) is what separates it from a generic "add comments" request — you can ask for an ADR, OpenAPI stub, or Postman description block in the same pass.
The [audience] variable is the most underrated part. Telling ChatGPT to write "clear enough for a junior Laravel developer" versus "a DevOps engineer reading an API contract" tends to produce structurally different output: one leans toward inline narrative explanation, the other toward tighter type contracts and HTTP status tables. The [style_guide] variable enforces house conventions — phpDocumentor-style PHPDoc for PHP, JSDoc or TSDoc for TypeScript, NumPy style for Python — so output slots into your codebase without a reformatting pass.
When to use it
- You have a legacy class with zero comments and a code review coming up — feed the whole class as
[target]and get PHPDoc blocks ready to paste. - You are open-sourcing a Laravel package and need a README plus docblock pass before the first public tag.
- Your team's API grew organically and the front-end team is guessing at parameter types — use
[additional_docs] = OpenAPI 3.0 YAML stub for each endpoint. - You onboarded a contractor who needs architecture context fast — set
[audience]to "external contractor unfamiliar with the system" and[additional_docs]to "architecture decision record for the authentication flow." - You are writing a course or tutorial and need clean, illustrative docblocks as teaching examples.
Example output
For [target] = PostRepository, [language] = PHP, [doc_format] = PHPDoc, [audience] = mid-level developer:
/**
* Retrieves published blog posts paginated by creation date.
*
* Applies Scout-based full-text filtering when $search is provided.
* Falls back to Eloquent scope when Scout is unavailable.
*
* @param int $perPage Posts per page. Default: 15. Range: 1–100.
* @param string|null $search Optional Algolia search query.
* @return LengthAwarePaginator<Post>
*
* @example
* $posts = $repo->getPaginated(perPage: 10, search: 'laravel queues');
*/
public function getPaginated(int $perPage = 15, ?string $search = null): LengthAwarePaginator
Pro tips
- Be specific with
[target]— paste the actual class name or file path, not "my code." ChatGPT documents what it can see; vague targets produce vague docs. - Set
[additional_docs] = architecture decision recordwhen the class has non-obvious design choices (e.g., why you used a Repository pattern over direct Eloquent). ADRs age far better than inline comments. - Chain requests by domain — run the prompt once per domain folder (Blog, Shop, Website) rather than dumping an entire codebase. Output stays coherent and token-efficient.
- Use
[style_guide] = PHPDoc with PHPStan genericsif your project runs static analysis. Ask ChatGPT to use@return Collection<int, Post>and@templatetags in the PHPStan dialect — these are consumed directly by PHPStan's type inference. If you run Psalm instead, specify[style_guide] = Psalm annotationsto get@psalm-returnand@psalm-templatetags, which are distinct from PHPStan's syntax. - Paste the output into your IDE before accepting it — ChatGPT occasionally documents what a method should do rather than what it does. A 30-second diff against the actual implementation catches drift before it ships.