Skip to main content
Search macros are URL shortcuts that expand search queries into full URLs for popular sites. Instead of manually constructing search URLs with proper encoding, use macros like @google_search or @youtube_search.

What are search macros?

Macros simplify navigation by handling URL construction and query encoding:
Both produce identical results, but macros eliminate manual encodeURIComponent() calls and URL structure knowledge.

Why macros exist

From practical experience building AI browser agents:
  1. Avoid encoding bugs: LLMs frequently forget to encode special characters (spaces, &, #, etc.)
  2. Site-specific URL structures: Each site has different query param names (q=, search_query=, keywords=)
  3. API format changes: When Reddit switches from HTML to JSON, only the macro needs updating
  4. Prompt brevity: Shorter tool calls = more context for reasoning
Macros are optional - you can always use the url parameter directly if you prefer full control.

Complete macro list

From lib/macros.js:1-16, here are all 14 supported macros:

Usage in navigate endpoint

From server.js:872-934, the navigate endpoint accepts both url and macro:
Server-side expansion:
Macro takes precedence - if both macro and url are provided, macro is used and url serves as fallback.

Real expansion examples

Input:
Expands to:
Input:
Expands to:
Input:
Expands to:
Input:
Expands to:
Input:
Expands to:

Reddit JSON behavior

Reddit macros return JSON instead of HTML, enabling direct parsing without snapshot/scraping.
From lib/macros.js:5:
Example:
Returns raw JSON response:

@reddit_subreddit

From lib/macros.js:6:
Fetch hot posts from a subreddit:
Expands to:
Returns JSON listing of top 25 posts in r/programming.
Use page.evaluate() to extract specific fields from the JSON instead of parsing the entire snapshot.

Implementation details

Macro expansion function

From lib/macros.js:18-21:
  • Returns null if macro doesn’t exist (triggers fallback to url parameter)
  • Query defaults to empty string if undefined
  • Uses native encodeURIComponent() for safety

Available macros lookup

From lib/macros.js:23-25:
For programmatic discovery:

Special characters handling

Macros automatically handle special characters:

Spaces

Ampersands

Unicode

Quotes

Error handling

Unknown macro

If macro doesn’t exist:
Behavior: Falls back to url parameter. If no url provided, returns error: “url or macro required”.

Empty query

From lib/macros.js:2:
Empty queries are allowed:
This navigates to the search homepage.

Workflow examples

Multi-site research

E-commerce price comparison

Social media monitoring

Adding custom macros

Custom macros require modifying lib/macros.js - there’s no runtime registration API.
To add a new macro:
  1. Edit lib/macros.js:
  1. Restart server:
  1. Use new macro:

Performance notes

Macro expansion cost

Macro expansion is synchronous and lightweight:
No measurable performance impact compared to direct URL usage.

Reddit JSON performance

JSON responses are typically faster than HTML:
  • Smaller payload (25 posts ≈ 50KB JSON vs 500KB+ HTML)
  • No need to wait for page hydration
  • Direct parsing without accessibility tree traversal
For Reddit data extraction, always use @reddit_search or @reddit_subreddit macros to get JSON directly.

Debugging

See expanded URL

Check server logs for expanded URL:

List all macros

From AGENTS.md:87-100:
Or programmatically: