📡 scanr

A fast, deterministic static-analysis and search CLI for TypeScript and JavaScript projects. scanr is a single local binary: it needs no database, network access, service, or API key.
Features
- Structural analysis — extract functions, captures, bindings, references, exports, and rule violations with oxc
- File outline — every file's nested declarations: what lives inside what, wrapped functions, re-exports
- Role drift — files grouped by name suffix, with the ones that break their group's pattern
- Dependency graph — each file's imports resolved to project files, and its importers
- Outline diff — declarations added, removed, renamed, moved, or changed since a Git base
- Name inventory and refs — folder-level name lists, then declaration usage sites
- Type-accurate rename — rewrite a symbol and its TypeScript-resolved usages (requires bun or node)
- Content and path search — gitignore-aware, parallel grep with stable JSON output
- Similarity detection — APTED-based function and type comparison, including type literals
- Slop review signals — evidence-backed exact, contextual, test-theater, and opt-in diff findings
- Dead factory members — unused members of factory-returned service objects, with an opt-in TypeScript-checked mode
- Project tree — compact repository structure for quick orientation
- Project xray — one-page overview of shape, hotspots, slop, and duplicates
- Agent-friendly — deterministic output suitable for scripts and coding agents
Install
brew install nikuscs/tap/scanr
Or with Cargo:
cargo install --git https://github.com/nikuscs/scanr
Or build from source with Rust 1.95+:
git clone https://github.com/nikuscs/scanr
cd scanr
cargo build --release
Quick start
scanr search "useState" --root . --json
scanr scan --root . --mode outline
scanr scan --root . --mode inventory
scanr refs Card --root .
scanr rename Card ProfileCard --root .
scanr dupes --root . --types
scanr slop --root .
scanr tree --root .
scanr tree --root . --outline
scanr roles --root .
scanr deps --root . --path src/commands
scanr diff --base main
scanr xray --root .
Commands
scanr search
Search file contents with a literal pattern:
scanr search "useState"
scanr search "todo" --ignore-case --glob '*.ts' --context 2
scanr search "handler" --max-count 5 --json
Search paths instead of contents:
scanr search --path "components"
scanr search --path '*.test.ts'
The walker respects .gitignore. Results are sorted by path and line, including when files are searched in parallel.
Search flags:
--root <path> — search root (default .)
--path <pattern> — search paths instead of contents; accepts substrings, *, and ?
-i, --ignore-case — ASCII case-insensitive matching
--glob <pattern> — gitignore-style path filter; repeatable
--max-count <n> — maximum matching lines per file
--context <n> — lines before and after each match (default 0)
--json — emit [{path,line,text,before,after}]
scanr scan
Extract TypeScript and JavaScript structure. For agents, start with a name inventory, then use compact/verbose when you need lines, captures, or rules:
scanr scan --mode outline
scanr scan --mode outline --deep
scanr scan --mode outline --signatures --exported
scanr scan --mode inventory
scanr scan --mode inventory --lines
scanr scan
scanr scan --root apps/web --mode verbose
scanr scan --file src/index.ts
scanr scan --mode files
scanr scan --mode folders
scanr scan --rules hoistable_nested_function
--mode outline emits {files:[{file,lines,symbols,reexports}]}: each file's declarations as a tree. A symbol is {name,kind,line,endLine} plus via (the callee that produced it, such as Effect.fn or new Map), extends, exported, exportedAs (public names that differ from name, such as default), exposedAs, and children. Kinds are function, const, let, var, class, method, getter, setter, constructor, property, interface, type, enum, enumMember, and namespace. reexports rows are {from,names}, {from,all} for export *, and {from,all,namespace} for export * as.