1---2name: create-mr3description: Create a merge request with full validation - commit format, black/flake8, merge conflicts, Jira link, reviewer suggestions. Use when user says "create MR", "open PR", "open merge request".4---56# Create Merge Request78## Inputs910| Input | Type | Default | Purpose |11|-------|------|---------|---------|12| `issue_key` | string | required | Jira issue key for linking |13| `repo` | string | "" | Repo path; resolved from issue key if empty |14| `repo_name` | string | - | Config repo name |15| `draft` | bool | true | Create as draft MR |16| `target_branch` | string | "" | Target branch (default from config) |17| `run_linting` | bool | true | Run black/flake8 before MR |18| `check_jira` | bool | false | Run jira_hygiene first |19| `auto_fix_lint` | bool | false | Auto-fix with black |20| `slack_format` | bool | false | Slack link format |21| `check_docs` | bool | false | Run update_docs check |22| `skip_docs_warning` | bool | false | Skip docs warnings |23| `run_precommit` | bool | false | Run pre-commit hooks |2425## Workflow2627### 1. Bootstrap28- `persona_load("developer")`29- `check_known_issues("gitlab_mr_create")`, `check_known_issues("git_push")`30- Resolve repo via `scripts.common.repo_utils.resolve_repo`3132### 2. Pre-flight33- `git_status(repo)` — block if uncommitted changes, detached HEAD, or on main/master34- Validate branch name: `^aap-[0-9]{3,6}` (required by CI)35- Fetch origin (subprocess or `git_fetch`)36- `git_log(repo, limit=20, oneline=true)` — validate commit format via `config.json` commit_format37- Test merge: `git merge --no-commit --no-ff origin/main` then `--abort`38- `gitlab_list_mrs(project)` — detect duplicate MR for branch3940### 3. Knowledge & Reviewers41- Suggest reviewers: git blame on changed `*.py` files42- `knowledge_query(project, section="patterns.coding")`43- `code_search(query=branch_name + " implementation", project, limit=3)`4445### 4. Linting (if run_linting)46- Run `black --check .` (or `black .` if auto_fix_lint)47- Run `flake8 --max-line-length=100 --ignore=E501,W503,E203` on changed `*.py`48- Block MR creation if lint fails4950### 5. Docs (if check_docs)51- `skill_run("update_docs", '{"repo": "...", "check_only": true}')` — warn only, non-blocking5253### 6. Jira & Create54- `jira_view_issue(issue_key)`55- If `check_jira`: `skill_run("jira_hygiene", '{"issue_key": "...", "auto_fix": true}')`56- Push: `git push -u origin branch` (subprocess or `git_push`)57- Build MR title from `format_commit_message` (config.json)58- Build description: summary, Jira link, commits, suggested reviewers, related code, patterns59- `gitlab_mr_create(project, title, description, target_branch, source_branch, draft)`6061### 7. Post-create62- `jira_add_comment(issue_key, "MR created: {url}\nBranch: {branch}\nStatus: Draft/Ready")`63- If not draft: `jira_set_status(issue_key, "In Review")`64- `skill_run("notify_mr", '{"mr_id": X, "issue_key": "..."}')`65- `jira_attach_session(issue_key, include_transcript=false)`6667### 8. Memory68- `memory_session_log("Created MR !X for AAP-Y", url)`69- `memory_append("state/current_work", "open_mrs", item)` — id, project, title, url, issue_key, pipeline_status, needs_review, is_draft, created7071### 9. Failure Learning72- "no such host" → `learn_tool_fix("gitlab_mr_create", "no such host", "VPN not connected", "Run vpn_connect()")`73- "unauthorized" → `learn_tool_fix("gitlab_mr_create", "unauthorized", "Token expired", "Check config.json")`74- "conflict" → `learn_tool_fix("git_merge", "conflict", "Merge conflicts", "skill_run('rebase_pr', ...)")`7576## Key MCP Tools7778- `persona_load`, `git_status`, `git_log`, `git_push`, `gitlab_list_mrs`, `gitlab_mr_create`79- `jira_view_issue`, `jira_add_comment`, `jira_set_status`, `jira_attach_session`80- `code_search`, `knowledge_query`, `check_known_issues`, `learn_tool_fix`81- `memory_session_log`, `memory_append`, `skill_run`