From 452a2a4ef2fa0baf29bb833868a718bfa0fcfe5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Wed, 18 Feb 2026 11:05:45 -0300 Subject: [PATCH] Add Claude Code skills and settings Add skills for implementing upstream changes, implementing puppeteer releases, and managing git worktrees. Also adds Claude Code settings. Co-Authored-By: Claude Opus 4.6 --- .claude/settings.json | 5 + .../implement-puppeteer-release/SKILL.md | 112 ++++++++++++++++++ .../skills/implement-upstream-change/SKILL.md | 10 ++ .claude/skills/prune-worktrees/SKILL.md | 14 +++ .claude/skills/remove-all-worktrees/SKILL.md | 10 ++ 5 files changed, 151 insertions(+) create mode 100644 .claude/settings.json create mode 100644 .claude/skills/implement-puppeteer-release/SKILL.md create mode 100644 .claude/skills/prune-worktrees/SKILL.md create mode 100644 .claude/skills/remove-all-worktrees/SKILL.md diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 000000000..ebcf5a248 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,5 @@ +{ + "enabledPlugins": { + "csharp-lsp@claude-plugins-official": true + } +} diff --git a/.claude/skills/implement-puppeteer-release/SKILL.md b/.claude/skills/implement-puppeteer-release/SKILL.md new file mode 100644 index 000000000..94070ece4 --- /dev/null +++ b/.claude/skills/implement-puppeteer-release/SKILL.md @@ -0,0 +1,112 @@ +# Implement Puppeteer Release + +## Context +You are automating the implementation of all PRs from a Puppeteer release into PuppeteerSharp using parallel sub-agents and git worktrees. + +## Task + +Process the GitHub release at `$ARGUMENTS` and implement each non-documentation PR in parallel (max 3 concurrent). + +## Workflow + +### Step 1: Parse the Release + +Extract the tag from the `$ARGUMENTS` URL (e.g. `https://github.com/nicknisi/puppeteer/releases/tag/puppeteer-v24.7.2` → `puppeteer-v24.7.2`). + +Fetch the release body: +```bash +gh release view --repo nicknisi/puppeteer --json body -q .body +``` + +### Step 2: Extract and Filter PRs + +Parse all PR references from the release notes. PRs appear as `[#NUMBER](URL)` links in the body. + +**Skip documentation-only PRs**: Any PR listed under a `Documentation` section header should be skipped. Track these for the final report. + +### Step 3: Fetch origin + +Run `git fetch origin` once before processing any PRs. + +### Step 4: Process PRs in Batches of 3 + +For each batch of up to 3 PRs, launch 3 `general-purpose` Task sub-agents **in parallel** (in a single message with multiple tool uses). Wait for the batch to complete before starting the next batch. + +Each sub-agent receives the following self-contained prompt (fill in `` and ``): + +~~~ +You are implementing upstream Puppeteer PR # () into the PuppeteerSharp .NET project. + +## Setup + +1. Create a git worktree for your work: + ```bash + git worktree add -b implement-upstream-change- ../puppeteer-sharp-pr- origin/master + ``` +2. Change your working directory to `../puppeteer-sharp-pr-` for ALL subsequent commands. + +## Research + +3. Read the upstream PR to understand the changes: + ```bash + gh pr view --repo nicknisi/puppeteer --json title,body,files + gh pr diff --repo nicknisi/puppeteer + ``` +4. Read the relevant upstream source files in `../../puppeteer/puppeteer` to understand context. +5. Read the corresponding PuppeteerSharp files to understand the current .NET implementation. + +## Implementation + +6. Implement the changes following .NET idioms and PuppeteerSharp patterns: + - Upstream `puppeteer-core/src/api/*` maps to abstract base classes + - Upstream `puppeteer-core/src/bidi/*` maps to `Bidi/` classes + - Upstream `puppeteer-core/src/cdp/*` maps to `Cdp/` classes + - All new tests must use `[Test, PuppeteerTest("", "", "")]` + - Look at existing tests for reference on attribute usage + +## Verification + +7. Build and run related tests: + ```bash + cd ../puppeteer-sharp-pr- + BROWSER=CHROME PROTOCOL=cdp dotnet build lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj + BROWSER=CHROME PROTOCOL=cdp dotnet test lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj --filter "FullyQualifiedName~" --no-build -- NUnit.TestOutputXml=TestResults + ``` + Fix any failing tests before proceeding. + +## Commit, Push, and PR + +8. Stage and commit your changes with a descriptive message referencing the upstream PR. +9. Push the branch: + ```bash + git push -u origin implement-upstream-change- + ``` +10. Create a PR: + ```bash + gh pr create --title "Implement upstream PR #" --body "Implements changes from " --base master + ``` + +## Important +- ALL file operations and commands must run inside the worktree at `../puppeteer-sharp-pr-` +- Do NOT modify the main working tree +- If the PR has no meaningful code changes for PuppeteerSharp (e.g. infra-only, upstream-tooling), commit a no-op with a note and still create the PR +~~~ + +### Step 5: Final Report + +After all batches complete, print a summary: + +``` +## Release Implementation Report + +### Implemented +- #XXXX - - <status: success/failed> +- ... + +### Skipped (Documentation) +- #XXXX - <title> +- ... + +### Cleanup +Run `/remove-all-worktrees` to clean up worktree directories. +``` diff --git a/.claude/skills/implement-upstream-change/SKILL.md b/.claude/skills/implement-upstream-change/SKILL.md index 3fffb22c3..88fbb70a9 100644 --- a/.claude/skills/implement-upstream-change/SKILL.md +++ b/.claude/skills/implement-upstream-change/SKILL.md @@ -18,6 +18,16 @@ Once you have all the context, you will implement the same changes in this .NET 5. Push the branch: `git push -u origin implement-upstream-change-<PR_NUMBER>` 6. Create a PR via `gh pr create` targeting `master` +### PR Title Convention + +Choose the PR title prefix based on the nature of the upstream change: + +- **New feature** (adds new functionality, new API, new capability): prefix the title with `"New Feature: "` — e.g. `"New Feature: Add support for request interception (#12345)"` +- **Bug fix** (corrects broken behavior): prefix the title with `"Fix: "` — e.g. `"Fix: Handle null pointer in frame navigation (#12345)"` +- **Other changes** (refactoring, improvements, updates, test changes): no special prefix — e.g. `"Handle shadow DOM in Frame.frameElement (#12345)"` + +Always include the upstream PR number in parentheses at the end of the title. + ## Implementation You will have to implement the code as close as possible to the original code, but adapted to .NET idioms and practices. diff --git a/.claude/skills/prune-worktrees/SKILL.md b/.claude/skills/prune-worktrees/SKILL.md new file mode 100644 index 000000000..dd8649056 --- /dev/null +++ b/.claude/skills/prune-worktrees/SKILL.md @@ -0,0 +1,14 @@ +# Task + +Prune git worktrees whose associated pull requests have been closed or merged. + +## Steps + +1. List all worktrees using `git worktree list` +2. Skip the main working tree (the first entry listed) +3. For each remaining worktree, extract the branch name +4. Use `gh pr list --head <branch> --state all --json number,state,title` to check if there is a PR for that branch +5. If the PR state is "CLOSED" or "MERGED", remove the worktree with `git worktree remove <path>` +6. If there is no PR for the branch, skip it and report it as "no PR found" +7. After processing all worktrees, run `git worktree prune` to clean up stale references +8. Report a summary: which worktrees were removed (and why), which were kept, and which had no PR diff --git a/.claude/skills/remove-all-worktrees/SKILL.md b/.claude/skills/remove-all-worktrees/SKILL.md new file mode 100644 index 000000000..3e2371ac6 --- /dev/null +++ b/.claude/skills/remove-all-worktrees/SKILL.md @@ -0,0 +1,10 @@ +# Task + +Remove all git worktrees from this repository. + +## Steps + +1. List all worktrees using `git worktree list` +2. Remove every worktree **except** the main working tree (the first entry listed) +3. After removing all worktrees, run `git worktree prune` to clean up stale references +4. Report what was removed