### Run Custom Configuration Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the custom configuration example script. ```bash python custom_config.py ``` -------------------------------- ### Run Git Integration Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the Git integration example script. ```bash python git_integration.py ``` -------------------------------- ### Run Output Split Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the output split example script. ```bash python output_split.py ``` -------------------------------- ### Run Basic Usage Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the basic usage example script. ```bash python basic_usage.py ``` -------------------------------- ### Run Full Directory Structure Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the full directory structure example script. ```bash python full_directory_structure.py ``` -------------------------------- ### Install Repomix Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Install the Repomix library using pip. ```bash pip install repomix ``` -------------------------------- ### Development 'cwd' Configuration Example Source: https://github.com/andersonby/python-repomix/blob/main/README.md Example of setting the 'cwd' parameter for development purposes, providing a flexible starting point for the Repomix server. ```json // Development - flexible starting point "cwd": "/Users/yourusername/dev" ``` -------------------------------- ### Run Remote Repository Handling Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the remote repository handling example script. ```bash python remote_repo_usage.py ``` -------------------------------- ### Run Security Check Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the security check example script. ```bash python security_check.py ``` -------------------------------- ### Run File Statistics Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the file statistics example script. ```bash python file_statistics.py ``` -------------------------------- ### Run JSON Output Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the JSON output example script. ```bash python json_output.py ``` -------------------------------- ### Run Token Count Tree Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the token count tree example script. ```bash python token_count_tree.py ``` -------------------------------- ### AI Prompt for Documentation Generation Source: https://github.com/andersonby/python-repomix/blob/main/README.md Generate project documentation, including an overview, features, setup, and usage examples, by providing the AI with the full codebase. ```text Based on the codebase in this file, please generate a detailed README.md that includes an overview of the project, its main features, setup instructions, and usage examples. ``` -------------------------------- ### Repomix uvx Examples Source: https://github.com/andersonby/python-repomix/blob/main/README_zh.md Examples demonstrating various ways to use Repomix with uvx, including JSON output, remote repository packaging, and specific include/ignore patterns. ```bash # 使用 JSON 输出打包 uvx repomix --style json # 打包远程仓库 uvx repomix --remote https://github.com/username/repo # 使用特定模式打包 uvx repomix --include "src/**/*.py" --ignore "tests/**" # 使用特定版本 uvx repomix@0.5.0 ``` -------------------------------- ### Run Tree-sitter Compression Example Source: https://github.com/andersonby/python-repomix/blob/main/examples/README.md Execute the tree-sitter compression demonstration script. ```bash python tree_sitter_compression.py ``` -------------------------------- ### Repomix Configuration File Example Source: https://github.com/andersonby/python-repomix/blob/main/README.md Example of a repomix.config.json file specifying the path to a custom instruction file. This allows for persistent configuration of Repomix settings. ```json { "output": { "instruction_file_path": "repomix-instruction.md" } } ``` -------------------------------- ### CLI: Start MCP Server Manually Source: https://context7.com/andersonby/python-repomix/llms.txt Start the Repomix MCP server manually from the command line. ```bash # Start MCP server manually repomix --mcp ``` -------------------------------- ### Repomix Configuration File Example Source: https://github.com/andersonby/python-repomix/blob/main/README_zh.md Example of a repomix.config.json file for customizing Repomix behavior. This file can be placed in the project root or loaded globally. ```json { "input": { "max_file_size": 52428800 }, "output": { "file_path": "repomix-output.md", "style": "markdown", "header_text": "", "instruction_file_path": "", "remove_comments": false, "remove_empty_lines": false, "top_files_length": 5, "show_line_numbers": false, "copy_to_clipboard": false, "include_empty_directories": false, "calculate_tokens": false, "show_file_stats": false, "show_directory_structure": true, "include_full_directory_structure": false, "split_output": null, "token_count_tree": false, "git": { "sort_by_changes": true, "sort_by_changes_max_commits": 100, "include_diffs": false, "include_logs": false, "include_logs_count": 50 } }, "security": { "enable_security_check": true, "exclude_suspicious_files": true }, "ignore": { "custom_patterns": [], "use_gitignore": true, "use_default_ignore": true, "use_dot_ignore": true }, "compression": { "enabled": false, "keep_signatures": true, "keep_docstrings": true, "keep_interfaces": true }, "remote": { "url": "", "branch": "" }, "include": [], "token_count": { "encoding": "o200k_base" } } ``` -------------------------------- ### Project-Specific 'cwd' Configuration Example Source: https://github.com/andersonby/python-repomix/blob/main/README.md Example of setting the 'cwd' parameter to a specific project directory, which is convenient for frequent analysis of that project. ```json // Project-specific - convenient for frequent analysis "cwd": "/Users/yourusername/projects/my-main-project" ``` -------------------------------- ### Repomix Command-Line Usage Source: https://github.com/andersonby/python-repomix/blob/main/README_zh.md Basic command-line examples for Repomix, including packaging the entire repository, specific directories, multiple directories, and remote repositories. ```bash # 要打包你的整个仓库: repomix # 要打包特定目录: repomix path/to/directory # 要同时打包多个目录: repomix src lib tests # 要打包一个远程仓库: repomix --remote https://github.com/username/repo # 要打包远程仓库的特定分支: repomix --remote https://github.com/username/repo --remote-branch feature-branch # 要初始化一个新的配置文件: repomix --init # 使用 --global 创建一个全局配置文件(详见下文配置选项) repomix --init --global ``` -------------------------------- ### Start Repomix MCP Server Source: https://github.com/andersonby/python-repomix/blob/main/README.md Command to start the Repomix MCP server, enabling AI assistants to interact directly with your codebase. ```bash repomix mcp start ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Install all necessary development dependencies, including linters and testing tools. Run this if you encounter import or type check errors. ```bash pdm install --dev ``` -------------------------------- ### Start Repomix MCP Server Source: https://github.com/andersonby/python-repomix/blob/main/README.md Run this command in your terminal to start the Repomix MCP server. Detailed logs will be output to stderr. ```bash repomix --mcp ``` -------------------------------- ### Verify Installation and Run Checks Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Verify the installation by testing the CLI, running tests with pytest, and performing code quality checks with Ruff and Pyright. ```bash pdm run python -m repomix --help pdm run python -m pytest pdm run ruff check . pdm run pyright ``` -------------------------------- ### General Use 'cwd' Configuration Example Source: https://github.com/andersonby/python-repomix/blob/main/README.md Example of setting the 'cwd' parameter for general use, allowing the Repomix server to run from a stable, accessible directory like your home folder. ```json // General use - works from anywhere "cwd": "/Users/yourusername" ``` -------------------------------- ### Install Dependencies with pip Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Install project dependencies using pip and a virtual environment. This is an alternative to using PDM. ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e . pip install pytest pytest-asyncio ruff pyright ``` -------------------------------- ### XML Repository Structure Example Source: https://github.com/andersonby/python-repomix/blob/main/README.md An example of the XML output structure, detailing repository contents, file statistics, and overall project statistics. ```xml (Directory and file structure) src/index.py 1234 567 # File contents here (...remaining files) 19 37377 11195 ``` -------------------------------- ### Run Repomix after pip installation Source: https://github.com/andersonby/python-repomix/blob/main/README.md Execute Repomix from any project directory after installing it globally with pip. ```bash repomix ``` -------------------------------- ### uvx Examples: JSON Output, Remote Repo, Specific Patterns Source: https://github.com/andersonby/python-repomix/blob/main/README.md Demonstrates using uvx with Repomix to customize output format, process remote repositories, and filter files using include/ignore patterns. ```bash # Pack with JSON output uvx repomix --style json # Pack a remote repository uvx repomix --remote https://github.com/username/repo # Pack with specific patterns uvx repomix --include "src/**/*.py" --ignore "tests/**" # Use a specific version uvx repomix@0.5.0 ``` -------------------------------- ### Repomix Remote Repository CLI Examples Source: https://github.com/andersonby/python-repomix/blob/main/README.md Examples of how to specify remote repositories for Repomix processing using the CLI. This includes GitHub shorthand, full URLs, and specific branches or tags. ```bash repomix --remote user/repo ``` ```bash repomix --remote https://github.com/user/repo ``` ```bash repomix --remote https://github.com/user/repo --remote-branch feature-branch ``` ```bash repomix --remote https://github.com/user/repo --remote-branch v1.0.0 ``` -------------------------------- ### Install Dependencies with PDM Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Install project dependencies, including development tools, using PDM. PDM is the recommended package manager for this project. ```bash pip install pdm pdm install --dev ``` -------------------------------- ### Run Repomix with uvx Source: https://github.com/andersonby/python-repomix/blob/main/README_zh.md Use uvx to quickly run Repomix without installation. This is the recommended method for quick usage. ```bash uvx repomix ``` -------------------------------- ### Repomix Compression Example: Code Overview Source: https://github.com/andersonby/python-repomix/blob/main/README.md Configures Repomix to generate a code overview by enabling compression and keeping only function signatures, excluding docstrings. ```python # Example 2: Code overview without implementation details config = RepomixConfig() config.compression.enabled = True config.compression.keep_signatures = True config.compression.keep_docstrings = False config.compression.keep_interfaces = False # Keep full signatures but remove docstrings config.output.file_path = "code-overview.md" processor = RepoProcessor(".", config=config) result = processor.process() ``` -------------------------------- ### JSON Repository Structure Example Source: https://github.com/andersonby/python-repomix/blob/main/README.md An example of the JSON output structure, including summary statistics, file tree representation, and detailed file information. ```json { "summary": { "total_files": 19, "total_chars": 37377, "total_tokens": 11195, "generation_date": "2025-01-28T12:00:00" }, "file_tree": { "src": { "index.py": "", "utils.py": "" } }, "files": [ { "path": "src/index.py", "content": "# File contents here", "chars": 1234, "tokens": 567 } ] } ``` -------------------------------- ### Repomix Remote URL Examples Source: https://github.com/andersonby/python-repomix/blob/main/README_zh.md Examples of using the --remote flag with various URL formats for specifying remote repositories, including shorthand, full URLs, and specific branches or tags. ```bash # GitHub 简写 repomix --remote user/repo # 完整 GitHub URL repomix --remote https://github.com/user/repo # 指定分支 repomix --remote https://github.com/user/repo --remote-branch feature-branch # 指定标签 repomix --remote https://github.com/user/repo --remote-branch v1.0.0 ``` -------------------------------- ### Repomix Compression Example: API Documentation Source: https://github.com/andersonby/python-repomix/blob/main/README.md Configures Repomix to generate API documentation by enabling compression and specifically keeping interface signatures and docstrings. ```python from repomix import RepoProcessor, RepomixConfig # Example 1: Generate API documentation (Interface Mode) config = RepomixConfig() config.compression.enabled = True config.compression.keep_interfaces = True # Keep signatures + docstrings only config.output.file_path = "api-documentation.md" processor = RepoProcessor(".", config=config) result = processor.process() print(f"API documentation generated: {result.config.output.file_path}") ``` -------------------------------- ### Conventional Commits Examples Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Examples of commit messages following the Conventional Commits specification for various types of changes. ```text feat: add remote repository support with branch selection fix: handle edge case in file encoding detection docs: update installation instructions test: add comprehensive MCP server tests ``` -------------------------------- ### MCP Tool Call Log Example Source: https://github.com/andersonby/python-repomix/blob/main/README.md This log demonstrates a typical interaction when an AI assistant calls the 'pack_codebase' MCP tool. It shows the parameters used and the processing steps. ```text 🔨 MCP Tool Called: pack_codebase 📁 Directory: /path/to/project 🗜️ Compress: false 📊 Top files: 10 🏗️ Creating workspace... 📝 Output will be saved to: /tmp/repomix_mcp_xxx/repomix-output.xml 🔄 Processing repository... ✅ Processing completed! 📊 Files processed: 45 📝 Characters: 125,432 🎯 Tokens: 0 🎉 MCP response generated successfully ``` -------------------------------- ### Build Repomix Docker Image Source: https://github.com/andersonby/python-repomix/blob/main/README.md Build a Docker image for Repomix. This allows running the tool in an isolated environment without local installation. ```bash # Build the Docker image docker build -t repomix . ``` -------------------------------- ### Run Repomix with Docker Source: https://github.com/andersonby/python-repomix/blob/main/README_zh.md Build and run Repomix using Docker for an isolated and consistent environment. This avoids local Python dependency installations. ```bash # 构建 Docker 镜像 docker build -t repomix . # 在当前目录运行 repomix docker run --rm -v "$(pwd)":/app repomix # 使用特定选项运行 repomix docker run --rm -v "$(pwd)":/app repomix --style markdown --output custom-output.md # 在不同目录运行 repomix docker run --rm -v "/path/to/your/project":/app repomix ``` -------------------------------- ### Extracting Information from JSON Output with jq Source: https://github.com/andersonby/python-repomix/blob/main/README.md Examples of using the `jq` command-line tool to extract specific data points from the JSON output of Repomix. ```bash # Extract file paths cat repomix-output.json | jq '.files[].path' ``` ```bash # Get total token count cat repomix-output.json | jq '.summary.total_tokens' ``` ```bash # Find files with more than 1000 tokens cat repomix-output.json | jq '.files[] | select(.tokens > 1000) | {path, tokens}' ``` -------------------------------- ### Python Function with Docstring and Type Hints Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Example of a public Python function adhering to Google-style docstrings and comprehensive type annotations. Use this for all public functions. ```python def process_repository( config: RepomixConfig, directory: Path ) -> ProcessResult: """Process a repository and generate output. Args: config: Configuration object with processing options directory: Path to the repository directory Returns: ProcessResult containing output and metadata Raises: RepositoryError: If repository cannot be processed ConfigurationError: If configuration is invalid """ ``` -------------------------------- ### Clone Repository Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Clone your fork of the Repomix repository locally. Ensure you have Git installed and have forked the repository on GitHub. ```bash git clone https://github.com/AndersonBY/python-repomix.git cd python-repomix ``` -------------------------------- ### Add Repomix MCP Server via Claude CLI Source: https://github.com/andersonby/python-repomix/blob/main/README.md Use this command in your terminal to add the Repomix MCP server for use with Claude. This command assumes Repomix is installed and accessible in your PATH. ```bash claude mcp add repomix -- repomix --mcp ``` -------------------------------- ### AI Prompt for Code Architecture Analysis Source: https://github.com/andersonby/python-repomix/blob/main/README.md Analyze code structure (with minimal implementation details) to identify design patterns, modularity, and separation of concerns, and get suggestions for improvement. ```text This file contains the code structure with function signatures but minimal implementation details. Please analyze the overall architecture, identify design patterns used, and suggest improvements for better modularity and separation of concerns. ``` -------------------------------- ### Python Test Class Structure Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md A standard structure for Python test classes using pytest. Includes setup methods and example test methods for basic functionality and edge cases. ```python class TestFeatureName: """Test suite for FeatureName functionality""" def setup_method(self): """Setup before each test method""" pass def test_basic_functionality(self): """Test basic feature behavior""" # Arrange # Act # Assert pass def test_edge_cases(self): """Test edge cases and error conditions""" pass ``` -------------------------------- ### CLI: Standard Output and Initialization Source: https://context7.com/andersonby/python-repomix/llms.txt Output directly to stdout using the --stdout flag. Initialize a configuration file with --init. ```bash # Output to stdout instead of file repomix --stdout ``` ```bash # Initialize configuration file repomix --init ``` -------------------------------- ### Repomix Command Line: Initialize Configuration File Source: https://github.com/andersonby/python-repomix/blob/main/README.md Command to generate a new Repomix configuration file. Use the --global flag to create a global configuration. ```bash # Initialize a new configuration file repomix --init # Use --global to create a global configuration file (see Configuration Options below) repomix --init --global ``` -------------------------------- ### CLI: MCP Server and uvx Source: https://context7.com/andersonby/python-repomix/llms.txt Run Repomix as an MCP server for AI assistant integration using --mcp. Use uvx for zero-installation execution. ```bash # Run as MCP server for AI assistant integration repomix --mcp ``` ```bash # Quick run with uvx (no installation required) uvx repomix ``` ```bash uvx repomix --style json ``` ```bash uvx repomix --remote https://github.com/username/repo ``` -------------------------------- ### Basic Repomix Library Usage Source: https://github.com/andersonby/python-repomix/blob/main/README.md Demonstrates the basic usage of the RepoProcessor class from the Repomix library to process a local repository. ```python from repomix import RepoProcessor # Basic usage processor = RepoProcessor(".") result = processor.process() # Process remote repository with specific branch processor = RepoProcessor(repo_url="https://github.com/username/repo", branch="feature-branch") result = processor.process() # Access processing results print(f"Total files: {result.total_files}") print(f"Total characters: {result.total_chars}") print(f"Total tokens: {result.total_tokens}") print(f"Output saved to: {result.config.output.file_path}") ``` -------------------------------- ### CLI: Output and Format Options Source: https://context7.com/andersonby/python-repomix/llms.txt Specify the output file name and format (e.g., markdown, json) using the --output and --style flags. ```bash # Specify output file and format repomix --output custom-output.md --style markdown ``` ```bash # Pack with JSON output repomix --style json --output repomix-output.json ``` -------------------------------- ### CLI: Compression and Filtering Source: https://context7.com/andersonby/python-repomix/llms.txt Enable code compression with --compress. Use --include and --ignore flags to specify patterns for files to include or exclude. ```bash # Enable code compression repomix --compress ``` ```bash # Include/ignore specific patterns repomix --include "src/**/*.py" --ignore "tests/**,*.log" ``` -------------------------------- ### CLI: Basic Repository Packing Source: https://context7.com/andersonby/python-repomix/llms.txt Pack the current directory or a specified directory using the repomix command. This is the most basic usage. ```bash # Basic usage - pack current directory repomix ``` ```bash # Pack specific directory repomix path/to/directory ``` ```bash # Pack multiple directories repomix src lib tests ``` -------------------------------- ### Specify Custom Instruction File via CLI Source: https://github.com/andersonby/python-repomix/blob/main/README.md Provide a path to a markdown file containing custom instructions for AI tools. These instructions will be included in the output. ```bash repomix --instruction-file-path repomix-instruction.md ``` -------------------------------- ### Create Feature Branch Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Create a new feature branch from the main branch to start working on new features or bug fixes. Ensure your local main branch is up-to-date with the upstream. ```bash git checkout main git pull upstream main git checkout -b feature/your-feature-name ``` -------------------------------- ### AI Prompt for Configuration Analysis Source: https://github.com/andersonby/python-repomix/blob/main/README.md Review configuration, constants, and global variables to identify potential issues and best practices for management. ```text This file contains only the configuration, constants, and global variables from my codebase. Please review these settings, identify potential configuration issues, and suggest best practices for configuration management. ``` -------------------------------- ### Advanced Repomix Configuration Source: https://github.com/andersonby/python-repomix/blob/main/README.md Shows how to create and apply a custom Repomix configuration using the RepomixConfig class for detailed control over output, security, compression, and file inclusion/exclusion. ```python from repomix import RepoProcessor, RepomixConfig # Create custom configuration config = RepomixConfig() # Output settings config.output.file_path = "custom-output.md" config.output.style = "markdown" # supports "plain", "markdown", and "xml" config.output.show_line_numbers = True # Security settings config.security.enable_security_check = True config.security.exclude_suspicious_files = True # Compression settings config.compression.enabled = True config.compression.keep_signatures = True config.compression.keep_docstrings = True config.compression.keep_interfaces = True # Interface mode for API documentation # Include/Ignore patterns config.include = ["src/**/*", "tests/**/*"] config.ignore.custom_patterns = ["*.log", "*.tmp"] config.ignore.use_gitignore = True # Remote repository configuration config.remote.url = "https://github.com/username/repo" config.remote.branch = "feature-branch" # Process repository with custom config processor = RepoProcessor(".", config=config) result = processor.process() ``` -------------------------------- ### Repomix Command Line: Pack Multiple Directories Source: https://github.com/andersonby/python-repomix/blob/main/README.md Command to pack multiple specified directories simultaneously. ```bash repomix src lib tests ``` -------------------------------- ### Apply Code Compression via CLI Source: https://github.com/andersonby/python-repomix/blob/main/README.md Use `--config-override` with a JSON string to apply compression settings directly from the command line. This allows for dynamic configuration of compression modes like API documentation generation or configuration extraction. ```bash repomix --config-override '{"compression": {"enabled": true, "keep_interfaces": true}}' ``` ```bash repomix --config-override '{"compression": {"enabled": true, "keep_interfaces": false, "keep_signatures": true, "keep_docstrings": false}}' ``` ```bash repomix --config-override '{"compression": {"enabled": true, "keep_signatures": false}}' ``` -------------------------------- ### Repomix Command Line: Pack Remote Repository Source: https://github.com/andersonby/python-repomix/blob/main/README.md Command to pack a repository directly from a remote URL. ```bash repomix --remote https://github.com/username/repo ``` -------------------------------- ### CLI: Output Splitting and Diffs Source: https://context7.com/andersonby/python-repomix/llms.txt Split output into multiple files based on size using --split-output. Include git diffs and logs with --include-diffs and --include-logs. ```bash # Split output into multiple files repomix --split-output 500kb ``` ```bash # Include git diffs and logs repomix --include-diffs --include-logs --include-logs-count 20 ``` -------------------------------- ### MCP Server Configuration for Claude Desktop Source: https://context7.com/andersonby/python-repomix/llms.txt Configure Repomix as an MCP server in Claude Desktop by defining the command, arguments, and working directory. ```json // Claude Desktop configuration (claude_desktop_config.json) { "mcpServers": { "repomix": { "command": "repomix", "args": ["--mcp"], "cwd": "/path/to/your/project" } } } ``` -------------------------------- ### Run Quality Checks with PDM Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Execute all project quality checks using PDM. Ensure these commands pass before submitting contributions. ```bash pdm run ruff check . ``` ```bash pdm run pyright ``` ```bash pdm run python -m pytest ``` -------------------------------- ### Process Local Repository - Basic Usage Source: https://context7.com/andersonby/python-repomix/llms.txt Use the RepoProcessor class to process a local directory. Access results like file counts, character counts, and token counts. The output can be written to a file or accessed directly. ```python from repomix import RepoProcessor # Create a processor instance pointing to current directory processor = RepoProcessor(".") # Process the repository result = processor.process() # Access processing results print(f"Total files: {result.total_files}") print(f"Total characters: {result.total_chars}") print(f"Total tokens: {result.total_tokens}") print(f"Output saved to: {result.config.output.file_path}") # Access the generated content directly output_content = result.output_content # Process without writing to file result = processor.process(write_output=False) ``` -------------------------------- ### Python API: Process Repository Source: https://context7.com/andersonby/python-repomix/llms.txt Use the RepoProcessor class to process a repository with custom configurations. Ensure the config object is properly initialized. ```python # Enable token count tree visualization config.output.token_count_tree = True # Use default depth # config.output.token_count_tree = 3 # Show 3 levels deep # config.output.token_count_tree = "full" # Show all levels # Process the repository processor = RepoProcessor(".", config=config) result = processor.process() print(f"Total tokens: {result.total_tokens}") # Access per-file token counts for file_path, token_count in result.file_token_counts.items(): print(f"{file_path}: {token_count} tokens") ``` -------------------------------- ### AI Prompt for Library Overview Source: https://github.com/andersonby/python-repomix/blob/main/README.md Obtain a high-level understanding of a library's purpose, features, and architecture by providing the AI with its entire codebase. ```text This file contains the entire codebase of library. Please provide a comprehensive overview of the library, including its main purpose, key features, and overall architecture. ``` -------------------------------- ### MCP Tools Source: https://context7.com/andersonby/python-repomix/llms.txt List of available MCP tools provided by Repomix for AI assistant integration. ```bash # Available MCP tools: # - pack_codebase: Package local codebase into XML format # - pack_remote_repository: Package remote repositories # - read_repomix_output: Read generated output files # - grep_repomix_output: Search within output files # - file_system_read_file: Read files from filesystem # - file_system_read_directory: List directory contents # - generate_skill: Generate Claude Agent Skills from codebase ``` -------------------------------- ### Split Output for Large Codebases Source: https://github.com/andersonby/python-repomix/blob/main/README.md Use `--split-output` with a size suffix (e.g., `kb`, `mb`) to divide the output into multiple files. Files are numbered sequentially and split at directory boundaries. ```bash repomix --split-output 500kb ``` ```bash repomix --split-output 2mb ``` -------------------------------- ### Run Tests with Coverage Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Run all tests and generate an HTML report of code coverage. This helps identify areas of the code that are not adequately tested. ```bash pdm run python -m pytest --cov=src/repomix --cov-report=html ``` -------------------------------- ### Repomix Command Line: Pack Remote Repository with Specific Branch Source: https://github.com/andersonby/python-repomix/blob/main/README.md Command to pack a repository from a remote URL, specifying a particular branch to process. ```bash repomix --remote https://github.com/username/repo --remote-branch feature-branch ``` -------------------------------- ### AI Prompt for API Documentation Review Source: https://github.com/andersonby/python-repomix/blob/main/README.md Review API interfaces (with implementation details removed) for design consistency, documentation gaps, and clarity of method signatures. ```text This file contains the API interfaces of my codebase with all implementation details removed. Please review the API design, suggest improvements for consistency, and identify any missing documentation or unclear method signatures. ``` -------------------------------- ### Generate XML Output Source: https://github.com/andersonby/python-repomix/blob/main/README.md Use the --style xml option to generate repository analysis in XML format. This format provides a hierarchical structure for the repository data. ```bash python -m repomix --style xml ``` -------------------------------- ### Custom Configuration for Repository Processing Source: https://context7.com/andersonby/python-repomix/llms.txt Configure output format, security, and ignore patterns using RepomixConfig. Set file paths, output styles (plain, xml, markdown, json), line numbers, and compression options. Define include/exclude rules and gitignore usage. ```python from repomix import RepoProcessor, RepomixConfig # Create custom configuration config = RepomixConfig() # Configure output options config.output.file_path = "custom-output.xml" config.output.style = "xml" # Options: "plain", "xml", "markdown", "json" config.output.show_line_numbers = True config.output.copy_to_clipboard = True config.output.remove_comments = False config.output.remove_empty_lines = False config.output.top_files_length = 10 # Configure include and exclude rules config.include = ["src/**/*", "tests/**/*"] config.ignore.custom_patterns = ["*.log", "*.tmp", "**/__pycache__/**"] config.ignore.use_gitignore = True config.ignore.use_default_ignore = True # Configure security checks config.security.enable_security_check = True config.security.exclude_suspicious_files = True # Create processor with custom configuration processor = RepoProcessor(".", config=config) result = processor.process() print(f"Output file: {result.config.output.file_path}") print(f"Files processed: {result.total_files}") ``` -------------------------------- ### CLI: Remote Repository Packing Source: https://context7.com/andersonby/python-repomix/llms.txt Pack a remote repository by providing its URL. You can also specify a branch using --remote-branch. ```bash # Pack a remote repository repomix --remote https://github.com/username/repo ``` ```bash # Pack specific branch of remote repository repomix --remote https://github.com/username/repo --remote-branch feature-branch ``` -------------------------------- ### CLI: Adding MCP Server to Claude Code Source: https://context7.com/andersonby/python-repomix/llms.txt Add Repomix as an MCP server to Claude Code using the 'claude mcp add' command. ```bash # Add to Claude Code claude mcp add repomix -- repomix --mcp ``` -------------------------------- ### Extract Configuration and Constants with Repomix Source: https://github.com/andersonby/python-repomix/blob/main/README.md Configure Repomix to extract only configuration settings and constants from a repository. This is useful for analyzing or providing configuration to AI models. ```python config = RepomixConfig() config.compression.enabled = True config.compression.keep_signatures = False # Remove all functions/classes config.output.file_path = "config-only.md" processor = RepoProcessor(".", config=config) result = processor.process() ``` -------------------------------- ### Run Repomix using Docker Source: https://github.com/andersonby/python-repomix/blob/main/README.md Execute Repomix within a Docker container, mounting the current directory to the container's app directory. This ensures consistent results and avoids host system dependency conflicts. ```bash # Run repomix on the current directory docker run --rm -v "$(pwd)":/app repomix # Run repomix with specific options docker run --rm -v "$(pwd)":/app repomix --style markdown --output custom-output.md # Run repomix on a different directory docker run --rm -v "/path/to/your/project":/app repomix ``` -------------------------------- ### Split Output for Large Codebases Source: https://context7.com/andersonby/python-repomix/llms.txt Configure Repomix to split large codebases into multiple files, each up to a specified size (e.g., 500KB), to manage AI model context limits. Splitting occurs at directory boundaries to maintain content relatedness. ```python from repomix import RepoProcessor, RepomixConfig # Create configuration with output splitting config = RepomixConfig() config.output.file_path = "split-output.md" config.output.style = "markdown" # Enable output splitting - split into parts of maximum 500KB each config.output.split_output = 500 * 1024 # 500KB per file # Process the repository processor = RepoProcessor(".", config=config) result = processor.process() print(f"Base output file: {result.config.output.file_path}") print(f"Files processed: {result.total_files}") # Output files: split-output.md, split-output-part2.md, split-output-part3.md, etc. ``` -------------------------------- ### Repomix Markdown Output Structure Source: https://github.com/andersonby/python-repomix/blob/main/README.md Illustrates the structure of Repomix output in Markdown format. ```markdown # File Summary (Metadata and usage AI instructions) # Repository Structure ``` src/ cli/ cliOutput.py index.py ``` # Repository Files ``` -------------------------------- ### CLI: Security and Token Count Source: https://context7.com/andersonby/python-repomix/llms.txt Disable security checks with --no-security-check. Visualize the token count tree with --token-count-tree. ```bash # Disable security check repomix --no-security-check ``` ```bash # Show token count tree repomix --token-count-tree ``` -------------------------------- ### Run Linter and Type Checker Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Execute Ruff for linting and auto-fixing code style issues, and Pyright for static type checking. These commands ensure code quality and adherence to standards. ```bash pdm run ruff check --fix . pdm run pyright ``` -------------------------------- ### Repomix Plain Text Output Structure Source: https://github.com/andersonby/python-repomix/blob/main/README.md Illustrates the structure of Repomix output in plain text format. ```text This file is a merged representation of the entire codebase, combining all repository files into a single document. ================================================================ File Summary ================================================================ (Metadata and usage AI instructions) ================================================================ Repository Structure ================================================================ src/ cli/ cliOutput.py index.py config/ configLoader.py (...remaining directories) ================================================================ Repository Files ================================================================ ================ File: src/index.py ================ # File contents here ================ File: src/utils.py ================ # File contents here (...remaining files) ================================================================ Statistics ================================================================ (File statistics and metadata) ``` -------------------------------- ### Claude Desktop MCP Server Configuration Source: https://github.com/andersonby/python-repomix/blob/main/README.md Add this JSON configuration to your 'claude_desktop_config.json' file to integrate Repomix as an MCP server. Ensure the 'cwd' path is set to your project's root directory or a stable location. ```json { "mcpServers": { "repomix": { "command": "repomix", "args": ["--mcp"], "cwd": "/path/to/your/project" } } } ``` -------------------------------- ### AI Prompt for Code Review and Refactoring Source: https://github.com/andersonby/python-repomix/blob/main/README.md Use this prompt with AI models to review an entire codebase for maintainability and scalability improvements. ```text This file contains my entire codebase. Please review the overall structure and suggest any improvements or refactoring opportunities, focusing on maintainability and scalability. ``` -------------------------------- ### Run Pyright for Type Checking Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Execute Pyright to perform static type checking on the project. This command is part of the quality checks and helps catch type-related errors. ```bash pdm run pyright ``` -------------------------------- ### Repomix Command Line: Pack Specific Directory Source: https://github.com/andersonby/python-repomix/blob/main/README.md Command to pack only a specified directory within the repository. ```bash repomix path/to/directory ``` -------------------------------- ### Commit Changes Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Stage and commit your changes following the Conventional Commits specification. Use descriptive commit messages. ```bash git add . git commit -m "feat: add new feature description" ``` -------------------------------- ### Enable Git Integration Features Source: https://context7.com/andersonby/python-repomix/llms.txt Configure Repomix to integrate Git features for AI models, including diff output for staged and unstaged changes, commit history logs, and sorting files by change frequency. This provides context on recent project activity. ```python from repomix import RepoProcessor, RepomixConfig # Create configuration with Git features enabled config = RepomixConfig() config.output.file_path = "git-integration-output.md" config.output.style = "markdown" # Enable Git diff integration (shows staged and unstaged changes) config.output.git.include_diffs = True # Enable Git log integration (includes recent commit history) config.output.git.include_logs = True config.output.git.include_logs_count = 20 # Number of recent commits # Enable sorting by git changes (frequently changed files first) config.output.git.sort_by_changes = True config.output.git.sort_by_changes_max_commits = 100 # Commits to analyze # Process the repository processor = RepoProcessor(".", config=config) result = processor.process() print(f"Output file: {result.config.output.file_path}") print(f"Files processed: {result.total_files}") ``` -------------------------------- ### Visualize Token Distribution Source: https://github.com/andersonby/python-repomix/blob/main/README.md Use `--token-count-tree` to display a file tree with token counts. An optional integer argument filters files with token counts greater than or equal to the specified value. ```bash repomix --token-count-tree ``` ```bash repomix --token-count-tree 100 ``` -------------------------------- ### Repomix Default Ignore Configuration (JSON) Source: https://github.com/andersonby/python-repomix/blob/main/README.md Enables the use of Repomix's default ignore patterns. ```json { "ignore": { "use_default_ignore": true } } ``` -------------------------------- ### Select Tokenizer Encoding Source: https://github.com/andersonby/python-repomix/blob/main/README.md Use `--token-count-encoding` to specify the tokenizer. `o200k_base` is the default for GPT-4o. `cl100k_base` is used for GPT-3.5/4. ```bash repomix --token-count-encoding o200k_base ``` ```bash repomix --token-count-encoding cl100k_base ``` -------------------------------- ### Generate JSON Output Source: https://github.com/andersonby/python-repomix/blob/main/README.md Use the --style json option to generate repository analysis in JSON format. This format is machine-readable and suitable for programmatic processing. ```bash python -m repomix --style json ``` -------------------------------- ### Repomix Ignore Configuration (JSON) Source: https://github.com/andersonby/python-repomix/blob/main/README.md Configures Repomix to use .gitignore files for ignore patterns. ```json { "ignore": { "use_gitignore": true } } ``` -------------------------------- ### Splitting Output for Large Codebases Source: https://github.com/andersonby/python-repomix/blob/main/README.md Split large codebases into manageable files to overcome AI model context limits. ```APIDOC ## Splitting Output for Large Codebases For large codebases that exceed AI model context limits, you can split the output into multiple files: ```bash # Split into files of approximately 500KB each repomix --split-output 500kb # Split into files of approximately 2MB each repomix --split-output 2mb ``` Output files will be numbered sequentially (e.g., `repomix-output.1.md`, `repomix-output.2.md`, etc.). Files are split at directory boundaries to keep related files together. ``` -------------------------------- ### Enable Token Counting and Distribution Source: https://context7.com/andersonby/python-repomix/llms.txt Enable token counting in Repomix to understand codebase size in AI model tokens. This configuration sets the output file, style, and enables token calculation, with options to specify the encoding (e.g., 'o200k_base' or 'cl100k_base'). ```python from repomix import RepoProcessor, RepomixConfig # Create configuration with token counting enabled config = RepomixConfig() config.output.file_path = "token-tree-output.md" config.output.style = "markdown" # Enable token counting config.output.calculate_tokens = True # Configure token encoding (default: o200k_base for GPT-4o) config.token_count.encoding = "o200k_base" # Or "cl100k_base" for GPT-3.5/4 ``` -------------------------------- ### Code Compression with Tree-sitter Source: https://context7.com/andersonby/python-repomix/llms.txt Utilize Tree-sitter for code compression to reduce token usage for LLM processing. This configuration preserves essential code elements like functions, classes, and imports, while optionally keeping signatures, docstrings, and interfaces. ```python from repomix import RepoProcessor, RepomixConfig # Create configuration with compression enabled config = RepomixConfig() config.output.file_path = "compressed-output.md" config.compression.enabled = True config.compression.keep_signatures = True config.compression.keep_docstrings = True config.compression.keep_interfaces = True # Interface mode for API documentation # Only include specific file patterns config.include = ["src/**/*.py"] # Process with compression processor = RepoProcessor(".", config=config) result = processor.process() print(f"Compressed output: {len(result.output_content):,} characters") print(f"Files processed: {result.total_files}") # Compare with uncompressed config_normal = RepomixConfig() config_normal.include = ["src/**/*.py"] config_normal.compression.enabled = False result_normal = RepoProcessor(".", config=config_normal).process(write_output=False) compression_ratio = (1 - len(result.output_content) / len(result_normal.output_content)) * 100 print(f"Compression ratio: {compression_ratio:.1f}%") ``` -------------------------------- ### Run All Tests Source: https://github.com/andersonby/python-repomix/blob/main/CONTRIBUTING.md Execute all tests in the project using pytest. This command verifies the overall functionality and stability of the codebase. ```bash pdm run python -m pytest ``` -------------------------------- ### AI Prompt for Test Case Generation Source: https://github.com/andersonby/python-repomix/blob/main/README.md Analyze code and generate comprehensive unit tests, including edge cases and error scenarios, by providing the AI with the codebase. ```text Analyze the code in this file and suggest a comprehensive set of unit tests for the main functions and classes. Include edge cases and potential error scenarios. ``` -------------------------------- ### Repomix Markdown Output Command Source: https://github.com/andersonby/python-repomix/blob/main/README.md Command to generate Repomix output in Markdown format. ```bash python -m repomix --style markdown ```