textcon
A text concatenation tool that fills in provided template by expanding file and directory references into a single corpus suitable for Large Language Model (LLM) consumption. Perfect for preparing code, configurations, and project structures for consumption by web versions of AI assistants like ChatGPT, Claude, Gemini, and others.
Can be used as either CLI tool or Rust library. Embeds file contents directly into templates, generates visual directory structures. Resolves relative paths and symlinks within the base directory only, but allows flexible path formatting (Postel's law) and uses explicit notation for including large files or deep directory contents.
Installation
Alternatively, download a release from GitHub.
Quick Start
Create a template file with {{ @file }} references:
# My Project
## Source Code
{{ @src/main.rs }}
## Project Structure
{{ @. }}
Process the template:
Alternatively, just stitch files together without a template file:
Reference Format
Basic Syntax
| Pattern | Description | Size Limit |
|---|---|---|
{{ @file.txt }} |
Include file contents | 64KB max |
{{ @!file.txt }} |
Force include large file | No limit |
{{ @dir/ }} |
Show directory tree only | N/A |
{{ @!dir/ }} |
Show tree + all file contents | No limit per file |
{{ @. }} |
Current directory tree | N/A |
{{ @!. }} |
Current dir tree + all files | No limit per file |
Path Formats
All these formats are equivalent for file.txt in the current directory:
{{ @file.txt }}{{ @/file.txt }}{{ @./file.txt }}
Exclusions
- .gitignore: Respected by default. Use
--no-gitignoreto disable. - Manual exclusions: Use
--exclude "GLOB"(e.g.,--exclude "node_modules/**") to exclude specific patterns. Note that manual exclusion patterns:- Are relative to the base directory.
- Do NOT support implicit recursion (e.g.,
dironly excludesdirat root, notsubdir/dir). Use**/dirfor recursive exclusion. - Do NOT support negation.
CLI Usage
# Process a template file
# Stitch files and directories together
# Process from stdin
|
# Write to file
# Use different base directory
# Limit directory tree depth
# Exclude specific files/patterns (glob)
# Disable .gitignore compliance (enabled by default)
# Remove file path comments
# Check validity of references
# (Works with inputs too)
# List references found in the template
# Detailed information
# JSON output for scripting
# View help with examples
Library Usage
use ;
Error Handling
Common errors and solutions:
| Error | Cause | Solution |
|---|---|---|
File not found |
Reference to non-existent file | Check file path and spelling |
Directory not found |
Reference to non-existent directory | Verify directory exists |
File size exceeds limit |
File larger than 64KB | Use @!filename to force |
Path traversal detected |
Trying to access outside base dir | Use only relative paths |
Invalid reference format |
Malformed template syntax | Check {{ @... }} format |
Copyright & License
© Hex @ aleph0 s.r.o. 2025 - Licensed under the EUPL. See LICENSE for more info.