Combicode is a CLI tool that intelligently combines your project's source code into a single, LLM-friendly text file with an expanded code map showing classes, functions, and loops with precise line references.
The generated file starts with a system prompt and an expanded tree structure that shows not just files, but also the code elements inside them (classes, functions, loops) with their line numbers and sizes. This gives the LLM a complete mental model of your codebase architecture before it reads a single line of code.
- Why use Combicode?
- Quick Start
- Supported Languages
- Usage and Options
- All CLI Options
- How the Code Map Works
- Examples
- License
| Feature | Description |
|---|---|
| πΊοΈ Expanded Code Map | Shows classes, functions, and loops with line numbers and sizes - LLMs understand your architecture instantly |
| π― Precise Navigation | Every element has [OL: X-Y | ML: X-Y | SIZE] references for both original and merged line numbers |
| π¦ Maximum Context | Gives your LLM a complete picture of your project structure and code |
| π 40+ Languages | Python (AST-based), JavaScript, TypeScript, Go, Rust, Java, C/C++, C#, PHP, Ruby, Swift, Kotlin, Scala, and more |
| π§Ή Intelligent Ignoring | Automatically skips node_modules, .venv, dist, .git, binary files, and other common junk |
π .gitignore Aware |
Respects your project's existing .gitignore rules out of the box |
| π Nested Ignore Support | Correctly handles .gitignore files located in subdirectories |
| β‘ Zero-Install Usage | Run it directly with npx or pipx without polluting your environment |
| π Recreate Support | Extract files from combicode.txt back to original project structure |
Navigate to your project's root directory in your terminal and run one of the following commands:
npx combicodepipx run combicodeThis will create a combicode.txt file in your project directory with the expanded code map.
Combicode parses code structure for 40+ programming languages:
| Language | Parser | Elements Detected |
|---|---|---|
| Python | AST (built-in) | class, def, async def, for, while |
| JavaScript | Regex | class, function, async function, arrow functions |
| TypeScript | Regex | class, interface, function, async function |
| Go | Regex | struct, interface, func |
| Rust | Regex | struct, enum, trait, impl, fn |
| Java | Regex | class, interface, enum, methods |
| C/C++ | Regex | class, struct, functions |
| C# | Regex | class, struct, interface, enum, record |
| PHP | Regex | class, interface, trait, function |
| Ruby | Regex | class, module, def |
| Swift | Regex | class, struct, enum, protocol, func |
| Kotlin | Regex | class, interface, object, fun |
| Scala | Regex | class, object, trait, def |
| Lua | Regex | function, local function |
| Perl | Regex | sub, package |
| Bash | Regex | function, for, while |
These files are included in the tree but not parsed for code structure:
| Type | Extensions |
|---|---|
| Config | .json, .yaml, .yml, .toml, .ini, .env |
| Markup | .md, .rst, .txt |
| Styles | .css, .scss, .less, .sass |
Use the --dry-run or -d flag to see a list of files without creating the output file.
npx combicode --dry-run
pipx run combicode -dExample output:
β¨ Combicode v2.0.0
π Root: /home/user/my-project
π Files to include (dry run):
src/index.ts (2.1KB)
src/server.ts (3.4KB)
src/utils/db.ts (1.2KB)
package.json (0.8KB)
tsconfig.json (0.3KB)
π Summary:
β’ Total files: 5
β’ Total size: 7.8KB
β
Done!
Use the --output or -o flag.
npx combicode -o my_project_context.md
pipx run combicode --output ./output/context.txtUse the --include-ext or -i flag with a comma-separated list of extensions.
# Include only TypeScript, TSX, and CSS files
npx combicode -i .ts,.tsx,.css
# Include only Python and YAML files
pipx run combicode -i .py,.yaml
# Include only markdown documentation
npx combicode -i .md -o llms.txtUse the --exclude or -e flag with comma-separated glob patterns.
# Exclude all test files and anything in a 'docs' folder
npx combicode -e "**/*_test.py,docs/**"
# Exclude generated files and fixtures
pipx run combicode -e "**/*.generated.*,fixtures/**"Use the --skip-content flag to include files in the tree structure but omit their content. This is useful for large files (like test files) that you want visible in the project overview but don't need their full content.
# Include .test.ts files in tree but skip their content
npx combicode --skip-content "**/*.test.ts"
# Skip content for multiple patterns
npx combicode --skip-content "**/*.test.ts,**/*.spec.ts,**/tests/**"
# Skip large generated files
pipx run combicode --skip-content "**/*.min.js,dist/**"Output with skipped content:
βββ tests/
βββ test_server.py [OL: 1-450 | ML: 183-184 | 12.1KB]
(Content omitted - file size: 12.1KB)
Use the --no-parse flag to generate a simple file tree without parsing classes, functions, or loops. This is useful for quick overviews or when parsing is not needed.
npx combicode --no-parseOutput with --no-parse:
<code_index>
project-root/
βββ src/
β βββ server.py [OL: 1-85 | ML: 53-137 | 2.4KB]
β βββ utils/
β βββ db.py [OL: 1-45 | ML: 138-182 | 1.2KB]
βββ tests/
βββ test_server.py [OL: 1-50 | ML: 183-232 | 1.1KB]
</code_index>
The --llms-txt or -l flag is designed for projects that use an llms.txt file to specify important documentation.
# Combine all markdown files for an llms.txt context
npx combicode -l -i .md -o llms.txt
# Combine documentation from docs folder
pipx run combicode -l -i .md,.rst -o llms.txtThe --recreate or -r flag extracts all files from a combicode.txt file and recreates the original project structure. This is useful for:
- π Restoring a project from an LLM-generated context
- π€ Extracting code shared by others in
combicode.txtformat - π οΈ Converting the merged file back to individual source files
# Recreate project from combicode.txt (default)
npx combicode --recreate
# Specify input file and output directory
npx combicode --recreate --input my_context.txt -o ./restored_project
# Short form
npx combicode -r -i my_context.txt -o ./output
# Dry run to see what files would be extracted
npx combicode --recreate --dry-run
# Overwrite existing files
npx combicode --recreate --overwriteExample output:
β¨ Combicode v2.0.0
π Root: /home/user/projects
π Output directory: /home/user/projects
src/index.ts (2.1KB)
src/server.ts (3.4KB)
src/utils/db.ts (1.2KB)
src/utils/logger.ts (0.8KB)
src/handlers/user.ts (1.5KB)
src/handlers/auth.ts (1.2KB)
config/app.yaml (0.4KB)
package.json (0.8KB)
tsconfig.json (0.3KB)
...
π Summary:
β’ Files recreated: 15
β’ Total size: 45.2KB
β
Done!
| Option | Alias | Description | Default |
|---|---|---|---|
--output |
-o |
Output file (combine) or directory (recreate). | combicode.txt |
--dry-run |
-d |
Preview without making changes. | false |
--include-ext |
-i |
Comma-separated list of extensions to exclusively include. | (include all) |
--exclude |
-e |
Comma-separated list of additional glob patterns to exclude. | (none) |
--skip-content |
Comma-separated glob patterns for files to include in tree but omit content. | (none) | |
--no-parse |
Disable code structure parsing (show only file tree). | false |
|
--llms-txt |
-l |
Use a specialized system prompt for context generated from an llms.txt file. |
false |
--no-gitignore |
Do not use patterns from the project's .gitignore file. |
false |
|
--no-header |
Omit the introductory prompt and file tree from the output. | false |
|
--recreate |
-r |
Recreate project from a combicode.txt file. | false |
--input |
Input combicode.txt file for recreate. | combicode.txt |
|
--overwrite |
Overwrite existing files when recreating. | false |
|
--version |
-v |
Show the version number. | |
--help |
-h |
Show the help message. |
Every element has dual line references:
| Reference | Description | Usage |
|---|---|---|
| OL (Original Line) | Line numbers in the source file on disk | Find code in original project |
| ML (Merged Line) | Line numbers in the combined combicode.txt file |
Extract code with sed command |
Extracting code using ML:
# Extract lines 100-150 from combicode.txt
sed -n '100,150p' combicode.txt
# Extract a specific function
sed -n '69,97p' combicode.txt # Extracts async start() methodThe code map extracts these element types:
| Label | Description | Example |
|---|---|---|
class |
Classes, structs, interfaces, enums, traits | class Server |
fn |
Functions and methods | fn parse_args() |
async |
Async functions | async fetch_data() |
ctor |
Constructors (__init__, constructor) |
ctor __init__(self, port: int) |
loop |
For/while loops (only if > 5 lines) | loop for item in items |
impl |
Implementation blocks (Rust) | impl Server |
test |
Test functions | test test_server_start |
describe |
Test suites | describe Server |
| Category | Elements |
|---|---|
| Always included | Files, classes, functions, constructors |
| Conditionally included | Loops and try/catch blocks (only if > 5-10 lines) |
| Excluded | Imports, comments, single-line elements, getters/setters |
src/
βββ main.py [OL: 1-85 | ML: 53-137 | 2.4KB]
β βββ class Server [OL: 5-60 | ML: 57-112 | 1.8KB]
β β βββ ctor __init__(self, host: str, port: int) [OL: 7-15 | ML: 59-67 | 284B]
β β βββ async start(self) -> None [OL: 17-45 | ML: 69-97 | 892B]
β β βββ fn stop(self) -> None [OL: 47-55 | ML: 99-107 | 256B]
β βββ fn parse_args() -> dict [OL: 63-85 | ML: 115-137 | 612B]
βββ utils/
β βββ db.py [OL: 1-45 | ML: 138-182 | 1.2KB]
β βββ class Database [OL: 5-40 | ML: 142-177 | 1.1KB]
β βββ ctor __init__(self, connection_string: str) [OL: 7-15 | ML: 144-152 | 312B]
β βββ fn query(self, sql: str) -> list [OL: 17-40 | ML: 154-177 | 756B]
βββ config.py [OL: 1-20 | ML: 183-202 | 0.4KB]
src/
βββ index.ts [OL: 1-52 | ML: 53-104 | 2.1KB]
β βββ class Server [OL: 5-42 | ML: 57-94 | 1.5KB]
β β βββ ctor (port: number, host?: string) [OL: 7-14 | ML: 59-66 | 256B]
β β βββ async start(): Promise<void> [OL: 16-32 | ML: 68-84 | 612B]
β β βββ fn stop(): void [OL: 34-42 | ML: 86-94 | 298B]
β βββ fn createApp(config: Config): Express [OL: 45-52 | ML: 97-104 | 412B]
βββ handlers/
β βββ user.ts [OL: 1-78 | ML: 105-182 | 2.4KB]
β βββ interface UserRoutes [OL: 5-15 | ML: 109-119 | 312B]
β βββ fn createUser(req: Request, res: Response) [OL: 17-78 | ML: 121-182 | 1.8KB]
βββ types/
βββ index.ts [OL: 1-25 | ML: 183-207 | 0.5KB]
βββ interface Config [OL: 3-25 | ML: 185-207 | 456B]
cmd/
βββ server/
βββ main.go [OL: 1-60 | ML: 53-112 | 1.6KB]
βββ fn main() [OL: 5-60 | ML: 57-112 | 1.4KB]
internal/
βββ handlers/
β βββ user.go [OL: 1-120 | ML: 113-232 | 3.2KB]
β βββ struct UserHandler [OL: 8-25 | ML: 120-137 | 512B]
β βββ fn NewUserHandler(db *sql.DB) *UserHandler [OL: 27-35 | ML: 139-147 | 234B]
βββ models/
βββ user.go [OL: 1-45 | ML: 233-277 | 1.1KB]
βββ struct User [OL: 5-45 | ML: 237-277 | 945B]
src/
βββ main.rs [OL: 1-45 | ML: 53-97 | 1.2KB]
β βββ fn main() [OL: 3-45 | ML: 55-97 | 1.0KB]
βββ server/
β βββ mod.rs [OL: 1-120 | ML: 98-217 | 3.4KB]
β βββ struct Server [OL: 5-25 | ML: 102-122 | 612B]
β βββ impl Server [OL: 27-100 | ML: 124-197 | 2.5KB]
β β βββ fn new(host: &str, port: u16) -> Self [OL: 29-45 | ML: 126-142 | 456B]
β β βββ async fn start(&self) -> Result<()> [OL: 47-100 | ML: 144-197 | 1.8KB]
β βββ fn create_server(config: Config) -> Server [OL: 102-120 | ML: 199-217 | 534B]
βββ config.rs [OL: 1-35 | ML: 218-252 | 0.8KB]
βββ struct Config [OL: 3-35 | ML: 220-252 | 712B]
src/main/java/com/example/
βββ Application.java [OL: 1-30 | ML: 53-82 | 0.9KB]
β βββ class Application [OL: 3-30 | ML: 55-82 | 756B]
β βββ fn main(String[] args) [OL: 5-30 | ML: 57-82 | 654B]
βββ server/
β βββ Server.java [OL: 1-150 | ML: 83-232 | 4.2KB]
β βββ class Server [OL: 5-120 | ML: 87-202 | 3.4KB]
β β βββ ctor Server(int port, String host) [OL: 15-35 | ML: 97-117 | 612B]
β β βββ fn start() [OL: 37-80 | ML: 119-162 | 1.2KB]
β β βββ fn stop() [OL: 82-120 | ML: 164-202 | 1.1KB]
β βββ class ServerBuilder [OL: 122-150 | ML: 204-232 | 756B]
βββ config/
βββ Config.java [OL: 1-45 | ML: 233-277 | 1.1KB]
βββ class Config [OL: 3-45 | ML: 235-277 | 1.0KB]
This project is licensed under the MIT License.
