Firecrawl CLI

repository·main·Indexed 19 days ago

https://github.com/firecrawl/cli

Command-line interface for Firecrawl version 1.19.29, enabling users and AI coding agents to scrape, crawl, search, and extract structured data from websites directly from the terminal. It includes specialized tools for AI agent integration (MCP, skills, and workflows), a developer-focused search index, autonomous AI-powered extraction via the `agent` command, and page monitoring for change detection.

Tokens
53.4K
Snippets
183
Records
229
Agent score
64%

What's inside firecrawl-cli

  1. Best practices for using firecrawl scrape

    main

    To get the most out of the firecrawl scrape command, follow these recommendations:

    • Prefer plain scrape over --query: It is often more efficient to scrape the page to a file and then use local tools like grep or an LLM to reason over the full markdown content. This avoids the 5-credit cost of --query.
    • Scrape before Interact: Use scrape for static or JS-rendered content. Only escalate to the interact command if you need to perform actions like clicking buttons, filling forms, or handling pagination.
    • Quote your URLs: Always wrap URLs in quotes (e.g., "<url>") in your terminal to prevent the shell from misinterpreting special characters like ? or &.
    • Concurrency: Multiple URLs are processed concurrently. You can check your current concurrency limit using firecrawl --status.
    • Naming Convention: When saving files, a common pattern is .firecrawl/{site}-{path}.md.
  2. How Agent Harnesses are scoped

    main

    When using firecrawl setup commands, you can target specific AI coding agents using the --agent flag. If no flag is provided, the CLI attempts to install to all detected harnesses.

    | Harness      | `--agent` value  |
    | ------------ | ---------------- |
    | Claude Code | `claude-code`    |
    | Codex        | `codex`          |
    | Cursor       | `cursor`         |
    | Windsurf     | `windsurf`       |
    | OpenCode     | `opencode`       |
    | OpenClaw     | `openclaw`       |
    | OpenHands    | `openhands`      |
    | Hermes Agent | `hermes-agent`   |
  3. How Firecrawl monitors work

    main

    Firecrawl monitors detect content changes on websites and provide notifications via webhooks or email. They eliminate the need for manual cron jobs, scrapers, or diffing scripts.

    Monitors are divided into two main types:

    1. Page Monitors: Watch specific URLs (single pages, batches of URLs, or entire sites via crawling) for changes.
    2. Web Monitors: Watch the entire web for new results matching a specific goal using search queries. These do not watch a fixed URL but alert you when new, relevant content is discovered via search.

    Each page in a check is assigned a status: same, new, changed, removed, or error. An AI judge uses the provided --goal to filter out noise like whitespace, formatting, or tracking parameters, ensuring notifications only trigger on substantive content changes.

  4. Determine the correct Firecrawl workflow

    main

    Firecrawl provides different commands based on your starting point and end goal. Follow this escalation pattern to choose the right tool:

    1. Search: Use when you have no specific URL and need to find pages or answer questions.
    2. Scrape: Use when you have a specific URL and want to extract its content (static or JS-rendered).
    3. Map + Scrape: Use map --search to find specific subpages within a site, then scrape them.
    4. Crawl: Use for bulk content extraction from an entire site section (e.g., all /docs/ pages).
    5. Monitor: Use for recurring checks or ongoing alerts (e.g., tracking pricing or job boards). Prefer monitor over repeated one-off scrapes.
    6. Interact: Use scrape + interact when the page requires clicks, form fills, pagination, or multi-step navigation.

    Key Distinctions:

    • Scrape vs. Interact: Use scrape for standard pages. Use scrape + interact only if you need to perform browser actions like clicking buttons or handling infinite scroll. Never use interact for web searches; use search instead.
    • Monitor: Use monitor for ongoing change detection. It compares results against snapshots and can trigger webhooks or emails.
    | Need                        | Command               | When                                                      |
    | --------------------------- | --------------------- | --------------------------------------------------------- |
    | Find pages on a topic       | `search`              | No specific URL yet                                        |
    | Get a page's content        | `scrape`              | Have a URL, page is static or JS-rendered                 |
    | Find URLs within a site     | `map`                 | Need to locate a specific subpage                         |
    | Bulk extract a site section | `crawl`               | Need many pages (e.g., all /docs/)                        |
    | AI-powered data extraction | `agent`               | Need structured data from complex sites                   |
    | Interact with a page        | `scrape` + `interact` | Content requires clicks, forms, pagination, or login     |
    | Download a site to files    | `download`            | Save an entire site as local files                        |
    | Parse a local file          | `parse`               | File on disk (PDF, DOCX, XLSX, etc.) — not a URL          |
    | Watch pages for changes     | `monitor`             | Schedule recurring scrapes/crawls, diff against snapshots |
  5. Best practices for using the firecrawl agent

    main

    To get the most out of the firecrawl agent, follow these tips:

    • Use --wait: Always include the --wait flag to receive results directly in your terminal/output. If you omit it, the command will only return a job ID.
    • Use --schema: For predictable, structured output, always provide a schema. Without it, the agent returns freeform data.
    • Manage costs: Agent runs consume more credits than simple scrapes. Use --max-credits <n> to cap your spending for a specific run.
    • Choose the right tool: For simple single-page extraction, prefer scrape—it's faster and cheaper.
  6. Pattern: Map then Scrape

    main

    A common and effective pattern is to use map --search to identify the exact URL you need, and then use the scrape command on that specific URL. This avoids wasting resources scraping irrelevant pages.

    Example Workflow:

    1. Run firecrawl map https://docs.example.com --search "auth".
    2. Identify the correct URL from the results (e.g., /docs/api/authentication).
    3. Run firecrawl scrape on that specific URL.
    # Step 1: Find the URL
    firecrawl map https://docs.example.com --search "auth"
    
    # Step 2: Scrape the discovered URL
    firecrawl scrape https://docs.example.com/docs/api/authentication
  7. Handle Scrape Output (Stdout, Files, and Formats)

    main

    Firecrawl allows you to direct output to different destinations and formats:

    • Stdout (Default): Output is printed directly to the terminal.
    • Save to File: Use the -o <filename> flag to save output to a file.
    • JSON/Multiple Formats:
      • If you specify a single format (e.g., --format markdown), the CLI outputs the raw content.
      • If you specify multiple formats (comma-separated, e.g., --format markdown,links), the CLI outputs a JSON object containing all requested data.
    • Pretty Print: Use the --pretty flag with JSON output for better readability.
    # Output to stdout (default)
    firecrawl https://example.com
    
    # Pipe to another command
    firecrawl https://example.com | head -50
    
    # Save to file
    firecrawl https://example.com -o output.md
    
    # JSON output with multiple formats
    firecrawl https://example.com --format markdown,links,images
  8. Verify Firecrawl setup with a test scrape

    main

    Once installed, verify your configuration by performing a small test request. It is recommended to output the result to a file to ensure write permissions and output handling are working correctly.

    Run the following command to scrape the Firecrawl website into a local directory:

    mkdir -p .firecrawl
    firecrawl scrape "https://firecrawl.dev" -o .firecrawl/install-check.md
  9. Use the firecrawl download command

    main

    The firecrawl download command is an experimental convenience tool that combines map and scrape operations to save an entire website as local files. It first maps the site to discover all pages and then scrapes each page into organized, nested directories under .firecrawl/.

    Note: Always pass the -y flag to skip the confirmation prompt, especially in automated workflows or scripts.

    firecrawl download https://docs.example.com -y
  10. Use firecrawl map to discover URLs

    main

    The firecrawl map command is used to discover and list URLs on a website. It is particularly useful for finding specific subpages on large sites or obtaining a full list of URLs before performing a scrape or crawl.

    Common use cases include:

    • Finding a specific page on a large site using the --search filter.
    • Listing all URLs on a site to understand its structure.
    • Preparing for a workflow escalation pattern: searchscrapemapcrawlinteract.
    # Find a specific page on a large site
    firecrawl map "<url>" --search "authentication" -o .firecrawl/filtered.txt
    
    # Get all URLs
    firecrawl map "<url>" --limit 500 --json -o .firecrawl/urls.json
  11. Set Firecrawl as the default web provider for AI agents

    main

    You can make Firecrawl the default web provider for supported AI agents. This disables the agent's native web fetch/search capabilities and routes all web work through Firecrawl.

    Use firecrawl setup defaults to apply this. You can use -y to apply to all harnesses or --agent <agent> to target a specific one. Use --undo to restore original settings.

    # Make Firecrawl default for all harnesses (non-interactive)
    firecrawl setup defaults -y
    
    # Make Firecrawl default for only Codex
    firecrawl setup defaults --agent codex
    
    # Undo changes for a specific agent
    firecrawl setup defaults --undo --agent claude
  12. Parallelize Firecrawl operations

    main

    You can run multiple independent Firecrawl operations in parallel using shell backgrounding. Before doing so, check your concurrency limit using firecrawl --status.

    # Run multiple scrapes in parallel and wait for completion
    firecrawl scrape "<url-1>" -o .firecrawl/1.md &
    firecrawl scrape "<url-2>" -o .firecrawl/2.md &
    firecrawl scrape "<url-3>" -o .firecrawl/3.md &
    wait