PR Jira Audit
Scans open MRs for Jira issue references. Reports compliance; optionally creates issues for MRs without links.
Inputs
| Input |
Type |
Default |
Purpose |
project |
string |
"" |
GitLab project path (resolved from repo_name) |
repo_name |
string |
automation-analytics-backend |
Repository from config |
jira_project |
string |
AAP |
Jira project for new issues |
limit |
int |
20 |
Max MRs to audit |
auto_create |
bool |
false |
Create Jira issues for MRs without one |
add_comment |
bool |
false |
Add comment to MR with created issue key |
dry_run |
bool |
true |
Report only, no changes |
slack_format |
bool |
false |
Use Slack link format in summary |
Workflow
1. Load Persona
persona_load(persona="developer")
2. Resolve Project
- From config.json repositories: use project if provided, else repo_name.gitlab, else match cwd, else session_project, else "automation-analytics/automation-analytics-backend"
3. Get Open MRs
gitlab_mr_list(project=resolved.gitlab_project, state="opened", per_page=limit)
- Parse: extract mr iid, title, author for each
4. Audit Each MR
For each MR, check title for Jira pattern [A-Z]{2,10}-\d+:
- has_jira_in_title: bool
- jira_keys: list of matches
- Categorize: missing_jira vs has_jira
5. Create Jira for First Missing (if auto_create and not dry_run)
skill_run(skill_name="create_jira_issue", inputs='{"summary": "' + mr_title + '", "description": "Auto-created for MR !' + str(iid) + '...", "issue_type": "Task", "project": "' + jira_project + '", "priority": "Normal"}')
- Parse: extract created issue_key
6. Comment on MR (if add_comment and created_issue.success)
gitlab_mr_comment(project=gitlab_project, mr_id=iid, message="## 🎫 Jira Issue Created\n**{issue_key}**\nView: https://issues.redhat.com/browse/{issue_key}")
7. Build Summary
- Compliance %: compliant_count / total * 100
- Health emoji: 🟢 ≥90%, 🟡 ≥70%, 🟠 ≥50%, 🔴 <50%
- List MRs missing Jira (with links)
- List compliant MRs (abbreviated)
- If created: show created issue
8. Log & Track
memory_session_log(action="PR Jira Audit on {project}", details="{missing_count} of {total} MRs missing Jira")
9. Learning from Failures
- If "no such host" or "dial tcp":
learn_tool_fix("gitlab_mr_list", "no such host", "VPN not connected", "Run vpn_connect()")
- If "unauthorized":
learn_tool_fix("gitlab_mr_list", "unauthorized", "GitLab auth failed", "Check GitLab token")
Output Format
## 🔍 PR Jira Audit Results
**Project:** automation-analytics/automation-analytics-backend
**Total MRs Audited:** 15
**Dry Run:** Yes
### 🟡 Compliance: 73%
- ✅ **With Jira:** 11
- ❌ **Missing Jira:** 4
### ❌ MRs Missing Jira Reference
- !1234: Fix auth bug (Author: user)
### ✅ MRs With Jira Reference
- !1235: AAP-12345 - Add endpoint
### Quick Actions
skill_run("pr_jira_audit", '{"dry_run": false, "auto_create": true}')
Key MCP Tools
persona_load, gitlab_mr_list, gitlab_mr_view, gitlab_commit_list, gitlab_mr_comment, skill_run, memory_session_log, learn_tool_fix
1---2name: pr-jira-audit3description: Audit open MRs/PRs for missing Jira issue references. Scans title, description, commits for Jira keys. Optionally creates Jira issues for unlinked MRs. Use when user says "audit PRs", "check Jira links on MRs", or "sprint hygiene".4---56# PR Jira Audit78Scans open MRs for Jira issue references. Reports compliance; optionally creates issues for MRs without links.910## Inputs1112| Input | Type | Default | Purpose |13|-------|------|---------|---------|14| `project` | string | "" | GitLab project path (resolved from repo_name) |15| `repo_name` | string | automation-analytics-backend | Repository from config |16| `jira_project` | string | AAP | Jira project for new issues |17| `limit` | int | 20 | Max MRs to audit |18| `auto_create` | bool | false | Create Jira issues for MRs without one |19| `add_comment` | bool | false | Add comment to MR with created issue key |20| `dry_run` | bool | true | Report only, no changes |21| `slack_format` | bool | false | Use Slack link format in summary |2223## Workflow2425### 1. Load Persona26- `persona_load(persona="developer")`2728### 2. Resolve Project29- From config.json repositories: use project if provided, else repo_name.gitlab, else match cwd, else session_project, else "automation-analytics/automation-analytics-backend"3031### 3. Get Open MRs32- `gitlab_mr_list(project=resolved.gitlab_project, state="opened", per_page=limit)`33- Parse: extract mr iid, title, author for each3435### 4. Audit Each MR36For each MR, check title for Jira pattern `[A-Z]{2,10}-\d+`:37- has_jira_in_title: bool38- jira_keys: list of matches39- Categorize: missing_jira vs has_jira4041### 5. Create Jira for First Missing (if auto_create and not dry_run)42- `skill_run(skill_name="create_jira_issue", inputs='{"summary": "' + mr_title + '", "description": "Auto-created for MR !' + str(iid) + '...", "issue_type": "Task", "project": "' + jira_project + '", "priority": "Normal"}')`43- Parse: extract created issue_key4445### 6. Comment on MR (if add_comment and created_issue.success)46- `gitlab_mr_comment(project=gitlab_project, mr_id=iid, message="## 🎫 Jira Issue Created\n**{issue_key}**\nView: https://issues.redhat.com/browse/{issue_key}")`4748### 7. Build Summary49- Compliance %: compliant_count / total * 10050- Health emoji: 🟢 ≥90%, 🟡 ≥70%, 🟠 ≥50%, 🔴 <50%51- List MRs missing Jira (with links)52- List compliant MRs (abbreviated)53- If created: show created issue5455### 8. Log & Track56- `memory_session_log(action="PR Jira Audit on {project}", details="{missing_count} of {total} MRs missing Jira")`5758### 9. Learning from Failures59- If "no such host" or "dial tcp": `learn_tool_fix("gitlab_mr_list", "no such host", "VPN not connected", "Run vpn_connect()")`60- If "unauthorized": `learn_tool_fix("gitlab_mr_list", "unauthorized", "GitLab auth failed", "Check GitLab token")`6162## Output Format6364```markdown65## 🔍 PR Jira Audit Results6667**Project:** automation-analytics/automation-analytics-backend68**Total MRs Audited:** 1569**Dry Run:** Yes7071### 🟡 Compliance: 73%72- ✅ **With Jira:** 1173- ❌ **Missing Jira:** 47475### ❌ MRs Missing Jira Reference76- !1234: Fix auth bug (Author: user)77### ✅ MRs With Jira Reference78- !1235: AAP-12345 - Add endpoint7980### Quick Actions81skill_run("pr_jira_audit", '{"dry_run": false, "auto_create": true}')82```8384## Key MCP Tools8586- `persona_load`, `gitlab_mr_list`, `gitlab_mr_view`, `gitlab_commit_list`, `gitlab_mr_comment`, `skill_run`, `memory_session_log`, `learn_tool_fix`