Commit 258b70331c6 for woocommerce
commit 258b70331c6c4a38f3f61ee03a980b5065e9c278
Author: James Kemp <me@jckemp.com>
Date: Wed Apr 8 22:39:44 2026 +0100
Add git commit and draft PR skills for Claude Code (#63883)
* Add draft PR skill and remove redundant git skill
Introduces woocommerce-git-draft-pr, a streamlined skill for creating
reviewer-friendly draft PRs with proper template, changelog, and
milestone handling. Removes woocommerce-git which is now superseded.
* Add woocommerce-git-commit skill
* Simplify draft PR skill body for non-plugin changes
* Remove changelog section from non-plugin PR template
* Update AGENTS.md skill references for git-commit and git-draft-pr
* Fix markdown lint errors in git skill files
* Clarify pre-commit linting workflow order in commit skill
diff --git a/.ai/skills/woocommerce-git-commit/SKILL.md b/.ai/skills/woocommerce-git-commit/SKILL.md
new file mode 100644
index 00000000000..885ba12d910
--- /dev/null
+++ b/.ai/skills/woocommerce-git-commit/SKILL.md
@@ -0,0 +1,89 @@
+---
+name: woocommerce-git-commit
+description: Commit uncommitted changes with well-crafted messages following WooCommerce repo conventions. Use when the user says "commit", "commit changes", "commit this", "git commit", or "save my work".
+---
+
+# Commit Changes
+
+Commit uncommitted work with clear, conventional messages. Groups unrelated changes into separate commits when appropriate.
+
+## Dynamic Context
+
+- Current branch: !`git branch --show-current`
+- Uncommitted changes: !`git status --short`
+- Diff stat: !`git diff --stat`
+- Staged diff stat: !`git diff --cached --stat`
+
+## Procedure
+
+### 1. Analyze Changes
+
+From the dynamic context above, determine what changed:
+
+- **No changes?** Stop — tell the user there's nothing to commit.
+- **Already staged?** Respect what the user staged. Only consider unstaged files for additional commits.
+- Read full diffs only for files where the stat summary is ambiguous.
+
+### 2. Decide Commit Grouping
+
+Default to a **single commit** unless changes are clearly unrelated. Split only when:
+
+- Changelog entries exist alongside source changes (changelog = separate commit)
+- Obviously independent changes are mixed (e.g., a bug fix AND an unrelated config change)
+
+Two files changed for the same reason = one commit. Don't over-split.
+
+### 3. Draft Commit Message(s)
+
+Use the current session context to understand what work was done and why. If motivation is still unclear after reviewing the diff and conversation, ask the user in a single question.
+
+**Format** — verb-first imperative, under 72 chars:
+
+- `Fix get_item_downloads() not always returning an array`
+- `Add cache priming to AJAX downloadable search`
+- `Update email editor reset action label for consistency`
+- `Refactor order count cache refresh logic`
+- `Remove deprecated payment gateway fallback`
+
+**Verbs**: Fix, Add, Update, Refactor, Remove, Restore, Bump, Prepare, Simplify, Improve, Replace
+
+For changelog-only commits: `Add changelog entries for [description]`
+
+Do NOT include issue/PR refs — GitHub adds those on squash-merge.
+
+If $ARGUMENTS is provided, use it as guidance for the commit message.
+
+### 4. Preview and Confirm
+
+Show the user each proposed commit:
+
+```text
+Commit 1: Fix double margin-top in flex layout
+ files: src/Blocks/EmailEditor/Layout.php
+ src/Blocks/EmailEditor/styles.css
+
+Commit 2: Add changelog entries for email editor fix
+ files: plugins/woocommerce/changelog/fix-email-margin
+```
+
+Wait for user approval or corrections before executing.
+
+### 5. Execute
+
+For each confirmed commit:
+
+```sh
+git add <specific files>
+git commit -m "<message>"
+```
+
+Always stage specific files — never `git add -A` or `git add .`.
+
+After all commits, show `git log --oneline -n <number of new commits>` to confirm.
+
+## Constraints
+
+- No Co-Authored-By lines or self-attribution
+- Never push to remote
+- Never use `git add -A` or `git add .`
+- Do not run pre-commit lint/test checks — the `woocommerce-dev-cycle` skill handles that. Linting should be run *before* invoking this skill, not after.
diff --git a/.ai/skills/woocommerce-git-draft-pr/SKILL.md b/.ai/skills/woocommerce-git-draft-pr/SKILL.md
new file mode 100644
index 00000000000..8f4bbe68ec7
--- /dev/null
+++ b/.ai/skills/woocommerce-git-draft-pr/SKILL.md
@@ -0,0 +1,99 @@
+---
+name: woocommerce-git-draft-pr
+description: Create a high-quality draft PR for the current branch. Use when the user says "create a PR", "draft PR", "open a PR", "make a PR", "push and create PR", or "submit PR".
+---
+
+# Create Draft PR
+
+Create a concise, reviewer-friendly draft PR from the current branch.
+
+## Dynamic Context
+
+- Current branch: !`git branch --show-current`
+- Commits: !`git log trunk..HEAD --format="%h %s" --reverse 2>/dev/null || echo "No commits ahead of trunk"`
+- Diff stat: !`git diff trunk...HEAD --stat 2>/dev/null`
+- Uncommitted changes: !`git status --short`
+- Existing changelogs: !`git diff trunk...HEAD --name-only -- '*/changelog/*' 2>/dev/null`
+- PR template: !`cat .github/PULL_REQUEST_TEMPLATE.md`
+
+## Procedure
+
+### 1. Preflight and Analyze
+
+Verify from dynamic context: not on trunk (ask which branch if so), commits exist ahead of trunk (stop if none), no uncommitted changes (ask user to commit/stash if dirty).
+
+**Base branch**: use `release/*` if the branch was created from one, otherwise `trunk`.
+
+From the dynamic context above (read full diffs only if the stat summary is ambiguous), determine:
+
+- **Change type**: Fix, Add, Update, Dev, Tweak, Performance, or Enhancement
+- **Significance**: Patch (most common), Minor (new features), Major (breaking — rare)
+- **Bug fix?** Look for issue refs in commits/branch name (e.g., `#12345`, `fix/issue-12345`)
+- **UI changes?** Changes in `client/`, `templates/`, CSS/SCSS, JSX/TSX
+- **Plugin-affecting?** Code shipped to users = yes. CI/CD, workflows, tooling, docs = no. This drives changelog, milestone, and PR body complexity — non-plugin PRs use a simplified body (see Step 3).
+
+### 2. Gather Context from User
+
+Extract issue/PR refs from commits and branch name. Ask the user (combine into one prompt):
+
+- If no issue ref: "Is there a GitHub issue?" (Linear is internal — only reference GitHub issues in PRs)
+- If bug fix, no origin PR found: "Which PR introduced this bug?"
+- If motivation unclear from code: "What's the context?"
+
+### 3. Generate PR Title + Body
+
+Use the PR template from the dynamic context above.
+
+**Title** (under 70 chars, verb-first — the repo convention):
+
+- `Fix <what was broken>`, `Add <what>`, or other verb (Restore, Bump, Prepare, etc.)
+- Optional area prefix: `[Email Editor] Fix double margin-top in flex layout`
+- No `fix:`/`feat:` prefixes. No Linear ticket refs — Linear is internal, PRs are public.
+
+**Body** — depends on whether the change is plugin-affecting:
+
+#### Non-plugin changes (CI/CD, tooling, docs, `.ai/skills/`, workflows)
+
+Use a simplified body with only these sections:
+
+- **Submission Review Guidelines**: Keep as-is from template.
+- **Changes proposed**: 2-3 sentences. Lead with WHY, then WHAT.
+
+Skip Screenshots, Testing instructions, Testing done, Milestone, and Changelog sections entirely.
+
+#### Plugin-affecting changes
+
+Use the full template:
+
+- **Submission Review Guidelines**: Keep as-is from template.
+- **Changes proposed**: 2-3 sentences. Lead with WHY, then WHAT. No filler ("This PR addresses..."). Include `Closes #1234.` if applicable. For bugs: `Bug introduced in PR #XXXX.` (omit this line entirely if not a bug fix).
+- **Screenshots**: Remove section if no UI changes. For UI changes, use Chrome DevTools MCP to capture screenshots if available; otherwise remind user to add them before marking ready.
+- **Testing instructions**: Concrete numbered steps with expected outcomes. Ask user to verify before finalizing. Each step must be actionable — don't reference links that won't exist yet.
+- **Testing done**: Ask user what testing they've performed.
+- **Milestone**: Check auto-assign `[x]` if plugin-affecting.
+- **Changelog**: If changelogs already in diff → "does not require" (created manually). Otherwise → "Automatically create" `[x]` with Significance, Type, and a user-facing Message.
+
+Strip all HTML comments (`<!-- -->`) and unfilled placeholder lines (e.g., `Closes # .`, `Bug introduced in PR # .`) from output.
+
+### 4. Preview and Confirm
+
+Show the user the generated title and body. Apply any corrections before proceeding.
+
+### 5. Push and Create
+
+```sh
+git push -u origin $(git branch --show-current)
+gh pr create --draft --title "<title>" --base <base-branch> --body "$(cat <<'PRBODY'
+<full PR body>
+PRBODY
+)"
+```
+
+Output the PR URL. If UI changes need screenshots, remind the user.
+
+## Constraints
+
+- No Co-Authored-By lines or self-attribution
+- Never commit code — pushing is fine
+- Preserve the PR template section headings exactly (for plugin-affecting PRs)
+- Changelog checkboxes must match CI automation format
diff --git a/.ai/skills/woocommerce-git/SKILL.md b/.ai/skills/woocommerce-git/SKILL.md
deleted file mode 100644
index 22e913b976c..00000000000
--- a/.ai/skills/woocommerce-git/SKILL.md
+++ /dev/null
@@ -1,10 +0,0 @@
----
-name: woocommerce-git
-description: Guidelines for git and GitHub operations in the WooCommerce repository.
----
-
-# WooCommerce Git Guidelines
-
-## Pull Requests
-
-When creating PRs, follow the template at `.github/PULL_REQUEST_TEMPLATE.md`. Include all sections from the template; if a section does not apply, write "N/A" under that heading. Pass the body via a HEREDOC to `gh pr create --body`.
diff --git a/AGENTS.md b/AGENTS.md
index b2975f4f06b..9e0badc297d 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -27,7 +27,8 @@ The `.ai/skills/` directory contains procedural HOW-TO instructions:
- **`woocommerce-copy-guidelines`** - UI text standards (sentence case rules)
- **`woocommerce-code-review`** - Code review standards and critical violations to flag
- **`woocommerce-markdown`** - Markdown writing and editing guidelines
-- **`woocommerce-git`** - Guidelines for git and GitHub operations
+- **`woocommerce-git-commit`** - Commit changes with conventional messages and smart grouping
+- **`woocommerce-git-draft-pr`** - Create draft PRs with proper template, changelog, and milestone handling
- **`woocommerce-email-editor`** - Email editor development setup and Mailpit configuration
- **`woocommerce-performance`** - Performance guardrails. **Invoke when writing or reviewing PHP code.**