amalgo is a command-line tool that recursively scans a directory for files with specified extensions and concatenates them into a single, amalgamated output file. It allows for filters files using .gitignore rules, custom patterns, and directory exclusions.
I use it for creating a single context file of a project's source code to use with AI coding assistants or for generating simple documentation bundles.
You can install amalgo by building from the source.
-
Clone the repository:
git clone https://github.com/sean-stapleton-doyle/amalgo.git cd amalgo -
Build the binary:
make build
This will create the
amalgoexecutable in the project's root directory. To install to your path:make install
The basic command requires you to specify the file extension(s) to include.
amalgo --ext <extension> [flags]1. Concatenate all .go files in the current directory
This will create an output file named concat.md.
amalgo -e .go2. Combine .rs and .toml files into a single output file
You can specify extensions as a comma-separated list or by repeating the flag.
amalgo --ext .rs,.toml --out rust_project.mdor
amalgo -e .rs -e .toml -o rust_project.md3. Scan a specific directory and pipe the output to the clipboard
This example scans the src directory for Python files and uses pbcopy (macOS) to copy the result.
amalgo -d ./src -e .py -o - | pbcopy4. Include hidden files and add a custom ignore pattern
This command includes hidden files (like .config.js) but specifically ignores any *.test.js files.
amalgo -e .js --include-hidden --ignore-pattern "*.test.js"Here is a complete list of available flags:
| Flag | Shorthand | Description | Default |
|---|---|---|---|
--dir |
-d |
Root directory to scan. | . |
--ext |
-e |
File extension(s) to include. Can be repeated or comma-separated. | (Required) |
--out |
-o |
Output file path. Use - for standard output. |
concat.<format> |
--ignore-dirs |
-i |
Directory names to ignore. | .git, node_modules, vendor |
--ignore-pattern |
-p |
Custom gitignore-style patterns to exclude. Can be repeated. | |
--heading-level |
-l |
Markdown heading level for file headers (1-6). | 1 |
--format |
-f |
Output format. | markdown |
--include-hidden |
Include hidden files and directories (those starting with .). |
false |
|
--use-gitignore |
Automatically use .gitignore in the base directory if present. |
true |
|
--gitignore |
-g |
Path to a specific .gitignore file to use. |
Auto-detected |
This project uses a Makefile for common dev tasks.
- Go (version 1.23+)
golangci-lint(for thelinttarget)
make build: Build theamalgobinary.make test: Run all tests.make fmt: Format the Go source code.make lint: Run the linter to check for code style and errors.make tidy: Tidy and verify Go modules.make run: Build and run the tool with a default example (-e .go).make clean: Remove build artifacts.
To see all available commands, run:
make helpThis project is licensed under the MIT License. See the LICENSE file for details.