Skip to main content

Overview

Preview session data in real-time without stopping the active session. Shows the last N network requests and console messages with optional filtering.

Syntax

bdg peek [options]

Options

--last
number
default:"10"
Number of items to show. Valid range: 1-1000.
bdg peek --last 50
--type
string
Filter network requests by resource type (comma-separated, case-insensitive).Valid types: Document, Stylesheet, Image, Media, Font, Script, TextTrack, XHR, Fetch, Prefetch, EventSource, WebSocket, Manifest, SignedExchange, Ping, CSPViolationReport, Preflight, FedCM, Other
bdg peek --type Document
bdg peek --type XHR,Fetch
bdg peek --type Script --last 100
--network
boolean
default:"false"
Show only network requests.
bdg peek --network
Deprecated in human-readable mode. Use bdg network list for enhanced filtering.
--console
boolean
default:"false"
Show only console messages.
bdg peek --console
--dom
boolean
default:"false"
Show DOM/A11y tree data (only available after session stops).
bdg peek --dom
DOM data is captured as a snapshot when the session ends. During a live session, this will show “(none)”.
--verbose
boolean
default:"false"
Use verbose output with full URLs and resource type information.
bdg peek --verbose
bdg peek -v --last 20
--follow
boolean
default:"false"
Watch for updates continuously (like tail -f). Updates every second.
bdg peek --follow
bdg peek -f --type XHR,Fetch
Press Ctrl+C to stop following.
--json
boolean
default:"false"
Output as JSON instead of human-readable format.
bdg peek --json
bdg peek --json | jq '.data.preview.data.network[0]'

Output Format

Human-Readable (Default)

Compact format (default):
NETWORK (3)
  DOC  200  https://example.com/
  XHR  200  /api/users
  SCR  200  /bundle.js

CONSOLE (2)
  [log]    User logged in
  [error]  Failed to load resource

Tip: Use --verbose for full URLs and resource types
Verbose format (--verbose):
NETWORK REQUESTS (3)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  [Document]   200  https://example.com/
  [XHR]        200  https://example.com/api/users
  [Script]     200  https://example.com/bundle.js

CONSOLE MESSAGES (2)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  [log]    User logged in
  [error]  Failed to load resource

JSON Format

Returns the complete session data structure:
{
  "version": "0.5.1",
  "success": true,
  "timestamp": "2025-11-06T12:00:00.000Z",
  "duration": 45230,
  "target": {
    "url": "http://localhost:3000",
    "title": "Example Page"
  },
  "data": {
    "preview": {
      "data": {
        "network": [
          {
            "requestId": "1234.1",
            "url": "https://example.com/",
            "method": "GET",
            "status": 200,
            "resourceType": "Document",
            "mimeType": "text/html"
          }
        ],
        "console": [
          {
            "type": "log",
            "text": "User logged in",
            "timestamp": 1699272000000,
            "args": []
          }
        ]
      }
    }
  }
}

Examples

Basic Usage

Preview last 10 items (default):
bdg peek
Show last 50 items:
bdg peek --last 50

Filter by Data Type

Show only network requests:
bdg peek --network
Show only console messages:
bdg peek --console

Filter by Resource Type

Show only Document requests (HTML pages):
bdg peek --type Document
Show API requests (XHR and Fetch):
bdg peek --type XHR,Fetch
Show scripts and stylesheets:
bdg peek --type Script,Stylesheet --last 100

Follow Mode

Watch for updates in real-time:
bdg peek --follow
Follow specific resource types:
bdg peek --follow --type XHR,Fetch
Follow with verbose output:
bdg peek --follow --verbose

JSON Output

Get JSON output for processing:
bdg peek --json
Extract specific fields with jq:
# Get all request URLs
bdg peek --json | jq -r '.data.preview.data.network[].url'

# Filter 404 errors
bdg peek --json | jq '.data.preview.data.network[] | select(.status == 404)'

# Count console errors
bdg peek --json | jq '[.data.preview.data.console[] | select(.type == "error")] | length'

Resource Type Filtering

The --type flag filters network requests by Chrome DevTools Protocol resource type:
TypeDescriptionExample URLs
DocumentHTML pages/, /about, /products
StylesheetCSS files/styles.css, /theme.css
ScriptJavaScript files/bundle.js, /app.js
XHRXMLHttpRequestAPI calls via XHR
FetchFetch APIAPI calls via fetch()
ImageImages/logo.png, /photo.jpg
FontWeb fonts/font.woff2, /icons.ttf
MediaAudio/video/video.mp4, /audio.mp3
WebSocketWebSocket connectionswss://api.example.com
Resource types are case-insensitive. Both --type xhr and --type XHR work.

Exit Codes

0
SUCCESS
Command completed successfully.
81
INVALID_ARGUMENTS
Invalid option value (e.g., --last 2000 exceeds max of 1000).Common causes:
  • --last value outside range 1-1000
  • Invalid resource type in --type
  • Conflicting options
83
RESOURCE_NOT_FOUND
No active session found.Solution: Start a session first with bdg <url>
101
CDP_CONNECTION_FAILURE
Cannot connect to daemon.Solution: Check session status with bdg status

Tips

Use bdg peek --follow --type XHR,Fetch to watch API calls in real-time during development.
Combine --verbose with --type Document to debug CSP headers: bdg peek --verbose --type Document
The --last validation limit of 1000 prevents excessive memory usage. For larger datasets, use bdg stop to write the full session to ~/.bdg/session.json.

Build docs developers (and LLMs) love