Skip to main content

A CLI tool to combine a project's codebase into a single file for LLM context with expanded code map.

Project description

Combicode

NPM Version PyPI Version License: MIT

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.


Table of Contents


Why use Combicode?

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

Quick Start

Navigate to your project's root directory in your terminal and run one of the following commands:

For Node.js/JavaScript/TypeScript projects (via npx)

npx combicode

For Python projects (via pipx)

pipx run combicode

This will create a combicode.txt file in your project directory with the expanded code map.


Supported Languages

Combicode parses code structure for 40+ programming languages:

Full Language Support Table

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

Configuration Files (No Parsing)

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

Usage and Options

Preview which files will be included

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 -d

Example 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!

Specify an output file

Use the --output or -o flag.

npx combicode -o my_project_context.md
pipx run combicode --output ./output/context.txt

Include only specific file types

Use 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.txt

Add custom exclude patterns

Use 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/**"

Skip content for specific files

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)

Disable code structure parsing

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-parse

Output 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>

Generating Context for llms.txt

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.txt

Recreate Project from combicode.txt

The --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.txt format
  • ๐Ÿ› ๏ธ 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 --overwrite

Example 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!

All CLI Options

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.

How the Code Map Works

Line Reference System

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() method

Element Types

The 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

Filtering Rules

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

Examples

Python Project

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]

TypeScript Project

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]

Go Project

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]

Rust Project

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]

Java Project

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]

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

combicode-2.0.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

combicode-2.0.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file combicode-2.0.0.tar.gz.

File metadata

  • Download URL: combicode-2.0.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for combicode-2.0.0.tar.gz
Algorithm Hash digest
SHA256 d2e6db574c33ff90aaf6e728bf154d8c0c514d4de87774ba569c428362ede1d3
MD5 d5aa567977901bae369558b16893de53
BLAKE2b-256 2856910fc153ce2b4b802db0c2e1b4ecf2b81c749632344c0b7f005fdf4ab0a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for combicode-2.0.0.tar.gz:

Publisher: publish-to-pypi.yml on aaurelions/combicode

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file combicode-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: combicode-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for combicode-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61015ecbdbade23225df3733cfbc338885e076f60f613409a35915e821231a3a
MD5 df8750c98d3af8106285ba4079763ba0
BLAKE2b-256 d2691c3bf304d7282d66b23df6da4adbf0da490621f5961d9d1b45434c01e81e

See more details on using hashes here.

Provenance

The following attestation bundles were made for combicode-2.0.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on aaurelions/combicode

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page