You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn how to track and monitor AI-driven pull requests in your development workflow using Port's software catalog and automation capabilities.
4
4
---
5
5
6
+
import Tabs from "@theme/Tabs"
7
+
import TabItem from "@theme/TabItem"
8
+
6
9
# Track AI-driven pull requests
7
10
8
11
As engineering teams integrate AI coding agents like GitHub Copilot, Claude, and Devin into their workflows, they face the challenge of managing an increased volume of pull requests. Tracking and reviewing these AI-generated contributions can be overwhelming without a centralized system. Port's AI control center addresses this issue by identifying pull requests originating from coding agents and displaying them in real-time, allowing you to efficiently monitor and act upon them.
@@ -29,6 +32,57 @@ This guide assumes you're using GitHub to manage your code. However, the princip
29
32
:::
30
33
31
34
35
+
## Identifying AI-driven pull requests
36
+
37
+
Before tracking statuses, we need to identify whether a PR was created or influenced by an AI coding agent.
- Copilot PRs are usually authored by the GitHub Copilot bot (`github-copilot[bot]`).
45
+
- They often start as **draft PRs** or use `"WIP"` in the title.
46
+
- Commits are signed with the Copilot signature.
47
+
48
+
**Example**
49
+
- PR title: `"WIP: Initial refactor"`.
50
+
- Author: `github-copilot[bot]`.
51
+
- Draft: `true`.
52
+
53
+
</TabItem>
54
+
55
+
56
+
<TabItemvalue="claude"label="Claude Code">
57
+
58
+
**How we detect it**
59
+
- PRs can be authored by either the **human user** or Claude itself. When authored by a human, Claude’s comments reveal its involvement.
60
+
- Claude typically adds **long, structured review comments**, often in a blockquote style or with headers like **“Here’s what I changed”**.
61
+
- No `draft` or `"WIP"` markers are added automatically when authored by Claude.
62
+
63
+
**Example**
64
+
- Author: `janedoe` (human) or `claude-bot`.
65
+
- Comment by Claude Code: `“Here are the changes I made for better error handling…”`.
66
+
67
+
</TabItem>
68
+
69
+
70
+
<TabItemvalue="devin"label="Devin">
71
+
72
+
**How we detect it**
73
+
- Devin usually opens a regular PR (not draft, no WIP).
74
+
- Commits are authored by a **dedicated GitHub user** configured for Devin.
75
+
- Commit messages often follow a **concise, imperative style** (e.g., `Fix API error handling`).
76
+
77
+
**Example**
78
+
- PR: opened by `devin-bot` (or the GitHub user assigned to Devin).
79
+
- Commits: `author: Devin <bot@devin.ai>`.
80
+
- No draft/WIP markers.
81
+
82
+
</TabItem>
83
+
</Tabs>
84
+
85
+
32
86
## Data model setup
33
87
34
88
We will create and configure blueprints to support tracking AI-driven pull requests. This includes setting up the AI coding agent blueprint and enhancing the existing pull request blueprint.
@@ -112,6 +166,10 @@ This blueprint will represent all known coding agents in your system.
112
166
113
167
5. Click `Create` to save the blueprint.
114
168
169
+
:::note Populate Coding Agents
170
+
Ensure that this blueprint is populated with the names of coding agents such as Copilot, Claude, Devin, etc. This will help in accurately tracking and managing AI-driven pull requests.
171
+
:::
172
+
115
173
116
174
### Update pull request blueprint
117
175
@@ -123,7 +181,7 @@ When installing Port's GitHub app, the `Service` and `Pull request` blueprints a
123
181
4. Add the following property to the `properties` section:
124
182
125
183
<details>
126
-
<summary><b>Draft property (Click to expand)</b></summary>
184
+
<summary><b>Draft and coding agent status property (Click to expand)</b></summary>
127
185
128
186
```json showLineNumbers
129
187
"draft": {
@@ -197,7 +255,6 @@ Now we will update the GitHub integration configuration to ensure that the new p
197
255
properties:
198
256
status: .status
199
257
closedAt: .closed_at
200
-
creata: .user.login
201
258
updatedAt: .updated_at
202
259
mergedAt: .merged_at
203
260
createdAt: .created_at
@@ -241,25 +298,37 @@ Now we will update the GitHub integration configuration to ensure that the new p
241
298
:::
242
299
</details>
243
300
301
+
:::tip Alternative mapping for Claude/Devin PRs
302
+
The default `workStatus` mapping is optimized for **GitHub Copilot**, which usually opens **draft PRs** or adds **"WIP"** to titles.
244
303
245
-
## Set up automations
304
+
For **Claude or Devin**, PRs are typically created as *regular, non-draft PRs* with no WIP indicators.
305
+
In that case, you can use this simplified mapping that relies only on **reviewers** and **merge status**:
246
306
247
-
We will create several automations to help track the status of coding agents. To figure out if a coding agent participated in a PR creation, we need to look into its comments and commits.
307
+
<details>
308
+
<summary><b>Alternative mapping for Claude/Devin PRs (Click to expand)</b></summary>
248
309
249
-
The automation flow works as follows:
250
-
1. **Ingest PRs** via Port's GitHub app
251
-
2. **Run automation** that gets commits or comments for each PR update
252
-
3. **Run second automation** that extracts and looks for names of coding agents
253
-
254
-
:::tip Avoid Recursive Updates
255
-
To prevent recursive updates and entity overwrites caused by two automations being triggered for each pull request update, ensure that the comment automation is executed only after the commit automation has completed. This sequential execution avoids simultaneous runs and potential conflicts.
310
+
```yaml showLineNumbers
311
+
workStatus: >-
312
+
if ((.requested_reviewers // []) | length) > 0 then
313
+
"Awaiting review"
314
+
elif ((.requested_reviewers // []) | length) == 0 then
315
+
"In Progress"
316
+
else
317
+
"Unknown"
318
+
end
319
+
```
320
+
</details>
256
321
:::
257
322
323
+
## Set up automations
324
+
325
+
To effectively track the status of coding agents, we will create several automations. You have the flexibility to determine if a coding agent participated in a PR creation by examining its comments, commits, or both, depending on your specific needs. This allows you to tailor the tracking process to best fit your requirements.
326
+
258
327
### Add Port secrets
259
328
260
-
To securely integrate GitHub REST API with your portal, you need to add secrets that will allow access to necessary data.
329
+
Before setting up the automations, ensure you have added the necessary secrets to securely interact with the GitHub REST API within your portal. This is essential for accessing the required data.
261
330
262
-
To add this secret to your portal:
331
+
To add the secret to your portal:
263
332
264
333
1. Click on the `...` button in the top right corner of your Port application.
265
334
2. Click on **Credentials**.
@@ -268,10 +337,22 @@ To add this secret to your portal:
268
337
269
338
-`GITHUB_TOKEN` - Your [GitHub fine-grained access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) with access to read repository commits and comments.
270
339
340
+
Once the secret is added, you can proceed with setting up the automations based on your chosen method of tracking AI participation:
341
+
342
+
<TabsgroupId="ai-participation">
343
+
<TabItemvalue="commits"label="Commits (AI wrote code)">
344
+
345
+
### Commits Automation Flow
346
+
347
+
This flow identifies AI involvement in code writing by analyzing commit data.
348
+
349
+
1.**Run automation** to fetch commits for each PR update.
350
+
2.**Run second automation** to extract and identify coding agent names from commits.
271
351
272
-
### Automation 1: Get commits on PR updated
273
352
274
-
This automation only runs when the `ai_coding_agent` relation is null (before and after) to ensure that it only processes pull requests that have not yet been associated with an AI coding agent, preventing redundant operations.
353
+
<h4> Automation 1: Get commits on PR updated </h4>
354
+
355
+
This automation only runs when the `ai_coding_agent` relation is null (before and after) to ensure that it only processes pull requests that have not yet been associated with an AI coding agent.
275
356
276
357
1. Go to the [Automations](https://app.getport.io/settings/automations) page of your portal.
277
358
2. Click on `+ Automation`.
@@ -325,7 +406,7 @@ This automation only runs when the `ai_coding_agent` relation is null (before an
325
406
4. Click `Create` to save the automation.
326
407
327
408
328
-
### Automation 2: Update PR with AI coding agent (commit-based)
409
+
<h4> Automation 2: Update PR with AI coding agent (commit-based) </h4>
329
410
330
411
This automation only runs if the commits response contains a match for AI agents, ensuring that only relevant pull requests are updated with AI coding agent information.
331
412
@@ -374,12 +455,19 @@ This automation only runs if the commits response contains a match for AI agents
This automation runs only after the commits automation and only if commits returned no AI agent, ensuring that the system checks for AI involvement through comments when it is not detected in commits.
463
+
This flow identifies AI involvement in code review by analyzing comment data.
381
464
382
-
1. Go back to the [Automations](https://app.getport.io/settings/automations) page of your portal.
465
+
1. **Run automation** to fetch comments for each PR update.
466
+
2. **Run second automation** to extract and identify coding agent names from comments.
467
+
468
+
<h4> Automation 1: Get comments on PR updated </h4>
469
+
470
+
1. Go to the [Automations](https://app.getport.io/settings/automations) page of your portal.
383
471
2. Click on `+ Automation`.
384
472
3. Copy and paste the following JSON schema:
385
473
@@ -389,8 +477,8 @@ This automation runs only after the commits automation and only if commits retur
389
477
```json showLineNumbers
390
478
{
391
479
"identifier": "get_comments_on_pr_updated",
392
-
"title": "Get Comments on PR Updated (after commits check)",
393
-
"description": "Fetch PR comments only if commit scan returned no AI agent",
480
+
"title": "Get Comments on PR Updated",
481
+
"description": "Fetch PR comments upon PR updates",
394
482
"icon": "GitPullRequest",
395
483
"trigger": {
396
484
"type": "automation",
@@ -401,15 +489,15 @@ This automation runs only after the commits automation and only if commits retur
@@ -429,8 +517,7 @@ This automation runs only after the commits automation and only if commits retur
429
517
430
518
4. Click `Create` to save the automation.
431
519
432
-
433
-
### Automation 4: Update PR with AI coding agent (comment-based)
520
+
<h4> Automation 2: Update PR with AI coding agent (comment-based) </h4>
434
521
435
522
This automation only runs if the comments response contains a match for AI agents, ensuring that the PR is updated only when relevant AI activity is detected.
436
523
@@ -479,6 +566,9 @@ This automation only runs if the comments response contains a match for AI agent
0 commit comments