2.6 Documentation
Course: Claude Code - Essentials Section: Core Workflows Video Length: 2-5 minutes Presenter: Daniel Treasure
Opening Hook
Code tells you how something works. Documentation tells you why and how to use it. Claude Code can generate comprehensive documentation: README files, API docs, code comments, and more. In this video, we'll show how to keep your project documented without the tedious writing.
Key Talking Points
- Generating README Files
- Ask: "Generate a README for this project"
- Claude reads the codebase and creates a complete README with sections: overview, installation, usage, and examples
- Saves hours of writing
-
Show on screen: Ask Claude to write a README and see a well-structured file appear
-
Writing Code Comments
- Comments explain why code exists, not just what it does
- Ask: "Add comments explaining the business logic in this function"
- Claude adds thoughtful comments that senior developers would write
-
Show: Comments added to a complex function, highlighting intent
-
API Documentation (JSDoc, etc.)
- Ask: "Add JSDoc to these functions" (for JavaScript)
- Claude documents parameters, return types, and examples
- Tools like VS Code use this to show inline documentation
-
Show: JSDoc appears; hover over a function in an editor to show the documentation
-
Architecture and Design Docs
- Ask: "Explain the overall architecture of this project"
- Claude generates a document describing how components fit together
-
Show: A markdown file describing the architecture, data flow, and design decisions
-
Keeping Docs in Sync with Code
- When you refactor (2.2) or change behavior (2.4), documentation can get stale
- Ask Claude: "Update the README to reflect the new API"
- Claude updates docs to match current code
- Show: A change is made; docs are updated to reflect it
Demo Plan
Demo Project: Continue with the same project from 2.1-2.5
Setup: - Project should have some code (from previous videos) - README (if one exists) should be outdated or minimal - Terminal ready with Claude Code session
On-Camera Sequence (2-3 minutes):
- Generate a README
Generate a comprehensive README for this project - Claude creates a README.md file
- Show sections: overview, installation, usage, API, testing
-
~40 seconds
-
Add Code Comments
@src/auth.js Add comments explaining the authentication flow - Claude adds comments to a specific file
- Highlight comments that explain why, not just what
-
~30 seconds
-
Document Functions with JSDoc (if JavaScript/TypeScript)
Add JSDoc comments to the functions in utils.js - Claude adds parameter descriptions, return types, and examples
- Show a function with JSDoc in an editor (if time)
-
~30 seconds
-
(Optional) Update Docs After a Change
- Make a small code change (e.g., add a parameter to a function)
- Ask: "Update the README and JSDoc to reflect this change"
- Claude updates the documentation
- ~20 seconds
Code Examples & Commands
Asking Claude to document:
Generate a comprehensive README for this project
Add comments explaining the business logic
Document all exported functions with JSDoc
Write architecture documentation
Explain how the API works
Add usage examples to the README
Document the database schema
Documentation requests with scope:
@src/models.js Add comments to explain the data models
@README Add an installation section
@docs/ Create a guide for contributing to this project
Example JSDoc (JavaScript):
/**
* Calculates the total price of items in a cart.
* @param {Array<{price: number, quantity: number}>} items - Cart items
* @returns {number} The total price before tax
* @example
* const total = calculateTotal([{price: 10, quantity: 2}]);
* console.log(total); // 20
*/
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
README Structure Claude Creates:
# Project Name
## Overview
## Installation
## Usage
## API Reference
## Testing
## Contributing
## License
Gotchas & Tips
-
Comments Should Explain Intent – "Gets the user" is a bad comment. "Fetch user from cache if available, otherwise from DB" is good. Claude usually gets this right.
-
Keep Docs Close to Code – Documentation in the same repo (not a separate wiki) stays in sync. Encourage this practice.
-
README Is Your First Impression – New contributors read the README first. A good one saves support questions.
-
Examples Are Gold – Code examples in documentation are worth a thousand words. Claude includes them; you can ask for more.
-
Document Edge Cases – Ask Claude: "Document error cases and edge cases" to ensure completeness.
-
Versioning Matters – If your project has versions or major API changes, mention this in the README.
Lead-out
You now have documented code, and your project is understandable. But what if you need to share a visual explanation? What if there's a screenshot or diagram to include? That's what the next video covers: working with images.
Reference Material
- Common Workflows - Writing Docs: https://code.claude.com/docs/en/common-workflows
- Quickstart - Document Code: https://code.claude.com/docs/en/quickstart
- Best Practices Guide: https://code.claude.com/docs/en/best-practices
Relevant Articles & Posts
- Documentation Patterns: Joe Njenga's "17 Best Claude Code Workflows" (Medium)
- Production Practices: Lukasz Fryc's "15 Tips from Running 6 Projects" (DEV Community)
- Official Resource: Common Workflows - Claude Code Docs (https://code.claude.com/docs/en/common-workflows)
Additional Notes
- Emphasize: good documentation saves time across the entire team lifetime
- Show real, well-structured examples (not placeholder text)
- If time, demo how VS Code shows JSDoc when you hover over a function
- Note: keeping docs in sync is critical to team productivity
- Mention CLAUDE.md files (coming in later sections) for documenting your development practices