---
name: submit-draft-pr
description: Optionally create a draft PR to the upstream repo from a local source directory. Used by coding agents when a local source path is available in the context file.
title: submit-draft-pr
canonical_url: https://skilld.dev/gh/openvinotoolkit/openvino/submit-draft-pr
last_updated: 2026-11-22T07:15:46.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install openvinotoolkit/openvino/submit-draft-pr`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/submit-draft-pr`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/openvinotoolkit/openvino/submit-draft-pr) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/submit-draft-pr`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/submit-draft-pr --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/submit-draft-pr --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Skill: Submit Draft PR

> **Optional.** Attempt this only when all of the following are true:
> - Your context file provides a local source path (e.g. `OpenVINO source code: /path/to/openvino`)
> - That path is accessible and is a git repository
> - `gh` CLI is available and authenticated (`gh auth status`)
>
> If any condition is not met — **skip silently** and log one line. Do not fail.

---

## When to invoke

After completing your main implementation work and writing results to
`agent-results/<agent>/`, call this skill to open a **draft PR** from your
changes to the upstream repo.

This is *in addition to* — never instead of — generating patch files and
writing results to `agent-results/`.

---

## Steps

### 1. Verify prerequisites

```bash
# Is gh available and authenticated?
gh auth status || { echo "[draft-pr] gh not available — skipping"; exit 0; }

# Is the source path a git repo?
[ -d "${SOURCE_PATH}/.git" ] || { echo "[draft-pr] ${SOURCE_PATH} is not a git repo — skipping"; exit 0; }
```

### 2. Choose a branch name

Use a descriptive kebab-case branch name derived from the work done:

```
agent/add-<op-name>-op              # core op or FE op
agent/add-<pass-name>-transformation
agent/<model-id>-export             # optimum-intel / tokenizers
agent/<component>-<short-desc>      # general
```

### 3. Check for an existing PR

Before creating a new PR, check whether one already exists from the same branch to avoid duplicates:

```bash
BRANCH="agent/<descriptive-name>"
EXISTING=$(gh pr list \
  --repo openvinotoolkit/openvino \
  --head "$(gh api user -q .login):$BRANCH" \
  --json url -q '.[0].url' 2>/dev/null)
if [ -n "$EXISTING" ]; then
  echo "[draft-pr] PR already exists: $EXISTING — skipping creation"
  exit 0
fi
```

If a PR exists, log the URL and stop — do **not** open a second one.

### 4. Compose the PR body

Every agent-generated PR **must** open with the following notice block (exact
wording, first lines of the body before any other content):

```markdown
> [!IMPORTANT]
> **This PR was generated by a Copilot coding agent and requires human review.**
> A maintainer must inspect the changes, run the relevant tests locally, and
> convert this draft to "Ready for review" only after verifying correctness.
> Do **not** merge without human sign-off.
```

After the notice, follow the upstream `pull_request_template.md` structure:

```markdown
> [!IMPORTANT]
> **This PR was generated by a Copilot coding agent and requires human review.**
> A maintainer must inspect the changes, run the relevant tests locally, and
> convert this draft to "Ready for review" only after verifying correctness.
> Do **not** merge without human sign-off.

### Details:
 - <what was changed and why>
 - Agent: <agent-name>
 - Model tested: <model-id or N/A>
 - Operator: <op-name or N/A>

### Tickets:
 - <linked issue URL or N/A>

### AI Assistance:
 - AI assistance used: yes
 - Generated by GitHub Copilot agent (`<agent-name>`). Human validation required:
   build verification, unit/functional tests, and inference sanity check.
```

Write this body to `agent-results/<agent>/pr_body.md` before calling `gh pr create`.

### 5. Create branch, commit, and open draft PR

```bash
cd <source_path>
BRANCH="fix/<descriptive-name>"
git checkout -b "$BRANCH"
git add -A
git commit -m "<one-line description>"
gh repo fork openvinotoolkit/openvino --clone=false 2>/dev/null || true
git remote add fork "$(gh repo view "$(gh api user -q .login)/openvino" --json sshUrl -q .sshUrl)" 2>/dev/null || true
git push fork "$BRANCH"
gh pr create --draft \
  --repo openvinotoolkit/openvino \
  --head "$(gh api user -q .login):$BRANCH" \
  --title "<one-line description>" \
  --body-file agent-results/<agent>/pr_body.md
```

### 6. Log the result

After the script runs, record the outcome in `agent-results/<agent>/session.md`:

```
[draft-pr] PR opened: <pr_url>
```

or

```
[draft-pr] Skipped: <reason>
```

---

## Per-repo upstream table

| Agent | Upstream repo |
|---|---|
| transformation, core-opspec, pytorch-fe, cpu, gpu, npu | `openvinotoolkit/openvino` |
| optimum-intel | `huggingface/optimum-intel` |
| openvino-tokenizers | `openvinotoolkit/openvino_tokenizers` |
| openvino-genai | `openvinotoolkit/openvino.genai` |

Pass `--upstream <value>` only when auto-detection from the git remote is likely
to fail (e.g. the local clone uses an internal mirror URL).

---

## Important constraints

- Always create PRs as **drafts** — never ready-for-review.
- PR target is the **upstream** repo, not the fork.
- Do not push to `main`/`master` of any repo.
- If `git push --force-with-lease` fails (e.g. diverged history), skip and log — do not `--force`.
- Do not block the agent's completion on PR success — log the failure and continue.
