derive-client
Skill này làm gì
Skill này ghi lại những gì một trang web gửi và nhận khi bạn dùng nó, rồi viết một script hoặc công cụ nhỏ tự gửi các yêu cầu tương tự. Nó dành cho người lặp lại cùng một tác vụ trên web thường xuyên.
Khi nào nên dùng
- ✓Khi bạn muốn dùng dữ liệu của một trang web mà không phải mở trình duyệt mỗi lần.
- ✓Khi bạn được yêu cầu xây một CLI cho một trang không có API chính thức.
- ✓Khi bạn cần xem trang web dùng những endpoint nội bộ nào.
Liên kết skill
https://github.com/vercel-labs/agent-browser/blob/main/skill-data/derive-client/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Xem tôi tìm chuyến bay trên trang này một lần, rồi viết một script làm đúng việc tìm kiếm đó cho tôi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Trình duyệt lưu một file HAR các yêu cầu mạng trong lúc bạn dùng trang. AI nghiên cứu các yêu cầu đó, rồi viết một client gọi trực tiếp các endpoint.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Derive an API client from a recorded session
Driving a browser is the right tool for the first visit and the wrong tool for the hundredth. This skill records a site's network traffic once while you use it, then turns the captured requests into a standalone client (script, CLI, or library) that talks to the site's internal API directly.
The recording alone contains everything needed: agent-browser embeds text response bodies (JSON/HTML/JS) in the HAR by default, so endpoint shapes can be studied offline after the browser is closed.
Workflow
1. Record Start HAR capture, drive the flows you want in the client
2. Identify Find the real API endpoints among the noise
3. Extract Pull request shapes, response schemas, and auth material
4. Generate Write the client, one function per flow
5. Verify Call every endpoint for real before declaring done
1. Record
agent-browser network har start # embeds text response bodies by default
# ... drive the site: search, open a detail page, paginate, etc. ...
agent-browser network har stop /tmp/site.har
- Exercise every flow the client should support, and run each one at least twice with different inputs (two search terms, two detail pages). Diffing the recorded URLs reveals which parts are parameters.
- If the site needs login, log in before starting the HAR so credentials don't land in the recording unnecessarily. The session cookies are exported separately in step 3.
--content allembeds binary bodies too (base64);--content nonedisables embedding. Per-body cap is 2 MB.
While the session is still open, agent-browser network requests and network request <id> give the same data interactively — but only the HAR survives navigation and browser close, so prefer it for anything multi-page.
2. Identify endpoints
Query the HAR with jq:
# All JSON API calls: method, URL, status
jq -r '.log.entries[]
| select(.response.content.mimeType | test("json"))
| "\(.request.method) \(.response.status) \(.request.url)"' /tmp/site.har
Ignore analytics and infrastructure noise: telemetry endpoints (/collect, /track, /beacon, /log), third-party domains (google-analytics, segment, sentry, datadog, intercom, hotjar), and static assets. The real API is usually first-party, JSON, and correlates with the actions you performed.
3. Extract shapes and auth
# Full detail for one endpoint: request headers, POST body, response body
jq '.log.entries[] | select(.request.url | test("api/search"))
| {request: {method: .request.method, headers: .request.headers,
postData: .request.postData.text},
response: .response.content.text}' /tmp/site.har
- Response schema: read
.response.content.text— this is the real payload, use it to derive types. - Auth: compare request headers across endpoints. Look for
authorization,cookie,x-csrf-token,x-api-key, and site-specificx-*headers. Replay only the ones that matter — test by omission in step 5. - Cookies: export the live session with
agent-browser cookies get --json > cookies.jsonfor the client to load at runtime. Never hardcode cookie values into generated source.
4. Generate the client
- One function per recorded flow (
search(query),getItem(id)), typed from the observed response bodies. - Auth material (cookies, bearer tokens) loads from a file or environment variable, with a clear error telling the user to re-run the browser login when it expires.
- Reproduce the headers the API actually requires — some sites 403 without a matching
user-agent,referer, orx-requested-with. - Keep pagination, sort, and filter parameters that appeared in the recorded query strings as function options.
5. Verify
Call every generated function against the live API and compare the response shape with the recording. Common failures:
| Symptom | Cause | Fix |
|---|---|---|
| 401/403 | Expired or missing session | Re-login via agent-browser, re-export cookies |
| 403/419 on writes | CSRF token is per-session or per-form | Fetch the token endpoint first, or keep that flow browser-driven |
| Works then breaks | Signed/expiring request params | Fall back to the browser for that step; derive the rest |
| Different shape than HAR | A/B tests or geo-dependent responses | Re-record and treat the union as optional fields |
Caveats
- Internal APIs are unversioned and change without notice — keep the HAR so
Câu hỏi thường gặp
Tôi có nên đăng nhập trước khi ghi lại không?
Có. Skill nói nên đăng nhập trước khi bắt đầu ghi, để thông tin đăng nhập không lọt vào file.
Client được tạo ra có được kiểm thử không?
Có. Skill nói mọi endpoint phải được gọi thật trước khi công việc được coi là xong.
Sau khi ghi lại, tôi có cần trình duyệt không?
Không. Skill nói client không cần trình duyệt sau lần ghi đầu tiên.
Chi tiết
Mô tả gốc của tác giả
Reverse-engineer a website's internal API by recording browser traffic into a HAR file, then generate a standalone client or CLI that calls the endpoints directly, with no browser needed after the first recording. Use when asked to "derive a client", "build a CLI for <site>", "reverse engineer this site's API", "record network requests", "turn this site into an API", or when the same site will be automated repeatedly and direct HTTP calls would beat driving the browser every time.
Độ phổ biến
- Sao GitHub
- 45k
- Vị trí xếp hạng
- #6357
- Giấy phép
- Apache-2.0
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
technical-writer
45kDạy agent của bạn viết và sửa tài liệu cho lập trình viên, như hướng dẫn, tham chiếu API và trang xử lý sự cố, rõ ràng và chính xác.
agentcore
45kCho agent của bạn chạy tự động hóa trình duyệt trên đám mây AgentCore của AWS Bedrock, dùng đăng nhập AWS sẵn có và các lệnh giống Chrome cục bộ.
core
45kDạy agent của bạn điều khiển trình duyệt web bằng snapshot và tham chiếu phần tử, để mở trang, nhấp, điền biểu mẫu và đọc nội dung.
dogfood
45kDạy agent của bạn kiểm thử ứng dụng web bằng cách khám phá nó, rồi viết báo cáo lỗi kèm ảnh chụp màn hình và các bước tái hiện cho từng vấn đề.
Skill tương tự
tavily
394kGiúp agent của bạn tìm kiếm web bằng Tavily và lấy văn bản từ các trang cụ thể, với tùy chọn về độ sâu, tên miền và ngày tháng.
blogwatcher
394kCho phép agent của bạn theo dõi blog và nguồn cấp RSS hoặc Atom, kiểm tra bài viết mới và đánh dấu những bài bạn đã đọc.
data-scraper-agent
280kGiúp agent tự động thu thập dữ liệu từ mọi nguồn công khai. Có thể lên lịch, bổ sung thông tin và lưu kết quả. Hữu ích để theo dõi dữ liệu trực tuyến.