Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Qa Plan?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/mnaimfaizy-qa-plan)
---
name: qa-plan
description: Write a QA Plan for an open pull request — only the manual verification a passing CI run would not establish — and deliver it where the team runs QA.
disable-model-invocation: true
argument-hint: "[pull request number or URL] [--answers <file>]"
metadata:
agent-kit-scope: user
---
# QA Plan
A user-invoked compose skill. For one open pull request it writes a **QA Plan**: the **Residue**, the manual verification a passing CI run would not establish, in a format a person or an agent elsewhere can run from the plan alone. The `manual-qa` skill runs it. This skill composes; it runs no scenario and commits nothing.
Load [ANATOMY.md](ANATOMY.md) before writing the plan: it is the format, section by section. Load [ADAPTER.md](ADAPTER.md) when reading or writing `qa.config.yml`, or when a Hazard pack is involved. Load [DESIGN.md](DESIGN.md) when a rule needs its reason, or before changing this skill.
`<skill>` in a command below is the absolute path of the folder this file is in, written with forward slashes (`C:/Users/me/...` on Windows), inside double quotes because it may contain spaces. Every command runs from the root of the repository the pull request belongs to.
## Which copy runs
A harness can load this skill from a user-level folder (under the home folder) while the repository keeps its own copy, pinned to the version the repository was set up with. The user-level copy can be older, and would then follow rules the repository no longer uses. So before anything else, check which copy this is:
```bash
node "<skill>/adapter.mjs" where qa-plan
```
It finds the repository from the folder it runs in, and lists the copies of `qa-plan` the repository keeps in the folders harnesses read skills from: `.claude/skills`, `.agents/skills`, `.github/skills` and `.cursor/skills`.
- `use` is `this`: go on. This copy is inside the repository, or the repository keeps none of its own.
- `use` is `repository`: stop, and run nothing more from this copy. Read the `SKILL.md` that `load` names and follow it from its start instead, with `<skill>` its folder. Tell the human that the copy at `this_copy` was not used, and that the repository's copy at `load` was.
- Exit 2, or no such script: compare by hand. When this file is outside the repository's root (`git rev-parse --show-toplevel`) and one of those folders in the repository holds `qa-plan/SKILL.md`, do as for `repository`.
## Rules
- **Residue only.** A scenario earns its place by naming what no passing suite establishes. Re-testing what CI proves wastes the tester and hides the scenarios that matter.
- **Every coverage claim is tagged** `[observed]` or `[reconstructed]` ([ANATOMY.md](ANATOMY.md#what-automation-already-proves)). A claim `two-point.mjs` saw test by test, at the merge-base and at the head, is `[observed]`; one it could only compare by exit code, or one read from CI results, the diff and the issue history, is `[reconstructed]`.
- **Read the UI from source.** Every step quotes the real label, button text or copy from the code or templates the pull request ships. When the source does not say, write that the step needs the label confirmed, rather than a guess.
- **No credentials in the plan**, not even a public QA Account's values: role ids, at most emails, and where the values come from ([ANATOMY.md](ANATOMY.md#no-credentials-travel-with-a-plan)).
- **Compose in `working_dir`, commit nothing**, and deliver only after the person has seen the draft and said yes.
## Run from an autonomous brief
This skill is invoked by a person. The one exception is a `go autonomous` orchestrate run: there a QA Delegation's brief tells its session to read this file and follow it as a phase of the brief, for one pull request at one pinned head, with the `--answers` file the brief names, when it names one, and `<skill>` the folder it names. Nobody types `/qa-plan`; the brief stands in for the invocation. Follow this section only then.
The workflow runs as written, except where a step waits on the person. Each such step is in the table, with what replaces the wait. Once QA is approved in the Dispatch Plan, this Delegation is never `waiting` on the human: each question is a fact already given in the Dispatch Plan, a Ruling, or held for close-out. A Decision Request goes in the brief's form, to its decisions file, only for a kind the table says is a Ruling. The Chief of Staff answers it with a Ruling when its evidence meets the evidence bar, and otherwise holds it for close-out and tells this session to go on; wait for that answer, as the brief says, and never queue anything for the human yourself.
| Step | Where it waits on the person | In a run from an autonomous brief |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 1 | It asks for the pull request's URL without `gh`, and stops on a branch with no pull request or a head that is not the pull request's. | The brief's first phase pinned the head with `gh`, so none of these arises. If one does, report it as that phase's mismatch, and run nothing more. |
| 2 | It asks for each readiness need, offers to save the answers, and asks before writing to a `working_dir` that is not ignored. | The answers are the `--answers` file the brief names, copied into `working_dir`; with no file, a pull request with another base, the QA is held for close-out, never asked mid-run, and with no needs there is nothing to hold: readiness answers are repository facts, the human's, never a Ruling. A need the file leaves is held the same way. It never offers to save a config. A `working_dir` that is not ignored at this head: write nothing and stop, and report it, so the row is held for close-out. |
| 3 | It asks which issue is the subject, when the pull request closes several or none. | A Decision Request naming the candidates. It is a Ruling when the evidence bar picks one, such as the issue the brief names; otherwise it is held for close-out, and nothing is composed. |
| 4 | It stops on a regression, asks which an `unknown` row is, and asks, promise by promise, whether to add a test or keep a scenario. | A regression: report its rows and stop; the Chief of Staff handles it as a QA FAIL. An `unknown` row: a Decision Request, ruled under the evidence bar, otherwise held for close-out. A test that could prove a promise: a Decision Request with both options. **Add the test** becomes a send-back Ruling to the building Delegation, which writes, commits and pushes the test: its head moves, so this QA is `void`, and a new QA Delegation runs on the new head. This session never writes the test, and commits nothing. |
| 7 | It shows the draft and asks the person to confirm or correct it. | Copy the draft to the brief's `qa-plan.md`, and raise its delivery as the brief's Decision Request, with the `answers.reused` line and each `Review:` box, each naming the file and the exact words it must carry, so the Chief of Staff can quote the source at the head. Deliver only on its answer, a Ruling; a correction comes as the answer, so redraft and raise it again. When the evidence does not settle the delivery, it is held for close-out: stop, with no plan delivered. |
| 8 | It asks whether to mark a QA Report for an older head stale. | Skip the stale edit and log that it was skipped: the posted report's header names its commit, so an older report is visibly stale, and a re-QA's post replaces the comment. No write as the human is made or asked about, and an older comment left standing because posting was not approved is listed at close-out. |
## Workflow
### 1. Check the precondition
A QA Plan is about one pull request at one head. Find it: the pull request the person named, or `gh pr view --json number,url,state,isDraft,baseRefName,headRefName,headRefOid,closingIssuesReferences` for the current branch.
Stop and name the next step when:
- the checkout is on the default branch or a detached head: _create a branch for the change, push it and open a pull request, then run `/qa-plan` again_;
- the branch has no open pull request: _push it and open one (`gh pr create --draft`), then run `/qa-plan` again_;
- the local `HEAD` is not the pull request's head commit: _push (or pull) so the two agree; the plan is pinned to the head the tester will get_.
Without `gh`, ask the person for the pull request's URL and the issue it closes; never compose a provisional plan for a change that has no pull request.
**Done when:** one open pull request is identified, and its head SHA equals the local `HEAD`.
### 2. Read the config
```bash
node "<skill>/adapter.mjs" check --for plan
```
With `--answers <file>` after the pull request (`/qa-plan <n> --answers <file>`), the readiness answers were given up front, as an orchestrate run gives them once in its Dispatch Plan. Run `check` with them instead:
```bash
node "<skill>/adapter.mjs" check --for plan --answers <file>
```
It merges the file over the config as `two-point.mjs --answers` does (step 4): the same JSON object `render` takes, read only from inside the `working_dir` the merge gives ([ADAPTER.md](ADAPTER.md#readiness-check)). Exit 2: the file is missing, is not a JSON object, or is outside `working_dir`; show the message and stop. Otherwise read its output as below, except that you ask only for what its `readiness.needs` still lists, and never offer to save a config: whoever gave the answers was offered that already. Keep its `answers.reused` line for step 7.
- Exit 1: the config, or the config with the answers merged in, has **problems**. Show each one, with its line, and stop until it is fixed. A misread config composes against the wrong base or the wrong suites.
- `readiness.needs` not empty: list exactly what is missing, and ask for it in one message. Compose goes on with the answers given in chat, or as the answer to a Decision Request. Always write the answers to a JSON file in `working_dir`, saved or not, since step 4 passes that file to `two-point.mjs`: in the `working_dir` the answers give, or the config's when they give none, with the `--answers` file's answers in it too when step 2 took one. Then, unless step 2 took `--answers`, offer to save them in the config: run `node "<skill>/adapter.mjs" render < <answers.json>`, and show the person the result: the config the lookup found (or a new `qa.config.yml`) with the answers merged in, every other key kept, and YAML comments dropped. Only on a yes, run it again with `--write` ([ADAPTER.md](ADAPTER.md#readiness-check)). If that exits 3, the file has comments: tell the person which lines would be lost, and only if they agree, run it with `--write --drop-comments`.
- `readiness.notes`: say each one, and go on.
Check that `working_dir` is ignored: `git check-ignore -q <working_dir>/x`. If it is not, say so and ask before writing there: everything in it must stay out of commits.
**Done when:** the base ref, the suites, `working_dir`, the publish rules and the Hazard packs are known, each from the config or from an answer the person gave.
### 3. Fix the anchors and the subject
- **Merge-base:** `git fetch` the base ref, then `git merge-base <base_ref> HEAD`.
- **Head:** the pull request's head SHA from step 1.
- **Subject issue:** the issue the pull request closes (`closingIssuesReferences`, or a `Closes #n` in its body). Several: ask which one is the subject. None: ask the person; compose no plan without one.
- **Child issues:** the subject's GitHub sub-issues (`gh api repos/{owner}/{repo}/issues/<n>/sub_issues`). With none, the branch's commits (`git log --reverse <merge-base>..HEAD`) are the breakdown of the change instead.
Read the subject, each child, and their comments: their acceptance criteria are what the change promises.
**Done when:** all four anchors are known, and every promise the subject and its children make is listed.
### 4. Establish what automation already proves
Run the configured suites at both points:
```bash
node "<skill>/two-point.mjs" --base <base_ref>
```
When step 2 took an `--answers` file, or used answers given in chat or by a Decision Request that the person did not save, pass the answers file: the one step 2 wrote, or else the `--answers` file. Add `--answers <working_dir>/<answers.json>`. The runner merges it over the config, or over none, as `render` does, and writes no config. It takes the file only from inside the `working_dir` the merge gives, so an answer that sets `working_dir` moves where the file must be. Never write a config, even a temporary one, to run it ([ADAPTER.md](ADAPTER.md#readiness-check)).
It runs each `plan.suites` command in the platform's default shell (`cmd.exe` on Windows, `/bin/sh` elsewhere; [ADAPTER.md](ADAPTER.md#which-shell-runs-command)), in the checkout, at the head, then in a detached worktree at the merge-base under `working_dir`, which it removes afterwards, whether the run succeeds or fails. It compares the two runs' JUnit XML test by test and prints a table. It takes as long as the suites, twice: say so before it starts. To run fewer, pass `--suite <name>` once for each suite whose `surfaces` cover the changed paths.
- **Exit 1: a regression.** A test that passes at the merge-base, or a new test, fails at the head. Stop: show the person those rows, and tell them to fix it before a plan is worth writing.
- **Exit 2:** nothing was compared (a config problem, a ref git cannot find, an interrupted run). Show the message. When it cannot be fixed, go on without the runner, and tag every claim `[reconstructed]`.
- **Exit 0:** read the table, row by row:
- `covered`, `covered (new)`, `covered (unskipped)`, `covered (fixed at head)`: a claim, with the tag the row prints. Name each new or unskipped test.
- `expected red herring`: it fails at both points; it goes in _Expected red herrings_, with its tag.
- `unknown`: it fails at the head, and the merge-base did not build or run, so it cannot be told from a red herring. Ask the person which it is before going on.
- `removed at head`: coverage the change took away; the promise that test proved may now be Residue.
- `skipped at head`: proves nothing.
- _Degraded suites_: say each one and why. A suite with no JUnit, or with a merge-base that will not build, is compared by exit code only, and its claims stay `[reconstructed]`.
Then, for each promise, find what proves it: the rows for the tests the diff adds or changes (`git diff --stat <merge-base> HEAD`), the suites whose `surfaces` cover the changed paths, and what the issue history says was tested. A CI check on the head (`gh pr checks`) that is not a configured suite gives a `[reconstructed]` claim; so does a failure on it, which is a red herring only when it also fails at the merge-base.
**A double does not prove a live path.** A suite that replaces a service the QA Stack provides (a database, a cache, a queue) with a double, such as SQLite for Postgres or a mocked Redis, proves the code against the double. Its claim does not by itself cover a promise whose code path reaches that service, however green it is. A suite's `services` ([ADAPTER.md](ADAPTER.md#plansuites-entries)) lists the services it runs against for real; a suite without it ran against doubles only. Such a promise is covered only when a suite against the real services covers it too: a configured suite whose `services` names each one, or a CI check on the head whose workflow starts them (a `services:` block, a compose file), read from the workflow and tagged `[reconstructed]`. Name that suite or check as the promise's live check, beside the in-memory claim. With none, the promise stays for the Residue.
Optional, when a claim carries the plan: perturb the code it covers (comment out the guard, invert the condition) and run the suite. A green suite that stays green is not a proving suite; the promise moves to the Residue. Revert the change before going on.
**Could a test prove it?** Last, for each promise left for the Residue, check whether a test in a configured suite could prove it; this check is yours, and the person is asked only where the answer is yes. A suite whose `services` names the real services counts as real infrastructure, so a test there is a live check. For a promise left for the Residue because only doubles covered it, only a suite whose `services` names each service its path reaches could prove it; with none, it stays for the Residue. What a test cannot reach is a real deployment, real infrastructure no configured suite starts, or a real browser; a promise that needs one stays for the Residue, with nothing to ask the person. When a test could prove one or more promises, stop before step 6, and for each one tell the person which suite, and what the test would assert. They choose, promise by promise:
- **Add the test.** They write it, commit it and push it. The head moves, so check step 1 again (the local `HEAD` must equal the pull request's new head), take the new head as step 3's head anchor and compute step 3's merge-base again (a rebase or a merge of the base ref moves it), and run step 4 again on the new head, from `two-point.mjs`. A promise the new test covers is then a claim like any other. A promise the person already chose to keep as a scenario is not asked about again on the new head; their choice stands, unless the new run covers it, in which case it is a claim and leaves the Residue.
- **Keep it as a scenario.** The promise stays for the Residue, and step 6 composes it.
Never write the test for them, and never carry the suggestion into the plan.
**Done when:** no regression is left, every `unknown` row has the person's answer, every promise is either covered by a named claim, with a named live check when its path reaches a QA Stack service, or left for the Residue, and every promise left for the Residue has been checked once for a test that could prove it, with the person's choice for each one a test could prove.
### 5. Match the Hazard packs
```bash
git diff --name-only <merge-base> HEAD | node "<skill>/adapter.mjs" hazards
```
Each pack it prints matched at least one changed path. Exit 1 means a pack in `hazards` is missing or malformed: show the problem and stop.
**Done when:** every matching pack is known, with the paths it matched.
### 6. Compose the Residue
Each promise step 4 left for the Residue, including each one the person chose to keep as a scenario, becomes a scenario ([ANATOMY.md](ANATOMY.md#scenarios)). The plan carries no test recommendations: step 4's question was for the person, not the tester. For each one, read the code and templates it exercises and quote their real labels in the steps. Write each expected result as [ANATOMY.md](ANATOMY.md#scenarios) says. A scenario that touches a path a Hazard pack matched gets that pack's _Rule out first_ list; every matching pack's _Capture rules_ go into the Run brief.
A promise that only a command can observe (a setting, a cache entry, internal state) is either observable through the product surface, or it is not Residue: Setup and steps are product actions, and the plan check reports one that reads as a shell command ([ANATOMY.md](ANATOMY.md#setup)).
A promise only reading can check (the copy of a doc, a static file the app does not serve, a code comment) has no surface to drive, so it is not a scenario, and it is never dropped: it becomes a `- [ ] Review: <what to read, and what it must say>` box in the **Sign-off checklist** ([ANATOMY.md](ANATOMY.md#sign-off-checklist)), such as `- [ ] Review: [local] docs/x.html says the token lasts 30 days`. Write each box as `Review: [<place>] <text>`, its Place one of the configured Places (`report.places` in the config, read by `adapter.mjs plan`; `local`, `staging` and `production` by default): `local` for a promise to read before the merge, a deferred Place for one that depends on staging or production. With Places turned off (`report.places: none`), write no Place. Name the file and the words it must carry, so a person can check it without the diff. A Residue of review boxes only is still a plan: its Scenarios says `None.`.
Pick each scenario's surface from what its **Expected result:** must observe, not from the config ([ANATOMY.md](ANATOMY.md#scenarios)). Response headers, cookies (including `HttpOnly`), status codes and response bodies are seen on `api`. Rendered copy, flows and layout are seen on `web`. The app itself is seen on `desktop` or `mobile`. The Run brief's **Surface:** is the one most scenarios use; give a scenario its own **Surface:** only when it needs another, so a promise no driver on the plan's default could see is still planned where one can. `run.surface` in the config is only the starting default for the Run brief's. When `run.surface` lists several Surfaces, pick the Run brief's **Surface:** as the one most scenarios use, choosing from the list when you can; a scenario needing a Surface outside the list still gets it as its own **Surface:**.
Give a scenario **Service:** only when the Run brief's target is `url` and the scenario tests a named service of its own (say `billing`) at an address other than its surface's, right after its **Surface:** ([ANATOMY.md](ANATOMY.md#scenarios)). Write the service's name only, never its address: the plan never holds one, and the person types each host in the run. Without one, the scenario uses its surface's entry.
Give a scenario **Observes:** whenever its **Expected result:** needs something not every driver of its surface can see: in practice response headers, `HttpOnly` cookies or a local file. List each such value from `headers`, `cookies`, `httponly-cookies`, `status`, `body`, `screen`, `local-file`, right after the scenario's **Surface:**, or after its sign-in field when it has none ([ANATOMY.md](ANATOMY.md#scenarios)), so `manual-qa` checks its driver before the run starts instead of finding out mid-scenario. Use the same list to choose the surface: `headers`, `cookies`, `httponly-cookies` and `status` are seen on `api`; `body` on `api`, and by some `web` drivers; `screen` on `web`, `desktop` or `mobile`; `local-file` on a surface whose driver can open a `file://` address, as `manual-qa`'s step 4 table gives it. A promise whose result needs values no single Surface's drivers see (for example, `status` and `screen`) is written as one scenario per Surface, each with its own setup so neither depends on the other's state; `adapter.mjs plan` refuses one scenario whose **Observes:** no single Surface can see.
Give a scenario **Expected before:** when it proves a defect is fixed: the subject issue or a child issue is a bug, or the promise reads as a fix. Write what the tester sees at the merge-base, drawn from the issue's reproduction or the merge-base's behaviour, never invented, in the product's own words as **Expected result:** is, right after **Expected result:** ([ANATOMY.md](ANATOMY.md#fix-scenarios)). It makes the scenario a fix scenario; a scenario that adds behaviour has none.
Give each scenario the **Capture:** its result needs, after its **Observes:** or wherever **Observes:** would sit ([ANATOMY.md](ANATOMY.md#scenarios)): `video` for a multi-session or timing-dependent scenario with a screen, `transcript` on `api`, `none` where an image would show nothing the written result does not, and otherwise `screenshot`, or leave it out, since a missing **Capture:** means `screenshot` on a screen surface.
When a promise needs two people signed in at once, compose a multi-session scenario. For example, an `admin`'s action ends a `user`'s session elsewhere. Give it **Sessions:** (`A = user, B = admin`) in place of **Signs in as:**, and start every step `In session <name>,` ([ANATOMY.md](ANATOMY.md#sessions)). Never fold the second person into a step's prose: the run would sign in once and could not carry the scenario out.
Plan a multi-session scenario's steps as Scenes, one Session's run of steps each, and at each Cut, show the new Session's on-screen result before the story moves on ([ANATOMY.md](ANATOMY.md#scenes-and-cuts)). A Scene ends on what its person sees, not on a click, and that result gets a step of its own. For an admin who ends a user's session, the story has four beats: the user signed in, the admin's confirming screen, the user's reload, and the user landing on the sign-in page. ANATOMY.md's S3 is the worked example.
Give a `Capture: video` scenario a **Story:**, right after its **Capture:**: one sentence per Scene, in order, in the product's own words and under the same public-text rules as **Expected result:** ([ANATOMY.md](ANATOMY.md#scenarios)). A single-session scenario is one Scene, so one sentence; each change of `In session <name>,` starts another. The plan check refuses a count that differs, and a `Capture: video` scenario without one. When a Scene opens a Session signed in as a Scenario account, its sentence says the person is already signed in: that sign-in is never on camera, because a Scenario account's values never go into the evidence.
When a promise reads as an `api` one (a status code, a response body) and its product has a screen where a person meets it, keep the `api` scenario and add a sibling `Surface: web`, `Capture: video` multi-session scenario that tells the story on screen. The sibling earns its Residue place only by what the screen shows, never by what the `api` scenario already proves.
A promise step 4 left for the Residue because only doubles covered it becomes a scenario that runs against the real services, even when the in-memory suite is green. A plan has one target for every scenario, so set the Run brief's **Target:** to `stack` ([ANATOMY.md](ANATOMY.md#run-brief)), unless a hosted test environment that runs those services is the target; with neither, say so to the person, since no run can carry the scenario out. Its steps drive the path that reaches them, through the API when no screen calls it.
**An empty Residue is a valid outcome.** When every promise is covered, write no plan: tell the person the change is proved by automation, name the claims that prove it, and recommend merging without one. For a promise whose path reaches a QA Stack service, name its live check, the suite against the real services that covers it, and say the QA Stack is not started because that suite is the live check. Stop here.
**Done when:** every promise step 4 left for the Residue is a scenario with every field [ANATOMY.md](ANATOMY.md#scenarios) requires, or a `Review:` box, or the Residue is empty and the person has been told.
### 7. Write the draft and show it
Write the plan to `<working_dir>/qa-plan-pr-<n>.md`, in the shape [ANATOMY.md](ANATOMY.md) gives, with the _Execution record_ exactly `_Not run yet._`. Read it back against [ANATOMY.md](ANATOMY.md): nine sections in order, the marker on line 1 with `format=4`, every claim tagged, no credentials. `node "<skill>/adapter.mjs" plan <file>` must exit 0: it is the check `manual-qa` runs before it accepts a plan. Show the person the draft and where it would be delivered (step 8). When step 2 took `--answers`, show the draft under its `answers.reused` line, `Readiness answers reused from <file>: <values>`, so the person sees the answers where they approve the plan. Then name each `Review:` box to the person, what to read and what it must say, since no run checks it and only a person ticks it. Ask them to confirm or correct the draft.
**Done when:** the person has confirmed the draft, as written or after the corrections they asked for.
### 8. Deliver
```bash
node "<skill>/adapter.mjs" delivery --label <label> --label <label> …
```
Pass each of the subject issue's labels. It prints `to`, and the rule that chose it:
- **`working-copy`:** the file from step 7 is the plan. Give the person its path to hand on.
- **`tracker-issue`:** one issue per subject. Find the one already there before creating one, in this order, and accept a candidate only when its body's first line starts with `<!-- qa-plan format=1 subject=#<n> `, `<!-- qa-plan format=2 subject=#<n> `, `<!-- qa-plan format=3 subject=#<n> ` or `<!-- qa-plan format=4 subject=#<n> ` (a plan written in an older format is still the one to replace):
1. the issue named in the pull request's link comment (the comment whose body starts with `<!-- qa-plan-link -->`);
2. with a rule `label`, each issue carrying it: `gh issue list --state all --label <label> --limit 200 --json number,body`;
3. otherwise a search, `gh issue list --state all --search "qa-plan subject=#<n> in:body" --json number,body`, which can lag behind an issue created minutes ago.
Edit the issue found (`gh api -X PATCH repos/{owner}/{repo}/issues/<m> -F body=@<plan>`). Create one only when none is found (`gh issue create --title "QA Plan: #<n> <title>" --body-file <plan>`, with `--label <label>` when the rule names one), then post the link comment on the pull request: `<!-- qa-plan-link -->` on its first line, then `QA Plan: #<m>`.
- **`pr-comment`:** one comment on the pull request. Find the comment whose body starts with the plan's marker, or the same marker with `format=1`, `format=2` or `format=3`, and edit it; post a new one only when there is none.
A revision of the plan replaces the delivered one; it never adds a second. With `tracker: none`, the plan stays in the working copy whatever the rules say.
Then check for a QA Report left over from an older head. `manual-qa` posts one comment on the pull request, its first line `<!-- qa-report -->`, whose header line (`QA Report: result=…; commit=<sha>; …`; on an older comment, its **Plan:** line) names the head it ran on; after a revision for a new head it describes a plan that no longer exists. Read it with `manual-qa`'s own `report.mjs`, in the `manual-qa` folder beside this one, rather than parsing the comment here:
```bash
gh api --paginate "repos/{owner}/{repo}/issues/<pr>/comments" --jq '.[] | {id, body, user: .user.login}' | node "<skill>/../manual-qa/report.mjs" find --login "<login>" --head <head>
```
`<login>` is `gh api user --jq .login`, and `<head>` is the plan's full head anchor (step 3). Write every file this check needs (`<tmp>` below) in the system's temporary directory, and delete them when done. Skip this check, and change nothing, when `gh` cannot reach the pull request, when there is no `manual-qa/report.mjs` beside this folder, when `report` is `create` (no report comment of the person's own), when `report` has no `stale` key (an older `manual-qa` that does not read `--head`), or when `find` exits 1 (the plan's head is not a full SHA: show the person the problems). A report comment someone else wrote, named in `others`, is never edited here.
- **`stale` is `false`:** the report is for the plan's head, or its **Stale:** line already names it. Say nothing about it.
- **`stale` is `null`:** the comment's **Plan:** line names no full head SHA. Tell the person its URL (as below) and that it could not be checked against the plan's head; offer no edit.
- **`stale` is `true`:** tell the person the comment's URL (`gh api "repos/{owner}/{repo}/issues/comments/<id>" --jq .html_url`), the head the report is for (`report.head`) and the plan's head, and ask whether to mark it stale. Editing the comment notifies the people watching the pull request, so do it only on their yes:
```bash
gh api "repos/{owner}/{repo}/issues/comments/<id>" --jq .body | node "<skill>/../manual-qa/report.mjs" stale --head <head> > "<tmp>/stale.md" &&
gh api -X PATCH "repos/{owner}/{repo}/issues/comments/<id>" -F body=@<tmp>/stale.md
```
Run the PATCH only after `stale` exits 0. On exit 1, `stale.md` holds `{"problems": …}`, not a comment body: show the person the problems and edit nothing. It adds `**Stale:** the plan was revised for head <head>; this report is for <old head>.` after the marker, and leaves the report itself as it is. On a no, leave the comment as it is. Never delete or hide it: the next `manual-qa` run replaces the whole comment, Stale line included. That run is also what clears a Stale line that is no longer true, such as after the plan is revised back to the report's head. This step never removes one.
**Done when:** the plan is at the target the rules chose, the person has its path or URL, nothing was committed, and, when the pull request carries a QA Report comment for another head, the person has its URL and both heads and has answered whether to mark it stale.