Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI Reference

This page documents all prx subcommands, flags, and arguments. Flags and behavior may change between minor versions. Use prx --version and the JSON output version field for programmatic detection.

Global Flags

These flags apply to all subcommands.

FlagDescription
--jsonJSON output (default)
--plainHuman-readable plain text output
--budget NMaximum tokens in response (default: unlimited)
--versionPrint version and exit
--helpPrint help and exit
-q, --quietSuppress non-essential output

Exit Codes

CodeMeaning
0Success
1Error (details in stdout JSON)
2Usage error (invalid arguments)

Search the codebase by query.

prx search <query> [path]
ArgumentDescription
querySearch query (required)
pathRoot path to search (default: .)
FlagDescription
--literalForce literal/regex matching
--semanticForce semantic search
--structuralForce ast-grep structural matching
--mode hybrid|semantic|bm25|literal|structuralExplicit mode selection (default: auto-detect)
--top-k NNumber of results (default: 5)
--budget NToken budget for results
--context function|class|block|noneReturn enclosing structural unit (default: none)
--existsBloom filter quick check — returns {"exists": true/false} only
--continue TOKENResume paginated results
--alpha FLOATOverride RRF alpha weight (0.0 = pure BM25, 1.0 = pure semantic)

Auto-detection: when no mode flag is provided, the query is classified automatically. Fewer than 3 tokens or regex metacharacters → --literal. Contains $VAR-style metavariables → --structural. Otherwise → --semantic.


prx read

Read file content with optional range and structural expansion.

prx read <file> [flags]
ArgumentDescription
fileFile path (required)
FlagDescription
--lines START-ENDLine range, 1-indexed, inclusive
--snap function|class|blockExpand range to enclosing structure
--skeletonReturn signatures, types, and exports only
--outlineReturn symbol table (name, kind, line range, signature)
--hashReturn content hash only (for change detection)
--if-changed HASHReturn 48-token stub if file hash matches (skip re-read)
--mode aggressive|diff|entropyContent reduction mode
--budget NMaximum tokens of file content
--metaInclude file metadata (language, lines, bytes, modified timestamp)

Read modes:

  • --mode aggressive — strip comments and collapse blank lines (1-19% savings)
  • --mode diff — changed lines vs git HEAD only (80-97% savings on modified files)
  • --mode entropy — filter repetitive/generated code (5-87% savings)

prx find

List and filter files in the workspace.

prx find [path] [flags]
ArgumentDescription
pathRoot path (default: .)
FlagDescription
--pattern GLOBFilter by glob pattern (e.g., *.ts)
--depth NMaximum directory depth (default: unlimited)
--related-to QUERYSemantic relevance scoring for files
--changed-since REFFiles modified since git ref or timestamp
--outlineInclude per-file symbol counts
--treeTree output only (no flat list)
--flatFlat list only (no tree)
--budget NToken budget

prx edit

Find and replace content in a file. Dry-run by default.

prx edit <file> --find STRING --replace STRING [flags]
ArgumentDescription
fileFile path (required)
FlagDescription
--find STRINGText to find (literal by default)
--replace STRINGReplacement text
--regexInterpret --find as regex
--applyApply changes to file (default: dry-run preview)
--in-function NAMEScope replacement to named function
--in-class NAMEScope replacement to named class
--allReplace all occurrences (default: first only)
--syntax-checkValidate syntax after edit (default: true)

--find and --replace can be specified multiple times. All replacements are applied atomically.


prx diff

Show git diffs with token-aware truncation.

prx diff [file] [flags]
ArgumentDescription
fileFile path (optional, default: all changed files)
FlagDescription
--since REFCompare against git ref (default: HEAD)
--stagedCompare staged changes
--stat-onlySummary and stats only (~30 tokens)
--budget NToken budget for hunks
--functionsGroup hunks by function

prx index

Build or update the search index.

prx index [path] [flags]
ArgumentDescription
pathRoot path to index (default: .)
FlagDescription
--watchWatch for file changes and re-index
--rebuildForce full re-index
--statsPrint index statistics

The index is written to .prx/index/. Subsequent searches use the cached index automatically.


prx outline

Print the symbol table for a file or directory.

prx outline <file|dir> [flags]
ArgumentDescription
file|dirFile or directory path (required)
FlagDescription
--depth NFor directories, max depth
--kind function|class|method|allFilter by symbol kind

prx exists

Probabilistic existence check for a pattern.

prx exists <pattern> [path]
ArgumentDescription
patternPattern to check (required)
pathRoot path (default: .)

Returns {"exists": true/false, "confidence": "exact"|"probable"}.

Uses a bloom filter for O(1) probable check. Falls back to literal search for exact confirmation when --exact is passed.


prx run

Run a command and return structured output with only actionable items.

prx run <command> [flags]
ArgumentDescription
commandCommand to run (required, captures all remaining args)
FlagDescription
--rawBypass parsing, return full output
--fullReturn parsed summary AND full output
--auto-jsonInject JSON flags for tools that support structured output
--budget NToken budget for output
--timeout NCommand timeout in seconds (default: 300)

Auto-detects the tool from the command string and applies tool-specific parsing. Unknown commands fall back to exit code + last N lines. See Run Parsers for the full parser catalog.


prx batch

Execute multiple commands in parallel from stdin.

prx batch

Reads JSONL from stdin. Each line is a command object. Executes commands in parallel. Writes JSONL to stdout, one result per line, in input order.

Input format:

{"cmd": "search", "query": "auth", "budget": 300}
{"cmd": "read", "file": "src/auth.ts", "id": "q2"}

The optional "id" field is echoed in the output line for request correlation.


prx context

Assemble a context package for a module or directory.

prx context <path> [flags]

Returns stats, documentation, entrypoints, file skeletons, and 1-hop import edges in a single call. Uses the symbol index for entrypoint ranking.


prx impact

Reverse dependency analysis.

prx impact <file> [flags]
FlagDescription
--symbol NAMENarrow analysis to a specific symbol

Walks the import graph backwards to find all files that depend on the given file or symbol.


prx mcp

Start the MCP server on stdio.

prx mcp

No arguments. Exposes all prx tools as MCP tools. Designed for agent framework integration. See the integration guide for configuration.


prx init

Generate integration files for agent frameworks.

prx init [flags]
FlagDescription
--agent FRAMEWORKTarget framework: claude-code, cursor, codex, opencode, all
--agents-mdAppend prx usage snippet to AGENTS.md in current directory

Without flags, auto-detects installed frameworks and writes appropriate configs.

FrameworkFile WrittenContent
Claude Code.claude/agents/ag-search.mdDedicated search sub-agent definition
Claude CodeRuns claude mcp add agMCP server registration
Cursor.cursor/mcp.jsonMCP server entry
Codex~/.codex/config.tomlMCP server entry
OpenCode~/.opencode/config.jsonMCP server entry
AnyAppends to AGENTS.mdUsage snippet with workflow guidance

prx stats

Print token savings dashboard.

prx stats [flags]
FlagDescription
--verbosePer-command breakdown
--resetClear saved statistics

Environment Variables

VariableDefaultDescription
PRX_MAX_FILE_SIZE1MBMaximum file size to process
PRX_CHUNK_SIZE1500Chunk target in characters
RUST_LOGDebug logging level (output goes to stderr)

Ignore Files

prx respects .gitignore by default. Add a .prxignore file alongside .gitignore for prx-specific exclusions. The format is identical to .gitignore.