Initial commit
This commit is contained in:
12
.claude-plugin/plugin.json
Normal file
12
.claude-plugin/plugin.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "gh",
|
||||
"description": "Intelligent PR creation tool that analyzes your changes and creates well-structured pull requests.",
|
||||
"version": "2.0.0",
|
||||
"author": {
|
||||
"name": "Kazuki Hashimoto",
|
||||
"email": "setouchi.develop@gmail.com"
|
||||
},
|
||||
"commands": [
|
||||
"./commands/create-pr.md"
|
||||
]
|
||||
}
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# gh
|
||||
|
||||
Intelligent PR creation tool that analyzes your changes and creates well-structured pull requests.
|
||||
87
commands/create-pr.md
Normal file
87
commands/create-pr.md
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
description: Analyze local git changes and create a structured GitHub pull request.
|
||||
argument-hint: "[-d|--draft] [-b <branch>] [-r <user> ...] [--no-push] [--no-assign]"
|
||||
allowed-tools: [Bash(git status:*), Bash(git diff:*), Bash(git branch:*), Bash(git rev-parse:*), Bash(git rev-list:*), Bash(gh:*), Bash(git push:*), Bash(git ls-remote:*), Bash(git symbolic-ref:*), Bash(awk:*), Bash(sed:*)]
|
||||
---
|
||||
|
||||
# Create Pull Request
|
||||
|
||||
You are a Claude Code slash command that prepares and creates a GitHub pull request from the current repository. Follow the protocol below exactly, using only the allowed tools.
|
||||
|
||||
## Inputs
|
||||
|
||||
Parse the arguments provided to this command (`$ARGUMENTS`) and support these flags:
|
||||
- `--draft`, `-d`: create the PR as draft.
|
||||
- `--base <branch>`, `-b <branch>`: base branch. If omitted, detect the default branch.
|
||||
- `--reviewer <user>`, `-r <user>`: may appear multiple times; add each as reviewer.
|
||||
- `--no-push`: do not push the branch before creating the PR.
|
||||
- `--no-assign`: skip assigning the PR to yourself (by default, PRs are assigned to `@me`).
|
||||
|
||||
## Context Gathering
|
||||
|
||||
Use Bash to collect repository context. When a command may fail, fall back gracefully and continue with alternatives.
|
||||
- Current branch: run `git branch --show-current`.
|
||||
- Default/base branch detection order:
|
||||
1) `--base` flag if provided.
|
||||
2) `git ls-remote --symref origin HEAD | awk '/^ref:/ {sub(/refs\\/heads\\//, "", $2); print $2}'` (directly queries remote HEAD).
|
||||
3) `git symbolic-ref -q --short refs/remotes/origin/HEAD | sed 's/^origin\\///'` (uses local origin/HEAD if set).
|
||||
4) `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` (only if `gh` is installed and authenticated).
|
||||
If still unknown, ask the user to specify `--base <branch>` and stop.
|
||||
- Working tree status: `git status --porcelain` and `git status -sb`.
|
||||
- Diff summary: `git diff --stat "origin/<base>"...HEAD` (fallback: `git diff --stat HEAD~5...HEAD`).
|
||||
- Staged vs unstaged changes: `git diff --staged` and `git diff`.
|
||||
- Ahead/behind: `git rev-list --left-right --count origin/<base>...HEAD` if upstream exists.
|
||||
|
||||
## Safety Check
|
||||
|
||||
Scan the diff for likely secrets or credentials. Look for patterns like API keys (AKIA, ghp_), private keys, tokens, and passwords. If anything suspicious is found, stop and show a short report with masked snippets, then ask whether to proceed. Default to cancel if the user doesn’t confirm.
|
||||
|
||||
## Compose PR
|
||||
|
||||
Draft a concise title (<= 72 chars, imperative mood). Create a structured body with the following sections:
|
||||
|
||||
```
|
||||
## Summary
|
||||
<1–3 sentence overview>
|
||||
|
||||
## Changes
|
||||
- <key change>
|
||||
- <key change>
|
||||
|
||||
## Motivation
|
||||
<why this change is needed>
|
||||
|
||||
## Testing
|
||||
- <how you validated it>
|
||||
|
||||
## Risks
|
||||
- <potential risks / rollbacks>
|
||||
```
|
||||
|
||||
Confirm the title and body with the user before proceeding.
|
||||
|
||||
## Push (optional)
|
||||
|
||||
If `--no-push` is NOT set and the branch is ahead of its remote (or has no upstream):
|
||||
- Show the exact push command you will run.
|
||||
- Ask for confirmation.
|
||||
- Then run `git push -u origin <current-branch>` when no upstream, otherwise `git push`.
|
||||
|
||||
## Create PR
|
||||
|
||||
Build the `gh pr create` command with the resolved options and show it before execution. Use these flags when available:
|
||||
- `--base <base>`
|
||||
- `--draft` when `--draft` was passed
|
||||
- `--reviewer <user>` per reviewer occurrence
|
||||
- `--title <title>` and `--body <body>` (prefer `--body` inline; if the content is large, write to a temp file and use `--body-file`)
|
||||
|
||||
Execute the command and capture the resulting PR URL or number. Unless `--no-assign` was provided, try `gh issue edit <number> --add-assignee @me` afterward; warn but do not fail if assignment is not permitted.
|
||||
|
||||
## Output
|
||||
|
||||
Print:
|
||||
- PR URL (or number) and status (draft/ready)
|
||||
- Base branch and source branch
|
||||
- Reviewers added (if any)
|
||||
|
||||
If any step fails, report the exact command and stderr, provide a short diagnosis, and suggest concrete next steps.
|
||||
45
plugin.lock.json
Normal file
45
plugin.lock.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"$schema": "internal://schemas/plugin.lock.v1.json",
|
||||
"pluginId": "gh:setouchi-h/cc-marketplace:packages/gh",
|
||||
"normalized": {
|
||||
"repo": null,
|
||||
"ref": "refs/tags/v20251128.0",
|
||||
"commit": "663b73d640baaf7039636d5239ae7376b50ebe41",
|
||||
"treeHash": "d9e3626fbcfd82f54f0f56ce4ef18f62606036af8277fd03f2705951ae5b3abf",
|
||||
"generatedAt": "2025-11-28T10:28:15.932947Z",
|
||||
"toolVersion": "publish_plugins.py@0.2.0"
|
||||
},
|
||||
"origin": {
|
||||
"remote": "git@github.com:zhongweili/42plugin-data.git",
|
||||
"branch": "master",
|
||||
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
|
||||
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
|
||||
},
|
||||
"manifest": {
|
||||
"name": "gh",
|
||||
"description": "Intelligent PR creation tool that analyzes your changes and creates well-structured pull requests.",
|
||||
"version": "2.0.0"
|
||||
},
|
||||
"content": {
|
||||
"files": [
|
||||
{
|
||||
"path": "README.md",
|
||||
"sha256": "22c83e878e0e443cd5af83fb15270e323c345ee769b212d103406a607ddf93ab"
|
||||
},
|
||||
{
|
||||
"path": ".claude-plugin/plugin.json",
|
||||
"sha256": "4576b969e8450bee233d5648a38d27a0edcd3cccc652ed4aec0285b020c13bb1"
|
||||
},
|
||||
{
|
||||
"path": "commands/create-pr.md",
|
||||
"sha256": "d67bc8f505dbaa1d9f8509b3bbf9dcf33dc7617cdf8202342995007d6cb3558f"
|
||||
}
|
||||
],
|
||||
"dirSha256": "d9e3626fbcfd82f54f0f56ce4ef18f62606036af8277fd03f2705951ae5b3abf"
|
||||
},
|
||||
"security": {
|
||||
"scannedAt": null,
|
||||
"scannerVersion": null,
|
||||
"flags": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user