|
| 1 | +--- |
| 2 | +title: Custom Reports |
| 3 | +sidebar_label: Custom Reports |
| 4 | +description: Learn how to create custom reports with CodeRabbit Pro's flexible reporting system |
| 5 | +sidebar_position: 8 |
| 6 | +--- |
| 7 | + |
| 8 | +```mdx-code-block |
| 9 | +import ProPlanNotice from '@site/src/components/ProPlanNotice.mdx'; |
| 10 | +
|
| 11 | +<ProPlanNotice /> |
| 12 | +``` |
| 13 | + |
| 14 | +CodeRabbit Pro allows you to create custom reports tailored to your specific needs using a flexible prompt-based system. This guide will help you understand how to create effective custom reports. |
| 15 | + |
| 16 | +## Understanding Custom Reports |
| 17 | + |
| 18 | +Custom reports allow you to: |
| 19 | + |
| 20 | +- Define exactly what information you want to see |
| 21 | +- Specify the format and structure of the report |
| 22 | +- Set custom filtering and grouping rules |
| 23 | +- Generate reports in different languages |
| 24 | + |
| 25 | +## Creating Custom Report Templates |
| 26 | + |
| 27 | +### Basic Structure |
| 28 | + |
| 29 | +A custom report template consists of instructions that tell CodeRabbit what information to include and how to present it. Here's a basic example: |
| 30 | + |
| 31 | +``` |
| 32 | +Please provide a summary of: |
| 33 | +- All merged pull requests |
| 34 | +- Critical bug fixes |
| 35 | +- Code review discussions |
| 36 | +
|
| 37 | +Group by: |
| 38 | +- Repository |
| 39 | +- Team |
| 40 | +
|
| 41 | +Format using: |
| 42 | +- Bullet points for changes |
| 43 | +- Tables for statistics |
| 44 | +``` |
| 45 | + |
| 46 | +### Available Data Points |
| 47 | + |
| 48 | +Your custom reports can access the following PR information that you can reference in your prompts: |
| 49 | + |
| 50 | +#### Pull Request Status |
| 51 | + |
| 52 | +- `Merged`: boolean (true/false) - Whether the PR has been merged |
| 53 | +- `Draft`: boolean (true/false) - Whether the PR is in draft state |
| 54 | +- `State`: string ("open"/"closed") - Current state of the PR |
| 55 | +- `Mergeable`: boolean (true/false) - Whether the PR can be merged |
| 56 | +- `Is stale`: boolean - Whether PR has been inactive for over 168 hours |
| 57 | + |
| 58 | +#### Basic Information |
| 59 | + |
| 60 | +- `Pull request number`: number - The PR's identifier |
| 61 | +- `Title`: string - PR title |
| 62 | +- `URL`: string - Link to the PR |
| 63 | +- `Author name`: string - PR creator's username |
| 64 | +- `Created at`: datetime - When the PR was created |
| 65 | +- `Last activity`: datetime - Most recent activity timestamp |
| 66 | +- `Closed at`: datetime (if applicable) - When the PR was closed |
| 67 | + |
| 68 | +#### Additional Context |
| 69 | + |
| 70 | +- `Labels`: array of strings - All labels applied to the PR |
| 71 | +- `Reviewers`: array of strings - Assigned reviewers' usernames |
| 72 | +- `Description`: markdown - Full PR description |
| 73 | +- `Summary`: string - AI-generated summary of changes |
| 74 | +- `Comments`: array of objects |
| 75 | + - `username`: string - Comment author |
| 76 | + - `body`: markdown - Comment content |
| 77 | + |
| 78 | +Here's an example prompt that uses these data points: |
| 79 | + |
| 80 | +``` |
| 81 | +Generate a summary with the following format for each PR: |
| 82 | +
|
| 83 | +## [PR Title](URL) |
| 84 | +**Status**: {Use these symbols based on state} |
| 85 | +- 🔀 if Merged is true |
| 86 | +- 📝 if Draft is true |
| 87 | +- 💬 if State is "open" |
| 88 | +- 🔒 if State is "closed" and not merged |
| 89 | +Add ⚠️ if Is stale is true |
| 90 | +
|
| 91 | +**Author**: {Author name} |
| 92 | +**Created**: {Created at} |
| 93 | +**Labels**: {Labels joined by commas} |
| 94 | +**Reviewers**: {Reviewers joined by commas} |
| 95 | +
|
| 96 | +### Summary |
| 97 | +{Summary limited to 50 words} |
| 98 | +
|
| 99 | +### Recent Activity |
| 100 | +{List last 3 comments with username and content} |
| 101 | +``` |
| 102 | + |
| 103 | +### Formatting Options |
| 104 | + |
| 105 | +CodeRabbit supports markdown formatting in custom reports. You can use: |
| 106 | + |
| 107 | +- Headers (`#`, `##`, `###`) |
| 108 | +- Lists (bullet points and numbered) |
| 109 | +- Tables |
| 110 | +- Code blocks |
| 111 | +- Bold and italic text |
| 112 | +- Links |
| 113 | + |
| 114 | +### Language Support |
| 115 | + |
| 116 | +You can generate reports in multiple languages by specifying the ISO language code in your template. For example: |
| 117 | + |
| 118 | +``` |
| 119 | +Language: fr |
| 120 | +Please provide a summary of: |
| 121 | +- All pull request activities |
| 122 | +- Code review discussions |
| 123 | +``` |
| 124 | + |
| 125 | +## Advanced Features |
| 126 | + |
| 127 | +### Filtering |
| 128 | + |
| 129 | +Include specific filtering instructions in your template: |
| 130 | + |
| 131 | +``` |
| 132 | +Include only: |
| 133 | +- PRs with "critical" or "bug" labels |
| 134 | +- Changes to production code |
| 135 | +- Reviews from senior developers |
| 136 | +
|
| 137 | +Exclude: |
| 138 | +- Automated commits |
| 139 | +- Documentation changes |
| 140 | +- Dependencies updates |
| 141 | +``` |
| 142 | + |
| 143 | +### Custom Grouping |
| 144 | + |
| 145 | +Organize information using custom grouping rules: |
| 146 | + |
| 147 | +``` |
| 148 | +Group by: |
| 149 | +1. Priority (High/Medium/Low) |
| 150 | +2. Component (Frontend/Backend/Infrastructure) |
| 151 | +3. Team (Team A/Team B) |
| 152 | +
|
| 153 | +Within each group, sort by: |
| 154 | +- Activity date (newest first) |
| 155 | +- Impact level |
| 156 | +``` |
| 157 | + |
| 158 | +### Time-Based Analysis |
| 159 | + |
| 160 | +Add temporal analysis to your reports: |
| 161 | + |
| 162 | +``` |
| 163 | +Provide: |
| 164 | +- Week-over-week comparison |
| 165 | +- Trend analysis for the past month |
| 166 | +- Velocity metrics |
| 167 | +- Time to merge statistics |
| 168 | +``` |
| 169 | + |
| 170 | +## Best Practices |
| 171 | + |
| 172 | +1. **Be Specific** |
| 173 | + - Clearly define what should be included/excluded |
| 174 | + - Use precise language to avoid ambiguity |
| 175 | + - Specify exact metrics you want to track |
| 176 | + |
| 177 | +2. **Structure Matters** |
| 178 | + - Start with high-level summaries |
| 179 | + - Use consistent grouping patterns |
| 180 | + - Include clear section breaks |
| 181 | + |
| 182 | +3. **Keep it Relevant** |
| 183 | + - Focus on actionable information |
| 184 | + - Avoid redundant data points |
| 185 | + - Consider your audience's needs |
| 186 | + |
| 187 | +4. **Optimize Readability** |
| 188 | + - Use appropriate formatting |
| 189 | + - Include visual breaks |
| 190 | + - Maintain consistent styling |
| 191 | + |
| 192 | +## Example Templates |
| 193 | + |
| 194 | +### Executive Summary Template |
| 195 | + |
| 196 | +``` |
| 197 | +Provide a high-level overview: |
| 198 | +1. Key metrics: |
| 199 | + - Total PRs merged |
| 200 | + - Average review time |
| 201 | + - Code quality scores |
| 202 | +2. Notable achievements |
| 203 | +3. Blocking issues |
| 204 | +4. Resource allocation |
| 205 | +
|
| 206 | +Format: |
| 207 | +- Use tables for metrics |
| 208 | +- Bullet points for achievements |
| 209 | +- Clear headers for sections |
| 210 | +``` |
| 211 | + |
| 212 | +### Technical Deep Dive Template |
| 213 | + |
| 214 | +``` |
| 215 | +Generate a detailed technical report: |
| 216 | +1. Code changes: |
| 217 | + - Architecture updates |
| 218 | + - API modifications |
| 219 | + - Database changes |
| 220 | +2. Testing coverage |
| 221 | +3. Performance impacts |
| 222 | +4. Security considerations |
| 223 | +
|
| 224 | +Include: |
| 225 | +- Links to significant PRs |
| 226 | +- Code snippets for major changes |
| 227 | +- Technical debt analysis |
| 228 | +``` |
| 229 | + |
| 230 | +### Advanced Formatting |
| 231 | + |
| 232 | +Heres a more advanced example of a custom report template: |
| 233 | + |
| 234 | +``` |
| 235 | +Generate a report of all pull requests in the following format: |
| 236 | +
|
| 237 | +- As the first paragraph, start with "🟣" if merged, "⚫" if draft, "🟢" if open, "🔴" if closed |
| 238 | + - On the same line, add the PR title in bold (and only the title; don't put anything else in bold after that) |
| 239 | + - On the same line, add the PR browser link (do not use an api link) |
| 240 | + - On the same line, add the last activity date in the format "Day Month Year, Hour:Minute AM/PM (Timezone)" in italic (don't put anything else in italic after that and make sure it's not bold) |
| 241 | +- Make a new bullet-point list of high-level changes in the PR |
| 242 | + - Start each change with a gitmoji followed by a very terse one-liner to mention at a high level what the change does and to what part of the application it applies to |
| 243 | + - Do not start with verbose non-speak such as "The pull request enhances" or "This PR introduces". Keep it terse and straight to the point. Start change descriptions with a verb |
| 244 | + - Do not end with justifications or reasons for the changes such as "... enhancing type safety". Stick to the facts, do not make up the outcome of a change |
| 245 | + - Limit to the 4 most relevant changes |
| 246 | + - Examples: "✨ Add a rotating tagline on the home page", "🔧 Add func-style to ESLint", "📝 Add download badge to `README.md`", "✅ Add unit tests for comment trees", "👷 Create a pipeline to publish to npmjs.org", "🐛 Fix comment submission in posts", "📄 License under AGPL-3.0-or-later", "📱 Change post view for mobile", "💄 Make sidebar links blue", "🩹 Fix unfollow button", "🔒️ Limit login cookies to a specific subdomain", "🥅 Handle errors when commenting in a post", "🙈 Stop ignoring `.env` and start ignoring `.env.local` and `.env.*.local`", "⬆️ Update lemmy-js-client to v0.19.4", "🏷️ Define interfaces for pull request events", "🔐 Add environment variables for Bitbucket Server", "🚚 Rename exported client instances in test files", "🏷️ Add type alias `EventKey` and its type guard `isEventKey`", "🏗️ Aggregate exports for pull request events in an index file" |
| 247 | +- Start the next paragraph with "Blockers:" in bold |
| 248 | + - Summarize any issues preventing the PR from progressing |
| 249 | + - Some examples: "Waiting for merge", "Waiting for review", "Failing CI/CD", "Needs more tests", "Needs rebase", "@username is waiting for a response", etc. |
| 250 | + - If the PR is stale, note it here |
| 251 | +- Do not add a "Report" heading |
| 252 | +- Make sure there is one empty line between each paragraph |
| 253 | +
|
| 254 | +These are the available emojis and the type of change they represent. Do not using any other emoji. Make sure the change corresponds to the gitmoji. |
| 255 | +
|
| 256 | +<gitmojis> |
| 257 | +🎨: Improve structure / format of the code. |
| 258 | +⚡️: Improve performance. |
| 259 | +🔥: Remove code or files. |
| 260 | +🐛: Fix a bug. |
| 261 | +🚑️: Critical hotfix. |
| 262 | +✨: Introduce new features. |
| 263 | +📝: Add or update documentation. |
| 264 | +🚀: Deploy stuff. |
| 265 | +💄: Add or update the UI and style files. |
| 266 | +🎉: Begin a project. |
| 267 | +✅: Add, update, or pass tests. |
| 268 | +🔒️: Fix security or privacy issues. |
| 269 | +🔐: Add or update secrets. |
| 270 | +🔖: Release / Version tags. |
| 271 | +🚨: Fix compiler / linter warnings. |
| 272 | +🚧: Work in progress. |
| 273 | +💚: Fix CI Build. |
| 274 | +⬇️: Downgrade dependencies. |
| 275 | +⬆️: Upgrade dependencies. |
| 276 | +📌: Pin dependencies to specific versions. |
| 277 | +👷: Add or update CI build system. |
| 278 | +📈: Add or update analytics or track code. |
| 279 | +♻️: Refactor code. |
| 280 | +➕: Add a dependency. |
| 281 | +➖: Remove a dependency. |
| 282 | +🔧: Add or update configuration files. |
| 283 | +🔨: Add or update development scripts. |
| 284 | +🌐: Internationalization and localization. |
| 285 | +✏️: Fix typos. |
| 286 | +💩: Write bad code that needs to be improved. |
| 287 | +⏪️: Revert changes. |
| 288 | +🔀: Merge branches. |
| 289 | +📦️: Add or update compiled files or packages. |
| 290 | +👽️: Update code due to external API changes. |
| 291 | +🚚: Move or rename resources (e.g.: files, paths, routes). |
| 292 | +📄: Add or update license. |
| 293 | +💥: Introduce breaking changes. |
| 294 | +🍱: Add or update assets. |
| 295 | +♿️: Improve accessibility. |
| 296 | +💡: Add or update comments in source code. |
| 297 | +🍻: Write code drunkenly. |
| 298 | +💬: Add or update text and literals. |
| 299 | +🗃️: Perform database related changes. |
| 300 | +🔊: Add or update logs. |
| 301 | +🔇: Remove logs. |
| 302 | +👥: Add or update contributor(s). |
| 303 | +🚸: Improve user experience / usability. |
| 304 | +🏗️: Make architectural changes. |
| 305 | +📱: Work on responsive design. |
| 306 | +🤡: Mock things. |
| 307 | +🥚: Add or update an easter egg. |
| 308 | +🙈: Add or update a .gitignore file. |
| 309 | +📸: Add or update snapshots. |
| 310 | +⚗️: Perform experiments. |
| 311 | +🔍️: Improve SEO. |
| 312 | +🏷️: Add or update types. |
| 313 | +🌱: Add or update seed files. |
| 314 | +🚩: Add, update, or remove feature flags. |
| 315 | +🥅: Catch errors. |
| 316 | +💫: Add or update animations and transitions. |
| 317 | +🗑️: Deprecate code that needs to be cleaned up. |
| 318 | +🛂: Work on code related to authorization, roles and permissions. |
| 319 | +🩹: Simple fix for a non-critical issue. |
| 320 | +🧐: Data exploration/inspection. |
| 321 | +⚰️: Remove dead code. |
| 322 | +🧪: Add a failing test. |
| 323 | +👔: Add or update business logic. |
| 324 | +🩺: Add or update healthcheck. |
| 325 | +🧱: Infrastructure related changes. |
| 326 | +🧑💻: Improve developer experience. |
| 327 | +💸: Add sponsorships or money related infrastructure. |
| 328 | +🧵: Add or update code related to multithreading or concurrency. |
| 329 | +🦺: Add or update code related to validation. |
| 330 | +</gitmojis> |
| 331 | +``` |
| 332 | + |
| 333 | +## Related Resources |
| 334 | + |
| 335 | +- [Scheduled Reports](./scheduled-reports.md) |
| 336 | +- [On-demand Reports](./ondemand-reports.md) |
| 337 | +- [API Documentation](https://api.coderabbit.ai/api/swagger/) |
0 commit comments