From f2acb6b65be7e62359b5ff37ce16dfb3e29b29f2 Mon Sep 17 00:00:00 2001 From: Federico Mastrini Date: Sat, 28 Nov 2026 11:54:29 +0100 Subject: [PATCH] feat(pr-open): tighten the skill and fix three PR-text mistakes Jira-style tickets get a Ticket: line instead of a GitHub closing keyword, a guessed why is flagged in the reply, and manual test steps must run on the branch as written. SKILL.md and previews.md are rewritten shorter (-30% words) with the same steps. --- .claude-plugin/plugin.json | 2 +- README.md | 2 +- gemini-extension.json | 2 +- plugin.json | 2 +- skills/pr-open/SKILL.md | 82 ++++++++++----------------- skills/pr-open/references/previews.md | 36 ++++++------ 6 files changed, 50 insertions(+), 76 deletions(-) diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 32e78be..d5941bc 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "fstack", "description": "Federico Mastrini's agent skills for everyday software engineering work.", - "version": "0.17.1", + "version": "0.17.2", "author": { "name": "Federico Mastrini", "url": "https://fedemas.dev" diff --git a/README.md b/README.md index 5a0b8b8..80eca29 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ **A short stack of agent skills for everyday software engineering work.** [![Claude Code plugin](https://img.shields.io/badge/Claude%20Code-plugin-D97757?style=flat-square)](https://www.fedemas.dev/fstack) -[![Version](https://img.shields.io/badge/version-0.17.1-B4A7E5?style=flat-square)](.claude-plugin/plugin.json) +[![Version](https://img.shields.io/badge/version-0.17.2-B4A7E5?style=flat-square)](.claude-plugin/plugin.json) [![License: MIT](https://img.shields.io/badge/license-MIT-93D3BB?style=flat-square)](LICENSE) diff --git a/gemini-extension.json b/gemini-extension.json index 3b9f22d..536b85a 100644 --- a/gemini-extension.json +++ b/gemini-extension.json @@ -1,5 +1,5 @@ { "name": "fstack", - "version": "0.17.1", + "version": "0.17.2", "description": "Federico Mastrini's agent skills for everyday software engineering work." } diff --git a/plugin.json b/plugin.json index a45eda7..7fee5fa 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", "name": "fstack", - "version": "0.17.1", + "version": "0.17.2", "description": "Federico Mastrini's agent skills for everyday software engineering work.", "author": { "name": "Federico Mastrini", diff --git a/skills/pr-open/SKILL.md b/skills/pr-open/SKILL.md index cbc3dee..2557b23 100644 --- a/skills/pr-open/SKILL.md +++ b/skills/pr-open/SKILL.md @@ -6,56 +6,42 @@ compatibility: Needs git and the gh CLI (authenticated, new enough for `gh pr cr # PR open -Turn the branch into a pull request a reviewer understands in a minute: a title that says what changes, and a body that shows why, what, and how to check it. The job ends when the PR is open, or when the title and body are shown to a user who asked only for the text. +Turn the branch into a PR a reviewer understands in a minute. The job ends when the PR is open, or, when the user asked only for the text, when the title and body are in the reply. ## 1. Read the change -1. **Base and state.** The base is the branch the user named, else the default branch (`gh repo view --json defaultBranchRef -q .defaultBranchRef.name`). Run `git fetch origin` and `git status -sb`. Look for this branch's PR: `gh pr view --json number,url,state,isDraft,title,body`. An open one gets its title and body rewritten with `gh pr edit`. -2. **Uncommitted work.** On the base branch, move the work to a new branch named the repo's way. Commit the files that belong to the change with conventional commit messages, and ask when it is unclear which do. Unrelated changes stay in the working tree; mention them in the reply. -3. **The change.** Read `git log --format='%h %s%n%b' origin/..HEAD`, `git diff --stat origin/...HEAD`, and the full diff. The PR describes this diff. -4. **The issue.** It resolves an issue when the user names one, the branch name carries one (`fix/42-…`, `feat/PAY-118-…`), or a commit says `Closes #42`. Read a GitHub issue with `gh issue view --json title,body,labels,comments`; it usually holds the why and, for a bug, the repro. A key-based ticket (`PAY-118`) you can't read keeps its key, and the why comes from the user and the commits. Tickets come only from these sources. The body's first line closes a GitHub issue (`Closes #`, one keyword per issue) when the base is the default branch, and refers to it (`Refs #`) otherwise; a tracker key becomes a link to its ticket when you know the URL. -5. **The template.** `pull_request_template.md` (any case) in `.github/`, the repo root, or `docs/`, or a `PULL_REQUEST_TEMPLATE/` folder in one of those. With several templates, take the one the change's type fits and say which. -6. **Conventions.** The title format the repo enforces or documents: a PR-title lint in `.github/workflows/`, commitlint config (its `scope-enum` lists the allowed scopes), CONTRIBUTING. Recent merged titles (`gh pr list --state merged --limit 15 --json title`) show the scopes in use. - -Done when you can state the base, what the diff does in a sentence, the issue it resolves (or none), and the template (or none). +- **Base**: the branch the user named, else the default (`gh repo view --json defaultBranchRef -q .defaultBranchRef.name`). Run `git fetch origin`. An open PR for this branch (`gh pr view --json number,url,state,isDraft,title,body`) gets rewritten with `gh pr edit`. +- **Uncommitted work**: on the base branch, move it to a new branch named the repo's way. Commit the files that belong to the change with conventional messages, asking when unclear; leave unrelated changes in the tree and mention them. +- **Diff**: `git log --format='%h %s%n%b' origin/..HEAD` and the full `git diff origin/...HEAD`. The PR describes this diff. +- **Issue**: named by the user, the branch (`fix/42-…`, `feat/PAY-118-…`), or a commit (`Closes #42`); tickets come only from these. `gh issue view --json title,body,labels,comments` holds the why and, for a bug, the repro. A tracker ticket you can't read keeps its key; the why comes from the user and the commits. +- **Template**: `pull_request_template.md` (any case) or a `PULL_REQUEST_TEMPLATE/` folder, in `.github/`, the root, or `docs/`. With several, pick by change type and say which. +- **Title rules**: a PR-title lint in `.github/workflows/`, commitlint (`scope-enum`), CONTRIBUTING; scopes in use from `gh pr list --state merged --limit 15 --json title`. ## 2. Title -`(): [] `, a Conventional Commits title. - -- **Type** from what the diff does: `feat` adds behavior a user or caller can use, `fix` corrects behavior, `refactor` keeps behavior, and `perf`, `docs`, `test`, `build`, `ci`, `style`, `chore`, `revert` as usual. A breaking change gets `!` before the colon (`feat(api)!:`). -- **Scope** is the domain the change lives in: a scope the repo lists or already uses, else the module, package, or feature most of the diff touches. A change spread across unrelated areas goes without one. -- **Ticket**, when the PR resolves one: `[#42]` for a GitHub issue, `[PAY-118]` for a tracker key, `[#42, #57]` for several. -- **Summary** in the imperative present, the way you'd finish "This PR will…": `add`, `fix`, `resolve`, `implement`, `remove`. Lowercase, ending without a period, about 70 characters for the whole title. Name the behavior a reader will notice: `fix(auth): [#42] reject expired refresh tokens`. +`(): [] `, Conventional Commits. A format the repo enforces wins; say which you followed. -A title format the repo enforces (a lint, a documented rule) wins over this one, since a title CI rejects helps no one; say which rule you followed. +- **Type**: `feat` adds behavior, `fix` corrects it, `refactor` keeps it; `perf`, `docs`, `test`, `build`, `ci`, `style`, `chore`, `revert` as usual. Breaking: `feat(api)!:`. +- **Scope**: one the repo lists or uses, else the module most of the diff touches; left out for changes across unrelated areas. +- **Ticket**, when the PR resolves one: `[#42]`, `[PAY-118]`, `[#42, #57]`. +- **Summary**: imperative, lowercase, ending without a period, whole title about 70 characters, naming the behavior a reader notices: `fix(auth): [#42] reject expired refresh tokens`. ## 3. Body -Fill the repo's template when it has one: keep its headings, order, and checkboxes, follow and then delete its HTML-comment guidance, and write `n/a` under a heading the change has nothing for. Put each piece below under the heading it fits; a piece with no fitting heading gets a short section of its own after the template's. Without a template, use the default below with the sections the change has content for. - -**Show the Why and What.** Pick the smallest view that makes the point and set it beside the one or two sentences it supports; one or two views tell most stories. - -- **A mermaid diagram** when the change touches how parts relate: a flow (`flowchart`), calls between services or components (`sequenceDiagram`), a state machine (`stateDiagram-v2`), a data model (`erDiagram`). Keep it to the nodes the change touches. -- **A `diff` block** when the point is a before and after of a shape that already exists: the few code lines that carry the change, or a sketch of a call tree, component tree, file tree, or rule in pseudocode with `+` and `-` lines. The Files tab holds the rest. -- **A table** when items share attributes: endpoints and their status codes, options and defaults. - -The prose around them is short sentences in everyday words, written for a reviewer who hasn't seen the conversation: use the project's own names for its things, and say everything else the way you'd say it to a teammate. Every claim about behavior comes from the diff, a test, or a command you ran. - -**Merge danger** gets its own section, in prose, right after What in the default template: - -- **Reversible**: yes when a revert undoes the change, no when it leaves something behind (a migration, deleted data, a published API, sent emails), with the reason in a sentence. -- **Blast radius**: one short paragraph, about three sentences: its size in a word (contained, moderate, wide), what else now behaves differently, and what stays as it was where a reader would worry. Find it by searching for the users of what changed: `git grep` every changed function, type, route, env var, schema field, and config key until each one's callers, consumers, and clients are accounted for. - -**Bugs** get a repro under How to test: the exact steps and inputs that show the bug on the base branch, what happens there, and what happens on this branch. The tester runs it on both and sees the difference. +With a repo template: keep its headings, order, and checkboxes, follow then delete its HTML comments, write `n/a` under empty headings, and put each piece below under the heading it fits, else in a short section after the template's. Without one: the default template below, with the sections that have content. -**How to test** names the automated checks that cover the change (the command and the tests added or changed, with their result when you ran them) and, when a person has to look, the manual steps. Manual checkboxes stay unticked for the person who runs them. +- **Issue line**, first: `Closes #` per GitHub issue when the base is the default branch, `Refs #` otherwise. Another tracker's ticket: `Ticket: [PAY-118]()`, or `Ticket: PAY-118` without a URL, since closing keywords act only on GitHub issues. +- **Why and What**: short everyday sentences for a reviewer who hasn't seen the conversation, in the project's own names. Every behavior claim comes from the diff, a test, or a command you ran. The why comes from the issue, the user, or the commits; when none gives one, write what the diff shows and say in the reply that you inferred it. Add the smallest view that makes the point, one or two at most: + - mermaid when parts relate (`flowchart`, `sequenceDiagram`, `stateDiagram-v2`, `erDiagram`), with only the nodes the change touches; + - a `diff` block for a before and after of an existing shape: the few lines that carry the change, or a sketched tree or rule; + - a table for items that share attributes. +- **Merge danger**, prose, after What: + - **Reversible**: yes, or no when a revert leaves something behind (a migration, deleted data, a published API, sent emails), with the reason in a sentence. + - **Blast radius**: one paragraph of about three sentences: size (contained, moderate, wide), what else now behaves differently, and what stays as it was where a reader would worry. `git grep` every changed function, type, route, env var, schema field, and config key until each one's callers and consumers are accounted for. +- **How to test**: the command and the tests added or changed, with results when you ran them. Manual steps when a person has to look, each runnable on this branch as written, checkboxes unticked. A bug gets a repro: exact steps and inputs, and the result on the base and on this branch. +- **Previews**, last, for a change seen on screen (UI, styles, copy, emails, generated images, CLI output): capture them per [references/previews.md](references/previews.md) before opening the PR. -**Previews** belong to a change a person sees on screen: UI, styles, copy, emails, generated images, CLI output. For those, read [references/previews.md](references/previews.md) and capture them yourself, before and after, before you open the PR. Other changes show their before and after in the diff block and the repro, and the body ends at How to test. - -### Default template - -Use it when the repo has none. The example shows the shape; the content is the change's. +Default template (the shape; the content is the change's): ````md Closes #42 @@ -85,33 +71,25 @@ Expired coupons still apply their discount at checkout, so lapsed promo codes ke **Manual** - [ ] Reproduce on `main`: apply coupon `SPRING24` (expired 1 June 2024) at checkout → 20% off applied. - [ ] Same steps on this branch → "This coupon expired on 1 June 2024", no discount. - -## Previews - -| Before | After | -| --- | --- | -| ![Checkout with an expired coupon, before](./before-checkout.png) | ![Checkout with an expired coupon, after](./after-checkout.png) | ```` -Done when every template heading (or default section) the change has content for is filled, and each behavior claim traces to the diff, a test, or a command you ran. - ## 4. Open it -Write the body to a file in a scratch directory, with the preview files beside it. Push with `git push -u origin HEAD`, then: +For a text-only request, the title and body go in the reply instead. + +Write the body to a scratch directory beside the preview files, `git push -u origin HEAD`, then: ```bash gh pr create --base --title "" --body-file <dir>/body.md --attach '<dir>/before-checkout.png#Checkout with an expired coupon, before' [--draft] ``` -`--attach`, repeated per file, uploads each image or video and points the body's matching `![…](./…)` reference at it. An existing PR takes the same flags on `gh pr edit`. Open it as a draft or ready for review the way the user and the repo open theirs (their instructions, the calling skill, the user's recent PRs); when nothing says, open a draft, which pings no reviewers until the user marks it ready. Labels, reviewers, and assignees come from the user or the template. - -When the user asked only for the text, show the title and body in place of this step. +`--attach`, once per file, uploads it and points the body's matching `![…](./…)` at the upload; `gh pr edit` takes the same flags. Draft or ready follows the user's and the repo's habit (their instructions, the calling skill, their recent PRs), else draft. Labels, reviewers, and assignees come from the user or the template. -Done when a read-back (`gh pr view --json title,body,url`) shows the title as written, every preview pointing at an uploaded asset, and the mermaid and diff blocks intact. +Read back with `gh pr view --json title,body,url`: the title as written, every preview on an uploaded asset, mermaid and diff blocks intact. ## Reply -The link and the title, then a line each for what the reviewer should know and what's left to the user, dropping lines that are empty. For example: +The link and the title, then a line each for what the reviewer should know and what's left to the user, dropping empty lines: **fix(checkout): [#42] reject expired coupons** — https://github.com/readwell-dev/shop/pull/57 (draft) - Previews: checkout before and after, attached. diff --git a/skills/pr-open/references/previews.md b/skills/pr-open/references/previews.md index ed3c6a9..78a10ce 100644 --- a/skills/pr-open/references/previews.md +++ b/skills/pr-open/references/previews.md @@ -1,34 +1,30 @@ # Previews -Before and after captures for a change a user sees. A reviewer judges a visual change from the picture, so capture them yourself before opening the PR. - ## What to capture -List the screens and states the diff changes: each page, route, component, email, or command it touches, plus the states the change reaches (empty, error, loading, a narrow viewport when layout moved). One row per changed state; three or four rows tell most stories. - -- **Interaction or motion** (a flow, an animation, a drag): a short video, when the capture tool records one. -- **Terminal output** (a CLI, a generated file): a `diff` block, before lines `-`, after lines `+`. -- **A new screen** has no before, and a removed one no after: write `—` in that cell. +One row per screen and state the diff changes: each page, route, component, email, or command, plus the states it reaches (empty, error, loading, a narrow viewport when layout moved). Three or four rows tell most stories. -## Capture before and after from the same setup +- **Interaction or motion**: a short video, when the tool records one. +- **Terminal output**: a `diff` block, before `-`, after `+`. +- **New or removed screen**: `—` in the missing cell. -1. **Run the base beside the branch.** `git worktree add <scratch>/base origin/<base>` gives the base version and keeps the user's checkout as it is. Install its dependencies the way the project does (its lockfile and package manager). -2. **Start both** with the project's own run command (README, package scripts, Makefile), on different ports. -3. **Same conditions on both sides**: the same seed or fixture data, viewport, theme, locale, and logged-in role, so every difference in the pair is the PR's. -4. **Capture** with the first tool that works: the harness's browser or preview tool; an installed headless browser CLI (`playwright-cli`, `browser-use`, `agent-browser`); or headless Chrome, `"<chrome binary>" --headless=new --window-size=1280,800 --screenshot=<file> <url>`. A mobile app goes through the harness's simulator or device tools. Ask before installing a tool. -5. **Clean up**: stop the servers you started, then `git worktree remove <scratch>/base`. +## Capture -Name the files `before-<state>.png` and `after-<state>.png` and save them beside the body file, so `--attach` matches them to the body's references. +1. **Base beside branch**: `git worktree add <scratch>/base origin/<base>`, with dependencies installed the project's way. +2. **Start both** with the project's run command, on different ports. +3. **Same conditions** on both sides (seed data, viewport, theme, locale, role), so every difference is the PR's. +4. **Tool**, first that works: the harness's browser or preview tool; `playwright-cli`, `browser-use`, `agent-browser`; headless Chrome, `"<chrome>" --headless=new --window-size=1280,800 --screenshot=<file> <url>` (it won't go narrower than about 500 px; use a browser CLI for phone widths). Mobile apps: the harness's simulator or device tools. Ask before installing a tool. +5. **Clean up**: stop the servers, `git worktree remove <scratch>/base`. -Done when every state on your list has a before and an after taken under the same conditions. +Name files `before-<state>.png` and `after-<state>.png`, beside the body file. -## Check every capture before it leaves the machine +## Check before attaching -Open each file and look. Attaching it publishes it, so it shows fixture data only: check for secrets or tokens, real names, emails, or customer data, internal hostnames and URLs, and other apps' notifications. Recapture with fixture data or crop it. Attach only captures you've made safe, and say in the reply which one you held back and why. +Attaching publishes. Open each capture and confirm it shows fixture data only: no secrets or tokens, real names, emails, customer data, internal hostnames, or other apps' notifications. Recapture or crop; hold back what you can't make safe and say so in the reply. -## When capture is blocked +## Blocked -The app needs credentials or services you lack, the build fails, or every capture tool fails: tell the user what blocked it, and ask whether they'll send the media or want the PR opened without previews. When they choose to open it, the Previews section says what's missing and why. +Missing credentials or services, a failing build, or no working tool: tell the user what blocked it and ask whether they'll send media or want the PR without previews. Without them, the Previews section says what's missing and why. ## Layout @@ -37,4 +33,4 @@ The app needs credentials or services you lack, the build fails, or every captur | Expired coupon | ![Checkout with an expired coupon, before](./before-expired.png) | ![Checkout with an expired coupon, after](./after-expired.png) | | Mobile, 375 px | ![Checkout on mobile, before](./before-mobile.png) | ![Checkout on mobile, after](./after-mobile.png) | -Drop the State column when there's one row. Alt text says what the image shows, for readers who can't see it. Videos go below the table, each on its own line under a bold **Before** or **After** label, since GitHub plays a video only on a line of its own. +Drop the State column for one row. Alt text describes the image. Videos go below the table, each on its own line under **Before** or **After**, since GitHub plays a video only on a line of its own.