A Roslyn-powered C# Header Extractor for AI Context Optimization
hsHeaderGen is a lightweight command-line tool designed to bridge the gap between large C# codebases and AI context windows (like Gemini, ChatGPT, or Claude). It extracts the "architectural skeleton" of your code, providing the AI with all the necessary information while saving up to 90% of tokens.
When working with LLMs, feeding entire source files often wastes precious tokens on boilerplate and implementation details. hsHeaderGen solves this by:
- Stripping method bodies: Keeping only the signatures.
- Filtering by visibility: Focusing on
publicandprotectedmembers. - Providing metadata: Adding estimated token counts and file statistics.
- 🧠 Roslyn-based: Uses the official Microsoft C# compiler platform for precise syntax analysis.
- ⚡ AI-Optimized: Generates
.h.aifiles (Header Files for AI) that are easy for LLMs to parse. - 📂 Flexible Crawling: Processes entire solutions while maintaining directory structures.
- 🛠️ Developer Friendly: Specifically designed to be used as an "External Tool" within Visual Studio.
- Publish the project as a Single File executable.
- Copy the
.exeto your preferred permanent location (e.g.,C:\Tools\). - Run the tool once manually from its new location.
On its first run, hsHeaderGen automatically adds its location to your User Path Environment Variable.
- The tool will then exit.
- From now on, you can call
hsHeaderGenfrom any command prompt or terminal without specifying the full path. (Note: You may need to restart your terminal or Visual Studio to refresh the environment variables).
Once registered, simply open a terminal in your project's root folder and type: bash> hsHeaderGen Options: hsHeaderGen . : Extracts public/protected members (standard). hsHeaderGen . -p : Includes private members for deeper AI analysis. hsHeaderGen [Path] : Processes a specific directory instead of the current one.
Go to Tools -> External Tools...
Title: hsHeaderGen
Command: C:\Tools\hsHeaderGen.exe
Arguments: "$(SolutionDir)"
Initial Directory: $(SolutionDir)
Check: "Use Output window"
Once integrated, simply run the tool from the Visual Studio Tools menu. It will:
- Scan your current solution.
- Extract headers for all relevant types.
- Save them to a dedicated output folder and copy the summary to the clipboard.
- Provide a summary in the Visual Studio Output window.
This project is licensed under the MIT License - see the LICENSE file for details.
This tool was designed by a craftsman and developed with AI assistance (Gemini). It serves as a prime example of human-AI collaboration to optimize modern software development workflows.