New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

llm-codebase-context

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

llm-codebase-context

A command-line tool to prepare your codebase for submission to Large Language Models (LLMs) like ChatGPT or Claude. It creates a formatted context file that includes your source code while intelligently filtering out binary files, large files, and commonl

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

LLM Codebase Context

A command-line tool to prepare your codebase for submission to Large Language Models (LLMs) like ChatGPT or Claude. It creates a formatted context file that includes your source code while intelligently filtering out binary files, large files, and commonly ignored directories.

Why Use This?

  • Quickly create LLM-ready snapshots of your codebase
  • Smart filtering removes irrelevant files (node_modules, binaries, build artifacts)
  • Avoids common issues like token limits by excluding overly large files
  • Structured XML output format is ideal for LLM context

Installation

# Install globally
npm install -g llm-codebase-context

# Or run with npx without installing
npx llm-codebase-context <project_root>

Usage

Basic Usage

# Process the current directory and output to structure.txt
codebase-context .

# Process a specific project and specify output file
codebase-context /path/to/project output.txt

# Process only a subdirectory of your project
codebase-context /path/to/project output.txt src

Advanced Usage

# Add custom ignore patterns
codebase-context . output.txt . "tests,fixtures,*.json"

# Process a specific subdirectory with custom ignores
codebase-context /path/to/project output.txt src "*.test.js,*.spec.js,__tests__"

Configuration

The tool comes with sensible defaults that work for most projects:

Default Limits

  • Maximum file size: 1MB
  • Maximum line count: 5000 lines

Default Ignore Patterns

The tool automatically ignores common patterns including:

  • Package management: node_modules, package-lock.json, etc.
  • Version control: .git, .gitignore
  • Build outputs: dist, build, .next, etc.
  • System files: .DS_Store, Thumbs.db
  • Environment/secrets: .env files, .pem, .key
  • Logs and temp files: logs, *.log, temp, tmp
  • Language-specific: __pycache__, *.class, etc.
  • Binary files: Images, videos, archives, executables

Output Format

The tool produces an XML-formatted file with each source file enclosed in <file> tags:

<file path="src/index.js">
// File content goes here
</file>

<file path="src/utils/helpers.js">
// Another file's content
</file>

This format is optimized for use with LLMs as it clearly delineates file boundaries and preserves path information.

Use Cases

  • Get help with bugs by providing full context to an LLM
  • Ask for architecture recommendations with full codebase knowledge
  • Generate documentation based on your entire project
  • Request refactoring suggestions with proper context

Contributing

Contributions are welcome! Feel free to submit issues or pull requests.

License

ISC

FAQs

Package last updated on 22 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts