crw-best-practices
Original:🇺🇸 English
Translated
Reference skill for building production-ready crw integrations. Covers verb selection, call surfaces (CLI/MCP/REST), post-filtering strategies, context-window hygiene, Hybrid RAG patterns, common pitfalls, and crw-specific operational considerations (search backend limits, renderer pool, proxy rotation). Load this when writing application code that embeds crw, designing a multi-step agent workflow, or debugging an integration that isn't behaving as expected.
33installs
Sourceus/crw
Added on
NPX Install
npx skill4agent add us/crw crw-best-practicesTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →crw Best Practices
Reference documentation for developers and AI agents using crw (fastCRW) in
production. Covers decision-making, integration patterns, and crw-specific
operational details.
1. Choosing the right verb
Stop at the cheapest rung that answers the need. Don't reach for a heavier verb
than the task requires.
| Need | Verb | Notes |
|---|---|---|
| You have a question/topic, not a URL | search | Own search backend, no API key required. Returns titles + URLs + snippets. Add |
| You have one (or a few) known URLs | scrape | Returns markdown, HTML, links, or structured JSON. JS auto-detected. |
| You need to discover which URLs exist on a site | map | Fast URL discovery via sitemap + BFS. No content fetched. Use before committing to a crawl. |
| You need content from many pages under a site | crawl | Async BFS job. Poll with |
| The source is a local file (PDF) | parse | |
| You need a typed JSON object from a page | extract | |
| You want to detect what changed on a page | watch / diff | |
Common chains:
- → pick URLs →
searchthe best onesscrape - (or
search --json) → filter in Python subprocess →crw_searchchosen URLscrw scrape - → estimate page count →
mapa bounded section → stream resultscrawl - → find URLs → filter for
map "https://docs.example.com"→/docs/api/auththat one URLscrape
2. Three call surfaces
crw runs identically in three modes. Pick the one available in your environment.
CLI (crw
)
crwBest for scripting, one-shot queries, and agent bash calls. Binary must be on PATH.
bash
crw search "query" --json --limit 5
crw scrape "https://example.com" --format json
crw map "https://docs.example.com"
crw scrape "report.pdf" # local PDF auto-detectedUse CLI when: the binary is on PATH and you're in a Bash context. Especially
good for the dynamic-search pattern (pipe into Python subprocess).
MCP tools (crw_search
, crw_scrape
, crw_map
, crw_crawl
, crw_parse_file
)
crw_searchcrw_scrapecrw_mapcrw_crawlcrw_parse_fileBest inside an MCP-capable agent harness. The MCP server runs the engine either
in-process (embedded mode, ~6 MB RAM, no server) or as a proxy to a REST endpoint.
crw_scrape(url="https://example.com", formats=["markdown"], onlyMainContent=true)
crw_search(query="query", limit=5)
crw_map(url="https://docs.example.com", limit=200)MCP output bounds (defaults): content truncated to ~15,000 chars per call;
returns ≤ 100 URLs. Both carry when clipped. Pass
/ to opt out.
crw_maptruncated: truemaxLength: 0limit: 0Use MCP when: you're inside Claude Code, Cursor, Windsurf, or any harness that
manages MCP connections. Lower per-call overhead than REST for agent loops.
REST API (/v1/scrape
, /v1/search
, etc.)
/v1/scrape/v1/searchBest for application code, cross-language clients (Go, Java, Ruby), or when you
need a shared microservice. Firecrawl-compatible — SDK swap is one change.
api_urlpython
# Python SDK (pip install crw)
from crw import CrwClient
client = CrwClient(api_url="https://api.fastcrw.com", api_key="crw_live_...")
result = client.scrape("https://example.com", formats=["markdown"])
results = client.search("AI news", limit=10)
# Drop-in for Firecrawl SDK
from firecrawl import FirecrawlApp
app = FirecrawlApp(api_url="https://api.fastcrw.com", api_key="crw_live_...")Use REST when: writing application code, needing async crawl jobs with polling,
or integrating with frameworks like LangChain / CrewAI / LlamaIndex.
3. Post-filtering strategy stack
Raw web results carry noise. Apply these in order, stopping when you have enough
signal.
Layer 1: Rank/order-based triage (free)
The search backend's raw score is unreliable (engine-dependent, often null).
Position is the reliable signal — it reflects the aggregator's Reciprocal
Rank Fusion over N engines. Default: trust the top 3-5 results unless they're
obviously off-topic.
python
# Rely on position, not score
top = [r for r in results if r['position'] <= 5]Layer 2: Regex / keyword density filter (cheap)
Before fetching full pages, filter descriptions for relevance. Drop results whose
description doesn't contain any query-adjacent term.
python
keywords = {'commercializ', 'battery', 'production', '2025', '2026'}
relevant = [r for r in results
if any(kw in r['description'].lower() for kw in keywords)]After scraping full markdown, apply paragraph-level filtering:
python
for para in markdown.split('\n\n'):
if len(para) > 60 and any(kw in para.lower() for kw in keywords):
print(para)Layer 3: LLM verify (expensive — use sparingly)
When layers 1-2 aren't precise enough, send a small batch of candidate snippets to
a cheap model for binary relevance classification.
python
import anthropic
def is_relevant(snippet: str, query: str) -> dict:
"""Returns {is_match: bool, confidence: float, reasoning: str}"""
client = anthropic.Anthropic()
msg = client.messages.create(
model="claude-haiku-4-5", # cheap model for classification
max_tokens=128,
messages=[{
"role": "user",
"content": (
f"Query: {query}\n\n"
f"Snippet: {snippet[:500]}\n\n"
"Does this snippet directly answer or provide evidence for the query? "
"Reply with JSON only: {\"is_match\": true/false, \"confidence\": 0-1, "
"\"reasoning\": \"one sentence\"}"
)
}]
)
import json
return json.loads(msg.content[0].text)Gate: only call LLM-verify on snippets that passed layers 1-2. Don't send all
10 results through an LLM — pick the 3-5 most promising first.
4. Context-window hygiene
The single most important practice. See crw-dynamic-search
for the full pattern. Summary:
- Never pipe or
crw search --jsonbare into context. Always filter in a Python subprocess — only yourcrw scrape --format jsonoutput enters context.print() - Write large results to or
.crw/, not stdout. Use/tmp/then read selectively withcrw scrape -o .crw/page.jsonor a Python heredoc.grep - MCP truncation is your first line of defense (default ~15K chars). But don't rely on it alone — a 15K char page is still 3,500+ tokens.
- Target 150-600 tokens per source in your filtered output. If you're printing more from a single page, you're probably including boilerplate.
5. Self-hosted Hybrid RAG pattern
crw is optimized for the retrieve → filter → embed pipeline. Typical setup:
crw search "query" → top-N results (titles + snippets)
→ scrape top 3-5 full pages → filter to relevant paragraphs
→ embed filtered paragraphs → merge with local vector store
→ retrieve top-K chunks → feed to generation modelWhy crw for RAG:
- Search costs $0 per query (no per-call API fees)
- Recurring crawls use VPS cost, not per-page credits
- +
crw_crawlcan extract typed objects per page directly — skip the embed step for structured datajsonSchema
Python RAG skeleton:
python
from crw import CrwClient
client = CrwClient() # embedded mode, no server
def retrieve_and_chunk(query: str, top_n: int = 5) -> list[str]:
results = client.search(query, limit=top_n)
chunks = []
for r in results:
# Scrape full page if the snippet isn't sufficient
page = client.scrape(r['url'], formats=['markdown'])
md = page.get('markdown', '') or ''
# Split into paragraphs, keep non-trivial ones
for para in md.split('\n\n'):
para = para.strip()
if len(para) > 100:
chunks.append(para)
return chunksFor a local vector store (Chroma, Qdrant, pgvector): embed these chunks, upsert
with URL + position as metadata, then merge vector-store retrieval results with
fresh results at query time (hybrid retrieval).
crw search6. Common pitfalls
| Problem | Impact | Solution |
|---|---|---|
| Piping raw JSON into context | 50K-500K chars enters context; token waste, reasoning degradation | Always filter in a Python subprocess — see crw-dynamic-search |
Trusting | The search backend's scores are engine-dependent, often | Triage by |
| Crawling without mapping first | Committing to a 500-page crawl when you needed 20 pages | Always |
| JS rendering on every scrape | Unnecessary browser spawn on plain-HTML pages; slow | crw auto-detects SPAs — don't add |
| Blocking on crawl job poll | Agent hangs waiting for async crawl | Set a poll interval (5-10s), set |
Ignoring | Missing content from MCP calls; silent data loss | Check for |
Writing one-shot scripts to | Wasteful; file left behind | Use heredocs for one-shot filtering; only write data (JSON results) to |
Scraping | 403/empty response; wasted call | crw respects |
7. crw-specific operational awareness
Unlike credit-based APIs (Firecrawl, Tavily), crw's costs are infra-denominated.
The right mental model: you're paying for VPS time and renderer pool capacity, not
per-page fees.
Search backend rate limits and politeness
- Public instances rate-limit or block JSON requests — always use a local
instance (boots one via Docker).
crw setup --local - The self-hosted search backend has no built-in per-client rate limit, but the upstream engines (Google, Bing, DDG) do. Burst too hard and engines start returning 429s or CAPTCHAs to your instance.
- Practical safe rate: 2-4 searches/second burst, < 1/second sustained. Space parallel searches with a short sleep or process them in series.
- and
--category newsbypass the general engine pool — lighter on upstream rate limits.--time-range week
Renderer pool sizing
crw runs a renderer ladder per request (HTTP → LightPanda → Chrome by default; additional tiers such as playwright and chrome_proxy are available via config).
- HTTP tier is instant and stateless (no pool cost).
- LightPanda is lightweight (~50 MB) but single-process per binary instance. Under load, requests queue behind the LightPanda instance.
- Chrome (optional, ) is the stealth fallback. Each Chrome instance is ~200 MB RAM. Scale by running multiple Chrome instances or pointing at a remote CDP endpoint via
docker compose --profile heavyin your server config (the[renderer.chrome] ws_urlenv var is honored byCRW_CDP_URLin CLI mode only, not by server/MCP mode).crw scrape --js - If you see consistent p90 timeouts, you're likely hitting the renderer queue. Add more Chrome instances or switch to fast mode (LightPanda-only, lower recall but faster tail).
Proxy rotation
Self-hosted crw supports per-request BYOP (bring-your-own-proxy) via
(CLI) or / (MCP/REST). Rotation modes: ,
, .
--proxy URLproxyproxyRotationround_robinrandomsticky_per_host- LightPanda can't proxy — when a proxy is active, LightPanda is skipped (fail-closed). Only the HTTP and Chrome tiers route through the proxy.
- If using proxies for scraping targets that block cloud IPs, set
so sessions from the same domain always hit the same exit IP (avoids anti-bot CAPTCHA triggers from IP-hopping mid-session).
proxyRotation: "sticky_per_host" - Proxy rotation applies to ,
scrape, andcrawl— notmap(which goes to your local search backend, not directly to search engines).search
Managed vs self-hosted call-surface differences
| Feature | Self-hosted | Managed ( |
|---|---|---|
| Search | Requires a local search-backend sidecar | Included (managed backend) |
| Proxy pool | BYOP via config | Managed proxy network |
| Rate limiting | Token-bucket (configurable) | Per-plan limits; |
| Credits | N/A | 500 one-time lifetime free credits |
| AGPL obligation | Applies if you expose to third parties | Carve-out included |
8. Links
- Hub skill: crw
- Token-saving subprocess pattern: crw-dynamic-search
- REST API reference: https://docs.fastcrw.com/#rest-api
- Self-host guide: https://docs.fastcrw.com/#self-hosting
- Firecrawl compatibility matrix: in the repo
COMPATIBILITY-firecrawl.md - Benchmarks: https://fastcrw.com/benchmarks