Agent Docstrings
A command-line tool to auto-generate and update file-level docstrings summarizing classes and functions. Useful for maintaining a high-level overview of your files, especially in projects with code generated or modified by AI assistants.
pip install agent-docstrings
How to
I’m adding this tool to my code quality control script, which the Agent uses for self-verification. I’ll add more information to the project’s README if there are any questions.
Why?
When working in Cursor and similar IDEs, Agents often start reading files from the beginning. And regarding Cursor’s behavior during the script’s creation, in normal mode, the model reads 250 lines of code per call, and in MAX mode, 750 lines. However, I have projects with files over 1000 lines of code, which are not very appropriate to divide into smaller files. And anyway, Agent still have to call reading tools for each individual file.
At the same time, the Agent can choose from which line to read the file. It can navigate and surf within your repository. The script literally provides the Agent with the table of contents of the current file, so that immediately after the first read, the Agent understands the entire structure and can read the file from a specific line, rather than trying to get to it (while also potentially making mistakes along the way).
In addition to the advantage of quick navigation, the initial docstring also serves as a method to reduce context window usage. For example, if a required method in a 900-line file is on line 856, the Agent will only read lines 1-250 and 856-900, instead of sequentially going to the desired forty lines and filling its context with unnecessary code.
Features
- Multi-language support: Python, Java, Kotlin, Go, PowerShell, Delphi, C, C++, C#, JavaScript, TypeScript
- Automatic discovery: Recursively scans directories for source files
- Smart filtering: Respects
.gitignore
files and custom blacklist/whitelist configurations - Incremental updates: Only modifies files when changes are detected
- Type annotations: Full type hint support for Python 3.8+
- CLI interface: Easy-to-use command-line tool