{"id":34226282,"url":"https://github.com/foresturquhart/grimoire","last_synced_at":"2026-03-10T23:02:40.580Z","repository":{"id":273438290,"uuid":"919660557","full_name":"foresturquhart/grimoire","owner":"foresturquhart","description":"A lightweight tool that converts directory contents into structured output optimized for LLM interpretation, featuring Git-aware file ordering, secret detection/redaction, token counting, and customizable filtering.","archived":false,"fork":false,"pushed_at":"2025-11-27T10:04:52.000Z","size":319,"stargazers_count":17,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-19T05:47:18.653Z","etag":null,"topics":["ai","artificial-intelligence","chatgpt","claude","cli","code-analysis","developer-tools","devtools","gemini","generative-ai","git","golang","language-model","llm","markdown","redaction","secrets-detection","text","utility","xml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foresturquhart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-20T19:15:43.000Z","updated_at":"2025-11-26T03:10:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"8011f882-fc9f-4022-b684-359f45969d41","html_url":"https://github.com/foresturquhart/grimoire","commit_stats":null,"previous_names":["foresturquhart/grimoire"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/foresturquhart/grimoire","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresturquhart%2Fgrimoire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresturquhart%2Fgrimoire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresturquhart%2Fgrimoire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresturquhart%2Fgrimoire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foresturquhart","download_url":"https://codeload.github.com/foresturquhart/grimoire/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresturquhart%2Fgrimoire/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30360557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"ssl_error","status_checked_at":"2026-03-10T21:40:59.357Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","chatgpt","claude","cli","code-analysis","developer-tools","devtools","gemini","generative-ai","git","golang","language-model","llm","markdown","redaction","secrets-detection","text","utility","xml"],"created_at":"2025-12-16T00:22:44.471Z","updated_at":"2026-03-10T23:02:40.568Z","avatar_url":"https://github.com/foresturquhart.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/foresturquhart/grimoire\"\u003e\n    \u003cimg src=\".github/grimoire.png\" alt=\"Grimoire\" width=\"500\" height=\"auto\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003chr /\u003e\n\n[![go](https://badgen.net/static/go/1.24.5)](https://go.dev/)\n[![license](https://badgen.net/github/license/foresturquhart/grimoire)](https://github.com/foresturquhart/grimoire/blob/main/LICENSE)\n[![release](https://badgen.net/github/release/foresturquhart/grimoire/stable)](https://github.com/foresturquhart/grimoire/releases)\n\nGrimoire is a command-line tool that converts the contents of a directory into structured output formats optimized for interpretation by Large Language Models (LLMs) like Claude, ChatGPT, Gemini, DeepSeek, Llama, Grok, and more. It is lightweight, highly configurable, and user-friendly.\n\n## Quick Start\n\n### Install Grimoire\n\nThe fastest way to get started is with our one-line installation script:\n\n```bash\ncurl -sSL https://raw.githubusercontent.com/foresturquhart/grimoire/main/install.sh | bash\n```\n\nThis script automatically detects your OS and architecture, downloads the appropriate binary, and installs it to your PATH.\n\n### Basic Usage\n\n```bash\n# Convert current directory to Markdown and copy to clipboard (macOS)\ngrimoire . | pbcopy\n\n# Convert current directory to Markdown and copy to clipboard (Linux with xclip)\ngrimoire . | xclip -selection clipboard\n\n# Convert current directory and save to file\ngrimoire -o output.md .\n\n# Convert current directory to XML format\ngrimoire --format xml -o output.xml .\n\n# Convert current directory to plain text format\ngrimoire --format txt -o output.txt .\n\n# Convert directory with secret detection and redaction\ngrimoire --redact-secrets -o output.md .\n```\n\n## Features\n\n* **Multiple Output Formats:** Generate output in Markdown, XML, or plain text formats to suit your needs.\n* **Recursive File Scanning:** Automatically traverses directories and subdirectories to identify eligible files based on customizable extensions.\n* **Content Filtering:** Skips ignored directories, temporary files, and patterns defined in the configuration.\n* **Directory Tree Visualization:** Includes an optional directory structure representation at the beginning of the output.\n* **Git Integration:** Prioritizes files by commit frequency when working within a Git repository.\n* **Secret Detection:** Scans files for potential secrets or sensitive information to prevent accidental exposure.\n* **Secret Redaction:** Optionally redacts detected secrets in the output while preserving the overall code structure.\n* **Token Counting:** Calculates the token count of generated output to help manage LLM context limits.\n* **Minified File Detection:** Automatically identifies minified JavaScript and CSS files to warn about high token usage.\n* **Flexible Output:** Supports output to stdout or a specified file.\n\n## Installation\n\n### Prerequisites\n\n* Git (required for repositories using Git-based sorting).\n\n### Quickest: One-line Installation Script\n\nThe easiest way to install Grimoire is with our automatic installation script:\n\n```bash\ncurl -sSL https://raw.githubusercontent.com/foresturquhart/grimoire/main/install.sh | bash\n```\n\nThis script automatically:\n- Detects your operating system and architecture\n- Downloads the appropriate binary for your system\n- Installs it to `/usr/local/bin` (or `~/.local/bin` if you don't have sudo access)\n- Makes the binary executable\n\n### Alternative: Download Pre-compiled Binary\n\nYou can also manually download a pre-compiled binary from the [releases page](https://github.com/foresturquhart/grimoire/releases).\n\n1. Visit the [releases page](https://github.com/foresturquhart/grimoire/releases).\n2. Download the appropriate archive for your system (e.g., `grimoire-1.2.2-linux-amd64.tar.gz` or `grimoire-1.2.2-darwin-arm64.tar.gz`).\n3. Extract the archive to retrieve the `grimoire` executable.\n4. Move the `grimoire` executable to a directory in your system's `PATH` (e.g., `/usr/local/bin` or `~/.local/bin`). You may need to use `sudo` for system-wide locations:\n   ```bash\n   tar -xzf grimoire-1.2.2-linux-amd64.tar.gz\n   cd grimoire-1.2.2-linux-amd64\n   sudo mv grimoire /usr/local/bin/\n   ```\n5. Verify the installation:\n   ```bash\n   grimoire --version\n   ```\n\n### Install using `go install`\n\nFor users with Go installed, `go install` offers a straightforward installation method:\n\n```bash\ngo install github.com/foresturquhart/grimoire/cmd/grimoire@latest\n```\n\n### Build from Source\n\nTo build Grimoire from source (useful for development or customization):\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/foresturquhart/grimoire.git\n   cd grimoire\n   ```\n2. Build the binary:\n   ```bash\n   go build -o grimoire ./cmd/grimoire\n   ```\n3. Move the binary to your `PATH`:\n   ```bash\n   mv grimoire /usr/local/bin/\n   ```\n4. Verify the installation:\n   ```bash\n   grimoire --version\n   ```\n\n## Usage\n\n### Basic Command\n\n```bash\ngrimoire [options] \u003ctarget directory\u003e\n```\n\n### Options\n\n- `-o, --output \u003cpath\u003e`: Specify an output file. Defaults to stdout if omitted.\n- `-f, --force`: Overwrite the output file if it already exists.\n- `--format \u003cformat\u003e`: Specify the output format. Options are `md` (or `markdown`), `xml`, and `txt` (or `text`, `plain`, `plaintext`). Defaults to `md`.\n- `--no-tree`: Disable the directory tree visualization at the beginning of the output.\n- `--no-sort`: Disable sorting files by Git commit frequency.\n- `--ignore-secrets`: Proceed with output generation even if secrets are detected.\n- `--redact-secrets`: Redact detected secrets in output rather than failing.\n- `--skip-token-count`: Skip counting output tokens.\n- `--version`: Display the current version.\n\n### Examples\n\n1. Convert a directory into Markdown and print the output to stdout:\n   ```bash\n   grimoire ./myproject\n   ```\n2. Save the output to a file:\n   ```bash\n   grimoire -o output.md ./myproject\n   ```\n3. Overwrite an existing file:\n   ```bash\n   grimoire -o output.md -f ./myproject\n   ```\n4. Generate XML output without a directory tree:\n   ```bash\n   grimoire --format xml --no-tree -o output.xml ./myproject\n   ```\n5. Generate plain text output without Git-based sorting:\n   ```bash\n   grimoire --format txt --no-sort -o output.txt ./myproject\n   ```\n6. Scan for secrets and redact them in the output:\n   ```bash\n   grimoire --redact-secrets -o output.md ./myproject\n   ```\n\n## Configuration\n\n### Allowed File Extensions\n\nGrimoire processes files with specific extensions. You can customize these by modifying the `DefaultAllowedFileExtensions` constant in the codebase.\n\n### Ignored Path Patterns\n\nFiles and directories matching patterns in the `DefaultIgnoredPathPatterns` constant are excluded from processing. This includes temporary files, build artifacts, and version control directories.\n\n### Custom Ignore Files\n\nGrimoire supports two types of ignore files to specify additional exclusion patterns:\n\n1. **`.gitignore`**: Standard Git ignore files are honored if present in the target directory.\n2. **`.grimoireignore`**: Grimoire-specific ignore files that follow the same syntax as Git ignore files.\n\nThese files allow you to specify additional ignore rules on a per-directory basis, giving you fine-grained control over which files and directories should be omitted during the conversion process.\n\n### Large File Handling\n\nBy default, Grimoire warns when processing files larger than 1MB. These files are still included in the output, but a warning is logged to alert you about potential performance impacts when feeding the output to an LLM.\n\n### Minified File Detection\n\nGrimoire automatically detects minified JavaScript and CSS files using several heuristics:\n- Excessive line length\n- Low ratio of lines to characters\n- Presence of coding patterns typical in minified files\n\nWhen a minified file is detected, Grimoire logs a warning, as these files can consume a large number of tokens while providing limited value to the LLM.\n\n## Output Formats\n\nGrimoire supports three output formats:\n\n1. **Markdown (md)** - Default format that wraps file contents in code blocks with file paths as headings.\n2. **XML (xml)** - Structures the content in an XML format with file paths as attributes.\n3. **Plain Text (txt)** - Uses separator lines to distinguish between files.\n\nEach format includes metadata, a summary section, an optional directory tree, and the content of all files.\n\n## Token Counting\n\nGrimoire includes built-in token counting to help you manage LLM context limits. The token count is estimated using the same tokenizer used by many LLMs. You can disable token counting entirely using the `--skip-token-count` flag.\n\n## Secret Detection\n\nGrimoire includes built-in secret detection powered by [gitleaks](https://github.com/gitleaks/gitleaks) to help prevent accidentally sharing sensitive information when using the generated output with LLMs or other tools.\n\nBy default, Grimoire scans for a wide variety of potential secrets including:\n\n- API keys and tokens (AWS, GitHub, GitLab, etc.)\n- Private keys (RSA, SSH, PGP, etc.)\n- Authentication credentials\n- Service-specific tokens (Stripe, Slack, Twilio, etc.)\n\nThe secret detection behavior can be controlled with the following flags:\n\n- `--ignore-secrets`: Continues with output generation even if secrets are detected (logs warnings)\n- `--redact-secrets`: Automatically redacts any detected secrets with the format `[REDACTED SECRET: description]`\n\nIf a secret is detected and neither of the above flags are specified, Grimoire will abort the operation and display a warning message, helping prevent accidental exposure of sensitive information.\n\n## Contributing\n\nContributions are welcome! To get started:\n\n1. Fork the repository.\n2. Create a new branch for your feature or fix:\n   ```bash\n   git checkout -b feature/my-new-feature\n   ```\n3. Commit your changes:\n   ```bash\n   git commit -m \"Add my new feature\"\n   ```\n4. Push the branch to your fork:\n   ```bash\n   git push origin feature/my-new-feature\n   ```\n5. Open a pull request.\n\n## License\n\nGrimoire is licensed under the [MIT License](LICENSE).\n\n## Acknowledgements\n\nGrimoire uses the following libraries:\n\n- [zerolog](https://github.com/rs/zerolog) for structured logging.\n- [gitleaks](https://github.com/zricethezav/gitleaks) for secret detection and scanning.\n- [go-gitignore](https://github.com/sabhiram/go-gitignore) for handling ignore patterns.\n- [urfave/cli](https://github.com/urfave/cli) for command-line interface.\n- [tiktoken-go](https://github.com/tiktoken-go/tokenizer) for token counting.\n\n## Feedback and Support\n\nFor issues, suggestions, or feedback, please open an issue on the [GitHub repository](https://github.com/foresturquhart/grimoire/issues).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesturquhart%2Fgrimoire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforesturquhart%2Fgrimoire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesturquhart%2Fgrimoire/lists"}