Skip to content
Back to skills

Brave Headless

ASecurity

Headless web search and content extraction via the Brave Search API.

  • 16 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added June 7, 2026
documentationbashnodegitapidocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 14 files and shows the line behind each finding

Scanned June 7, 2026

npx -y skills add modbender/skill-library-mcp --skill brave-headless --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Brave Headless?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Brave Headless
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/modbender-brave-headless/badge)](https://www.skillsdirectory.com/skills/modbender-brave-headless)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: brave-headless
description:
  Headless web search and content extraction via the Brave Search API.
  Features exponential-backoff retry, circuit breaker fault isolation, bounded-concurrency
  parallel page fetching, structured leveled logging, and smart paragraph-boundary truncation.
  No browser required. Use for web research, documentation lookup, URL content extraction,
  and any workflow requiring scriptable, non-interactive web search.
version: 0.2.0
license: MIT
compatibility: Requires Node.js >= 20 and npm. Works on macOS and Linux.
metadata:
  author: kelexine
  homepage: https://github.com/kelexine/brave-headless
  openclaw:
    requires:
      env:
        - BRAVE_API_KEY
      bins:
        - node
        - npm
    primaryEnv: BRAVE_API_KEY
    emoji: "πŸ”"
    homepage: https://github.com/kelexine/brave-headless
    os:
      - macos
      - linux
    install:
      - kind: node
        package: "@mozilla/readability"
        bins: []
      - kind: node
        package: jsdom
        bins: []
      - kind: node
        package: turndown
        bins: []
      - kind: node
        package: turndown-plugin-gfm
        bins: []
---

# brave-search

Headless web search and content extraction via the Brave Search API.

## Setup

Run once before first use:

```bash
cd <skill-root>
npm ci
```

Required environment variable:

```bash
export BRAVE_API_KEY="your-key-here"
```

Get a free API key at [brave.com/search/api](https://brave.com/search/api).

## Usage

### Search

```bash
node scripts/search.js "query"                        # Basic (5 results)
node scripts/search.js "query" -n 10                  # Up to 20 results
node scripts/search.js "query" --content              # Include page content
node scripts/search.js "query" -n 3 --content         # Combined
node scripts/search.js "query" --json                 # Newline-delimited JSON
node scripts/search.js --help                         # Full options + env vars
```

### Extract page content

```bash
node scripts/content.js https://example.com/article
node scripts/content.js https://example.com/article --json
node scripts/content.js https://example.com/article --max-length 8000
```

## Output format (plain text)

```
--- Result 1 ---
Title:   Page Title
URL:     https://example.com/page
Snippet: Description from Brave Search
Content:
  # Page Title

  Extracted markdown content...

--- Result 2 ---
...
```

Pass `--json` to get one JSON object per line instead, suitable for piping.

## Exit codes

| Code | Meaning                                          |
|------|--------------------------------------------------|
| `0`  | Success                                          |
| `1`  | Invalid input or configuration error             |
| `2`  | Page had no extractable content (`content.js`)   |
| `130`| Interrupted (SIGINT)                             |

## Configuration (environment variables)

All behaviour is configurable without touching code:

| Variable               | Default  | Description                                    |
|------------------------|----------|------------------------------------------------|
| `BRAVE_API_KEY`        | β€”        | **Required.** Brave Search subscription token  |
| `LOG_LEVEL`            | `info`   | `debug` Β· `info` Β· `warn` Β· `error` Β· `silent` |
| `LOG_JSON`             | `false`  | Emit logs as newline-delimited JSON to stderr  |
| `FETCH_TIMEOUT_MS`     | `15000`  | Per-page fetch timeout                         |
| `SEARCH_TIMEOUT_MS`    | `10000`  | Brave API call timeout                         |
| `MAX_CONTENT_LENGTH`   | `5000`   | Max chars of extracted content                 |
| `MAX_RETRY_ATTEMPTS`   | `3`      | Retry attempts on transient errors             |
| `RETRY_BASE_DELAY_MS`  | `500`    | Base delay for exponential backoff             |
| `RETRY_MAX_DELAY_MS`   | `30000`  | Backoff delay cap                              |
| `CONCURRENCY_LIMIT`    | `3`      | Parallel page fetches when `--content` is set  |
| `CB_FAILURE_THRESHOLD` | `5`      | Consecutive failures before circuit opens      |
| `CB_RESET_TIMEOUT_MS`  | `60000`  | Circuit breaker reset window                   |

All variables are validated at startup β€” misconfigured runs fail immediately with a descriptive
list of every bad value rather than crashing mid-execution.

## Architecture

See [`references/ARCHITECTURE.md`](references/ARCHITECTURE.md) for a full module breakdown.

```
scripts/
β”œβ”€β”€ search.js            ← Search CLI entry point
β”œβ”€β”€ content.js           ← Content extraction CLI entry point
β”œβ”€β”€ content-fetcher.js   ← HTTP fetch + Readability + DOM fallback
β”œβ”€β”€ config.js            ← Schema-validated env config
β”œβ”€β”€ circuit-breaker.js   ← Fault isolation (CLOSED β†’ OPEN β†’ HALF_OPEN)
β”œβ”€β”€ retry.js             ← Exponential backoff with full jitter
β”œβ”€β”€ concurrency.js       ← Bounded parallel execution pool
β”œβ”€β”€ utils.js             ← htmlToMarkdown, smartTruncate, parseURL
β”œβ”€β”€ logger.js            ← Structured leveled logger β†’ stderr
└── errors.js            ← Typed error hierarchy
```

Files in this skill

  • ARCHITECTURE.md5.7 KB
  • SKILL.md5.2 KB
  • package-lock.json20.7 KB
  • package.json539 B
  • scripts/circuit-breaker.js3.2 KB
  • scripts/concurrency.js2.5 KB
  • scripts/config.js4.5 KB
  • scripts/content-fetcher.js6.2 KB
  • scripts/content.js4 KB
  • scripts/errors.js2.5 KB
  • scripts/logger.js2.5 KB
  • scripts/retry.js2.6 KB
  • scripts/search.js7.6 KB
  • scripts/utils.js4.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.