This feature is available exclusively as part of the Pro plan and is not included in the Lite plan. Please refer to our pricing page for more information about our plans and features.
@coderabbitai generate docstrings
or check the box in your PR walkthrough to trigger generation.
The system scans your changes with ast-grep, identifies functions needing documentation, and generates docstrings that match your codebase’s existing format. Generated docstrings are committed to a new branch and opened as a PR for your review.
This handles the initial documentation grunt work while keeping you in control through the standard PR review process.
How it works
1
Trigger generation
Comment
@coderabbitai generate docstrings
in your PR or check Generate Docstrings in the CodeRabbit Walkthrough2
Function analysis
ast-grep scans your PR changes to identify functions missing docstrings or with incomplete documentation
3
Format-aware generation
AI analyzes your existing docstrings to detect format patterns (JSDoc, Google-style, Sphinx) and generates matching documentation
4
PR workflow
Generated docstrings are committed to a new branch with a PR opened against your original branch for review and merge (typically 30-60 seconds)

CodeRabbit automatically detects your docstring format by analyzing existing documentation patterns. It matches JSDoc, Google-style, Sphinx, custom formats, or even Go’s doc comment conventions without any configuration.
Platform and integration support
Full PR workflow
Complete integration:
- GitHub
- GitLab
- Azure DevOps
Comment integration
Streamlined process:
- Bitbucket
Language coverage
18+ languages supported:
- Python, JavaScript, TypeScript
- Go, Rust, Java, Kotlin, Swift
- C, C++, C#, Ruby, PHP, Lua, Elixir, Bash
Bitbucket integration: Currently receives docstrings as PR comments rather than separate PRs. Full workflow support is in development.
Configure per-directory styles
Customize documentation format using .coderabbit.yaml
Customize documentation format using .coderabbit.yaml
Different parts of your codebase need different documentation approaches. Use path-based instructions to match your team’s standards:Path patterns use minimatch syntax to target specific directories, file types, or naming conventions.API endpoints:Utility functions:Database models:
Common configuration examples
Frontend components:Reviewing generated docstrings
When CodeRabbit opens a docstring PR, focus your review on: Content accuracy:- Parameter descriptions match actual function behavior
- Return value documentation reflects real outputs
- Edge cases and error conditions are correctly described
- Generated format matches your codebase conventions
- Examples use appropriate syntax for your language
- Terminology aligns with your project’s vocabulary
- All parameters are documented with appropriate detail
- Complex functions include usage examples
- Error conditions and exceptions are covered
Technical implementation
CodeRabbit uses ast-grep for precise code parsing across different programming languages and coding styles. This enables accurate function detection while respecting your code structure and automatically detecting your preferred docstring format. Language support depends on ast-grep capabilities. To request additional language support, contribute to the ast-grep language addition guide. Currently supported: Bash, C, C++, C#, Elixir, Go, Java, JavaScript, Kotlin, Lua, PHP, Python, React TypeScript, Ruby, Rust, Swift, TypeScript.Next steps
Ready to enhance your development workflow? Explore these related features and resources:Finishing touches overview
Discover all code improvement features available in the finishing touches suite
Configure CodeRabbit
Set up .coderabbit.yaml to match your team’s documentation standards and workflows
Unit test generation
Automatically generate comprehensive unit tests for your functions and methods
Join our community
Connect with other developers and share feedback in our Discord community