AST-aware code search for agents and developers

Find code evidence, map relationships, and return structured results.

lmprobe is a one-shot CLI for structural search, symbol context, history, impact graphs, safe mutations, GraphQL composition, and evidence-first security scans.

lmprobe converts repository input into search, graph, history, mutation, and scanner envelopes.
Search a symbol lmprobe def --body handle_request src/service.ts
Map impact lmprobe --format mermaid impact UserService --depth 3 .
Review PR signals lmprobe pr-triage --since all https://github.com/owner/repo/pull/123
Compose queries lmprobe query @investigate.graphql --var name='"User"'

Chapter 1

Install And First Run

Install once from npm for repeated agent loops, then run one-off or scripted inspections against any repository path.

Install the CLI

npm install -g @lmctl-ai/lmprobe
lmprobe --help

The npm package exposes the same command surface as the manual. Repeated runs are fastest with npm install -g @lmctl-ai/lmprobe; use npx only for one-off execution because it re-resolves each time and can add seconds per invocation. The homepage is lmctl.com/lmprobe.

First run from an installed CLI

lmprobe --version
lmprobe --format json search --name HandleRequest .

Start with a read-only search. Add query and mutation commands as your workflow needs grow.

Exit model: 0 means matched, 1 means no clean match, and 2 means a diagnostic error or safety refusal.

Chapter 3

Graph And Context Commands

Relationship verbs answer questions about callers, callees, imports, exports, decorators, inheritance, impact, and symbol context. These verbs are call/symbol graph focused and currently do not model framework dependency wiring (for example Angular providers/modules or Spring autowire/scope annotations).

Call relationships

lmprobe callers Pattern .
lmprobe callees run .

Module edges

lmprobe imports react .
lmprobe exports useState .

Impact graph

lmprobe --format mermaid impact Pattern --depth 3 .

One-shot symbol context

context bundles the first definition, one-hop callers/callees, imports from the defining file, recent history, TODO markers, and a file outline.

lmprobe --format json context --around 3 UserService .
lmprobe --format json context --usage UserService src/app.ts --parents
lmprobe --format json context --import-aware UserService src/app.ts

For framework DI/module registration paths, use ref and grep --parents --body as fallback evidence (for example SessionSyncInterceptor) before switching to graph verbs for call-surface follow-up.

Chapter 4

History And Change Evidence

History commands use Git evidence to explain where a symbol came from, how a file changed, and which files tend to move together.

Blame lmprobe history blame Pattern .
Introduced lmprobe history introduced Pattern .
Diff lmprobe history diff -p 'auth|login' --since 30d .
Co-change lmprobe history co-change src/auth.ts --top 10 .
AST diff lmprobe ast-diff --from HEAD~1 --to HEAD src/service.ts

Chapter 5

Safe Mutations

Mutation verbs are deliberately conservative. Start with dry-run output, keep worktrees clean, and inspect generated patches before applying changes.

Trace a runtime path

lmprobe trace 'fn handle_$NAME' . \
  --exec 'cargo test' \
  --worktree

Worktree mode isolates instrumentation and rolls it back after the run.

Preview a rewrite

lmprobe fix -p 'old_api($X)' -r 'new_api($X)' src
lmprobe fix -p 'old_api($X)' -r 'new_api($X)' src --apply

Apply mode refuses unsafe working trees unless explicitly forced.

Chapter 6

Output Formats

Choose human-readable markdown, machine-readable envelopes, CI annotations, or graph renderers.

autoTTY markdown, pipe NDJSON.
jsonPretty full envelope for jq.
ndjsonOne item per line plus summary.
sarifStatic-analysis upload format.
githubActions annotations.
mermaidPR-friendly graph diagrams.
dotGraphviz output.
lmprobe --format json search --name Pattern . | jq '.hits | length'
lmprobe --format github grep 'TODO|FIXME' .
lmprobe --format dot impact Pattern --depth 2 . > impact.dot

Chapter 7

GraphQL Composition

lmprobe query runs an in-process GraphQL document. Use it when one investigation needs multiple evidence streams.

Naming is surface-native: CLI JSON uses snake_case fields and lowercase status strings (for example line_start, line_number, exit_status: "matched"), while GraphQL uses camelCase keys and uppercase enum-style values (lineStart, lineNumber, exitStatus: "MATCHED"). The meaning is compatible, but field names are not normalized across both surfaces. Note: line-like anchors are spread across CLI families (line_number, line_start, start_line) and map to GraphQL line fields by semantics on each output shape. Inspect warnings for coverage diagnostics such as FILE_METADATA_FAILED, FILE_TOO_LARGE, FILE_READ_FAILED, WALK_ERROR, or WALK_ENTRY_ERROR; hits from readable files remain useful, but those warnings mean the scan was partial. Partial runs report partial: true where supported and exit with code 3; exit_status stays in the stable matched/no_match/error enum.

Batch search, context, and raw evidence

Aliases keep the result organized while every field still uses the same underlying CLI envelopes and exit semantics.

{
  defs: def(name: "UserService", path: ".") {
    hits { name filePath lineStart }
    exitStatus
  }
  env: grep(pattern: "process\\.env", path: "apps/web", paths: ["packages/shared"]) {
    hits { filePath lineNumber lineContent }
    warnings { code message hint }
    exitStatus
  }
  packages: grepDirsWith(
    markerPattern: "(^|[\\\\/])package\\.json$",
    pattern: "login",
    path: ".",
    parents: true
  ) {
    hits { filePath lineNumber lineContent parents { kind name } }
    exitStatus
  }
}
Variables are JSON-parsed: lmprobe query @q.graphql --var name='"User"'.

Chapter 8

Secrets And Provider Evidence

The secrets scanner is gitleaks-compatible and can add semantic evidence about provider SDK calls and source reads without claiming a vulnerability by itself.

Filesystem scan

lmprobe secrets .
lmprobe --format json secrets --ast-fp-cut annotate .

Provider recipes

lmprobe secrets-recipes list --provider aws
lmprobe secrets-sources list --provider aws
lmprobe query --recipe secrets/aws/python --all-shapes

Treat scanner output as evidence for review. Confirm findings with project context and rotation policy before taking action.

Rule compatibility stays unchanged by default. Teams with repeated i18n/locale false positives can use an opt-in --config overlay that adds path allowlists (for example assets/i18n/**, locales/**, translations/**) and keeps all other secret scanners enabled. Keep decoded-only natural-language translation hits low-confidence unless corroborated by additional context.

Chapter 9

Recipes By Scenario

Filter recipes by keyword or scan the cards directly. Commands assume you are at the repository root.

Find login paths with local context

lmprobe --format json grep -C 3 'login|signin|authenticate' apps/web

Search only packages with markers

lmprobe query '{
  grepDirsWith(markerPattern: "(^|[\\\\/])package\\.json$", pattern: "login", path: ".") {
    hits { filePath lineNumber lineContent }
    exitStatus
  }
}'

Open the exact implementation

lmprobe --format json def --body --around 4 handle_request src

Collect PR evidence

lmprobe pr-triage --since all https://github.com/owner/repo/pull/123
lmprobe --format json pr-triage --compact https://github.com/owner/repo/pull/123

Render impact for a pull request

lmprobe --format mermaid impact BillingClient --depth 3 .

Review resource and crypto risks

lmprobe resource-sites . --acquire 'os.Open|File::open' --release 'Close|drop'
lmprobe async-leaks . --call stop
lmprobe crypto-sites . --algorithm sha1 --fips-check

Inspect scanner family evidence

lmprobe config-keys package.json pyproject.toml
lmprobe guard-sites . --sensitive 'Delete|exec' --guard 'auth'
lmprobe route-anchors .

Find when a symbol changed

lmprobe history blame --semantic UserRepository .
lmprobe history introduced UserRepository .

Collect provider evidence

lmprobe secrets-recipes list --language python
lmprobe query --recipe secrets/aws/python --all-shapes

Emit CI annotations

lmprobe --format github grep 'TODO|FIXME|HACK' .

Preview a mechanical rewrite

lmprobe fix -p 'old_fn($X)' -r 'new_fn($X)' src

Chapter 10

Command Reference Map

A compact map of the major surfaces covered by this manual.

Searchsearch, def, ref, find, grep, discover, list-kinds
Graphcallers, callsites, callees, imports, exports, decorations, supertypes, subtypes, overrides, impact, context
Reviewpr-triage
Scannersresource-sites, async-leaks, crypto-sites, config-keys, guard-sites, openapi-facts, route-anchors, http-client-calls, py-slice-candidates
Historyhistory blame, introduced, commit, diff, churn, co-change, todos, evolution, ast-diff, diff-context
Mutationtrace, fix, GraphQL mutations (fix, trace, untrace)
Securitysecrets, secrets-recipes, secrets-sources, source/provider GraphQL recipes
Compositionquery, serve, aliases, variables, introspection, selected fields