Code-Reducer
A lightweight, high-performance command-line tool written in Go that automatically generates and maintains developer-friendly, comprehensive wikis for extensive repositories using local LLMs.
View on GitHubWhat is Code-Reducer?
Code-Reducer is designed specifically for local development and private LLMs. It uses a custom Hierarchical Map-Reduce Strategy to analyze large codebases using small, local LLM models (e.g., 7B, 9B, or 26B parameters) via Ollama without exceeding context windows or degrading output quality.
Features
Breaks codebase synthesis into a structured Map-Reduce pipeline to document large directories recursively, staying strictly within local LLM context limits.
Built specifically to leverage Ollama (e.g., ornith:9b or gemma4:26b), eliminating expensive cloud API costs and keeping proprietary code local.
Allows overriding default system prompts, synthesis rules, architecture blueprints, and file fact consolidation directly from YAML configuration.
Features path traversal guards, atomic process locking, and TOCTOU symlink hijacking defenses for safe workspace operations.
Uses a filesystem SHA256 hash cache to only re-document modified files, propagating changes upward to minimize LLM calls.
Automatically detects changes in your extraction steps pipeline and invalidates the cache to ensure documentation accuracy.
Architecture & Security
Code-Reducer uses a Multi-Layer Map-Reduce engine to prevent massive folders from blowing out Ollama's context window. It applies a recursive bottom-up consolidation strategy.
Every filesystem operation passes through a security sandbox with path traversal guards and atomic locks to serialize execution.
Quick Start
Ensure you have Go (1.26+) and Ollama running locally.
Build and Run
go build -o code-reducer main.go
./code-reducer init
Keep your docs updated incrementally by running ./code-reducer update.