Agent skill
Teach lesson
Your agent writes a five-minute lesson that ends with the reader applying the idea, not just reading it.
Install the global Vite+ CLI before running this command. Without it, replace vp dlx with pnpm dlx.
Pick teach-lesson from the list.
Keep both writers' changes
After this lesson, you can predict how a server handles two changes to the same record, with or without a version check.
Why it matters
Section titled "Why it matters"In this example, Ana and Ben open the same help article. Ana corrects a spelling error and saves the article. Ben adds a paragraph to his older copy and saves it. His save removes Ana's correction without a warning. This is a lost update.
The idea
Section titled "The idea"An ETag is a version label, such as "v7", that the server sends with a resource. The If-Match header carries that label back to require the same version before saving a change. If the labels match, the server saves the change. If the labels differ, the server returns 412 Precondition Failed and keeps the resource unchanged.
Worked example
Section titled "Worked example"Both load version 7
Section titled "Both load version 7"Ana and Ben each
GET /articles/42, and both getETag: "v7".Ana saves first
Section titled "Ana saves first"PUT /articles/42 If-Match: "v7"The article is still at
"v7". The server saves Ana's change and returns200 OKwithETag: "v8".Ben saves second
Section titled "Ben saves second"PUT /articles/42 If-Match: "v7"The article is now at
"v8". The labels differ, so the server returns412 Precondition Failed. Ana's correction stays.Ben reloads and merges
Section titled "Ben reloads and merges"Ben's editor fetches
"v8"and shows Ana's correction. Ben adds his paragraph to that version. He saves again withIf-Match: "v8".
Check yourself
Section titled "Check yourself"This API accepts requests without If-Match. Ben's editor sends his PUT without that header. The article is at "v8". What happens?
Show answer
If-Match, the server has no version condition to check. The server saves Ben's version. This removes Ana's correction.If-Match to protect the change. An API can require that header. If the header is absent, that API can return 428 Precondition Required.What does a server answer when If-Match names an old version?
Show answer
412 Precondition Failed, and it leaves the resource unchanged.Read next
Section titled "Read next"
RFC 9110, section 13.1.1 defines
If-Match.
The next lesson explains weak ETags and why W/"v7" never matches If-Match.
# Keep both writers' changes
After this lesson, you can predict how a server handles two changes to the same record, with or without a version check.
## Why it matters
In this example, Ana and Ben open the same help article. Ana corrects a spelling error and saves the article. Ben adds a paragraph to his older copy and saves it. His save removes Ana's correction without a warning. This is a **lost update**.
## The idea
An **ETag** is a version label, such as `"v7"`, that the server sends with a resource. The **If-Match** header carries that label back to require the same version before saving a change. If the labels match, the server saves the change. If the labels differ, the server returns `412 Precondition Failed` and keeps the resource unchanged.
## Worked example
::steps
### Both load version 7
Ana and Ben each `GET /articles/42`, and both get `ETag: "v7"`.
### Ana saves first
```http
PUT /articles/42
If-Match: "v7"
```
The article is still at `"v7"`. The server saves Ana's change and returns `200 OK` with `ETag: "v8"`.
### Ben saves second
```http
PUT /articles/42
If-Match: "v7"
```
The article is now at `"v8"`. The labels differ, so the server returns `412 Precondition Failed`. Ana's correction stays.
### Ben reloads and merges
Ben's editor fetches `"v8"` and shows Ana's correction. Ben adds his paragraph to that version. He saves again with `If-Match: "v8"`.
::
## Check yourself
::question{#etag-no-if-match}
This API accepts requests without `If-Match`. Ben's editor sends his `PUT` without that header. The article is at `"v8"`. What happens?
- [x] The server saves Ben's version and removes Ana's correction
> Without `If-Match`, the server has no version condition to check. The server saves Ben's version. This removes Ana's correction.
- [ ] The server refuses the save with a 412 status code
> A 412 response requires a condition that failed. Ben sent no condition, so the server has no labels to compare.
- [ ] The server merges Ben's paragraph into version 8
> The server does not combine the two versions. After a 412 response, the client must get the current version and combine the changes.
#explain
The client must send its original version label for `If-Match` to protect the change. An API can require that header. If the header is absent, that API can return `428 Precondition Required`.
::
::recall{#etag-412}
What does a server answer when `If-Match` names an old version?
#answer
`412 Precondition Failed`, and it leaves the resource unchanged.
::
## Read next
[RFC 9110, section 13.1.1](https://www.rfc-editor.org/rfc/rfc9110#name-if-match) defines `If-Match`.
The next lesson explains weak ETags and why `W/"v7"` never matches `If-Match`.What it does
Section titled "What it does"The skill writes one lesson on one concept that takes five minutes. You get the outcome, the idea, a worked example, and a question that changes one input of that example.
It fits the depth to your question and what you know. A plain definition leads to how the concept works and why it solves your problem, and the example adds detail. When diagrams help, each one redraws the last with the next part added.
For an existing system, it checks behavior against the sources and looks for recorded design reasons. It labels reasons it inferred and says what's uncertain.
The lesson, its question, and the answer explanations follow the ASD-STE100 Simplified Technical English rules. Sentences are short, each term keeps one meaning, and technical names stay exact.
The skill keeps no record of what you've learned. A second concept gets its own lesson, linked at the end. Your browser or a host such as Drop can save answers.
When to use it
Section titled "When to use it"Ask "Teach me how ETags prevent lost updates" or "Write a lesson on React keys for new hires." Your agent loads the skill when someone asks to learn or understand a concept. To be sure, say "Use the teach-lesson skill."
Choose by what you want:
- One idea, learned and checked in a few minutes: this skill.
- How a system works, with no check: Visual explanation.
- A course over many sessions that remembers what you've learned: a tutor skill such as Matt Pocock's teach, which this skill draws on.
Its reader context, how-and-why explanation, evidence handling, and step-by-step diagrams draw on pstack's teach skill. They're built in, so this skill installs on its own.
It's working if
Section titled "It's working if"- The outcome under the title uses a verb a question can test, such as predict, explain, or choose.
- The idea starts with a plain definition and ties it to your case.
- The explanation separates verified behavior from inferred design reasons.
- Each step of the worked example shows the value that changed.
- Instructions are at most 20 words, and descriptive sentences at most 25.
- Each technical term is explained at first use and keeps one meaning.
- The question changes one input of the example instead of asking for the definition back.
- Each wrong option is a real mistake, and picking it says why it's tempting and why it's wrong.
- You can't spot the right answer by its length or place, since comark-quiz shuffles the options.
- The lesson ends with one primary source, linked to the exact section.