CLI tool for Python code symbol extraction
Top 90.0% on sourcepulse
Symbex is a command-line tool for finding and extracting Python code for specific functions and classes. It's designed for developers and researchers who need to quickly locate, inspect, or programmatically manipulate Python source code, offering powerful filtering and integration with LLM workflows.
How It Works
Symbex parses Python files using the ast
module to identify symbol definitions (functions, classes, methods). It supports flexible searching with exact names, wildcards, and class.method notation. The tool can search specified directories, files, or even the Python standard library. Its advantage lies in its granular filtering capabilities and its seamless integration with LLM tools for code explanation, embedding generation, and automated code modification.
Quick Start & Requirements
pip install symbex
brew install simonw/llm/symbex
Highlighted Details
-s
), include docstrings (--docstrings
), or provide import paths (-i
).--replace
) and command-based replacement (--rexec
).--check
option for CI to fail if undocumented public symbols are found.Maintenance & Community
The project is maintained by Simon Willison. Development dependencies are managed via pip install -e '.[test]'
and tests can be run with pytest
.
Licensing & Compatibility
The project is distributed under the MIT License, allowing for commercial use and integration with closed-source projects.
Limitations & Caveats
Symbex relies on Python's ast
module, meaning it may encounter issues with syntactically incorrect Python code, though it can suppress warnings with --silent
. The --replace
and --rexec
features modify files in-place and should be used with caution, preferably with version control.
3 months ago
1+ week