Symbols Command

June 27, 2026 · View on GitHub

List all symbols (functions, structs, classes, constants, etc.) in files — a table of contents with line numbers and nesting.

TL;DR

# List symbols in a file
probe symbols src/main.rs

# JSON output (for programmatic use)
probe symbols src/main.rs --format json

# Multiple files
probe symbols src/main.rs src/lib.rs

# Include test functions
probe symbols src/main.rs --allow-tests

# Plain-text fallback for documentation/config files
probe symbols rsync.1 --format json

# Treat a custom extension as plain text
probe symbols notes.req --text-extension req --format json

Basic Syntax

probe symbols <FILES> [OPTIONS]

Options

OptionDescriptionDefault
-o, --formatOutput format: text or jsontext
--allow-testsInclude test functions/methodsfalse
--strictDisable plain-text fallback for unsupported extensionsfalse
--text-extension EXTTreat an extension as plain text (repeatable, with or without .)-

Plain-Text Fallback

Unsupported extensions fall back to line-oriented text symbols by default. Standard documentation and config-style extensions such as .1, .5, .txt, .conf, .tex, .sh, and .json are treated as plain text.

Plain-text entries use kind: "text", an empty name, and the source line as signature:

[{
  "file": "rsync.1",
  "symbols": [
    {
      "name": "",
      "kind": "text",
      "signature": ".TH rsync 1",
      "line": 1,
      "end_line": 1
    }
  ]
}]

Use --strict when a caller only wants AST-backed symbols and wants unsupported extensions to be reported as warnings. Use --text-extension EXT to force additional suffixes into plain-text mode.

Output Formats

Text Output

Shows symbols with indentation for nesting:

src/main.rs:
  1:795   fn main()
  15:28   struct Config { ... }
  30:55   impl Config
    32:44   fn new() -> Config
    45:54   fn validate(&self) -> bool
  60      const MAX_SIZE: usize
  65:72   enum Status

JSON Output

Returns structured data with nested children:

[{
  "file": "src/main.rs",
  "symbols": [
    {
      "name": "main",
      "kind": "function",
      "signature": "fn main()",
      "line": 1,
      "end_line": 795,
      "children": []
    },
    {
      "name": "Config",
      "kind": "impl",
      "signature": "impl Config { ... }",
      "line": 30,
      "end_line": 55,
      "children": [
        {
          "name": "new",
          "kind": "function",
          "signature": "fn new() -> Config",
          "line": 32,
          "end_line": 44
        }
      ]
    }
  ]
}]

Symbol Types

The symbols command detects the following symbol types across languages:

KindLanguagesExamples
functionAllfn main(), def greet(), function hello()
methodAllMethods inside classes/impl blocks
structRust, Gostruct Config { ... }
classPython, TS/JS, Javaclass App { ... }
interfaceTS, Gointerface Config { ... }
traitRusttrait Handler { ... }
implRustimpl Config { ... }
enumRust, TS, Javaenum Status { ... }
constRust, Go, TS/JSconst MAX_SIZE: usize
staticRuststatic INSTANCE: ...
typeRust, TS, Gotype Alias = ...
moduleRust, TSmod utils, namespace Api
macroRustmacro_rules! my_macro
variableTS/JS, Pythonconst config = ..., MAX_COUNT = 100

Nesting

Container symbols (impl blocks, classes, traits, modules) show their children indented:

  • Rust: methods inside impl and trait blocks
  • TypeScript/JavaScript: methods inside class declarations
  • Python: methods inside class definitions
  • Go: methods are shown at top level (Go uses receiver syntax, not nesting)

Use Cases

  • Quick file overview: Understand a file's structure before reading it
  • Find the right symbol name: Get exact names for probe extract file.rs#symbol
  • Navigate large files: Find line numbers for functions of interest
  • Code review: See what changed at a structural level

SDK Usage

import { symbols } from '@probelabs/probe';

const result = await symbols({
  files: ['src/main.rs'],
  cwd: './project'
});

console.log(result[0].symbols);

See also: Search | Extract | Query | CLI Reference