home / skills / openharmonyinsight / openharmony-skills / create-pr

create-pr skill

/skills/create-pr

This skill automates PR work by analyzing changes, generating descriptions, signing off with DCO, and creating linked issues and PRs.

npx playbooks add skill openharmonyinsight/openharmony-skills --skill create-pr

Review the files below or copy the command above to add this skill to your agents.

Files (7)
SKILL.md
3.3 KB
---
name: create-pr
description: "Automated PR workflow: analyze code changes, auto-generate Issue/PR descriptions, auto-commit with DCO sign-off, auto-push, auto-create Issue + PR, and link PR to Issue."
version: 7.0.0
platform-agnostic: true
---

# Create PR Skill v7.0.0

Platform-agnostic automated PR workflow:
1. Analyze code changes and detect logic changes (functions/classes + file stats)
2. Auto-generate Issue + PR titles and descriptions
3. Auto-commit **with DCO sign-off** (`Signed-off-by`)
4. Auto-push
5. Auto-create Issue (optional, via API)
6. Auto-create PR with Issue linkage (`Fixes #id`)

## Quick Start

### 1) Configure Token (one time, for API features)

The script supports multiple platforms via configuration:

```bash
# For GitCode/GitLab
git config --global gitcode.token "your_token"

# For GitHub
git config --global github.token "your_token"

# Or use environment variables
export GITCODE_TOKEN="your_token"
export GITHUB_TOKEN="your_token"
```

Token permissions: `api`, `read_api`, `write_repository`

### 2) Run

```bash
python scripts/create-pr/full_auto_pr.py
```

## What It Does

- Deep change analysis from `git diff`
- Detects:
  - added/modified/removed functions
  - added/modified/removed classes
  - top changed files with line stats
- Generates structured Issue + PR descriptions based on real diffs
- **Auto-adds DCO sign-off** (`Signed-off-by: Name <email>`)
- Pushes to remote
- Creates Issue + PR via platform API (when configured)
- Links PR to Issue (adds `Fixes #id`)
- Falls back to web interface if API unavailable

## Usage Options

```bash
python scripts/create-pr/full_auto_pr.py --target main
python scripts/create-pr/full_auto_pr.py --no-issue
python scripts/create-pr/full_auto_pr.py --no-commit
python scripts/create-pr/full_auto_pr.py --no-push
python scripts/create-pr/full_auto_pr.py --analyze-only
```

## Output Artifacts

Generated Issue description:
- Summary + change type
- Affected components
- Added/modified/removed functions and classes
- Key file changes with +/-
- File type stats
- Commit history
- Diff stats

Generated PR description:
- Summary (from commits)
- Changes (function/class + component groups)
- Test plan
- Related Issue (`Fixes #id`)

## Files

```
create-pr/
├── SKILL.md
├── CHANGELOG.md
├── README.md
├── examples/
│   └── example-workflow.md
├── references/
│   ├── commit-message-guide.md
│   ├── pr-description-template.md
│   ├── platform-apis.md
│   └── common-issues.md
└── scripts/
    ├── repo_api.py         # Platform-agnostic API client + analyzer
    └── full_auto_pr.py     # End-to-end automation
```

## Platform Support

The script automatically detects the platform from your git remote URL:
- **GitCode/GitLab**: Uses GitLab-compatible API v4
- **GitHub**: Uses GitHub REST API v3
- **Others**: Falls back to web-based PR creation

## Notes

- **DCO (Developer Certificate of Origin)** is automatically added to commit messages
  - Requires `git config user.name` and `git config user.email` to be set
  - Adds `Signed-off-by: Name <email>` line to each commit
  - Ensures PR passes DCO validation checks
- If platform API is not configured or fails, the script opens browser for manual PR creation
- Token can be set via git config, environment variables, or `~/.platform-token` file

Overview

This skill automates the end-to-end pull request workflow for git projects. It analyzes code changes, generates structured Issue and PR descriptions, signs commits with DCO, pushes changes, and optionally creates and links Issues and PRs via platform APIs.

How this skill works

The script inspects git diffs to detect added, modified, or removed functions and classes and compiles file-level change stats. It auto-generates Issue and PR titles and bodies from the real diffs, creates a DCO-signed commit, pushes the branch, and uses the detected remote platform API (GitHub, GitLab/GitCode) to create an Issue and a PR that references the Issue with a Fixes #id link. If the API is unavailable, it falls back to opening the web PR creation page.

When to use it

  • You want consistent, detailed PR and Issue descriptions derived from actual diffs.
  • You need automated DCO sign-off on commits to meet contribution policies.
  • You want to reduce manual steps: commit, push, create Issue, create PR, and link them.
  • You maintain multiple platforms (GitHub, GitLab/GitCode) and want a single workflow.
  • You want an analyze-only mode to preview detected changes before committing.

Best practices

  • Set git user.name and user.email so DCO sign-off is accurate.
  • Configure a platform token via git config or environment variables with api/read_api/write_repository scope.
  • Run in a feature branch and verify the analyze-only output before auto-committing.
  • Use --no-commit or --no-push flags when integrating into CI or when you need manual control.
  • Review generated Issue/PR drafts to add context or testing details before final submission.

Example use cases

  • Feature branch workflow: run end-to-end to commit with DCO, push, create Issue, and open a linked PR automatically.
  • Small fixes: auto-generate a concise PR body and link to an auto-created Issue with a single command.
  • Open-source projects requiring DCO: ensure every automated commit includes Signed-off-by metadata.
  • CI helper: run in analyze-only mode in pipelines to produce a change summary without making repo changes.
  • Multi-platform repos: let the script detect remote and call the appropriate API for Issue/PR creation.

FAQ

What tokens are required for API actions?

Provide a platform token with api/read_api/write_repository permissions. Tokens can be set via git config, environment variables, or a tokens file.

How does DCO sign-off work?

The script appends a Signed-off-by line to commits using git user.name and git user.email; ensure those are configured to pass DCO checks.