Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

codebase-digest

> AI 编程
Open source

️ Codebase-digest is your AI-friendly codebase packer and analyzer. Features 60+ coding prompts and generates structured overviews with metrics. Ideal for fee

393 stars0 likes2 views
WebsiteGitHub

About

️ Codebase-digest is your AI-friendly codebase packer and analyzer. Features 60+ coding prompts and generates structured overviews with metrics. Ideal for fee

Codebase Digest

Codebase Digest is a command-line tool written in Python that helps you analyze and understand your codebase. It provides a structured overview of your project's directory structure, file sizes, token counts, and even consolidates the content of all text-based files into a single output for easy analysis with Large Language Models (LLMs).

Table of Contents

  • Features
  • Installation
  • Usage
  • Configuration
  • Ignore Functionality
  • LLM Prompts for Enhanced Analysis
  • Contributing
  • License

Features

  • Directory Tree Visualization: Generate a hierarchical view of your project structure
  • Codebase Statistics: Calculate total files, directories, code size, and token counts
  • File Content Consolidation: Combine all text-based files into a single output
  • Flexible Ignore System: Support for custom patterns, defaults, and .gitignore files
  • Multiple Output Formats: Choose between text, JSON, Markdown, XML, or HTML
  • Colored Console Output: Visually appealing and informative summaries
  • LLM Analysis Support: Comprehensive prompt library for in-depth codebase analysis

Installation

Via pip (Recommended)

bash
pip install codebase-digest

From source

bash
git clone https://github.com/kamilstanuch/codebase-digest.git
cd codebase-digest
pip install -r requirements.txt

Usage

Basic usage:

bash
cdigest [path_to_directory] [options]

Examples:

  1. Analyze a project with default settings:

    bash
    cdigest /path/to/my_project
  2. Analyze with custom depth and output format:

    bash
    cdigest /path/to/my_project -d 3 -o markdown
  3. Ignore specific files and folders:

    bash
    cdigest /path/to/my_project --ignore "*.log" "temp_folder" "config.ini"
  4. Show file sizes and include git directory:

    bash
    cdigest /path/to/my_project --show-size --include-git
  5. Analyze and copy output to clipboard:

    bash
    cdigest /path/to/my_project --copy-to-clipboard

Configuration

Option Description
path_to_directory Path to the directory you want to analyze
-d, --max-depth Maximum depth for directory traversal
-o, --output-format Output format (text, json, markdown, xml, or html). Default: text
-f, --file Output file name
--show-size Show file sizes in directory tree
--show-ignored Show ignored files and directories in tree
--ignore Patterns to ignore (e.g., '*.pyc' '.venv' 'node_modules')
--keep-defaults Keep default ignore patterns when using --ignore
--no-content Exclude file contents from the output
--include-git Include .git directory in the analysis
--max-size Maximum allowed text content size in KB (default: 10240 KB)
--copy-to-clipboard Copy the output to clipboard

Ignore Functionality

Default Ignore Patterns

The following patterns are ignored by default:

python
DEFAULT_IGNORE_PATTERNS = [
'.pyc', '.pyo', '.pyd', 'pycache', # Python
'node_modules', 'bower_components', # JavaScript
'.git', '.svn', '.hg', '.gitignore', # Version control
'venv', '.venv', 'env', # Virtual environments
'.idea', '.vscode', # IDEs
'.log', '.bak', '.swp', '.tmp', # Temporary and log files
'.DS_Store', # macOS
'Thumbs.db', # Windows
'build', 'dist', # Build directories
'.egg-info', # Python egg info
'.so', '.dylib', '.dll' # Compiled libraries
]

Custom Ignore Patterns

You can specify additional patterns to ignore using the --ignore option. These patterns will be added to the default ignore patterns unless --no-default-ignores is used.

Patterns can use wildcards (* and ?) and can be:

  • Filenames (e.g., 'file.txt')
  • Directory names (e.g., 'node_modules')
  • File extensions (e.g., '*.pyc')
  • Paths (e.g., '/path/to/ignore')

Example:

bash
cdigest /path/to/my_project --ignore ".txt" "temp" "/path/to/specific/file.py"

.cdigestignore File

You can create a .cdigestignore file in your project root to specify project-specific ignore patterns. Each line in this file will be treated as an ignore pattern.

Overriding Default Ignores

To use only your custom ignore patterns without the default ones, use the --no-default-ignores option:

bash
cdigest /path/to/my_project --no-default-ignores --ignore "custom_pattern" "another_pattern"

LLM Prompts for Enhanced Analysis

Codebase Digest includes a comprehensive set of prompts in the prompt_library directory to help you analyze your codebase using Large Language Models. These prompts cover various aspects of code analysis and business alignment:

Use Cases

  1. Codebase Mapping and Learning: Quickly understand the structure and functionality of a new or complex codebase.
  2. Improving User Stories: Analyze existing code to refine or generate user stories.
  3. Initial Security Analysis: Perform a preliminary security assessment.
  4. Code Quality Enhancement: Identify areas for improvement in code quality, readability, and maintainability.
  5. Documentation Generation: Automatically generate or improve codebase documentation.
  6. Learning Tool: Use as a teaching aid to explain complex coding concepts or architectures.
  7. Business Alignment: Analyze how the codebase supports business objectives.
  8. Stakeholder Communication: Generate insights to facilitate discussions with non-technical stakeholders.

Prompt Categories

I. Code Quality & Understanding:

  • Analysis:
    • Codebase Error and Inconsistency Analysis: Identify and analyze errors and inconsistencies in the codebase.
    • Codebase Risk Assessment: Evaluate potential risks within the codebase (e.g., security vulnerabilities, maintainability issues).
    • Code Complexity Analysis: Identify areas with high cyclomatic complexity, deep nesting, or excessive method lengths.
    • Code Duplication Analysis: Identify duplicated code fragments and suggest refactoring opportunities.
    • Code Style Consistency Analysis: Analyze the codebase for consistency in code style, naming conventions, and formatting.
    • Code Documentation Coverage Analysis: Determine the coverage and quality of code documentation.
  • Generation:
    • Codebase Documentation Generation: Automatically generate or improve codebase documentation.

II. Learning & Knowledge Extraction:

  • Analysis:
    • Frontend Code Analysis: Analyze the frontend codebase to identify best practices, potential improvements, and common pitfalls.
    • Backend Code Analysis: Analyze the backend codebase to identify best practices, potential improvements, and common pitfalls.
    • Code Style and Readability Analysis: Evaluate the codebase's overall style and readability, providing suggestions for improvement.
    • Personal Development Recommendations: Analyze the codebase and provide personalized recommendations for areas where the engineer can improve their skills.
  • Generation:
    • User Story Reconstruction from Code: Reconstruct and structure user stories based on the codebase.
    • Code-Based Mini-Lesson Generation: Create mini-lessons to explain complex coding concepts or architectures.
    • Algorithmic Storytelling: Generate engaging narratives that explain the logic and flow of key algorithms in the codebase.
    • Code Pattern Recognition and Explanation: Identify and explain design patterns, architectural patterns, and common coding idioms used in the codebase.
    • Socratic Dialogue Generation for Code Review: Generate Socratic-style dialogues that explore the reasoning behind code design decisions and encourage critical thinking during code reviews.
    • Code Evolution Visualization: Create visualizations that illustrate how the codebase has evolved over time, highlighting key milestones, refactorings, and architectural changes.
    • Codebase Trivia Game Generation: Generate trivia questions and answers based on the codebase to gamify learning and encourage team engagement.
    • Code-Inspired Analogies and Metaphors: Generate analogies and metaphors inspired by the codebase to help explain complex technical concepts to non-technical stakeholders.
    • Frontend Component Documentation: Generate documentation for frontend components, including props, usage examples, and best practices.
    • Backend API Documentation: Generate documentation for backend APIs, including endpoints, request/response formats, and authentication requirements.
    • Code Refactoring Exercises: Generate code refactoring exercises based on the codebase to help engineers improve their refactoring skills.
    • Code Review Checklist Generation: Generate a checklist of important points to consider during code reviews, based on the codebase's specific requirements and best practices.

III. Code Improvement & Transformation:

  • Analysis:
    • Codebase Best Practice Analysis: Analyze the codebase for good and bad programming practices.
  • Generation:
    • Codebase Translation to Another Programming Language: Translate the codebase from one programming language to another.
    • Codebase Refactoring for Improved Readability and Performance: Suggest refactoring improvements for better readability and performance.

IV. Testing & Security:

  • Generation:
    • Unit Test Generation for Codebase: Generate unit tests for the provided codebase.
  • Analysis:
    • Security Vulnerability Analysis of Codebase: Identify potential security vulnerabilities in the codebase.

V. Business & Stakeholder Analysis:

  • Analysis:
    • Business Impact Analysis: Identify key features and their potential business impact.
    • SWOT Analysis: Evaluate the codebase's current state and future potential.
    • Jobs to be Done (JTBD) Analysis: Understand core user needs and identify potential improvements.
    • OKR (Objectives and Key Results) Analysis: Align codebase features with potential business objectives and key results.
    • Value Chain Analysis: Understand how the codebase supports the larger value cre

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythonaianthropicchatgptclaude

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.