RepoLens – An interactive local codebase packer and token optimizer (TUI/CLI) written in Go

Reddit r/openclaw Tools

Summary

RepoLens is a zero-dependency Go tool that packs local codebases into a single file for LLM context, featuring an interactive TUI file explorer, live token counting, comment stripping, and secret scanning.

I wanted to share a tool I just open-sourced called **RepoLens**. While there are existing tools like Repomix (Node.js) or code2prompt (Rust) to pack a repository into a single file for LLM context, I found that they either require a heavy runtime setup or lack an easy way to select files visually from the terminal. RepoLens solves this. It's a zero-dependency, compiled Go tool that runs entirely locally. It features an Elm-architecture TUI (built on Charm's Bubble Tea) and several smart context-optimization mechanisms. ### Why use RepoLens? **Interactive File Explorer (TUI)**: Select files and folders recursively using your spacebar. Expand/collapse nested folders visually. **Live Tiktoken Counter**: A dynamic progress bar estimates context limit consumption (GPT-4o encoding) in real-time as you select files. **Smart Comment Stripping**: Automatically removes comments/docstrings for Go, Python, TS, JS, Shell, and HTML/CSS while keeping executable shebangs (`#!/bin/bash`). * *Benchmark*: On the `spf13/cobra` repo, compression shrunk the prompt size from **621 KB to 518 KB (a 17.2% token savings)**. **Token-based File Splitting**: If your codebase exceeds a token threshold (e.g. `--max-tokens 50000`), RepoLens splits the output into sequential parts, automatically prepending the tree layout diagram to every part. **Local Secret Scanner**: Flags potential AWS keys, OpenAI keys, Slack webhooks, and generic passwords. In TUI mode, it blinks a yellow `⚠️ [SECRET!]` warning next to the file. **Robust XML Formatting**: Safely wraps code payloads inside `<![CDATA[ ... ]]>` blocks and escapes nested brackets to prevent prompt formatting breakdown. ### Quick Start Install via Go: `go install github.com/catball912/repolens@latest` Or run in direct CLI mode: `repolens -n -d . -i "*_test.go,*.log" -o output.md` GitHub Repository: https://github.com/catball912/repolens
Original Article

Similar Articles

SecureLens - A self-hosted AppSec agent and CLI scanner

Reddit r/AI_Agents

SecureLens is an open-source, self-hosted security auditing tool that uses an LLM-powered async pipeline to triage codebases and probe web infrastructure, with an interactive REPL for follow-up questions and patch generation.