Source URL: https://simonwillison.net/2025/Apr/23/llm-fragment-symbex/#atom-everything
Source: Simon Willison’s Weblog
Title: llm-fragment-symbex
Feedly Summary: llm-fragment-symbex
I released a new LLM fragment loader plugin that builds on top of my Symbex project.
Symbex is a CLI tool I wrote that can run against a folder full of Python code and output functions, classes, methods or just their docstrings and signatures, using the Python AST module to parse the code.
llm-fragments-symbex brings that ability directly to LLM. It lets you do things like this:
llm install llm-fragments-symbex
llm -f symbex:path/to/project -s ‘Describe this codebase’
I just ran that against my LLM project itself like this:
cd llm
llm -f symbex:. -s ‘guess what this code does’
Here’s the full output, which starts like this:
This code listing appears to be an index or dump of Python functions, classes, and methods primarily belonging to a codebase related to large language models (LLMs). It covers a broad functionality set related to managing LLMs, embeddings, templates, plugins, logging, and command-line interface (CLI) utilities for interaction with language models. […]
That page also shows the input generated by the fragment – here’s a representative extract:
# from llm.cli import resolve_attachment
def resolve_attachment(value):
“""Resolve an attachment from a string value which could be:
– "-" for stdin
– A URL
– A file path
Returns an Attachment object.
Raises AttachmentError if the attachment cannot be resolved."""
# from llm.cli import AttachmentType
class AttachmentType:
def convert(self, value, param, ctx):
# from llm.cli import resolve_attachment_with_type
def resolve_attachment_with_type(value: str, mimetype: str) -> Attachment:
If your Python code has good docstrings and type annotations, this should hopefully be a shortcut for providing full API documentation to a model without needing to dump in the entire codebase.
The above example used 13,471 input tokens and 781 output tokens, using openai/gpt-4.1-mini. That model is extremely cheap, so the total cost was 0.6638 cents – less than a cent.
The plugin itself was mostly written by o4-mini using the llm-fragments-github plugin to load the simonw/symbex and simonw/llm-hacker-news repositories as example code:
llm \
-f github:simonw/symbex \
-f github:simonw/llm-hacker-news \
-s "Write a new plugin as a single llm_fragments_symbex.py file which
provides a custom loader which can be used like this:
llm -f symbex:path/to/folder – it then loads in all of the python
function signatures with their docstrings from that folder using
the same trick that symbex uses, effectively the same as running
symbex . ‘*’ ‘*.*’ –docs –imports -n" \
-m openai/o4-mini -o reasoning_effort high"
Here’s the response. 27,819 input, 2,918 output = 4.344 cents.
In working on this project I identified and fixed a minor cosmetic defect in Symbex itself. Technically this is a breaking change (it changes the output) so I shipped that as Symbex 2.0.
Tags: symbex, llm, ai-assisted-programming, generative-ai, projects, ai, llms
AI Summary and Description: Yes
**Summary:** The text introduces a new plugin for large language model (LLM) fragment loading that enhances the capabilities of the existing Symbex project, which parses Python code to aid in generating API documentation and managing LLMs. This development is particularly relevant for professionals in AI and cloud computing, as it provides a streamlined method to document and work with codebases more efficiently.
**Detailed Description:**
The provided text outlines the release of a new plugin, `llm-fragments-symbex`, which builds upon the Symbex project, a command-line interface (CLI) tool designed for Python code analysis. Here are the key points:
– **Plugin Functionality:**
– The `llm-fragments-symbex` plugin allows users to integrate the Symbex capabilities directly with LLMs.
– It enables users to execute commands to describe their codebases efficiently using predefined queries.
– **Example Commands:**
– Installation command: `llm install llm-fragments-symbex`
– Querying a project with a command example: `llm -f symbex:path/to/project -s ‘Describe this codebase’`
– **Code Parsing and Documentation:**
– The tool directly extracts functions, classes, methods, and their docstrings from Python code, using the Abstract Syntax Tree (AST) for parsing.
– This provides a handy shortcut for generating API documentation without the need to review the entire codebase manually.
– **Performance Metrics:**
– The implementation showed effective token usage when processing inputs and outputs with the GPT-4.1-mini model, demonstrating cost efficiency (less than a cent for the queries discussed).
– **Collaboration and Development:**
– The plugin was primarily authored by `o4-mini` and incorporated examples from other GitHub repositories.
– Development and maintenance involved identifying and fixing defects, contributing back to the Symbex project (notably upgrading it to version 2.0 due to breaking changes in output).
– **Relevance for Professionals:**
– This tool is significant for developers and teams working with AI-assisted programming, as it simplifies the documentation process and aligns with modern practices of utilizing LLMs for enhancing productivity.
– It addresses common challenges in large codebases, such as maintaining accurate documentation and efficiently managing interactions with language models.
Overall, the `llm-fragments-symbex` plugin represents an advancement in leveraging LLMs for Python development, enhancing efficiency and collaboration in AI-related projects.