Skip to content

egrm/sx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sx - Agent-optimized SearXNG CLI

A minimal CLI that wraps SearXNG's search API. Designed for LLM agents (Claude Code, etc.) but works fine for humans too.

  • Markdown bullets by default, source, title, and summary without JSON noise
  • --json flag for structured output when needed
  • Single binary, zero dependencies (Go stdlib only)

Prerequisites

Install

go install github.com/stardust/sx@latest

Or build from source:

git clone https://github.com/stardust/sx
cd sx
go build -o sx .
cp sx ~/.local/bin/

Setup

Point sx at your SearXNG instance:

# Option 1: Environment variable (recommended for agents)
export SX_URL=https://your-searxng-instance.com

# Option 2: Config file
sx config set url https://your-searxng-instance.com

SX_URL takes priority over the config file.

Usage

Search

Search is the default action, no subcommand needed.

sx "rust async patterns"                    # basic search
sx "query" -n 5                             # limit results
sx "query" -e google                        # specific engines
sx "query" -c news                          # news category
sx "query" -t week                          # last week only
sx "query" -l en                            # English results
sx "query" -p 2                             # page 2
sx "site:github.com searxng" -e google      # site-scoped

Flags

Flag Description Default
-n Max results 10
-e Engines (comma-separated) instance default
-c Category general
-l Language code instance default
-p Page number 1
-t Time range: day, week, month, year none
-s Safe search: 0/1/2 0
--json JSON output off
--human Alias for default Markdown output off

Output

Markdown bullets to stdout by default.

$ sx "test" -n 2
- [Test Result Title](https://example.com)
  example.com | published: 2026-03-30
  Description of the result...

- [Another Result](https://example.org)
  example.org
  Another description...

Use --json for compact structured output.

$ sx "test" -n 2 --json
{"query":"test","results":[{"url":"https://...","title":"...","content":"...","engines":["google","brave"],"score":4.0},{"url":"https://...","title":"...","content":"...","engines":["duckduckgo"],"score":2.5}],"suggestions":["related query"]}

Each result contains only what matters:

Field Description
url The link
title Page title
content Snippet / abstract
engines Which engines found it
score Composite relevance score
published Publish date (omitted if unavailable)

Top-level response also includes answers (direct answers), suggestions (related queries), and corrections (spelling fixes), all omitted when empty.

--human remains available as an alias for the default readable output:

$ sx "test" -n 2 --human
- [Test Result Title](https://example.com)
  example.com
  Description of the result...

- [Another Result](https://example.org)
  example.org
  Another description...

Suggestions: related query, another suggestion

Subcommands

sx engines                          # list available search engines
sx categories                       # list available categories
sx config                           # show current config
sx config set url <url>             # set SearXNG instance URL
sx help                             # full command reference

For LLM Agents

sx is designed for agent consumption:

  • Markdown by default - directly readable by humans and agents
  • JSON on demand - use --json when structured output is actually needed
  • Only useful fields - url, title, content, engines, score, published. No template names, parsed URLs, image placeholders, or other noise from the raw SearXNG response.
  • Direct answers - factual queries return an answers array (e.g. "speed of light = 299,792,458 m/s")
  • Structured errors - {"error":"message"} to stderr, exit code 1
  • Suggestions - related queries for follow-up searches

Testing

Requires a running SearXNG instance:

export SX_URL=https://your-instance.com
bash test.sh

License

MIT

About

Agent-optimized SearXNG CLI — compact JSON output for LLM agents, zero dependencies

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages