servo-fetch
AGENTS.md166 starsChanged 7 months agoApache-2.0View on GitHub
Instructions for AI coding agents working on servo-fetch. This file complements, not replaces, CONTRIBUTING.md (human-oriented) and skills/servo-fetch/SKILL.md (consumer-oriented). Treat this file as living documentation; update it when conventions change. servo-fetch is a Rust workspace with two crates: Language bindings live outside the cargo workspace in bindings/python/ (PyO3/maturin) and bindings/node/ (TypeScript wrapper over the CLI; bindings/node is excluded from the workspace). Toolchain pinned in rust-toolchain.toml; MSRV declared as rust-version in Cargo.toml — do not use features stabilized after the MSRV. Workspace-wide…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- servo-fetchSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Run these from the workspace root unless noted.
- Very specific: line 58
cargo clippyis a gate: Use -D warnings in CI; keep it passing locally before pushing. - Very specific: line 116
Read CONTRIBUTING.md for the human-oriented workflow and the AI usage policy.
- Very specific: line 117
Read SECURITY.md before changing anything SSRF-, TLS-, or signing-related.
- Distinctive: line 125
Do not submit autonomously-generated PRs.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Instructions for AI coding agents working on servo-fetch. This file complements, not replaces, CONTRIBUTING.md (human-oriented) and skills/servo-fetch/SKILL.md (consumer-oriented). Treat this file as living documentation; update it when conventions change.
Project overview
servo-fetch is a Rust workspace with two crates:
servo-fetch(library): wraps the Servo browser engine to fetch, render, and extract web content. Main entry points:fetch(),crawl()/crawl_each()(streaming),map()(sitemap discovery).servo-fetch-cli(binary): CLI + HTTP API + MCP server. Depends onservo-fetch.
Language bindings live outside the cargo workspace in bindings/python/ (PyO3/maturin) and bindings/node/ (TypeScript wrapper over the CLI; bindings/node is excluded from the workspace).
Toolchain pinned in rust-toolchain.toml; MSRV declared as rust-version in Cargo.toml — do not use features stabilized after the MSRV. Workspace-wide version bumping via [workspace.package].version.
The Servo dependency dominates build time (several minutes on first build, ~30-40 minutes for release). Plan long-running commands accordingly.
Setup and commands
Run these from the workspace root unless noted. Copy-paste ready:
cargo build # Debug build
cargo build --release # Release build (slow)
cargo +nightly fmt --all # Format
cargo +nightly fmt --all -- --check # CI fmt check
cargo clippy --workspace --all-targets -- -D warnings # Lint (pedantic, warnings are errors)
cargo test --workspace # Unit + integration tests (fast)
cargo test -- --ignored # Include Servo-backed e2e tests (slow)
cargo deny check # License + advisory audit
taplo check # TOML lint (install: cargo install taplo-cli --locked)
taplo fmt # TOML format
typos # Spell checkNextest profiles (preferred over cargo test in CI):
cargo nextest run --workspace --profile ci # Unit + integration, CI output
cargo nextest run -p servo-fetch-cli --run-ignored only --profile ci-e2e # E2E, retries on flakeCargo aliases for exact CI parity (defined in .cargo/config.toml):
cargo lint # cargo-clippy job
cargo test-ci # cargo-test job (unit/integration via nextest)
cargo test-doc # cargo-test job (doc tests)
cargo test-e2e # e2e job (Servo-backed, retries on flake)Ignored tests require a working Servo environment. Servo uses SoftwareRenderingContext internally, so no X server is needed in CI (the apt install list in release.yml includes X11 libs for linking, not for runtime). If an ignored test fails locally, first retry; if it still fails, check whether the test hits the network or a site that requires --settle.
Code conventions
Rust style
cargo clippyis a gate. Use-D warningsin CI; keep it passing locally before pushing.- Inline
format!args —format!("x={x}"), notformat!("x={}", x). See the clippy ruleuninlined_format_args. #[non_exhaustive]on public structs/enums that we expect to grow (e.g.,Page,CrawlResult,ConsoleMessage). Do not add new public enum variants or struct fields without it unless the type is intentionally sealed.- Fields
pub(crate)+ builder methods for option structs likeCrawlOptions,FetchOptions,MapOptions. Callers construct viaOptions::new(url)and chain.method(value). Adding a newpub(crate)field + builder method is always non-breaking. Result<T, Error>end-to-end — crate-localerror::Result. Nounwrap()in non-test code except where a panic is documented as the only sane behaviour (e.g., poisoned mutex).- Single-concern modules over strict line counts. Large files are acceptable when they remain one semantic concern (e.g.,
crawl.rsowns all crawl logic). Split when a second concern emerges, not when LoC crosses a threshold. - No
#[async_trait]— prefer native RPITIT (fn foo(&self, ...) -> impl Future<Output = T> + Send) when the return type is nameable.
Commits
Conventional Commits, subject-only by default. Use the body only when critical context cannot fit in the subject. Scopes used in this repo:
chore(deps)— external dependencies the product ships (cargo crates, docker base image).chore(ci)— CI/workflow configuration, github-actions entries, Dependabot config itself.fix(<area>)— bug fixes;<area>is typically a module (crawl,map,build,tests) orci.feat(<area>)— user-facing additions.refactor(<area>),test(<area>),docs,perf,build.
Examples: fix(build): drop +crt-static on Windows to match mozjs-sys CRT, chore(deps): bump rustls.
Breaking changes: mark with ! in the subject (feat(api)!: split sync and async, refactor(error)!: rename Error::Timeout). The marker drives release-plz's minor/major bump and the ### Breaking Changes changelog section. Put migration guidance for users in the release PR's CHANGELOG.md under ### Migration Guide, not in commit bodies (release-plz does not surface commit bodies).
Branch names
Kebab-case under a type prefix: fix/windows-crt-mismatch, refactor/wiremock-body-mime-consistency, ci/trivy-image-scan.
GitHub Actions
All third-party actions must be SHA-pinned with a version comment: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2. This is enforced for supply-chain hygiene (see the March 2026 trivy-action compromise). Dependabot (chore(ci)) keeps SHAs current.
Testing idioms
wiremock mocks
Always use set_body_raw(body, mime), never set_body_string + insert_header("content-type", ...). set_body_string unconditionally overwrites the content-type to text/plain, regardless of chain order, and the resulting mock silently serves the wrong MIME — which breaks browser-level HTML parsing (Servo receives text/plain and wraps the body in <pre>).
// WRONG — insert_header is overridden by set_body_string's forced text/plain
ResponseTemplate::new(200)
.insert_header("content-type", "text/html")
.set_body_string(html)
// RIGHT
ResponseTemplate::new(200).set_body_raw(html.into_bytes(), "text/html; charset=utf-8")Shared helper: crates/servo-fetch-cli/tests/common.rs::mock_page.
E2E tests
Mark Servo-backed tests with #[ignore = "e2e: requires Servo engine"] and run them via the ci-e2e nextest profile, which enables retries with a 2-second backoff. Keep the mock HTML minimal but syntactically valid (<!doctype html><html>...</html>).
Assertions
Compare whole values with assert_eq! over field-by-field checks. Failing diffs are easier to read when the entire structure is dumped.
When contributing
- Read
CONTRIBUTING.mdfor the human-oriented workflow and the AI usage policy. - Read
SECURITY.mdbefore changing anything SSRF-, TLS-, or signing-related. - User-facing behavior changes must update:
README.md(CLI + library usage)crates/servo-fetch-cli/README.md(CLI flags reference)skills/servo-fetch/SKILL.mdandskills/servo-fetch/references/guide.mdif behavior or flags changebindings/python/README.mdandbindings/node/README.mdif the public binding API changesSECURITY.mdif policy defaults change
- PR template:
.github/pull_request_template.md. Keep the Summary concise; explain why where non-obvious, not what (the diff shows what). - Do not submit autonomously-generated PRs. Human-in-the-loop is a hard requirement (see CONTRIBUTING.md § Use of AI).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

