@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. Depending on platform support, CodeRabbit either opens a follow-up PR with the generated docstrings or posts them back as a PR comment for manual application.
This handles the initial documentation grunt work while keeping you in control through the standard PR review process.
How it works
Trigger generation
Comment
@coderabbitai generate docstrings in your PR or check Generate
Docstrings in the CodeRabbit WalkthroughFunction analysis
ast-grep scans your PR changes to identify functions missing docstrings or
with incomplete documentation
Format-aware generation
AI analyzes your existing docstrings to detect format patterns (JSDoc,
Google-style, Sphinx) and generates matching documentation

Platform support
GitHub
Docstrings are committed to a new branch and a follow-up PR is opened against your original branch for review and merge.
GitLab
Docstrings are committed to a new branch and a follow-up PR is opened against your original branch for review and merge.
Azure DevOps
Docstrings are committed to a new branch and a follow-up PR is opened against your original branch for review and merge.
Bitbucket Cloud / Server
Docstrings are posted as a PR comment for manual application. Branch-and-PR workflow is not supported on this platform.
Language support
Docstring generation supports 18+ languages via ast-grep: Bash, C, C++, C#, Elixir, Go, Java, JavaScript, Kotlin, Lua, PHP, Python, React TypeScript, Ruby, Rust, Swift, TypeScript Language support is provided byast-grep. If your language is missing, consider making a contribution following the ast-grep language addition guide.
Configure per-directory styles
Different parts of your codebase need different documentation approaches. Use path-based instructions to match your team’s standards:.coderabbit.yaml
Common configuration examples
Frontend components
API endpoints
Utility functions
Database models
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.What’s next
Finishing Touches overview
See all available finishing touches and how to trigger them from any PR
Autofix
Automatically implement fixes for unresolved CodeRabbit review findings
Custom recipes
Define reusable, named recipes that encode your team’s repeated tasks into one-click agentic actions