Best AI Prompts for Technical Documentation with ChatGPT
Technical documentation is the unsexy work that every team deprioritizes until the absence of it becomes a crisis. ChatGPT can change the economics of documentation, making it fast enough to keep up with code development rather than constantly playing catch-up.
This guide covers the prompting strategies that make ChatGPT most useful for technical documentation, from READMEs to API docs to internal documentation.
TL;DR
- ChatGPT accelerates technical documentation by handling the drafting and structure work
- The Docs as Code approach works well with AI-assisted documentation
- Providing code context produces more accurate documentation than generic requests
- Reviewing AI-generated documentation is essential; do not publish without human checking
- API documentation, READMEs, and runbooks are the highest-value documentation targets
- Building a documentation prompt library for your tech stack accelerates future doc work
- The “Generate, Review, Refine” model produces better results than pure generation
Introduction
Technical documentation serves developers who need to understand, use, and extend your systems. The best documentation is accurate, complete, and maintained. Most documentation fails because it starts out decent and gradually becomes inaccurate as the code evolves.
ChatGPT helps with the drafting phase, making it faster to get documentation started. But the real value comes from integrating AI assistance into a sustainable documentation workflow where documentation gets updated when code changes.
This guide covers prompting strategies for technical documentation that developers can actually use.
Table of Contents
- What Technical Documentation Does ChatGPT Do Well?
- README Generation Prompts
- API Documentation Prompts
- Runbook and Operational Documentation Prompts
- Code Comment and Inline Documentation Prompts
- Docs as Code Workflow Prompts
- Documentation Review Prompts
- FAQ
What Technical Documentation Does ChatGPT Do Well?
README generation: Given a repository structure and main files, ChatGPT can generate a comprehensive README with installation, usage, and contribution guides.
API documentation: Given endpoint definitions or code, ChatGPT can generate API documentation in various formats.
Runbook creation: Given a system description, ChatGPT can draft operational runbooks for common procedures.
Code comments: ChatGPT can add clarifying comments to code to explain complex logic.
Documentation templates: ChatGPT can generate templates for recurring documentation types.
Translation: ChatGPT can translate documentation between formats or adapt documentation for different audiences.
README Generation Prompts
Master README Prompt
Generate a comprehensive README.md for a [LANGUAGE/FRAMEWORK] project.
Project overview:
- Name: [PROJECT NAME]
- Purpose: [ONE-LINE DESCRIPTION]
- What problem it solves: [DESCRIPTION]
Code structure:
[FILE/FOLDER STRUCTURE]
Key files and their purpose:
[FILE - PURPOSE]
Dependencies:
[LANGUAGE, FRAMEWORKS, KEY PACKAGES]
Current status: [EARLY STAGE/PRODUCTION/MAINTAINED]
Please generate a README with these sections:
1. Badge bar (build, tests, coverage, version)
2. One-line description
3. Background/motivation (2-3 sentences)
4. Installation instructions for developers
5. Quick start example
6. Usage documentation with code examples
7. Configuration options (if applicable)
8. Architecture overview
9. Contributing guidelines
10. License
11. Changelog format placeholder
Make it immediately useful for a developer who just cloned the repo.
README Update Prompt
I have an existing README.md that needs updating after code changes.
Please review the current README and the changes below, then update
the relevant sections.
Current README:
[EXISTING README]
Code changes since last README update:
[CHANGES MADE]
Files modified:
[FILES]
Files added:
[FILES]
Files removed:
[FILES]
Please update the README to:
1. Reflect all changes accurately
2. Keep all still-accurate existing content
3. Remove references to removed files
4. Add documentation for new significant features
5. Update version numbers or badges if needed
Flag any sections that may need attention but are beyond current scope.
API Documentation Prompts
API Endpoint Documentation Prompt
Generate API documentation for the following endpoints.
API base URL: [URL]
Authentication: [METHOD]
Endpoints to document:
[ENDPOINT 1: METHOD, PATH, DESCRIPTION]
[ENDPOINT 2: METHOD, PATH, DESCRIPTION]
For each endpoint, provide:
1. Method and path
2. Description of what it does
3. Request parameters (path params, query params, body)
4. Request body schema (if applicable)
5. Response schema and status codes
6. Example request and response
7. Error codes and what they mean
8. Authentication requirements
Format as Markdown suitable for inclusion in API docs or a README.
SDK Documentation Prompt
Generate SDK documentation for a [LANGUAGE] library.
Library name: [NAME]
Purpose: [DESCRIPTION]
Core functionality: [WHAT IT DOES]
Classes/functions:
[CLASS 1 - METHODS AND PURPOSE]
[CLASS 2 - METHODS AND PURPOSE]
Please provide:
1. Library overview
2. Installation instructions for [LANGUAGE]
3. Quick start example
4. Class-by-class documentation with:
- Purpose of the class
- Constructor parameters
- Methods with parameter descriptions
- Return types
- Code examples for each method
5. Error handling patterns
6. Type definitions (if applicable)
Runbook and Operational Documentation Prompts
Incident Runbook Prompt
Generate an incident runbook for [SYSTEM/PROCESS NAME].
System overview:
- What it does: [DESCRIPTION]
- Dependencies: [SERVICES IT DEPENDS ON]
- Criticality: [HOW CRITICAL IS THIS TO BUSINESS]
Common failure scenarios:
[SCENARIO 1 - E.G., "Service returns 500 errors"]
[SCENARIO 2 - E.G., "Database connection pool exhausted"]
[SCENARIO 3 - E.G., "High latency observed"]
For each scenario, document:
1. Symptoms to look for
2. Initial diagnostic commands/steps
3. Common causes
4. Remediation steps (in order of likelihood)
5. How to verify the fix
6. Who to escalate to if unresolved
7. Post-incident steps
Format as a markdown runbook suitable for on-call rotation.
Deployment Runbook Prompt
Generate a deployment runbook for [SERVICE/APPLICATION NAME].
Deployment context:
- Environment: [DEV/STAGING/PRODUCTION]
- Current deployment method: [HEROKU/DOCKER/K8S/ETC.]
- Rollback procedure: [HOW TO ROLL BACK]
Pre-deployment checklist:
[DETERMINE YOUR STANDARD CHECKLIST]
Deployment steps:
[STEP BY STEP DEPLOYMENT PROCESS]
Post-deployment verification:
[HOW TO VERIFY DEPLOYMENT WAS SUCCESSFUL]
Rollback steps:
[STEP BY STEP ROLLBACK IF NEEDED]
Monitoring to watch:
[METRICS/LOG SIGNALS TO WATCH POST-DEPLOY]
Include time estimates for each step.
Code Comment and Inline Documentation Prompts
Code Comment Generation Prompt
Add clarifying comments to this code. Focus on explaining WHY,
not WHAT (the code itself shows what).
[CODE]
Please:
1. Add comments above complex logic blocks explaining the purpose
2. Add inline comments for non-obvious decisions
3. Add TODO comments for known issues or improvements
4. Do not comment obvious things that are clear from reading the code
5. Use a consistent comment style
Format the output as the complete annotated code file.
Function Documentation Prompt
Generate JSDoc (or appropriate doc format for [LANGUAGE]) comments
for these functions.
[CODE]
Please:
1. Document the purpose of each function in a sentence
2. Document all parameters with types and descriptions
3. Document return values with types and descriptions
4. Document any exceptions or error conditions
5. Document any side effects
6. Add example usage if helpful
Use [JSDOC/PYDOC/DOCSTRING] format appropriate for [LANGUAGE].
Docs as Code Workflow Prompts
Docs as Code Setup Prompt
Help me set up a Docs as Code workflow for [PROJECT NAME].
Current situation:
[WHAT DOCS TOOLS/CONTENT YOU HAVE]
Goal:
[WHAT YOU WANT TO ACHIEVE WITH DOCS-AS-CODE]
Please recommend:
1. Documentation location (docs/ folder in repo? Separate repo?)
2. Static site generator (MkDocs / Docsify / GitBook / Docusaurus)
3. Hosting solution (GitHub Pages / Netlify / ReadTheDocs)
4. Contribution workflow (PRs? Direct commits? Review required?)
5. How to integrate docs updates with code changes
Then provide prompts I can use to generate initial documentation
content that fits this workflow.
Pull Request Doc Check Prompt
I have a pull request that modifies [WHAT CHANGED].
Please help me determine what documentation needs updating.
PR changes:
[SUMMARY OF CHANGES]
Files modified:
[FILES]
Files added:
[FILES]
Please:
1. Identify which documentation files need updating
2. Describe what changes are needed in each file
3. Check whether new files need documentation
4. Identify whether the changes require documentation at all
(sometimes code changes do not need doc updates)
Documentation Review Prompts
Doc Accuracy Review Prompt
Please review this documentation for accuracy and completeness.
Documentation:
[DOCUMENTATION TEXT]
System/code it documents:
[REFERENCE TO CODE OR DESCRIPTION]
Please review:
1. Accuracy: Does the doc match the actual system behavior?
2. Completeness: Are all important aspects covered?
3. Clarity: Is the explanation clear to someone unfamiliar with the system?
4. Currency: Is anything clearly outdated?
5. Correctness: Are code examples accurate and runnable?
Flag any issues by severity:
- Must fix: Will mislead or cause errors
- Should fix: Significant improvement needed
- Consider: Minor improvements
FAQ
How do I get developers to actually maintain documentation? Integrate documentation updates into the PR process. Require documentation updates when code changes affect user-facing behavior. Use Docs as Code to make documentation updates as easy as code commits. Recognize documentation contributions in code review.
What is the most important documentation to write first? Focus on documentation that prevents the same questions from being answered repeatedly. READMEs for any project, API documentation for any external API, and runbooks for any operational process are highest value. Internal architecture docs are valuable but lower priority.
Can ChatGPT write documentation for poorly documented code? ChatGPT can infer intent from code structure and naming conventions, producing better documentation than exists. However, the accuracy of such documentation depends on the code itself being clear. Poorly documented code produces less accurate AI documentation.
How do I prevent documentation from going stale? Tie documentation reviews to code changes. When code changes, the PR should include documentation updates. Set calendar reminders for quarterly documentation reviews. Use automated link checking to catch broken references.
Should I use AI to write documentation for security-sensitive code? Use AI for drafting but have security experts review. AI can generate documentation that sounds authoritative without accurately describing security implications. Human review is essential for security documentation.
How detailed should code comments be? Comment the why, not the what. If the code is self-documenting, do not add comments. If a decision required significant reasoning or trade-offs, document that reasoning. Comments that state the obvious become noise and maintenance burden.
Conclusion
ChatGPT makes technical documentation faster but not automatic. Use it to draft, structure, and get started. Maintain human review to ensure accuracy. Build documentation into your code workflow so it stays current as systems evolve.
Start with READMEs for your projects. Add runbooks for operational processes. Build a documentation update step into your PR process. The prompts in this guide give you the starting points.
Your next step: Pick one project without a good README. Use the Master README prompt to generate a first draft. Review it for accuracy. You now have documentation that did not exist before.