Learn-by-Demo Lite
Stop letting your agent guess APIs. Capture one real demonstration — every
URL, header, and payload the workflow actually sends — then draft your
automation from observed traffic, not hallucinated endpoints.
Why guessing fails
When an agent is told to automate a UI-driven system with no API docs, the
default failure mode is to guess: it invents an endpoint path, invents the
auth scheme, invents the body shape. Every wrong guess comes back as:
- 401 / 403 — the auth header is missing, malformed, or the wrong scheme.
- HTML instead of JSON — the guessed path doesn't exist, so the server
returns a login page or a SPA shell.
- Burned iterations — each wrong guess is a full request/parse/retry
loop converging on nothing.
A single real demonstration solves both halves at once: the real endpoint,
method, and body shape, and the real authorization as it was actually
sent. You capture facts, then replay facts.
The Iron Rules
- Never hardcode an API or form flow before you have seen the real
request. No endpoint path, no header, no body schema goes into
automation until it appeared in a capture.
- Prefer the user's already-logged-in browser session. A second
automated login can trigger single-device kick-out and invalidate the
user's session. In this Lite edition that means: capture from the user's
own browser window (DevTools), don't open a parallel login.
- Copy exactly what you captured — endpoint, headers, auth, body
schema — then parameterize. Reproduce first, generalize second.
The capture workflow (Lite)
Decide. Does the task drive a UI, and are the exact endpoints
unknown? If the target has documented public APIs, read the docs instead.
Capture. Two zero-install options:
- Your agent runtime's own network reader — if the runtime you are in
can read network requests from a browser it controls, arm it before the
user clicks anything, then read the captured requests directly.
- Browser DevTools HAR export — the user opens DevTools → Network,
checks "Preserve log", performs the workflow slowly (pausing per step),
then right-clicks → "Save all as HAR".
Draft. Feed the capture to the draft tool:
python scripts/har_draft.py capture.har
You get a redacted Markdown draft per endpoint: method, URL template
(volatile ids normalized to {id}/{uuid}), auth type, query
parameters, request-body field names, and statuses seen.
Build replay from the draft. Reproduce one call exactly as captured
(same headers, same body shape) and confirm it returns the same result
the user saw. Only then parameterize.
Persist. Write the endpoint/field/flow knowledge into a project-level
skill or memory so the next run needs no demonstration.
Try it on the bundled synthetic capture:
python scripts/har_draft.py fixtures/sample_capture.har
Handling captured secrets
Captures contain live credentials. Discipline is non-negotiable:
har_draft.py always redacts Authorization, Cookie, API-key headers,
and token-ish query parameters. There is no off switch.
- Never commit a raw HAR. Keep captures out of version control
(add them to
.gitignore) and delete them when done.
- Replay reads tokens from an environment variable, never a literal in
the script.
- Never paste a raw capture into a prompt, issue, or chat. Draft first.
Anti-patterns
- Guessed-endpoint loop. Inventing
/api/.../records and its body,
getting 401s and HTML, and retrying with another guess. Fix: capture the
real request once.
- Second-login kick-out. Spinning up a separate automated login "to
test", which invalidates the user's live session. Fix: capture from the
user's own window.
- Committing a live token. Saving a raw HAR with a valid
Authorization header into the repo. Fix: draft (redacted) goes in the
repo; the HAR does not.
Lite vs. full
This Lite edition covers the methodology plus HAR-to-draft. The full
Learn-by-Demo adds: a Playwright capture harness that attaches to the
user's already-logged-in browser over CDP (JSONL + HAR output),
session-preservation recipes (storage state, persistent profiles, the three
ways around single-device kick-out), a machine-readable endpoint-spec
format, a replay-script scaffold generator (tokens via env var), and
batch-hardening patterns (pagination, token-expiry refresh, polite rate
pacing, baseline verification) — with a worked end-to-end example against a
public demo site.
Responsible use
Only automate systems you are authorized to use, and respect the target
system's terms of service. This skill does not help bypass authentication,
CAPTCHAs, bot detection, or access controls.
Not affiliated with Anthropic; Claude is a trademark of Anthropic,
referenced only to describe compatibility.
1---2name: learn-by-demo-lite3description: Capture a real user demonstration of a web workflow (browser DevTools HAR export, or your agent runtime's own network reader) and turn it into a redacted endpoint draft, so automation is built from observed traffic instead of guessed APIs. Use when automating an internal tool, legacy SPA, or vendor portal that has no API docs; when guessed endpoints keep returning 401/403 or HTML instead of JSON; or when the user says "watch me do it once", "let me show you the steps", or "record what I click". Not for: services with documented public APIs (read the docs instead), bypassing CAPTCHAs, bot detection, or logins you are not authorized to use, scraping sites against their terms, generating UI test suites, or mobile-app reverse engineering. The Playwright capture harness, session-preservation (CDP attach), replay scaffold generator, and batch-hardening patterns are in the full Learn-by-Demo.4---56# Learn-by-Demo Lite78Stop letting your agent guess APIs. Capture one real demonstration — every9URL, header, and payload the workflow actually sends — then draft your10automation from observed traffic, not hallucinated endpoints.1112## Why guessing fails1314When an agent is told to automate a UI-driven system with no API docs, the15default failure mode is to *guess*: it invents an endpoint path, invents the16auth scheme, invents the body shape. Every wrong guess comes back as:1718- **401 / 403** — the auth header is missing, malformed, or the wrong scheme.19- **HTML instead of JSON** — the guessed path doesn't exist, so the server20 returns a login page or a SPA shell.21- **Burned iterations** — each wrong guess is a full request/parse/retry22 loop converging on nothing.2324A single real demonstration solves both halves at once: the **real endpoint,25method, and body shape**, and the **real authorization** as it was actually26sent. You capture facts, then replay facts.2728## The Iron Rules29301. **Never hardcode an API or form flow before you have seen the real31 request.** No endpoint path, no header, no body schema goes into32 automation until it appeared in a capture.332. **Prefer the user's already-logged-in browser session.** A second34 automated login can trigger single-device kick-out and invalidate the35 user's session. In this Lite edition that means: capture from the user's36 own browser window (DevTools), don't open a parallel login.373. **Copy exactly what you captured** — endpoint, headers, auth, body38 schema — *then* parameterize. Reproduce first, generalize second.3940## The capture workflow (Lite)41421. **Decide.** Does the task drive a UI, and are the exact endpoints43 unknown? If the target has documented public APIs, read the docs instead.442. **Capture.** Two zero-install options:45 - **Your agent runtime's own network reader** — if the runtime you are in46 can read network requests from a browser it controls, arm it before the47 user clicks anything, then read the captured requests directly.48 - **Browser DevTools HAR export** — the user opens DevTools → Network,49 checks "Preserve log", performs the workflow slowly (pausing per step),50 then right-clicks → "Save all as HAR".513. **Draft.** Feed the capture to the draft tool:5253 ```54 python scripts/har_draft.py capture.har55 ```5657 You get a redacted Markdown draft per endpoint: method, URL template58 (volatile ids normalized to `{id}`/`{uuid}`), auth type, query59 parameters, request-body field names, and statuses seen.604. **Build replay from the draft.** Reproduce one call exactly as captured61 (same headers, same body shape) and confirm it returns the same result62 the user saw. Only then parameterize.635. **Persist.** Write the endpoint/field/flow knowledge into a project-level64 skill or memory so the next run needs no demonstration.6566Try it on the bundled synthetic capture:67`python scripts/har_draft.py fixtures/sample_capture.har`6869## Handling captured secrets7071Captures contain **live credentials**. Discipline is non-negotiable:7273- `har_draft.py` **always redacts** Authorization, Cookie, API-key headers,74 and token-ish query parameters. There is no off switch.75- **Never commit a raw HAR.** Keep captures out of version control76 (add them to `.gitignore`) and delete them when done.77- **Replay reads tokens from an environment variable**, never a literal in78 the script.79- **Never paste a raw capture into a prompt, issue, or chat.** Draft first.8081## Anti-patterns8283- **Guessed-endpoint loop.** Inventing `/api/.../records` and its body,84 getting 401s and HTML, and retrying with another guess. Fix: capture the85 real request once.86- **Second-login kick-out.** Spinning up a separate automated login "to87 test", which invalidates the user's live session. Fix: capture from the88 user's own window.89- **Committing a live token.** Saving a raw HAR with a valid90 `Authorization` header into the repo. Fix: draft (redacted) goes in the91 repo; the HAR does not.9293## Lite vs. full9495This Lite edition covers the methodology plus HAR-to-draft. The full96**Learn-by-Demo** adds: a Playwright capture harness that attaches to the97user's already-logged-in browser over CDP (JSONL + HAR output),98session-preservation recipes (storage state, persistent profiles, the three99ways around single-device kick-out), a machine-readable endpoint-spec100format, a replay-script scaffold generator (tokens via env var), and101batch-hardening patterns (pagination, token-expiry refresh, polite rate102pacing, baseline verification) — with a worked end-to-end example against a103public demo site.104105## Responsible use106107Only automate systems you are authorized to use, and respect the target108system's terms of service. This skill does not help bypass authentication,109CAPTCHAs, bot detection, or access controls.110111*Not affiliated with Anthropic; Claude is a trademark of Anthropic,112referenced only to describe compatibility.*