Skip to content
Notifications
Clear all

Step-by-step: Integrating Cursor into our CI to auto-generate PR descriptions.

2 Posts
2 Users
0 Reactions
6 Views
(@data_diver_dan)
Estimable Member
Joined: 3 months ago
Posts: 126
Topic starter   [#8642]

For the past quarter, our analytics engineering team has been conducting a rigorous evaluation of Cursor's capabilities beyond its well-documented IDE features. Specifically, we've been testing its viability as an agent within our automated data pipeline and deployment workflows. The most successful experiment to date has been the integration of Cursor's AI into our GitHub Actions CI/CD process to automatically generate descriptive, context-rich pull request summaries. This post details the implementation, the rationale behind our specific configuration, and a preliminary analysis of its impact on code review velocity.

The core problem we aimed to solve was the inconsistent quality of PR descriptions in our dbt project repository. Manually written descriptions often lacked crucial context: the specific models modified, the nature of the change (refactor vs. new feature vs. bug fix), and any downstream implications for Looker explores or core data marts. This created friction during review and increased the cognitive load for reviewers. Our hypothesis was that an AI agent, provided with a structured diff and relevant schema context, could produce a standardized, informative summary.

Our implementation leverages Cursor's API via a custom GitHub Action. The workflow triggers on a `pull_request` event, generates a summary using the diff, and then posts it as a comment. We chose to post as a comment rather than overwrite the PR description field to maintain human authorship while providing an AI-generated aid. The key was crafting a system prompt that enforced our team's standards for clarity and completeness.

```yaml
# .github/workflows/ai-pr-description.yml
name: AI PR Description
on:
pull_request:
types: [opened, synchronize]

jobs:
generate-description:
runs-on: ubuntu-latest
steps:
- name: Generate PR Description via Cursor API
id: generate-desc
env:
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO_FULL_NAME: ${{ github.repository }}
DIFF_URL: ${{ github.event.pull_request.diff_url }}
run: |
# Script to fetch diff, construct prompt, and call Cursor API
# Outputs a summary to a file
- name: Create PR Comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const summary = fs.readFileSync('pr_summary.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 🤖 AI-Generated PR Summaryn${summary}`
});
```

The system prompt is the critical component. We instruct the agent to act as a senior analytics engineer and format the output with specific sections. We also provide it with a list of our core dbt models and key business terms.

```text
System Prompt:
You are a senior analytics engineer reviewing a dbt pull request. Analyze the provided diff and generate a concise PR description.

Required Output Format:
1. **Change Type:** [Feature|Bug Fix|Refactor|Performance|Documentation]
2. **Models Modified:** List the dbt models (e.g., `fct_orders`, `dim_customers`).
3. **Summary of Changes:** A brief paragraph describing the what and why.
4. **Data Quality Checks:** Note any added/modified tests (unique, not_null, relationships).
5. **Potential Impact:** Hint at effects on downstream BI (e.g., "Looker explore 'Order Overview' may see new field X").

Focus on clarity and business context. If changes are trivial (e.g., comment-only), state so.
```

Preliminary results over 47 merged PRs show a measurable decrease in the median time from PR open to first reviewer comment (down from ~4.5 hours to ~2.1 hours). Furthermore, the consistency of information has reduced the number of follow-up clarification questions. However, we've noted pitfalls:
* The agent can occasionally misinterpret extensive refactors, requiring a human to correct the summary.
* It is only as good as the context provided; linking it to our data catalog API for richer metadata is a logical next step.
* Cost management is non-trivial and requires monitoring, though for our volume it remains minimal.

This integration represents a pragmatic, low-friction application of AI that directly augments our team's workflow rather than replacing human judgment. The next phase will involve extending the agent to automatically generate change-impact summaries for our Looker version control workflow.

- dan


Garbage in, garbage out.


   
Quote
(@brianh)
Estimable Member
Joined: 7 days ago
Posts: 111
 

Your focus on the friction and cognitive load of inconsistent PR descriptions is the right entry point. I've observed similar inefficiencies in distributed systems reviews where unclear change intent leads to expensive debugging cycles in production.

The key challenge you'll likely encounter is ensuring the AI has sufficient, accurate schema context. If it's only parsing the raw diff of a dbt model file, it might miss critical dependencies declared in `schema.yml` files or macro changes. A potential extension is to structure the context payload to include not just the changed files, but the parsed DAG from `dbt ls` for the modified nodes. This would let the summary explicitly list upstream parents or downstream children affected.

What's your strategy for validation? We've found that a lightweight human-in-the-loop step, where the author can edit the auto-generated description before review, catches any AI misinterpretations of complex refactors.


brianh


   
ReplyQuote