- Overview
- Core Functionality
- Key Features
- Architecture
- Installation & Setup
- Usage
- CLI Reference
- LLM Provider Integration
- Internal Workflow
- Dependency Management
- Project Structure
- Extending Runesmith
- .gitignore Policy
- Versioning & Python Version
- License
- Acknowledgements
- Planned Enhancements
- Contribution Guidelines
- Changelog
Runesmith is a Python-based CLI tool for generating, updating, and managing high-quality code documentation using large language models (LLMs) such as OpenAI, Azure OpenAI, Anthropic, Gemini, and Ollama. It automates the creation and maintenance of documentation for codebases, supporting both interactive and configuration-driven workflows. Runesmith also provides infrastructure-as-code (IaC) blueprint management, focusing on modular, reusable, and composable infrastructure definitions for cloud-agnostic deployments.
- Purpose: Automate code documentation generation and management using LLMs.
- Modes: Interactive CLI wizard or YAML config-driven operation.
- IaC Support: Modular, composable infrastructure blueprints for cloud-agnostic deployments.
- LLM Integration: Multi-provider/model support, custom instructions, context window/token management.
- Documentation Generation: Per-chunk summarization, smoothing/merging, minimal/safe updates, doc type selection.
- Codebase Awareness: Honors
.gitignore, blacklist, and existing documentation. - IaC Blueprints: Author, compose, validate, and deploy with version/state management.
- Extensibility: Plugin-based architecture for providers and workflows.
- CLI: Built with Typer.
- Modular/Plugin Design: Extensible for providers and workflows.
- Declarative IaC: YAML/JSON blueprints.
- Provider SDK/CLI Integration: For cloud operations.
- State/Version Tracking: For blueprints and deployments.
- Python: Version 3.10 (enforced via
.python-versionfor tools like pyenv). - uv: For dependency management and virtual environments.
You can install Runesmith directly from PyPI:
pip install runesmith-
Clone the Repository
git clone <repo-url> cd runesmith
-
Install Dependencies
uv sync
-
Activate the Virtual Environment
source .venv/bin/activate -
Set Up Environment Variables
- Create a
.envfile in the project root or export variables directly (see LLM Provider Integration).
- Create a
Launch the guided wizard to configure and generate documentation:
runesmith generateUse a YAML configuration file for repeatable, automated runs:
runesmith generate --config config.yamlprovider: openai
model: gpt-4o
code_path: ./src
output_dir: ./docs
blacklist:
- .pyc
- .pyo
doc_types:
- Readme
- API docs
- Quickstart
custom_instruct: |
Please focus on clarity and conciseness.- provider: LLM provider (
openai,azure,anthropic,gemini,ollama) - model: Model name (e.g.,
gpt-4o,claude-3.5-haiku) - code_path: Path to codebase to document
- output_dir: Directory for generated documentation
- blacklist: List of file extensions to ignore
- doc_types: Types of documentation to generate (e.g.,
Readme,API docs,Quickstart,Tutorial,User guide,Reference) - custom_instruct: Additional instructions for the LLM
The CLI is implemented using Typer. The main entry point is:
runesmith generate [--config config.yaml]- Interactive prompts: If no config is provided, the CLI will guide you through provider/model selection, code/output directories, blacklist, doc types, and custom instructions.
- Config file: If
--configis specified, settings are loaded from the YAML file.
Workflow:
- Crawl codebase (respects
.gitignoreand blacklist). - For each chunk, generate a technical summary using the selected LLM.
- Write per-chunk summaries to a temporary folder.
- For each documentation type:
- If smoothing/merging is required (e.g., API docs), merge chunk summaries using the LLM.
- Otherwise, mark as complete.
- Clean up temporary files.
| Provider | Example Models | Notes |
|---|---|---|
| OpenAI | gpt-4o, gpt-4-turbo, gpt-4.5 | Default, tested |
| Azure OpenAI | gpt-4o, gpt-4-turbo | Requires Azure credentials |
| Anthropic | claude-3.5-haiku, claude-3-opus | |
| Gemini | gemini-1.5-pro, gemini-2.5-pro | |
| Ollama | Any local model | No API key required, tested |
| Provider | Required Variables |
|---|---|
| OpenAI | OPENAI_API_KEY |
| Azure OpenAI | AZURE_OPENAI_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_VERSION |
| Anthropic | ANTHROPIC_API_KEY |
| Gemini | GEMINI_API_KEY |
| Ollama | None |
- All providers support loading variables from a
.envfile in the project root.
- Module:
runesmith.crawler - Functions:
collect_code_chunks(dir_path, blacklist): Recursively yields code chunks, skipping files per.gitignoreand blacklist.find_extensions(dir_path): Lists unique file extensions in the codebase.
- Module:
runesmith.llm - Functions:
count_tokens(text, model): Usestiktokento count tokens for the selected model.get_context_window(provider, model): Returns the model's context window size.- Warns if the codebase exceeds the model's context window.
- Per-Chunk Summarization: Each code chunk is summarized by the LLM.
- Smoothing/Merging: For certain doc types (e.g., API docs), chunk summaries are merged and polished by the LLM.
- Minimal Updates: Existing documentation is updated minimally and safely.
- Dependency Locking: Uses
uv.lockfor deterministic, reproducible installs. - Dependency Graph: All direct and transitive dependencies are pinned with SHA256 hashes for security.
- Editable Install: The main project is installed in editable mode for development.
| Package | Version | Role/Functionality |
|---|---|---|
| runesmith | 0.1.0 | Main project |
| ollama | 0.4.8 | LLM API client |
| openai | 1.76.0 | OpenAI API client |
| tiktoken | 0.9.0 | Tokenizer for LLMs |
| typer | 0.15.2 | CLI framework |
| questionary | 2.1.0 | Interactive CLI prompts |
| rich | 14.0.0 | Terminal formatting |
| pydantic | 2.11.3 | Data validation |
| httpx | 0.28.1 | HTTP client |
| requests | 2.32.3 | HTTP client |
| python-dotenv | 1.1.0 | .env file loader |
| pyyaml | 6.0.2 | YAML parsing |
| pathspec | 0.12.1 | Path pattern matching |
runesmith/
├── src/
│ └── runesmith/
│ ├── __init__.py
│ ├── __main__.py
│ ├── cli.py
│ ├── crawler.py
│ └── llm.py
├── pyproject.toml
├── uv.lock
├── .python-version
├── .gitignore
├── README.md
└── LICENSE
- src/runesmith/init.py: Package initializer, may expose public API or metadata.
- src/runesmith/cli.py: CLI implementation using Typer and Questionary.
- src/runesmith/crawler.py: Codebase crawling and file filtering, with .gitignore and blacklist support.
- src/runesmith/llm.py: LLM provider integration, token counting, and documentation generation utilities.
- src/runesmith/main.py: CLI entry point.
- pyproject.toml: Project metadata, dependencies, CLI entry point, and build system.
- uv.lock: Locked dependency versions and hashes for reproducibility.
- .python-version: Specifies Python 3.10 for development.
- .gitignore: Excludes generated, environment-specific, and project-specific files.
- Custom Providers: Add via the plugin interface.
- Hooks: Pre/post-deployment actions for IaC workflows.
- Blueprints: Author in
/blueprintsdirectory using YAML/JSON. - Examples & Docs: See
/examplesand/docsfor usage scenarios and API/plugin documentation.
The .gitignore file is configured to:
- Ignore Python bytecode and cache directories:
__pycache__/,*.pyc,*.pyo - Exclude build artifacts and distribution directories:
build/,dist/,wheels/,*.egg-info - Omit virtual environment directories and environment files:
.venv,*.env - Ignore files/directories matching
batch*,config* - Exclude the
web/directory andtest.pyfile - Ignore cache files and directories:
cache*
This prevents versioning of generated, environment-specific, and certain project-specific files and directories, maintaining repository cleanliness.
- Project Version: 0.1.0 (see
pyproject.toml) - Python Version: 3.10 (enforced via
.python-version)
MIT License
Copyright (c) 2025 yail259
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Disclaimer:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- uv for dependency management
- Typer, Rich, Questionary, and other open-source libraries
- Add generated docs to LLM context window for improved updates
- Retrieval-Augmented Generation (RAG) for large codebases
- Package as a standalone binary
- Multilanguage support
- Iterative prompting/looping for refinement
- Open-source under the MIT License.
- Contribution guidelines are provided in the repository.
- Please see the
CONTRIBUTING.mdfile for details on submitting issues and pull requests.
- First public release.
- Supports documentation generation and updating for codebases using OpenAI, Azure OpenAI, Anthropic, Gemini, and Ollama LLMs.
- Interactive CLI wizard and YAML config-driven operation.
- Honors
.gitignoreand file extension blacklist. - Per-chunk summarization and optional smoothing/merging for coherent documentation.
- IaC blueprint management (author, compose, validate, deploy).
- Deterministic dependency management via
uv.lock. - Python 3.10 support.
- Installable via PyPI (
pip install runesmith).
This documentation is self-generated and updated by Runesmith.