Skip to main content

Give LLMs perfect context about your codebase

Project description

CodeCanopy ๐ŸŒณ

PyPI version Python 3.7+ License: MIT Downloads Code style: black

Give LLMs perfect context about your codebase

CodeCanopy solves the pain of manually copying file contents for LLM conversations. Get clean directory structures and file contents in one command - optimized for pasting into ChatGPT, Claude, or any LLM.

โšก Quick Start

pip install codecanopy
# Get project structure
codecanopy tree --focus src --ignore node_modules,dist

# Get file contents for LLM
codecanopy cat "src/**/*.js" --exclude "**/*.test.js"

๐ŸŽฏ Why CodeCanopy?

Before CodeCanopy:

# Manual, tedious process
tree -I node_modules
cat src/utils.js
cat src/components/Header.js  
cat src/api/users.js
# ...repeat for 20+ files

With CodeCanopy:

# One command, perfect output
codecanopy tree --focus src --ignore node_modules,dist
codecanopy cat "src/**/*.js" --exclude "**/*.test.js"

๐Ÿš€ Installation

# Install via pip
pip install codecanopy

# Install via pipx (recommended)
pipx install codecanopy

# Development install
git clone https://github.com/sawradip/CodeCanopy
cd CodeCanopy
pip install -e .

๐ŸŒณ Tree Command - Smart Directory Structure

Selective Depth Control

# Focus on src/, shallow everything else
codecanopy tree --focus src --depth 1

# Multiple focused directories  
codecanopy tree --focus src,lib --ignore node_modules,dist

Example Output:

project/
โ”œโ”€โ”€ src/                    [focused]
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ Header.js
โ”‚   โ”‚   โ”œโ”€โ”€ Footer.js
โ”‚   โ”‚   โ””โ”€โ”€ Navigation.js
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ api.js
โ”‚   โ”‚   โ””โ”€โ”€ helpers.js
โ”‚   โ””โ”€โ”€ index.js
โ”œโ”€โ”€ tests/                  [depth: 1]
โ”‚   โ”œโ”€โ”€ unit/
โ”‚   โ””โ”€โ”€ integration/
โ”œโ”€โ”€ docs/                   [depth: 1]
โ”‚   โ””โ”€โ”€ ...
โ””โ”€โ”€ package.json

Advanced Tree Options

# Show files and directories
codecanopy tree --focus src

# Custom depth and ignore patterns
codecanopy tree --depth 2 --ignore "*.log,tmp,cache"

# Analyze different directory
codecanopy tree /path/to/project --focus app,lib

๐Ÿ“„ Cat Command - Smart File Contents

Glob Pattern Matching

# All JavaScript files
codecanopy cat "src/**/*.js"

# Multiple file types
codecanopy cat "src/**/*.{js,ts,jsx}"

# Specific files only
codecanopy cat src/index.js src/app.js config/database.js

Smart Filtering

# Exclude test files
codecanopy cat "src/**/*.js" --exclude "**/*.test.js,**/*.spec.js"

# Size limits to avoid token overflow
codecanopy cat "src/**/*.py" --max-size 50KB

# Custom headers for better LLM context
codecanopy cat "src/**/*.js" --header "// File: {path}"

Example Output:

=== src/utils/api.js ===
export const fetchUser = async (id) => {
  const response = await fetch(`/api/users/${id}`);
  return response.json();
};

=== src/components/Header.js ===
import React from 'react';

const Header = ({ title }) => {
  return <h1>{title}</h1>;
};

export default Header;

โš™๏ธ Configuration

Create .codecanopy.json in your project root:

{
  "ignore": [
    "node_modules",
    ".git", 
    "dist",
    "build",
    ".next",
    "__pycache__"
  ],
  "default_depth": 3,
  "header_format": "=== {path} ===",
  "max_file_size": "100KB",
  "focus_dirs": ["src", "lib"]
}

๐ŸŽจ Real-World Examples

Frontend React Project

# Project structure
codecanopy tree --focus src/components,src/hooks --depth 2

# Component code for LLM review
codecanopy cat "src/components/**/*.{js,jsx}" --exclude "**/*.test.*"

Backend API Project

# API structure
codecanopy tree --focus src/routes,src/models --ignore node_modules

# All API code
codecanopy cat "src/{routes,models,middleware}/**/*.js"

Python Django Project

# Project overview
codecanopy tree --focus myapp --ignore "__pycache__,migrations"

# Models and views
codecanopy cat "myapp/**/*.py" --exclude "**/tests/**"

Full Stack Project Context

# Complete project for LLM
codecanopy tree --focus src,api --ignore node_modules,dist
codecanopy cat "src/**/*.{js,ts}" "api/**/*.py" --max-size 20KB

๐Ÿ› ๏ธ Advanced Usage

Debug Specific Feature

# Focus on auth module
codecanopy tree --focus src/auth
codecanopy cat "src/auth/**/*.js" "src/middleware/auth.js"

Prepare for Code Review

# Clean overview
codecanopy tree --ignore node_modules,dist,coverage

# Recent changes only (requires git)
codecanopy cat $(git diff --name-only HEAD~5 | grep -E '\.(js|py|go))

Documentation Generation

# Project structure for docs
codecanopy tree --files > STRUCTURE.md

# Code samples for documentation
codecanopy cat "examples/**/*.js" --header "### {filename}" > EXAMPLES.md

๐Ÿ“Š Command Reference

Tree Command

codecanopy tree [PATH] [OPTIONS]

Options:
  --focus TEXT     Focus directories (full depth). Can be used multiple times.
  --ignore TEXT    Ignore directories/files. Can be used multiple times.
  --depth INTEGER  Global depth limit (default: 3)
  --no-files       Hide files, show only directories
  --config TEXT    Config file path (default: .codecanopy.json)
  --help           Show this message and exit.

Cat Command

codecanopy cat PATTERNS [OPTIONS]

Arguments:
  PATTERNS            File patterns (supports globs)

Options:
  --exclude PATTERNS  Exclude file patterns
  --header FORMAT     Header format ({path}, {filename}, {dir})
  --no-headers       Skip file headers
  --max-size SIZE    Skip files larger than size (e.g., 100KB)
  --base-path PATH   Base path for relative paths
  --config FILE      Custom config file path

๐Ÿ’ก Pro Tips for LLM Usage

Optimal File Selection

# โœ… Focused and clean
codecanopy tree --focus src --ignore node_modules
codecanopy cat "src/**/*.js" --exclude "**/*.test.js" --max-size 20KB

# โŒ Too much noise
codecanopy tree
codecanopy cat "**/*"

Token Management

# Large codebase strategy
codecanopy tree --focus src --depth 2  # Structure overview
codecanopy cat "src/index.js" "src/app.js"  # Entry points only

# Feature-specific context
codecanopy tree --focus src/features/auth
codecanopy cat "src/features/auth/**/*.js"

Custom Headers for Context

# Better LLM understanding
codecanopy cat "src/**/*.py" --header "# File: {path}\n# Purpose: {dir}"

# Markdown-friendly output
codecanopy cat "src/**/*.js" --header "## {filename}\n\`\`\`javascript"

๐Ÿ”ง Integration Examples

VS Code Task

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "CodeCanopy: Full Context",
      "type": "shell",
      "command": "codecanopy tree --focus src && codecanopy cat 'src/**/*.js'",
      "group": "build"
    }
  ]
}

Git Hook (Pre-commit)

#!/bin/sh
# Generate project context for commit messages
codecanopy tree --focus src --depth 2 > .git/PROJECT_CONTEXT
codecanopy cat $(git diff --cached --name-only | head -5) >> .git/PROJECT_CONTEXT

Shell Alias

# Add to .bashrc or .zshrc
alias llm-context="codecanopy tree --focus src --ignore node_modules && codecanopy cat 'src/**/*.{js,py}' --exclude '**/*.test.*' --max-size 30KB"

๐Ÿ†š Comparison

Tool Selective Depth Custom Headers LLM Optimized Pattern Matching Size Control
tree โŒ โŒ โŒ โŒ โŒ
cat โŒ โŒ โŒ โŒ โŒ
find + cat โŒ โš ๏ธ โŒ โœ… โŒ
CodeCanopy โœ… โœ… โœ… โœ… โœ…

๐Ÿค Contributing

We welcome contributions! CodeCanopy is built for developers who work with LLMs daily.

# Development setup
git clone https://github.com/yourusername/codecanopy
cd codecanopy
pip install -e .

# Run tests
python test_codecanopy.py

# Format code
black codecanopy/

Feature Requests

  • ๐Ÿ”„ Git integration (show only changed files)
  • ๐Ÿ“Š Token counting for different LLM models
  • ๐ŸŽจ Syntax highlighting in output
  • ๐Ÿ“ฆ Export to different formats (JSON, Markdown)

๐Ÿ“ License

MIT License - use it, modify it, ship it.


Made with โค๏ธ for the AI-assisted development community

Stop copying files manually. Start using CodeCanopy. ๐Ÿš€

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

codecanopy-0.1.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

codecanopy-0.1.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file codecanopy-0.1.0.tar.gz.

File metadata

  • Download URL: codecanopy-0.1.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for codecanopy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ee3d1f779dc770c64d715eb96fb0446871563c55ab68c721d4b9cbe162b58475
MD5 bc2a8eb0175a8113141bc8066d9d563d
BLAKE2b-256 862f6eb0457420b6ff417556eee44e1c6b8219a0e9a483d89a8dd0026c74961f

See more details on using hashes here.

File details

Details for the file codecanopy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: codecanopy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for codecanopy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccaea3a2b8b67904cb366eebe374e4cc5761dfa0a70f4e45a2022f9de245950d
MD5 8218ef87593dd5b8cf39e93e61f0cc5a
BLAKE2b-256 8b66bf8d9229955fbe5928f5954acba0ceeb5c4b57649c6349eb94e0307686b5

See more details on using hashes here.

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