├── .gitignore ├── MANIFEST.in ├── README.md ├── VERSION ├── codebase-digest.gif ├── codebase_digest ├── __init__.py └── app.py ├── prompt_library ├── ansoff_matrix_analysis.md ├── architecture_api_client_code_generation.md ├── architecture_api_conformance_check.md ├── architecture_coupling_cohesion_analysis.md ├── architecture_database_schema_documentation.md ├── architecture_database_schema_review.md ├── architecture_design_pattern_identification.md ├── architecture_diagram_generation.md ├── architecture_layer_identification.md ├── architecture_refactoring_for_design_patterns.md ├── bcg_matrix_analysis.md ├── blue_ocean_strategy_analysis.md ├── business_impact_analysis.md ├── business_model_canvas_analysis.md ├── competitive_positioning_map.md ├── customer_journey_map_analysis.md ├── evolution_code_churn_hotspot_analysis.md ├── evolution_code_evolution_report_generation.md ├── evolution_codebase_evolution_visualization.md ├── evolution_impact_analysis_of_code_changes.md ├── evolution_refactoring_recommendation_generation.md ├── evolution_technical_debt_estimation.md ├── improvement_best_practice_analysis.md ├── improvement_language_translation.md ├── improvement_refactoring.md ├── jobs_to_be_done_analysis.md ├── kano_model_analysis.md ├── lean_canvas_analysis.md ├── learning_algorithmic_storytelling.md ├── learning_backend_api_documentation.md ├── learning_backend_code_analysis.md ├── learning_code_analogies_metaphors.md ├── learning_code_evolution_visualization.md ├── learning_code_pattern_recognition.md ├── learning_code_refactoring_exercises.md ├── learning_code_review_checklist.md ├── learning_code_style_readability_analysis.md ├── learning_codebase_trivia_game.md ├── learning_frontend_code_analysis.md ├── learning_frontend_component_documentation.md ├── learning_mini_lesson_generation.md ├── learning_personal_development_recommendations.md ├── learning_socratic_dialogue_code_review.md ├── learning_user_story_reconstruction.md ├── mckinsey_7s_analysis.md ├── okr_analysis.md ├── performance_bottleneck_identification.md ├── performance_code_optimization_suggestions.md ├── performance_concurrency_synchronization_analysis.md ├── performance_configuration_tuning.md ├── performance_resource_usage_profiling.md ├── performance_scalability_analysis.md ├── performance_test_scenario_generation.md ├── pestel_analysis.md ├── porters_five_forces_analysis.md ├── product_market_fit_analysis.md ├── quality_code_complexity_analysis.md ├── quality_code_documentation_coverage_analysis.md ├── quality_code_duplication_analysis.md ├── quality_code_style_consistency_analysis.md ├── quality_documentation_generation.md ├── quality_error_analysis.md ├── quality_risk_assessment.md ├── security_vulnerability_analysis.md ├── stakeholder_persona_generation.md ├── swot_analysis.md ├── tech_adoption_lifecycle_analysis.md ├── testing_unit_test_generation.md ├── value_chain_analysis.md └── value_proposition_canvas_analysis.md ├── requirements-dev.txt ├── requirements.txt ├── setup.py └── update_package.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Python 2 | __pycache__/ 3 | *.py[cod] 4 | *.so 5 | 6 | # Distribution / packaging 7 | .Python 8 | build/ 9 | develop-eggs/ 10 | dist/ 11 | downloads/ 12 | eggs/ 13 | .eggs/ 14 | lib/ 15 | lib64/ 16 | parts/ 17 | sdist/ 18 | var/ 19 | wheels/ 20 | *.egg-info/ 21 | .installed.cfg 22 | *.egg 23 | 24 | # Virtual environments 25 | venv/ 26 | env/ 27 | ENV/ 28 | 29 | # IDEs 30 | .vscode/ 31 | .idea/ 32 | 33 | # OS generated files 34 | .DS_Store 35 | .DS_Store? 36 | ._* 37 | .Spotlight-V100 38 | .Trashes 39 | ehthumbs.db 40 | Thumbs.db 41 | 42 | *.egg-info/ -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include VERSION 2 | include README.md 3 | include requirements.txt 4 | include requirements-dev.txt 5 | recursive-include codebase_digest/prompt_library *.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Codebase Digest 2 | 3 | [![PyPI version](https://badge.fury.io/py/codebase-digest.svg)](https://badge.fury.io/py/codebase-digest) 4 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 5 | 6 | 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). 7 | 8 | ![Codebase Digest in action](codebase-digest.gif) 9 | 10 | ## Table of Contents 11 | 12 | - [Features](#features) 13 | - [Installation](#installation) 14 | - [Usage](#usage) 15 | - [Configuration](#configuration) 16 | - [Ignore Functionality](#ignore-functionality) 17 | - [LLM Prompts for Enhanced Analysis](#llm-prompts-for-enhanced-analysis) 18 | - [Contributing](#contributing) 19 | - [License](#license) 20 | 21 | ## Features 22 | 23 | - 📊 **Directory Tree Visualization:** Generate a hierarchical view of your project structure 24 | - 📈 **Codebase Statistics:** Calculate total files, directories, code size, and token counts 25 | - 📄 **File Content Consolidation:** Combine all text-based files into a single output 26 | - 🚫 **Flexible Ignore System:** Support for custom patterns, defaults, and `.gitignore` files 27 | - 🎨 **Multiple Output Formats:** Choose between text, JSON, Markdown, XML, or HTML 28 | - 🌈 **Colored Console Output:** Visually appealing and informative summaries 29 | - 🧠 **LLM Analysis Support:** Comprehensive prompt library for in-depth codebase analysis 30 | 31 | ## Installation 32 | 33 | ### Via pip (Recommended) 34 | 35 | ```bash 36 | pip install codebase-digest 37 | ```` 38 | 39 | 40 | ### From source 41 | 42 | ````bash 43 | git clone https://github.com/kamilstanuch/codebase-digest.git 44 | cd codebase-digest 45 | pip install -r requirements.txt 46 | ```` 47 | 48 | 49 | ## Usage 50 | 51 | Basic usage: 52 | 53 | ````bash 54 | cdigest [path_to_directory] [options] 55 | ```` 56 | 57 | 58 | Examples: 59 | 60 | 1. Analyze a project with default settings: 61 | ```bash 62 | cdigest /path/to/my_project 63 | ``` 64 | 65 | 2. Analyze with custom depth and output format: 66 | ```bash 67 | cdigest /path/to/my_project -d 3 -o markdown 68 | ``` 69 | 70 | 3. Ignore specific files and folders: 71 | ```bash 72 | cdigest /path/to/my_project --ignore "*.log" "temp_folder" "config.ini" 73 | ``` 74 | 75 | 4. Show file sizes and include git directory: 76 | ```bash 77 | cdigest /path/to/my_project --show-size --include-git 78 | ``` 79 | 80 | 5. Analyze and copy output to clipboard: 81 | ```bash 82 | cdigest /path/to/my_project --copy-to-clipboard 83 | ``` 84 | 85 | ## Configuration 86 | 87 | | Option | Description | 88 | |--------|-------------| 89 | | `path_to_directory` | Path to the directory you want to analyze | 90 | | `-d, --max-depth` | Maximum depth for directory traversal | 91 | | `-o, --output-format` | Output format (text, json, markdown, xml, or html). Default: text | 92 | | `-f, --file` | Output file name | 93 | | `--show-size` | Show file sizes in directory tree | 94 | | `--show-ignored` | Show ignored files and directories in tree | 95 | | `--ignore` | Patterns to ignore (e.g., '*.pyc' '.venv' 'node_modules') | 96 | | `--keep-defaults` | Keep default ignore patterns when using --ignore | 97 | | `--no-content` | Exclude file contents from the output | 98 | | `--include-git` | Include .git directory in the analysis | 99 | | `--max-size` | Maximum allowed text content size in KB (default: 10240 KB) | 100 | | `--copy-to-clipboard` | Copy the output to clipboard | 101 | 102 | ## Ignore Functionality 103 | 104 | ### Default Ignore Patterns 105 | 106 | The following patterns are ignored by default: 107 | 108 | ```python 109 | DEFAULT_IGNORE_PATTERNS = [ 110 | '.pyc', '.pyo', '.pyd', 'pycache', # Python 111 | 'node_modules', 'bower_components', # JavaScript 112 | '.git', '.svn', '.hg', '.gitignore', # Version control 113 | 'venv', '.venv', 'env', # Virtual environments 114 | '.idea', '.vscode', # IDEs 115 | '.log', '.bak', '.swp', '.tmp', # Temporary and log files 116 | '.DS_Store', # macOS 117 | 'Thumbs.db', # Windows 118 | 'build', 'dist', # Build directories 119 | '.egg-info', # Python egg info 120 | '.so', '.dylib', '.dll' # Compiled libraries 121 | ] 122 | ``` 123 | 124 | ### Custom Ignore Patterns 125 | 126 | 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. 127 | 128 | Patterns can use wildcards (* and ?) and can be: 129 | - Filenames (e.g., 'file.txt') 130 | - Directory names (e.g., 'node_modules') 131 | - File extensions (e.g., '*.pyc') 132 | - Paths (e.g., '/path/to/ignore') 133 | 134 | Example: 135 | ```bash 136 | cdigest /path/to/my_project --ignore ".txt" "temp" "/path/to/specific/file.py" 137 | ``` 138 | 139 | 140 | ### .cdigestignore File 141 | 142 | 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. 143 | 144 | ### Overriding Default Ignores 145 | 146 | To use only your custom ignore patterns without the default ones, use the `--no-default-ignores` option: 147 | 148 | ```bash 149 | cdigest /path/to/my_project --no-default-ignores --ignore "custom_pattern" "another_pattern" 150 | ``` 151 | 152 | 153 | ## LLM Prompts for Enhanced Analysis 154 | 155 | 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: 156 | 157 | ### Use Cases 158 | 159 | 1. **Codebase Mapping and Learning**: Quickly understand the structure and functionality of a new or complex codebase. 160 | 2. **Improving User Stories**: Analyze existing code to refine or generate user stories. 161 | 3. **Initial Security Analysis**: Perform a preliminary security assessment. 162 | 4. **Code Quality Enhancement**: Identify areas for improvement in code quality, readability, and maintainability. 163 | 5. **Documentation Generation**: Automatically generate or improve codebase documentation. 164 | 6. **Learning Tool**: Use as a teaching aid to explain complex coding concepts or architectures. 165 | 7. **Business Alignment**: Analyze how the codebase supports business objectives. 166 | 8. **Stakeholder Communication**: Generate insights to facilitate discussions with non-technical stakeholders. 167 | 168 | ### Prompt Categories 169 | 170 | #### I. Code Quality & Understanding: 171 | - **Analysis:** 172 | - [Codebase Error and Inconsistency Analysis](prompt_library/quality_error_analysis.md): Identify and analyze errors and inconsistencies in the codebase. 173 | - [Codebase Risk Assessment](prompt_library/quality_risk_assessment.md): Evaluate potential risks within the codebase (e.g., security vulnerabilities, maintainability issues). 174 | - [Code Complexity Analysis](prompt_library/quality_code_complexity_analysis.md): Identify areas with high cyclomatic complexity, deep nesting, or excessive method lengths. 175 | - [Code Duplication Analysis](prompt_library/quality_code_duplication_analysis.md): Identify duplicated code fragments and suggest refactoring opportunities. 176 | - [Code Style Consistency Analysis](prompt_library/quality_code_style_consistency_analysis.md): Analyze the codebase for consistency in code style, naming conventions, and formatting. 177 | - [Code Documentation Coverage Analysis](prompt_library/quality_code_documentation_coverage_analysis.md): Determine the coverage and quality of code documentation. 178 | - **Generation:** 179 | - [Codebase Documentation Generation](prompt_library/quality_documentation_generation.md): Automatically generate or improve codebase documentation. 180 | 181 | #### II. Learning & Knowledge Extraction: 182 | - **Analysis:** 183 | - [Frontend Code Analysis](prompt_library/learning_frontend_code_analysis.md): Analyze the frontend codebase to identify best practices, potential improvements, and common pitfalls. 184 | - [Backend Code Analysis](prompt_library/learning_backend_code_analysis.md): Analyze the backend codebase to identify best practices, potential improvements, and common pitfalls. 185 | - [Code Style and Readability Analysis](prompt_library/learning_code_style_readability_analysis.md): Evaluate the codebase's overall style and readability, providing suggestions for improvement. 186 | - [Personal Development Recommendations](prompt_library/learning_personal_development_recommendations.md): Analyze the codebase and provide personalized recommendations for areas where the engineer can improve their skills. 187 | - **Generation:** 188 | - [User Story Reconstruction from Code](prompt_library/learning_user_story_reconstruction.md): Reconstruct and structure user stories based on the codebase. 189 | - [Code-Based Mini-Lesson Generation](prompt_library/learning_mini_lesson_generation.md): Create mini-lessons to explain complex coding concepts or architectures. 190 | - [Algorithmic Storytelling](prompt_library/learning_algorithmic_storytelling.md): Generate engaging narratives that explain the logic and flow of key algorithms in the codebase. 191 | - [Code Pattern Recognition and Explanation](prompt_library/learning_code_pattern_recognition.md): Identify and explain design patterns, architectural patterns, and common coding idioms used in the codebase. 192 | - [Socratic Dialogue Generation for Code Review](prompt_library/learning_socratic_dialogue_code_review.md): Generate Socratic-style dialogues that explore the reasoning behind code design decisions and encourage critical thinking during code reviews. 193 | - [Code Evolution Visualization](prompt_library/learning_code_evolution_visualization.md): Create visualizations that illustrate how the codebase has evolved over time, highlighting key milestones, refactorings, and architectural changes. 194 | - [Codebase Trivia Game Generation](prompt_library/learning_codebase_trivia_game.md): Generate trivia questions and answers based on the codebase to gamify learning and encourage team engagement. 195 | - [Code-Inspired Analogies and Metaphors](prompt_library/learning_code_analogies_metaphors.md): Generate analogies and metaphors inspired by the codebase to help explain complex technical concepts to non-technical stakeholders. 196 | - [Frontend Component Documentation](prompt_library/learning_frontend_component_documentation.md): Generate documentation for frontend components, including props, usage examples, and best practices. 197 | - [Backend API Documentation](prompt_library/learning_backend_api_documentation.md): Generate documentation for backend APIs, including endpoints, request/response formats, and authentication requirements. 198 | - [Code Refactoring Exercises](prompt_library/learning_code_refactoring_exercises.md): Generate code refactoring exercises based on the codebase to help engineers improve their refactoring skills. 199 | - [Code Review Checklist Generation](prompt_library/learning_code_review_checklist.md): Generate a checklist of important points to consider during code reviews, based on the codebase's specific requirements and best practices. 200 | 201 | #### III. Code Improvement & Transformation: 202 | - **Analysis:** 203 | - [Codebase Best Practice Analysis](prompt_library/improvement_best_practice_analysis.md): Analyze the codebase for good and bad programming practices. 204 | - **Generation:** 205 | - [Codebase Translation to Another Programming Language](prompt_library/improvement_language_translation.md): Translate the codebase from one programming language to another. 206 | - [Codebase Refactoring for Improved Readability and Performance](prompt_library/improvement_refactoring.md): Suggest refactoring improvements for better readability and performance. 207 | 208 | #### IV. Testing & Security: 209 | - **Generation:** 210 | - [Unit Test Generation for Codebase](prompt_library/testing_unit_test_generation.md): Generate unit tests for the provided codebase. 211 | - **Analysis:** 212 | - [Security Vulnerability Analysis of Codebase](prompt_library/security_vulnerability_analysis.md): Identify potential security vulnerabilities in the codebase. 213 | 214 | #### V. Business & Stakeholder Analysis: 215 | - **Analysis:** 216 | - [Business Impact Analysis](prompt_library/business_impact_analysis.md): Identify key features and their potential business impact. 217 | - [SWOT Analysis](prompt_library/swot_analysis.md): Evaluate the codebase's current state and future potential. 218 | - [Jobs to be Done (JTBD) Analysis](prompt_library/jobs_to_be_done_analysis.md): Understand core user needs and identify potential improvements. 219 | - [OKR (Objectives and Key Results) Analysis](prompt_library/okr_analysis.md): Align codebase features with potential business objectives and key results. 220 | - [Value Chain Analysis](prompt_library/value_chain_analysis.md): Understand how the codebase supports the larger value creation process. 221 | - [Porter's Five Forces Analysis](prompt_library/porters_five_forces_analysis.md): Analyze competitive forces shaping the product's market. 222 | - [Product/Market Fit Analysis](prompt_library/product_market_fit_analysis.md): Evaluate how well the product meets market needs. 223 | - [PESTEL Analysis](prompt_library/pestel_analysis.md): Analyze macro-environmental factors affecting the product. 224 | - **Generation:** 225 | - [Business Model Canvas Generation](prompt_library/business_model_canvas_analysis.md): Create a Business Model Canvas based on codebase analysis. 226 | - [Value Proposition Canvas Generation](prompt_library/value_proposition_canvas_analysis.md): Generate a Value Proposition Canvas aligning technical features with user needs and benefits. 227 | - [Lean Canvas Generation](prompt_library/lean_canvas_analysis.md): Create a Lean Canvas to evaluate business potential and identify areas for improvement or pivot. 228 | - [Customer Journey Map Creation](prompt_library/customer_journey_map_analysis.md): Generate a map showing how different parts support various stages of the user's journey. 229 | - [Blue Ocean Strategy Canvas](prompt_library/blue_ocean_strategy_analysis.md): Create a strategy canvas to identify untapped market space and new demand. 230 | - [Ansoff Matrix Generation](prompt_library/ansoff_matrix_analysis.md): Produce an Ansoff Matrix to evaluate growth strategies for the product. 231 | - [BCG Growth-Share Matrix Creation](prompt_library/bcg_matrix_analysis.md): Generate a BCG Matrix to assess the product portfolio and resource allocation. 232 | - [Kano Model Diagram](prompt_library/kano_model_analysis.md): Create a Kano Model diagram to prioritize product features based on customer satisfaction. 233 | - [Technology Adoption Lifecycle Curve](prompt_library/tech_adoption_lifecycle_analysis.md): Generate a curve showing the product's position in the adoption lifecycle. 234 | - [Competitive Positioning Map](prompt_library/competitive_positioning_map.md): Create a visual map of the product's position relative to competitors. 235 | - [McKinsey 7S Framework Diagram](prompt_library/mckinsey_7s_analysis.md): Generate a diagram evaluating internal elements for organizational effectiveness. 236 | - [Stakeholder Persona Generation](prompt_library/stakeholder_persona_generation.md): Infer and create potential stakeholder personas based on codebase functionalities. 237 | 238 | #### VI. Architecture & Design: 239 | - **Analysis:** 240 | - [Identify Architectural Layers](prompt_library/architecture_layer_identification.md): Analyze the codebase and identify different architectural layers (e.g., presentation, business logic, data access), highlighting inconsistencies or deviations from common architectural patterns. 241 | - [Analyze Coupling and Cohesion](prompt_library/architecture_coupling_cohesion_analysis.md): Evaluate coupling and cohesion between modules or components, identifying areas with high coupling or low cohesion that might indicate design flaws. 242 | - [Identify Design Patterns](prompt_library/architecture_design_pattern_identification.md): Analyze the codebase for instances of common design patterns (e.g., Singleton, Factory, Observer), explaining their implementation and purpose. 243 | - [Database Schema Review](prompt_library/architecture_database_schema_review.md): Review the database schema for normalization, indexing, and potential performance bottlenecks, suggesting improvements based on best practices. 244 | - [API Conformance Check](prompt_library/architecture_api_conformance_check.md): Given an API specification (e.g., OpenAPI), analyze the codebase to identify any inconsistencies or deviations from the defined API contract. 245 | - **Generation:** 246 | - [Generate Architectural Diagram](prompt_library/architecture_diagram_generation.md): Based on codebase structure and dependencies, generate a visual representation of the system architecture, including components, layers, and interactions. 247 | - [Suggest Refactoring for Design Patterns](prompt_library/architecture_refactoring_for_design_patterns.md): Analyze the codebase and suggest opportunities to implement design patterns for improved maintainability, extensibility, or reusability. 248 | - [Generate Database Schema Documentation](prompt_library/architecture_database_schema_documentation.md): Create comprehensive documentation for the database schema, including table descriptions, relationships, indexes, and constraints. 249 | - [Generate API Client Code](prompt_library/architecture_api_client_code_generation.md): Based on an existing API specification or codebase implementation, generate client code (e.g., in JavaScript, Python) to interact with the API. 250 | 251 | #### VII. Performance & Optimization: 252 | - **Analysis:** 253 | - [Identify Performance Bottlenecks](prompt_library/performance_bottleneck_identification.md): Analyze the codebase for performance bottlenecks like inefficient algorithms, excessive database queries, or slow network requests, focusing specifically on performance-related issues. 254 | - [Resource Usage Profiling](prompt_library/performance_resource_usage_profiling.md): Analyze the codebase to identify areas with high CPU utilization, memory consumption, or disk I/O, providing insights into potential optimizations for efficient resource usage. 255 | - [Scalability Analysis](prompt_library/performance_scalability_analysis.md): Analyze the codebase and architectural choices to assess the system's scalability, identifying potential limitations and suggesting improvements for handling increased load. 256 | - [Concurrency and Synchronization Analysis](prompt_library/performance_concurrency_synchronization_analysis.md): Analyze the codebase for potential concurrency issues like race conditions or deadlocks. Suggest solutions to improve thread safety and synchronization mechanisms. 257 | - **Generation:** 258 | - [Suggest Code Optimization Techniques](prompt_library/performance_code_optimization_suggestions.md): Based on the analysis of potential bottlenecks, suggest specific code optimization techniques like caching, asynchronous operations, or algorithm improvements. 259 | - [Generate Performance Test Scenarios](prompt_library/performance_test_scenario_generation.md): Create realistic performance test scenarios (e.g., using tools like JMeter or Gatling) to simulate high load and identify performance bottlenecks. 260 | - [Suggest Configuration Tuning](prompt_library/performance_configuration_tuning.md): Recommend optimal configuration settings for databases, application servers, or other infrastructure components to improve performance. 261 | 262 | #### VIII. Code Evolution & History: 263 | - **Analysis:** 264 | - [Code Churn Hotspot Analysis](prompt_library/evolution_code_churn_hotspot_analysis.md): Analyze code commit history to identify areas of the codebase with high churn rates, which can indicate areas requiring refactoring or potentially problematic code. 265 | - [Technical Debt Estimation](prompt_library/evolution_technical_debt_estimation.md): Based on code complexity, code smells, and other factors, estimate the amount of technical debt present in the codebase and prioritize areas for refactoring. Focus on estimations derived from historical code analysis rather than general code quality. 266 | - [Impact Analysis of Code Changes](prompt_library/evolution_impact_analysis_of_code_changes.md): Analyze the potential impact of specific code changes (e.g., bug fixes, new features) on other parts of the system to identify potential regressions or conflicts. 267 | - **Generation:** 268 | - [Generate Code Evolution Report](prompt_library/evolution_code_evolution_report_generation.md): Create a report summarizing the evolution of the codebase over time, including key metrics like code churn, code complexity, and contributor activity. 269 | - [Generate Refactoring Recommendations (History-Based)](prompt_library/evolution_refactoring_recommendation_generation.md): Based on code evolution analysis and technical debt estimation, generate specific refactoring recommendations to improve code quality and reduce maintenance costs, focusing on areas identified through historical analysis. 270 | - [Visualize Codebase Evolution](prompt_library/evolution_codebase_evolution_visualization.md): Generate visualizations (e.g., heatmaps, graphs) to represent the codebase's evolution, highlighting areas of frequent change, code complexity, and potential technical debt. 271 | 272 | 273 | 274 | For detailed instructions on using these prompts, refer to the individual files in the `prompt_library` directory. 275 | 276 | ## Contributing 277 | 278 | Contributions are welcome! Please feel free to submit a Pull Request. 279 | 280 | ## License 281 | 282 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 283 | 284 | 285 | 286 | 287 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.1.43 -------------------------------------------------------------------------------- /codebase-digest.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kamilstanuch/codebase-digest/77efab57528cbc825129a94adc521492ac0e65fa/codebase-digest.gif -------------------------------------------------------------------------------- /codebase_digest/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def read_version(): 4 | version_file = os.path.join(os.path.dirname(__file__), '..', 'VERSION') 5 | try: 6 | with open(version_file) as f: 7 | return f.read().strip() 8 | except FileNotFoundError: 9 | return "unknown" 10 | 11 | __version__ = read_version() -------------------------------------------------------------------------------- /codebase_digest/app.py: -------------------------------------------------------------------------------- 1 | # CodeConsolidator - Consolidates and analyzes codebases for insights. 2 | 3 | import os 4 | import argparse 5 | import json 6 | from collections import defaultdict 7 | import fnmatch 8 | import mimetypes 9 | import tiktoken 10 | from colorama import init, Fore, Back, Style 11 | import sys 12 | import pyperclip 13 | import xml.etree.ElementTree as ET 14 | import html 15 | 16 | # Initialize colorama for colorful console output. 17 | init() 18 | 19 | # At the top of the file, after imports 20 | DEFAULT_IGNORE_PATTERNS = [ 21 | '*.pyc', '*.pyo', '*.pyd', '__pycache__', # Python 22 | 'node_modules', 'bower_components', # JavaScript 23 | '.git', '.svn', '.hg', '.gitignore', # Version control 24 | 'venv', '.venv', 'env', # Virtual environments 25 | '.idea', '.vscode', # IDEs 26 | '*.log', '*.bak', '*.swp', '*.tmp', # Temporary and log files 27 | '.DS_Store', # macOS 28 | 'Thumbs.db', # Windows 29 | 'build', 'dist', # Build directories 30 | '*.egg-info', # Python egg info 31 | '*.so', '*.dylib', '*.dll' # Compiled libraries 32 | ] 33 | 34 | def print_frame(text): 35 | """Prints a framed text box with colored borders.""" 36 | width = max(len(line) for line in text.split('\n')) + 4 37 | print(Fore.CYAN + "+" + "-" * (width - 2) + "+") 38 | for line in text.split('\n'): 39 | print(Fore.CYAN + "| " + Fore.WHITE + line.ljust(width - 4) + Fore.CYAN + " |") 40 | print(Fore.CYAN + "+" + "-" * (width - 2) + "+" + Style.RESET_ALL) 41 | 42 | def load_gitignore(path): 43 | """Loads .gitignore patterns from a given path.""" 44 | gitignore_patterns = [] 45 | gitignore_path = os.path.join(path, '.gitignore') 46 | if os.path.exists(gitignore_path): 47 | with open(gitignore_path, 'r') as f: 48 | gitignore_patterns = [line.strip() for line in f if line.strip() and not line.startswith('#')] 49 | return gitignore_patterns 50 | 51 | def should_ignore(path, base_path, ignore_patterns): 52 | """Checks if a file or directory should be ignored based on patterns.""" 53 | name = os.path.basename(path) 54 | rel_path = os.path.relpath(path, base_path) 55 | abs_path = os.path.abspath(path) 56 | 57 | for pattern in ignore_patterns: 58 | if fnmatch.fnmatch(name, pattern) or \ 59 | fnmatch.fnmatch(rel_path, pattern) or \ 60 | fnmatch.fnmatch(abs_path, pattern) or \ 61 | (pattern.startswith('/') and fnmatch.fnmatch(abs_path, os.path.join(base_path, pattern[1:]))) or \ 62 | any(fnmatch.fnmatch(part, pattern) for part in rel_path.split(os.sep)): 63 | print(f"Debug: Ignoring {path} due to pattern {pattern}") 64 | return True 65 | return False 66 | 67 | def is_text_file(file_path): 68 | """Determines if a file is likely a text file based on its content.""" 69 | try: 70 | with open(file_path, 'rb') as file: 71 | chunk = file.read(1024) 72 | return not bool(chunk.translate(None, bytes([7, 8, 9, 10, 12, 13, 27] + list(range(0x20, 0x100))))) 73 | except IOError: 74 | return False 75 | 76 | def count_tokens(text): 77 | """Counts the number of tokens in a text string using tiktoken.""" 78 | enc = tiktoken.get_encoding("cl100k_base") 79 | try: 80 | return len(enc.encode(text, disallowed_special=())) 81 | except Exception as e: 82 | print(f"Warning: Error counting tokens: {str(e)}") 83 | return 0 84 | 85 | def read_file_content(file_path): 86 | """Reads the content of a file, handling potential encoding errors.""" 87 | try: 88 | with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: 89 | return f.read() 90 | except Exception as e: 91 | return f"Error reading file: {str(e)}" 92 | 93 | def analyze_directory(path, ignore_patterns, base_path, include_git=False, max_depth=None, current_depth=0): 94 | """Recursively analyzes a directory and its contents.""" 95 | if max_depth is not None and current_depth > max_depth: 96 | return None 97 | 98 | result = { 99 | "name": os.path.basename(path), 100 | "type": "directory", 101 | "size": 0, 102 | "children": [], 103 | "total_tokens": 0, 104 | "file_count": 0, 105 | "dir_count": 0, 106 | "text_content_size": 0, 107 | "total_text_size": 0 # New field for total size of all text files 108 | } 109 | 110 | try: 111 | for item in os.listdir(path): 112 | item_path = os.path.join(path, item) 113 | 114 | # Skip .git directory unless explicitly included 115 | if item == '.git' and not include_git: 116 | continue 117 | 118 | is_ignored = should_ignore(item_path, base_path, ignore_patterns) 119 | print(f"Debug: Checking {item_path}, ignored: {is_ignored}") # Debug line 120 | 121 | if os.path.isfile(item_path) and is_text_file(item_path): 122 | file_size = os.path.getsize(item_path) 123 | result["total_text_size"] += file_size 124 | 125 | if is_ignored: 126 | continue # Skip ignored items for further analysis 127 | 128 | # Log progress 129 | print(Fore.YELLOW + f"Analyzing: {item_path}" + Style.RESET_ALL) 130 | 131 | if os.path.isfile(item_path): 132 | file_size = os.path.getsize(item_path) 133 | is_text = is_text_file(item_path) 134 | if is_text: 135 | content = read_file_content(item_path) 136 | tokens = count_tokens(content) 137 | print(f"Debug: Text file {item_path}, size: {file_size}, content size: {len(content)}") 138 | else: 139 | content = "[Non-text file]" 140 | tokens = 0 141 | print(f"Debug: Non-text file {item_path}, size: {file_size}") 142 | child = { 143 | "name": item, 144 | "type": "file", 145 | "size": file_size, 146 | "tokens": tokens, 147 | "content": content, 148 | "is_ignored": is_ignored 149 | } 150 | result["children"].append(child) 151 | if not is_ignored: 152 | result["size"] += file_size 153 | result["total_tokens"] += tokens 154 | result["file_count"] += 1 155 | if is_text: 156 | result["text_content_size"] += len(content) 157 | elif os.path.isdir(item_path): 158 | subdir = analyze_directory(item_path, ignore_patterns, base_path, include_git, max_depth, current_depth + 1) 159 | if subdir: 160 | subdir["is_ignored"] = is_ignored 161 | result["children"].append(subdir) 162 | if not is_ignored: 163 | result["size"] += subdir["size"] 164 | result["total_tokens"] += subdir["total_tokens"] 165 | result["file_count"] += subdir["file_count"] 166 | result["dir_count"] += 1 + subdir["dir_count"] 167 | result["text_content_size"] += subdir["text_content_size"] 168 | except PermissionError: 169 | print(Fore.RED + f"Permission denied: {path}" + Style.RESET_ALL) 170 | 171 | return result 172 | 173 | def generate_tree_string(node, prefix="", is_last=True, show_size=False, show_ignored=False, use_color=False): 174 | """Generates a string representation of the directory tree.""" 175 | if node.get("is_ignored", False) and not show_ignored: 176 | return "" 177 | 178 | if use_color: 179 | result = prefix + (Fore.GREEN + "└── " if is_last else "├── ") 180 | result += Fore.BLUE + node["name"] + Style.RESET_ALL 181 | else: 182 | result = prefix + ("└── " if is_last else "├── ") + node["name"] 183 | 184 | if show_size and node["type"] == "file": 185 | size_str = f" ({node['size']} bytes)" 186 | result += Fore.YELLOW + size_str + Style.RESET_ALL if use_color else size_str 187 | 188 | if node.get("is_ignored", False): 189 | ignored_str = " [IGNORED]" 190 | result += Fore.RED + ignored_str + Style.RESET_ALL if use_color else ignored_str 191 | 192 | result += "\n" 193 | 194 | if node["type"] == "directory": 195 | prefix += " " if is_last else "│ " 196 | children = node["children"] 197 | if not show_ignored: 198 | children = [child for child in children if not child.get("is_ignored", False)] 199 | for i, child in enumerate(children): 200 | result += generate_tree_string(child, prefix, i == len(children) - 1, show_size, show_ignored, use_color) 201 | return result 202 | 203 | def generate_summary_string(data, estimated_size, use_color=True): 204 | summary = "\nSummary:\n" 205 | summary += f"Total files analyzed: {data['file_count']}\n" 206 | summary += f"Total directories analyzed: {data['dir_count']}\n" 207 | summary += f"Estimated output size: {estimated_size / 1024:.2f} KB\n" 208 | summary += f"Actual analyzed size: {data['size'] / 1024:.2f} KB\n" 209 | summary += f"Total tokens: {data['total_tokens']}\n" 210 | summary += f"Actual text content size: {data['text_content_size'] / 1024:.2f} KB\n" 211 | 212 | if use_color: 213 | return Fore.CYAN + summary + Style.RESET_ALL 214 | return summary 215 | 216 | def generate_content_string(data): 217 | """Generates a structured representation of file contents.""" 218 | content = [] 219 | 220 | def add_file_content(node, path=""): 221 | if node["type"] == "file" and not node.get("is_ignored", False) and node["content"] != "[Non-text file]": 222 | content.append({ 223 | "path": os.path.join(path, node["name"]), 224 | "content": node["content"] 225 | }) 226 | elif node["type"] == "directory": 227 | for child in node["children"]: 228 | add_file_content(child, os.path.join(path, node["name"])) 229 | 230 | add_file_content(data) 231 | return content 232 | 233 | def generate_markdown_output(data): 234 | output = f"# Codebase Analysis for: {data['name']}\n\n" 235 | output += "## Directory Structure\n\n" 236 | output += "```\n" 237 | output += generate_tree_string(data, show_size=True, show_ignored=True) 238 | output += "```\n\n" 239 | output += "## Summary\n\n" 240 | output += f"- Total files: {data['file_count']}\n" 241 | output += f"- Total directories: {data['dir_count']}\n" 242 | output += f"- Analyzed size: {data['size'] / 1024:.2f} KB\n" 243 | output += f"- Total text file size (including ignored): {data['total_text_size'] / 1024:.2f} KB\n" 244 | output += f"- Total tokens: {data['total_tokens']}\n" 245 | output += f"- Analyzed text content size: {data['text_content_size'] / 1024:.2f} KB\n\n" 246 | output += "## File Contents\n\n" 247 | for file in generate_content_string(data): 248 | output += f"### {file['path']}\n\n```\n{file['content']}\n```\n\n" 249 | return output 250 | 251 | def generate_xml_output(data): 252 | root = ET.Element("codebase-analysis") 253 | ET.SubElement(root, "name").text = data['name'] 254 | structure = ET.SubElement(root, "directory-structure") 255 | structure.text = generate_tree_string(data, show_size=True, show_ignored=True) 256 | summary = ET.SubElement(root, "summary") 257 | ET.SubElement(summary, "total-files").text = str(data['file_count']) 258 | ET.SubElement(summary, "total-directories").text = str(data['dir_count']) 259 | ET.SubElement(summary, "analyzed-size-kb").text = f"{data['size'] / 1024:.2f}" 260 | ET.SubElement(summary, "total-text-file-size-kb").text = f"{data['total_text_size'] / 1024:.2f}" 261 | ET.SubElement(summary, "total-tokens").text = str(data['total_tokens']) 262 | ET.SubElement(summary, "analyzed-text-content-size-kb").text = f"{data['text_content_size'] / 1024:.2f}" 263 | contents = ET.SubElement(root, "file-contents") 264 | for file in generate_content_string(data): 265 | file_elem = ET.SubElement(contents, "file") 266 | ET.SubElement(file_elem, "path").text = file['path'] 267 | ET.SubElement(file_elem, "content").text = file['content'] 268 | return ET.tostring(root, encoding="unicode") 269 | 270 | def generate_html_output(data): 271 | output = f""" 272 | 273 | 274 | Codebase Analysis for: {html.escape(data['name'])} 275 | 278 | 279 | 280 |

Codebase Analysis for: {html.escape(data['name'])}

281 |

Directory Structure

282 |
{html.escape(generate_tree_string(data, show_size=True, show_ignored=True))}
283 |

Summary

284 | 292 |

File Contents

293 | """ 294 | for file in generate_content_string(data): 295 | output += f"

{html.escape(file['path'])}

{html.escape(file['content'])}
" 296 | output += "" 297 | return output 298 | 299 | def load_ignore_patterns(args, base_path): 300 | patterns = set() 301 | if not args.no_default_ignores: 302 | patterns.update(DEFAULT_IGNORE_PATTERNS) 303 | 304 | if args.ignore: 305 | patterns.update(args.ignore) 306 | 307 | # Load patterns from .cdigestignore file if it exists 308 | cdigestignore_path = os.path.join(base_path, '.cdigestignore') 309 | if os.path.exists(cdigestignore_path): 310 | with open(cdigestignore_path, 'r') as f: 311 | file_patterns = {line.strip() for line in f if line.strip() and not line.startswith('#')} 312 | patterns.update(file_patterns) 313 | 314 | print(f"Debug: Final ignore patterns: {patterns}") 315 | return patterns 316 | 317 | def estimate_output_size(path, ignore_patterns, base_path): 318 | estimated_size = 0 319 | file_count = 0 320 | for root, dirs, files in os.walk(path): 321 | dirs[:] = [d for d in dirs if not should_ignore(os.path.join(root, d), base_path, ignore_patterns)] 322 | for file in files: 323 | file_path = os.path.join(root, file) 324 | if not should_ignore(file_path, base_path, ignore_patterns) and is_text_file(file_path): 325 | file_size = os.path.getsize(file_path) 326 | estimated_size += file_size 327 | file_count += 1 328 | 329 | # Add some overhead for the directory structure and summary 330 | estimated_size += file_count * 100 # Assume 100 bytes per file for structure 331 | estimated_size += 1000 # Add 1KB for summary 332 | 333 | return estimated_size 334 | 335 | def main(): 336 | parser = argparse.ArgumentParser( 337 | description="Analyze and visualize codebase structure.", 338 | formatter_class=argparse.RawTextHelpFormatter 339 | ) 340 | parser.add_argument("path", nargs="?", 341 | help="Path to the directory to analyze") 342 | parser.add_argument("-d", "--max-depth", type=int, 343 | help="Maximum depth for directory traversal") 344 | parser.add_argument("-o", "--output-format", 345 | choices=["text", "json", "markdown", "xml", "html"], 346 | default="text", 347 | help="Output format (default: text)") 348 | parser.add_argument("-f", "--file", 349 | help="Output file name (default: _codebase_digest.)") 350 | parser.add_argument("--show-size", action="store_true", 351 | help="Show file sizes in directory tree") 352 | parser.add_argument("--show-ignored", action="store_true", 353 | help="Show ignored files and directories in tree") 354 | parser.add_argument("--ignore", nargs="+", default=None, 355 | help="Additional patterns to ignore. These will be added to the default ignore patterns.\n" 356 | "Examples:\n" 357 | " --ignore '*.txt' 'temp_*' '/path/to/specific/file.py'\n" 358 | "Patterns can use wildcards (* and ?) and can be:\n" 359 | " - Filenames (e.g., 'file.txt')\n" 360 | " - Directory names (e.g., 'node_modules')\n" 361 | " - File extensions (e.g., '*.pyc')\n" 362 | " - Paths (e.g., '/path/to/ignore')\n" 363 | f"Default ignore patterns: {', '.join(DEFAULT_IGNORE_PATTERNS)}") 364 | parser.add_argument("--no-default-ignores", action="store_true", 365 | help="Do not use default ignore patterns. Only use patterns specified by --ignore.") 366 | parser.add_argument("--no-content", action="store_true", 367 | help="Exclude file contents from the output") 368 | parser.add_argument("--include-git", action="store_true", 369 | help="Include .git directory in the analysis (ignored by default)") 370 | parser.add_argument("--max-size", type=int, default=10240, 371 | help="Maximum allowed text content size in KB (default: 10240 KB)") 372 | parser.add_argument("--copy-to-clipboard", action="store_true", 373 | help="Copy the output to clipboard after analysis") 374 | 375 | if len(sys.argv) == 1: 376 | parser.print_help(sys.stderr) 377 | sys.exit(1) 378 | 379 | args = parser.parse_args() 380 | 381 | if not args.path: 382 | print(Fore.RED + "Error: Path argument is required." + Style.RESET_ALL) 383 | parser.print_help(sys.stderr) 384 | sys.exit(1) 385 | 386 | ignore_patterns = load_ignore_patterns(args, args.path) 387 | print(f"Debug: Ignore patterns after load_ignore_patterns: {ignore_patterns}") 388 | 389 | print_frame("Codebase Digest") 390 | print(Fore.CYAN + "Analyzing directory: " + Fore.WHITE + args.path + Style.RESET_ALL) 391 | 392 | # Estimate the output size 393 | estimated_size = estimate_output_size(args.path, ignore_patterns, args.path) 394 | print(f"Estimated output size: {estimated_size / 1024:.2f} KB") 395 | 396 | # Perform a quick size check of all text files 397 | total_size = sum(os.path.getsize(os.path.join(dirpath, f)) 398 | for dirpath, _, filenames in os.walk(args.path) 399 | for f in filenames if is_text_file(os.path.join(dirpath, f))) 400 | 401 | if estimated_size / 1024 > args.max_size: 402 | print(Fore.YELLOW + f"\nWarning: The estimated output size ({estimated_size / 1024:.2f} KB) exceeds the maximum allowed size ({args.max_size} KB)." + Style.RESET_ALL) 403 | proceed = input("Do you want to proceed? (y/n): ").lower().strip() 404 | if proceed != 'y': 405 | print(Fore.YELLOW + "Analysis aborted." + Style.RESET_ALL) 406 | sys.exit(0) 407 | elif total_size / 1024 > args.max_size * 2: # Only show this if total size is significantly larger 408 | print(Fore.YELLOW + f"\nNote: The total size of all text files in the directory ({total_size / 1024:.2f} KB) is significantly larger than the estimated output size." + Style.RESET_ALL) 409 | print(Fore.YELLOW + "This is likely due to large files or directories that will be ignored in the analysis." + Style.RESET_ALL) 410 | 411 | try: 412 | data = analyze_directory(args.path, ignore_patterns, args.path, include_git=args.include_git, max_depth=args.max_depth) 413 | 414 | # Generate output based on the chosen format 415 | if args.output_format == "json": 416 | output = json.dumps(data, indent=2) 417 | file_extension = "json" 418 | elif args.output_format == "markdown": 419 | output = generate_markdown_output(data) 420 | file_extension = "md" 421 | elif args.output_format == "xml": 422 | output = generate_xml_output(data) 423 | file_extension = "xml" 424 | elif args.output_format == "html": 425 | output = generate_html_output(data) 426 | file_extension = "html" 427 | else: # text 428 | output = f"Codebase Analysis for: {args.path}\n" 429 | output += "\nDirectory Structure:\n" 430 | output += generate_tree_string(data, show_size=args.show_size, show_ignored=args.show_ignored, use_color=False) 431 | output += generate_summary_string(data, estimated_size, use_color=False) 432 | if not args.no_content: 433 | output += "\nFile Contents:\n" 434 | for file in generate_content_string(data): 435 | output += f"\n{'=' * 50}\n" 436 | output += f"File: {file['path']}\n" 437 | output += f"{'=' * 50}\n" 438 | output += file['content'] 439 | output += "\n" 440 | file_extension = "txt" 441 | 442 | # Save the output to a file 443 | file_name = args.file or f"{os.path.basename(args.path)}_codebase_digest.{file_extension}" 444 | full_path = os.path.abspath(file_name) 445 | with open(full_path, 'w', encoding='utf-8') as f: 446 | f.write(output) 447 | print(Fore.GREEN + f"\nAnalysis saved to: {full_path}" + Style.RESET_ALL) 448 | 449 | # Print colored summary to console immediately 450 | print_frame("Analysis Summary") 451 | print(generate_tree_string(data, show_size=args.show_size, show_ignored=args.show_ignored, use_color=True)) 452 | print(generate_summary_string(data, estimated_size, use_color=True)) 453 | 454 | # Handle clipboard functionality for all formats 455 | if args.copy_to_clipboard: 456 | try: 457 | pyperclip.copy(output) 458 | print(Fore.GREEN + "Output copied to clipboard!" + Style.RESET_ALL) 459 | except Exception as e: 460 | print(Fore.RED + f"Failed to copy to clipboard: {str(e)}" + Style.RESET_ALL) 461 | else: 462 | copy_to_clipboard = input("Do you want to copy the output to clipboard? (y/n): ").lower().strip() 463 | if copy_to_clipboard == 'y': 464 | try: 465 | pyperclip.copy(output) 466 | print(Fore.GREEN + "Output copied to clipboard!" + Style.RESET_ALL) 467 | except Exception as e: 468 | print(Fore.RED + f"Failed to copy to clipboard: {str(e)}" + Style.RESET_ALL) 469 | 470 | except Exception as e: 471 | print(Fore.RED + f"An error occurred: {str(e)}" + Style.RESET_ALL) 472 | sys.exit(1) 473 | 474 | if data['text_content_size'] / 1024 > args.max_size: 475 | print(Fore.RED + f"\nWarning: The text content size ({data['text_content_size'] / 1024:.2f} KB) exceeds the maximum allowed size ({args.max_size} KB)." + Style.RESET_ALL) 476 | proceed = input("Do you want to proceed? (y/n): ").lower().strip() 477 | if proceed != 'y': 478 | print(Fore.YELLOW + "Analysis aborted." + Style.RESET_ALL) 479 | sys.exit(0) 480 | 481 | if __name__ == "__main__": 482 | main() -------------------------------------------------------------------------------- /prompt_library/ansoff_matrix_analysis.md: -------------------------------------------------------------------------------- 1 | # Ansoff Matrix Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase using the Ansoff Matrix framework to evaluate potential growth strategies and identify opportunities for expansion. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key features and functionalities it provides. 8 | 2. Analyze each of the four quadrants of the Ansoff Matrix in relation to the codebase: 9 | 10 | a. Market Penetration (Existing Products, Existing Markets): 11 | - How can the codebase increase its market share within its current market? 12 | - Are there opportunities for increasing usage or adoption among existing customers? 13 | 14 | b. Product Development (New Products, Existing Markets): 15 | - What new features or functionalities could be added to the codebase to better serve existing markets? 16 | - Are there opportunities for product line extensions or variations? 17 | 18 | c. Market Development (Existing Products, New Markets): 19 | - Are there new customer segments or geographic markets that the codebase could target? 20 | - How could the codebase be adapted or marketed to appeal to these new markets? 21 | 22 | d. Diversification (New Products, New Markets): 23 | - Are there opportunities for the codebase to expand into entirely new product areas and markets? 24 | - What synergies or advantages could the codebase leverage in pursuing diversification? 25 | 26 | 3. Evaluate the potential risks and rewards associated with each growth strategy. 27 | 4. Identify the most promising growth strategies for the codebase based on its current capabilities and market position. 28 | 5. Develop high-level recommendations for pursuing the identified growth opportunities. 29 | 30 | **Expected Output:** A comprehensive Ansoff Matrix analysis of the codebase, including: 31 | - Assessment of growth opportunities within each of the four quadrants 32 | - Evaluation of risks and rewards associated with each growth strategy 33 | - Identification of the most promising growth strategies for the codebase 34 | - High-level recommendations for pursuing growth opportunities 35 | -------------------------------------------------------------------------------- /prompt_library/architecture_api_client_code_generation.md: -------------------------------------------------------------------------------- 1 | ## Generate API Client Code 2 | 3 | **Objective:** Generate client-side code in a specified programming language (e.g., JavaScript, Python) that can interact with an API, given the API specification or a codebase implementing the API. 4 | 5 | **Instructions:** 6 | 7 | 1. **Access the API definition:** Obtain the API specification (e.g., OpenAPI/Swagger definition) or access the codebase that implements the API. 8 | 2. **Determine the target language:** Use the specified programming language for the generated client code. 9 | 3. **Generate the client code:** 10 | * **API Methods:** Generate functions or methods for each API endpoint (e.g., `getUser(userId)`, `createOrder(orderData)`). 11 | * **Data Models:** Create data structures or classes that represent request and response payloads for API interactions, matching the API specification. 12 | * **Authentication:** If the API requires authentication, include necessary authentication mechanisms (e.g., API keys, OAuth) in the generated code. 13 | * **Error Handling:** Implement robust error handling to handle different API response codes (e.g., 400 Bad Request, 500 Server Error) and provide helpful error messages. 14 | 4. **Ensure code quality:** The generated code should be: 15 | * **Readable and Well-Formatted:** Follow coding conventions and style guides for the target language. 16 | * **Well-Documented:** Include comments to explain the purpose of different methods, classes, and how to use the client code. 17 | 18 | **Expected Output:** Working API client code in the specified programming language that can: 19 | 20 | * Authenticate with the API (if required). 21 | * Make requests to different API endpoints. 22 | * Handle responses and errors gracefully. 23 | * Be easily integrated into a larger project. 24 | -------------------------------------------------------------------------------- /prompt_library/architecture_api_conformance_check.md: -------------------------------------------------------------------------------- 1 | ## API Conformance Check 2 | 3 | **Objective:** Given an API specification, analyze a codebase to identify any inconsistencies or deviations from the defined API contract. 4 | 5 | **Instructions:** 6 | 7 | 1. **Obtain the API specification:** Access the API definition in a suitable format (e.g., YAML, JSON). 8 | 2. **Map API endpoints to code:** Identify the code modules or functions responsible for handling each API endpoint defined in the specification. 9 | 3. **Compare the API specification with the codebase implementation:** 10 | * **HTTP Methods:** Verify that the implemented methods (GET, POST, PUT, DELETE, etc.) match those defined for each endpoint. 11 | * **Request Parameters:** Check that the code handles all required and optional parameters as specified. 12 | * **Request and Response Bodies:** Ensure that the data structures used in the code for request and response payloads match the data models defined in the specification. 13 | * **Error Handling:** Verify that the code returns the correct HTTP status codes and error responses for different scenarios, as defined in the specification. 14 | 4. **Document inconsistencies:** 15 | * Clearly describe any discrepancies found between the API specification and the code implementation. 16 | * Provide specific code examples and line numbers where the deviations occur. 17 | 5. **Assess the severity of inconsistencies:** Determine if the inconsistencies are: 18 | * Minor (e.g., differences in parameter naming) 19 | * Major (e.g., missing endpoints, different data structures). 20 | 21 | **Expected Output:** A detailed report that: 22 | 23 | 1. Lists all identified inconsistencies between the API specification and the codebase. 24 | 2. Provides a clear description of each inconsistency, its location in the code, and its potential severity. 25 | 3. Helps prioritize fixes by highlighting major conformance issues. 26 | -------------------------------------------------------------------------------- /prompt_library/architecture_coupling_cohesion_analysis.md: -------------------------------------------------------------------------------- 1 | ## Analyze Coupling and Cohesion 2 | 3 | **Objective:** Evaluate the coupling and cohesion of modules or components within the codebase, identifying areas of high coupling or low cohesion that might indicate design flaws. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze module dependencies:** Examine how different modules or components in the codebase depend on each other. Tools like dependency graphs can be helpful for visualization. 8 | 2. **Evaluate coupling:** 9 | * **Identify areas of high coupling:** Look for modules that depend heavily on many other modules or have complex, intertwined dependencies. 10 | * **Explain the implications of high coupling:** For example, explain how high coupling can make modules harder to understand, test, and maintain independently. 11 | 3. **Evaluate cohesion:** 12 | * **Identify areas of low cohesion:** Look for modules that contain unrelated functionalities or classes that don't seem to belong together logically. 13 | * **Explain the implications of low cohesion:** For example, explain how low cohesion can make modules harder to understand and can lead to code that is more difficult to reuse. 14 | 4. **Provide concrete examples:** Illustrate your findings with specific code examples from the codebase. Show instances of tight coupling, complex dependencies, or modules with low cohesion. 15 | 5. **Suggest potential improvements:** Where applicable, suggest ways to refactor the code to reduce coupling and improve cohesion, such as: 16 | * Extracting shared functionality into separate modules. 17 | * Applying design principles like the Single Responsibility Principle. 18 | 19 | **Expected Output:** A well-structured report that: 20 | 21 | 1. Provides an assessment of the codebase's overall coupling and cohesion. 22 | 2. Identifies specific areas of high coupling and low cohesion, supported by code examples. 23 | 3. Explains the potential negative consequences of these design issues. 24 | 4. Suggests actionable steps to improve the codebase's structure. -------------------------------------------------------------------------------- /prompt_library/architecture_database_schema_documentation.md: -------------------------------------------------------------------------------- 1 | ## Generate Database Schema Documentation 2 | 3 | **Objective:** Create clear, comprehensive, and well-structured documentation for the provided database schema, including descriptions of tables, columns, relationships, indexes, and constraints. 4 | 5 | **Instructions:** 6 | 7 | 1. **Access the database schema:** Obtain the schema definition, including information about: 8 | * Tables: Names, primary keys, foreign keys, indexes, and any other constraints. 9 | * Columns: Names, data types, default values, constraints (e.g., NOT NULL, UNIQUE), and whether they are part of a primary or foreign key. 10 | * Relationships: How tables are related to each other (one-to-one, one-to-many, many-to-many). 11 | 2. **Organize the documentation:** Structure the documentation logically, for example: 12 | * By table: Provide a dedicated section for each table in the schema. 13 | * By relationship: Group tables based on their relationships (e.g., orders and order items). 14 | 3. **Provide clear and concise descriptions:** 15 | * **Table Descriptions:** Explain the purpose of each table and the type of data it stores. 16 | * **Column Descriptions:** Explain the purpose of each column, its data type, allowed values, and any relevant business rules. 17 | * **Relationship Descriptions:** Clearly describe how tables are related, including cardinality (one-to-one, etc.). 18 | 4. **Consider using visuals:** Incorporate diagrams (like Entity-Relationship Diagrams) to visually represent relationships between tables. 19 | 20 | **Expected Output:** Well-structured and informative database schema documentation that can be: 21 | 22 | * Easily understood by both technical and non-technical audiences. 23 | * Used for reference, onboarding new team members, or generating data dictionaries. 24 | * Output formats could be: 25 | * Markdown files (`.md`) 26 | * HTML pages 27 | * Database schema documentation tools (e.g., SchemaSpy). 28 | 29 | -------------------------------------------------------------------------------- /prompt_library/architecture_database_schema_review.md: -------------------------------------------------------------------------------- 1 | ## Database Schema Review 2 | 3 | **Objective:** Review the database schema for normalization, indexing, and potential performance bottlenecks, providing recommendations for improvement based on best practices. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the database schema:** Obtain the schema definition (tables, columns, data types, relationships, keys, constraints, etc.) 8 | 2. **Evaluate normalization levels:** Determine the normalization level of the schema (e.g., 1NF, 2NF, 3NF). Identify any tables that might benefit from further normalization to reduce data redundancy and improve data integrity. 9 | 3. **Assess indexing strategy:** 10 | * Analyze existing indexes and their effectiveness. 11 | * Identify columns or combinations of columns that are frequently used in query WHERE clauses or JOIN conditions and might benefit from indexing. 12 | 4. **Identify potential performance bottlenecks:** 13 | * Look for large tables, complex queries, or inefficient data types that could negatively impact performance. 14 | * Check for the appropriate use of primary and foreign keys for efficient data retrieval. 15 | 5. **Suggest improvements and optimizations:** Based on your analysis: 16 | * Recommend specific normalization steps if needed. 17 | * Suggest indexes to improve query performance. 18 | * Recommend changes to data types or table structures to enhance efficiency. 19 | * Provide general recommendations for database optimization based on best practices. 20 | 21 | **Expected Output:** A comprehensive database schema review report that includes: 22 | 23 | 1. An assessment of normalization levels. 24 | 2. An evaluation of the indexing strategy. 25 | 3. Identification of potential performance bottlenecks. 26 | 4. Concrete and actionable recommendations for improving the schema design and performance. 27 | 28 | -------------------------------------------------------------------------------- /prompt_library/architecture_design_pattern_identification.md: -------------------------------------------------------------------------------- 1 | ## Identify Design Patterns 2 | 3 | **Objective:** Analyze the codebase to identify and understand the implementation and purpose of common design patterns. 4 | 5 | **Instructions:** 6 | 7 | 1. **Examine the codebase structure and logic:** Look for recurring code structures, relationships between classes, or ways that common software design problems are addressed. 8 | 2. **Identify design pattern instances:** Determine if any of the following design patterns (or others) are used: 9 | * **Creational Patterns:** Singleton, Factory, Abstract Factory, Builder, Prototype 10 | * **Structural Patterns:** Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy 11 | * **Behavioral Patterns:** Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor 12 | 3. **For each identified pattern:** 13 | * **Name the pattern.** 14 | * **Provide a brief description of the pattern** and its general purpose. 15 | * **Explain the specific implementation details** within the codebase, including relevant classes, interfaces, and relationships. 16 | * **Explain the reasoning behind using the pattern** in the context of the codebase. What benefits does it provide? 17 | 18 | **Expected Output:** A structured analysis that: 19 | 20 | 1. Lists all identified design patterns found in the codebase. 21 | 2. Provides a clear description and explanation for each identified pattern instance. 22 | 3. Explains the reasoning and benefits of using each design pattern within the specific context of the codebase. 23 | -------------------------------------------------------------------------------- /prompt_library/architecture_diagram_generation.md: -------------------------------------------------------------------------------- 1 | ## Generate Architectural Diagram 2 | 3 | **Objective:** Generate a clear and informative architectural diagram that visually represents the structure and components of the codebase, based on its actual structure and dependencies. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the codebase:** Examine the directory structure, modules, classes, and their relationships to understand the system's architecture. 8 | 2. **Identify key components:** Determine the major building blocks of the system, such as: 9 | * User Interface components 10 | * APIs or services 11 | * Databases 12 | * External systems 13 | * Business logic modules 14 | 3. **Determine relationships:** Analyze how these components interact with each other. For example: 15 | * Which modules depend on others? 16 | * How do data flows between components? 17 | * What are the communication protocols used? 18 | 4. **Choose a suitable diagram type:** Select a diagram type that effectively represents the architecture. Common choices include: 19 | * Component diagrams 20 | * Layered architecture diagrams 21 | * Data flow diagrams 22 | 5. **Generate the diagram:** Use a diagramming tool or library to create a visually appealing and informative diagram that includes: 23 | * Clearly labeled components 24 | * Well-defined relationships (e.g., arrows indicating data flow or dependencies) 25 | * A legend or key to explain symbols and notations 26 | 27 | **Expected Output:** A visual representation of the codebase's architecture, either as an image file or in a text-based format that can be easily rendered (e.g., PlantUML, Mermaid). The diagram should be: 28 | 29 | * **Accurate:** It should correctly reflect the actual structure and dependencies in the codebase. 30 | * **Clear and Concise:** Avoid clutter and use concise labels for easy understanding. 31 | * **Informative:** The diagram should convey the key architectural elements and their interactions effectively. 32 | -------------------------------------------------------------------------------- /prompt_library/architecture_layer_identification.md: -------------------------------------------------------------------------------- 1 | **Objective:** Analyze the codebase and identify different architectural layers (e.g., presentation, business logic, data access), highlighting inconsistencies or deviations from common architectural patterns. 2 | 3 | **Instructions:** 4 | 5 | 1. **Analyze the codebase structure:** Examine the directory structure, modules, and classes to understand how code is organized. 6 | 2. **Identify distinct layers:** Look for code sections responsible for: 7 | * **Presentation:** Handling user interface, user input, and displaying information (e.g., UI components, views, controllers). 8 | * **Business Logic:** Implementing business rules, workflows, and data processing (e.g., services, business objects, use case classes). 9 | * **Data Access:** Interacting with databases or external data sources (e.g., repositories, data access objects, API clients). 10 | 3. **Document each identified layer:** 11 | * Name the layer (e.g., "Presentation Layer", "Domain Layer", "Persistence Layer"). 12 | * Describe its purpose and responsibilities. 13 | * List the key components or modules belonging to that layer. 14 | 4. **Analyze adherence to architectural patterns:** 15 | * Determine if the codebase follows any recognizable architectural patterns (e.g., Model-View-Controller, Model-View-ViewModel, Layered Architecture). 16 | * Highlight any inconsistencies or deviations from these patterns. For example, if business logic is found within the presentation layer, explain the potential implications. 17 | 5. **Provide specific code examples:** Illustrate your findings by referencing relevant code snippets that clearly demonstrate the separation (or lack thereof) between architectural layers. 18 | 19 | **Expected Output:** A clear and well-structured report that: 20 | 21 | 1. Identifies the architectural layers present in the codebase. 22 | 2. Describes the purpose and responsibilities of each layer. 23 | 3. Provides concrete code examples to support the analysis. 24 | 4. Analyzes the codebase's adherence to common architectural patterns and highlights any inconsistencies or deviations. 25 | -------------------------------------------------------------------------------- /prompt_library/architecture_refactoring_for_design_patterns.md: -------------------------------------------------------------------------------- 1 | ## Suggest Refactoring for Design Patterns 2 | 3 | **Objective:** Analyze the codebase and identify opportunities to refactor code by implementing suitable design patterns to improve code maintainability, extensibility, or reusability. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the codebase:** Examine the existing code structure, identify areas that are complex, difficult to maintain, or lack flexibility. 8 | 2. **Identify potential design pattern applications:** Determine if any of the following situations exist: 9 | * **Code Smells:** Look for common code smells like "Large Class", "Long Method", "Shotgun Surgery" (many small changes across multiple classes), or "Divergent Change" (one class changing for multiple reasons) as indicators for refactoring. 10 | * **Repetitive Code:** Identify duplicated code or logic that could be extracted and made reusable. 11 | * **Tight Coupling:** Look for areas where components are too tightly dependent on each other, making it difficult to change one without affecting others. 12 | * **Lack of Flexibility:** Identify code that is difficult to extend or modify to accommodate new requirements. 13 | 3. **Suggest specific design patterns:** Based on your analysis, recommend suitable design patterns to address the identified issues. For each suggestion: 14 | * **Name the pattern.** 15 | * **Explain why the pattern is a good fit for the specific situation.** 16 | * **Describe how the pattern should be implemented:** Include specific details about which classes or modules should be created or modified. 17 | * **Illustrate with code examples (if possible):** Show how the code could be refactored using the suggested pattern. 18 | 19 | **Expected Output:** A report (or a series of suggestions) that: 20 | 21 | 1. Clearly identifies specific areas in the codebase that would benefit from refactoring. 22 | 2. Recommends appropriate design patterns to address each identified issue. 23 | 3. Provides detailed explanations and (ideally) code examples to guide the refactoring process. -------------------------------------------------------------------------------- /prompt_library/bcg_matrix_analysis.md: -------------------------------------------------------------------------------- 1 | # BCG Growth-Share Matrix Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase and its associated product portfolio using the BCG Growth-Share Matrix to assess resource allocation and identify growth opportunities. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key products or features it supports. 8 | 2. For each product or feature, analyze its position within the BCG Growth-Share Matrix: 9 | 10 | a. Relative Market Share: 11 | - How does the product's market share compare to that of its largest competitor? 12 | - Is the product a market leader or a follower? 13 | 14 | b. Market Growth Rate: 15 | - How fast is the market for this product growing? 16 | - Is the market in a high-growth or low-growth phase? 17 | 18 | 3. Based on the analysis, classify each product or feature into one of the four categories: 19 | 20 | a. Stars (High Market Share, High Market Growth): 21 | - These products are market leaders in high-growth markets. 22 | - They require significant investment to maintain their position. 23 | 24 | b. Cash Cows (High Market Share, Low Market Growth): 25 | - These products are market leaders in mature, slow-growth markets. 26 | - They generate significant cash flow that can be used to fund other products. 27 | 28 | c. Question Marks (Low Market Share, High Market Growth): 29 | - These products have low market share in high-growth markets. 30 | - They require investment to increase market share, with the potential to become stars. 31 | 32 | d. Dogs (Low Market Share, Low Market Growth): 33 | - These products have low market share in slow-growth markets. 34 | - They may generate little profit and consume resources that could be better used elsewhere. 35 | 36 | 4. Evaluate the overall balance and sustainability of the product portfolio. 37 | 5. Identify potential strategies for each product category (e.g., invest, maintain, harvest, divest). 38 | 6. Develop high-level recommendations for optimizing the product portfolio and allocating resources. 39 | 40 | **Expected Output:** A comprehensive BCG Growth-Share Matrix analysis of the codebase and its associated product portfolio, including: 41 | - Classification of each product or feature into the four categories (Stars, Cash Cows, Question Marks, Dogs) 42 | - Evaluation of the overall balance and sustainability of the product portfolio 43 | - Identification of potential strategies for each product category 44 | - High-level recommendations for portfolio optimization and resource allocation 45 | -------------------------------------------------------------------------------- /prompt_library/blue_ocean_strategy_analysis.md: -------------------------------------------------------------------------------- 1 | # Blue Ocean Strategy Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase to identify opportunities for creating uncontested market space and generating new demand, based on the principles of Blue Ocean Strategy. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify key features and functionalities. 8 | 2. Analyze the industry landscape and existing solutions: 9 | - What are the common features and assumptions in the industry? 10 | - What factors do competitors typically compete on? 11 | 3. Identify opportunities for value innovation: 12 | - How can the codebase eliminate features that the industry takes for granted? 13 | - What features could be reduced well below the industry standard? 14 | - Which features could be raised well above the industry standard? 15 | - What features could be created that the industry has never offered? 16 | 4. Assess the potential for creating new market space: 17 | - How do the identified opportunities differentiate the codebase from existing solutions? 18 | - What new customer segments or needs could be addressed? 19 | 5. Evaluate the strategic fit and feasibility of pursuing these opportunities: 20 | - Are the opportunities aligned with the overall business strategy? 21 | - What are the potential challenges or risks in pursuing these opportunities? 22 | 6. Develop a high-level roadmap for implementing the identified blue ocean opportunities. 23 | 24 | **Expected Output:** A comprehensive Blue Ocean Strategy analysis of the codebase, including: 25 | - Identification of industry assumptions and factors of competition 26 | - Opportunities for value innovation through the four actions framework (eliminate, reduce, raise, create) 27 | - Assessment of the potential for creating uncontested market space 28 | - Evaluation of strategic fit and feasibility 29 | - High-level implementation roadmap 30 | -------------------------------------------------------------------------------- /prompt_library/business_impact_analysis.md: -------------------------------------------------------------------------------- 1 | # Codebase Business Impact Analysis 2 | 3 | **Objective:** Analyze the codebase to identify key features and their potential business impact. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify major features or functionalities. 8 | 2. For each feature, analyze its potential business impact: 9 | * Revenue generation potential 10 | * Cost-saving opportunities 11 | * Customer satisfaction improvements 12 | * Competitive advantage 13 | 3. Prioritize features based on their estimated business value. 14 | 4. Suggest potential enhancements or new features that could increase business value. 15 | 16 | **Expected Output:** A report detailing the business impact of key features, their prioritization, and suggestions for value-adding enhancements. -------------------------------------------------------------------------------- /prompt_library/business_model_canvas_analysis.md: -------------------------------------------------------------------------------- 1 | # Business Model Canvas Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase using the Business Model Canvas framework to understand its business implications and potential. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify key features and functionalities. 8 | 2. For each element of the Business Model Canvas, analyze how the codebase contributes: 9 | 10 | a. Value Propositions: 11 | - What user problems does the code solve? 12 | - What value does it deliver to users? 13 | 14 | b. Customer Segments: 15 | - Who are the target users/customers for this code? 16 | - Are there different user groups with distinct needs? 17 | 18 | c. Channels: 19 | - How does the code facilitate reaching users? 20 | - Are there features for distribution or communication? 21 | 22 | d. Customer Relationships: 23 | - How does the code support user engagement and retention? 24 | - Are there features for customer support or community building? 25 | 26 | e. Revenue Streams: 27 | - How could this code generate revenue? 28 | - Are there monetization features implemented? 29 | 30 | f. Key Resources: 31 | - What are the critical technical assets in the codebase? 32 | - Are there unique algorithms or data structures? 33 | 34 | g. Key Activities: 35 | - What are the core functionalities that keep the application running? 36 | - What ongoing processes does the code support? 37 | 38 | h. Key Partnerships: 39 | - Does the code integrate with external services or APIs? 40 | - Are there dependencies on third-party libraries? 41 | 42 | i. Cost Structure: 43 | - What are the main cost drivers in running this code? 44 | - Are there features aimed at optimizing costs? 45 | 46 | 3. Identify potential gaps or opportunities in the business model based on the codebase analysis. 47 | 4. Suggest improvements or new features that could enhance the business model. 48 | 49 | **Expected Output:** A comprehensive analysis of the codebase using the Business Model Canvas framework, highlighting how the code supports different aspects of the business model and identifying areas for improvement or expansion. -------------------------------------------------------------------------------- /prompt_library/competitive_positioning_map.md: -------------------------------------------------------------------------------- 1 | # Competitive Positioning Map for Codebase 2 | 3 | **Objective:** Create a visual map of the codebase's associated product and its competitors, positioning each based on key dimensions that are important to the target market. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key features and functionalities it provides. 8 | 2. Define the target market for the product and identify the main competitors. 9 | 3. Select two key dimensions that are important to the target market and can be used to differentiate the products. Examples might include: 10 | - Price vs. Quality 11 | - Ease of Use vs. Functionality 12 | - Performance vs. Customization 13 | - Brand Reputation vs. Innovation 14 | 4. Create a two-dimensional grid with the chosen dimensions as the axes. 15 | 5. Plot the codebase's associated product on the grid based on its relative position along the two dimensions. 16 | 6. Plot the main competitors on the grid based on their relative positions along the two dimensions. 17 | 7. Analyze the resulting map: 18 | - Where is the codebase's product positioned relative to competitors? 19 | - Are there any gaps or clusters in the market? 20 | - Is the codebase's product positioned in a way that aligns with its target market and value proposition? 21 | 8. Identify opportunities for differentiating or repositioning the codebase's product based on the competitive landscape. 22 | 9. Develop strategies for strengthening the product's position and competing effectively in the market. 23 | 24 | **Expected Output:** A visual Competitive Positioning Map for the codebase's associated product, including: 25 | - A two-dimensional grid with labeled axes representing the chosen key dimensions 26 | - The codebase's product plotted on the grid based on its relative position 27 | - Main competitors plotted on the grid based on their relative positions 28 | - Analysis of the product's position relative to competitors and market gaps/clusters 29 | - Identification of opportunities for differentiation and repositioning 30 | - Strategies for strengthening the product's competitive position 31 | -------------------------------------------------------------------------------- /prompt_library/customer_journey_map_analysis.md: -------------------------------------------------------------------------------- 1 | # Customer Journey Map Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase to map out how different parts support various stages of the user's journey or experience. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify key features and functionalities. 8 | 9 | 2. Define the main stages of the customer journey that the code supports. Typical stages might include: 10 | - Awareness 11 | - Consideration 12 | - Decision 13 | - Onboarding 14 | - Usage 15 | - Support 16 | - Retention 17 | - Advocacy 18 | 19 | 3. For each stage of the journey: 20 | a. Identify the specific code components or features that support this stage. 21 | b. Analyze how these components contribute to the user's experience: 22 | - What actions can the user take? 23 | - What information or feedback does the user receive? 24 | - How does the code facilitate the user's progression to the next stage? 25 | 26 | 4. Evaluate the user's emotional state at each stage: 27 | - How might the user feel when interacting with this part of the code? 28 | - Are there potential pain points or moments of delight? 29 | 30 | 5. Identify touchpoints where the code interacts with the user: 31 | - User interface elements 32 | - Data input/output points 33 | - Notifications or alerts 34 | - Integration with external services or platforms 35 | 36 | 6. Analyze the flow and continuity between stages: 37 | - How smoothly does the code facilitate the user's transition between stages? 38 | - Are there any gaps or disconnects in the user's journey? 39 | 40 | 7. Identify opportunities for improvement: 41 | - Are there stages of the journey that lack adequate support in the code? 42 | - Could additional features enhance the user's experience at any stage? 43 | - Are there ways to streamline the journey or reduce friction points? 44 | 45 | 8. Consider personalization and adaptability: 46 | - Does the code account for different user personas or use cases? 47 | - How flexible is the implementation in supporting various journey paths? 48 | 49 | **Expected Output:** A comprehensive analysis of how the codebase supports the customer journey, including: 50 | - A mapping of code components to each stage of the journey 51 | - Insights into the user's experience and emotional state at each stage 52 | - Identified strengths and weaknesses in the current implementation 53 | - Opportunities for enhancing the user journey through code improvements or new features 54 | 55 | This analysis should provide a clear picture of how the code facilitates the user's experience from start to finish, and guide decisions for future development to optimize the customer journey. -------------------------------------------------------------------------------- /prompt_library/evolution_code_churn_hotspot_analysis.md: -------------------------------------------------------------------------------- 1 | #### Code Churn Hotspot Analysis 2 | 3 | **Objective:** Analyze the codebase's commit history to identify areas with high churn rates (frequent changes), which often indicate areas that are complex, error-prone, or in need of refactoring. 4 | 5 | **Instructions:** 6 | 7 | 1. **Access the Version Control System (VCS):** Obtain the commit history from the codebase's version control system (e.g., Git). 8 | 2. **Calculate code churn:** For each file or code module, calculate the churn rate, which can be defined as: 9 | - Number of times the file has been modified 10 | - Number of lines of code added, deleted, or changed over a specific period. 11 | 3. **Identify hotspots:** Identify files or modules with significantly higher churn rates compared to the rest of the codebase. 12 | 4. **Investigate the reasons for high churn:** Try to understand why these hotspots are frequently modified. This might involve: 13 | - Looking at commit messages associated with the changes. 14 | - Analyzing the types of changes made (bug fixes, new features, refactoring). 15 | 5. **Correlate with other metrics:** Combine churn analysis with other code quality metrics (e.g., complexity) to get a more comprehensive view of problematic areas. 16 | 17 | **Expected Output:** A report or visualization (e.g., a heatmap) that highlights: 18 | 19 | - Files or modules with the highest code churn rates. 20 | - Trends in churn over time (e.g., increasing or decreasing churn). 21 | - Potential reasons for high churn based on commit history analysis. 22 | - Recommendations for refactoring or further investigation. 23 | -------------------------------------------------------------------------------- /prompt_library/evolution_code_evolution_report_generation.md: -------------------------------------------------------------------------------- 1 | **Objective:** Create a comprehensive report summarizing the evolution of a codebase over time, using version control data and potentially other code quality metrics. 2 | 3 | **Instructions:** 4 | 5 | 1. **Gather data from the VCS:** Access the codebase's version control system (e.g., Git) to retrieve historical data, including: 6 | - Commit history 7 | - Author information 8 | - Dates and times of changes 9 | - Files changed in each commit 10 | - Lines of code added, deleted, or modified 11 | 2. **Calculate relevant metrics:** Compute metrics that provide insights into the codebase's evolution: 12 | - Code Churn: Measure the frequency of changes to different parts of the codebase. 13 | - Code Complexity: Track the complexity of the code over time using metrics like cyclomatic complexity. 14 | - Contributor Activity: Analyze the number of contributors, their contributions over time, and the distribution of code ownership. 15 | 3. **Identify trends and patterns:** Look for significant trends in the data, such as: 16 | - Areas of the codebase with high churn. 17 | - Increasing or decreasing code complexity. 18 | - Changes in contributor activity. 19 | 4. **Structure the report:** Organize the report logically to present a clear narrative of the codebase's evolution, potentially including: 20 | - An overall summary of key trends. 21 | - Sections focused on specific metrics (churn, complexity, contributor activity). 22 | - Visualizations (graphs, charts) to illustrate trends and patterns. 23 | 24 | **Expected Output:** A comprehensive report that: 25 | 26 | - Summarizes the codebase's evolution over time. 27 | - Provides insights into code churn, complexity trends, and contributor activity. 28 | - Highlights important events or milestones in the codebase's history. 29 | - Uses visualizations to effectively communicate trends and patterns. -------------------------------------------------------------------------------- /prompt_library/evolution_codebase_evolution_visualization.md: -------------------------------------------------------------------------------- 1 | **Objective:** Generate visualizations that effectively represent the evolution of a codebase over time, using data from version control and other relevant sources. 2 | 3 | **Instructions:** 4 | 5 | 1. **Determine the key aspects to visualize:** Select the most relevant aspects of code evolution to display visually, such as: 6 | - Code Churn 7 | - Code Complexity 8 | - Contributor Activity 9 | - Growth in lines of code 10 | - Evolution of directory structure 11 | 2. **Choose appropriate visualization types:** Select chart types and visualization techniques that best represent the chosen data and insights, such as: 12 | - Line charts for showing trends over time. 13 | - Heatmaps for highlighting areas of high churn or complexity. 14 | - Treemaps for representing the evolution of directory structures or code modules. 15 | - Network graphs for visualizing relationships between code entities. 16 | 3. **Use clear and informative labels:** Provide meaningful titles, axis labels, and legends to make the visualizations easy to understand. 17 | 4. **Focus on key insights:** Highlight the most important patterns or trends that the visualizations reveal about the codebase's evolution. 18 | 19 | **Expected Output:** A set of clear and informative visualizations that: 20 | 21 | - Effectively communicate key aspects of the codebase's evolution. 22 | - Use appropriate visualization techniques to represent data and insights. 23 | - Include clear labels and annotations for easy understanding. 24 | - Help identify important trends, patterns, or potential areas for improvement. 25 | 26 | 27 | -------------------------------------------------------------------------------- /prompt_library/evolution_impact_analysis_of_code_changes.md: -------------------------------------------------------------------------------- 1 | **Objective:** Analyze the potential ripple effects of specific code changes (e.g., bug fixes, feature additions, refactoring) to identify areas of the codebase that might be affected and predict potential conflicts or regressions. 2 | 3 | **Instructions:** 4 | 5 | 1. **Identify the code changes:** Obtain a specific set of code changes, which could be: 6 | - A single commit 7 | - A pull request 8 | - A set of related modifications 9 | 2. **Analyze dependencies:** Determine which modules, classes, or functions are directly or indirectly affected by the code changes by analyzing: 10 | - Direct code dependencies (function calls, class inheritance, etc.). 11 | - Shared data structures or global state that is modified by the changes. 12 | 3. **Predict potential impacts:** Based on the analysis of dependencies: 13 | - Identify areas where the changes might introduce bugs or regressions. 14 | - Look for potential conflicts with other parts of the codebase. 15 | - Assess the risk level of the changes (e.g., low risk if changes are isolated, high risk if core components are affected). 16 | 4. **Suggest testing strategies:** Recommend specific tests or test cases that should be run to validate the code changes and mitigate the risk of regressions. 17 | 18 | **Expected Output:** An impact analysis report that: 19 | 20 | - Lists all potentially affected parts of the codebase. 21 | - Describes the nature of the potential impact (bugs, conflicts, performance regressions). 22 | - Assesses the risk level of the code changes. 23 | - Suggests targeted testing strategies to validate the changes and prevent regressions. 24 | 25 | -------------------------------------------------------------------------------- /prompt_library/evolution_refactoring_recommendation_generation.md: -------------------------------------------------------------------------------- 1 | **Objective:** Provide specific refactoring recommendations based on the analysis of code evolution and historical data. Focus on areas where past code changes, churn, or technical debt indicate a need for improvement. 2 | 3 | **Instructions:** 4 | 5 | 1. **Review code evolution analysis:** Consider the results from code churn analysis, technical debt estimation, and other historical code assessments. 6 | 2. **Identify refactoring opportunities:** Look for areas where: 7 | - Code churn is consistently high, indicating potential design flaws or areas that are difficult to maintain. 8 | - Technical debt has accumulated, making the code hard to understand or modify. 9 | - Architectural inconsistencies have emerged over time due to various changes and additions. 10 | 3. **Suggest specific refactoring actions:** Provide concrete recommendations, such as: 11 | - Extracting methods or classes to improve code organization and reduce complexity. 12 | - Applying design patterns to improve flexibility and maintainability. 13 | - Removing code smells or anti-patterns. 14 | 4. **Prioritize recommendations:** Rank the suggestions based on: 15 | - Their potential impact on code quality and maintainability. 16 | - The feasibility and effort required to implement them. 17 | 18 | **Expected Output:** A prioritized list of refactoring recommendations that: 19 | 20 | - Clearly identifies the specific areas of the codebase that need improvement. 21 | - Provides specific refactoring actions to be taken (e.g., "Extract Method", "Apply Strategy Pattern"). 22 | - Explains the rationale behind each recommendation and the expected benefits. -------------------------------------------------------------------------------- /prompt_library/evolution_technical_debt_estimation.md: -------------------------------------------------------------------------------- 1 | **Objective:** Estimate the amount of technical debt present in the codebase based on historical code analysis, focusing on identifying areas where past code evolution has led to accumulated technical debt. 2 | 3 | **Instructions:** 4 | 5 | 1. **Analyze commit history:** Examine commit messages, code changes, and refactoring patterns over time to identify potential sources of technical debt, such as: 6 | - Hasty bug fixes or workarounds that weren't properly addressed. 7 | - Lack of consistent coding standards or code reviews, leading to inconsistent code style and potential issues. 8 | - Postponed refactoring or architectural improvements. 9 | 2. **Identify code quality indicators:** Look for signs of technical debt based on historical changes, such as: 10 | - Increased code complexity over time. 11 | - High code churn in specific areas, indicating frequent rework or fixes. 12 | - Presence of code smells or anti-patterns that have accumulated over time. 13 | 3. **Estimate the impact:** Assess the potential consequences of the identified technical debt: 14 | - Increased maintenance effort and costs. 15 | - Reduced development velocity due to difficult-to-understand or modify code. 16 | - Increased risk of bugs or regressions. 17 | 4. **Prioritize areas for refactoring:** Rank areas with high technical debt based on their potential impact and the feasibility of addressing them. 18 | 19 | **Expected Output:** A technical debt report that provides: 20 | 21 | - An overview of the estimated technical debt in the codebase. 22 | - Identification of specific areas with high technical debt, supported by evidence from the code's history. 23 | - An assessment of the potential impact of the technical debt. 24 | - A prioritized list of recommendations for addressing the technical debt through refactoring or code improvements. 25 | 26 | -------------------------------------------------------------------------------- /prompt_library/improvement_best_practice_analysis.md: -------------------------------------------------------------------------------- 1 | # Codebase Best Practice Analysis 2 | 3 | **Objective:** Analyze the provided codebase and identify examples of both good and bad programming practices. 4 | 5 | **Instructions:** 6 | 7 | 1. **Carefully review the attached code** and pinpoint instances of exemplary and problematic coding practices. 8 | 2. **For each example, provide a detailed analysis** that includes: 9 | * **What is good/bad about the specific solution?** 10 | * **What concepts or principles underpin the solution?** 11 | * **What are the potential positive/negative consequences of using this solution?** 12 | 13 | **Expected Output:** A comprehensive report highlighting both positive and negative coding practices within the codebase, with in-depth explanations and analysis of their impact. -------------------------------------------------------------------------------- /prompt_library/improvement_language_translation.md: -------------------------------------------------------------------------------- 1 | # Codebase Translation to Another Programming Language 2 | 3 | **Objective:** Translate the provided codebase from [Source Language] to [Target Language] while preserving its functionality and structure. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the attached code** written in [Source Language] and understand its logic and functionalities. 8 | 2. **Translate the code** into [Target Language], ensuring that the translated code performs the same tasks as the original code. 9 | 3. **Maintain the original code's structure and organization** as much as possible in the translated version. 10 | 4. **Adhere to the coding conventions and best practices** of the target language. 11 | 5. **Comment the translated code** to explain any significant changes or adaptations made during the translation process. 12 | 13 | **Expected Output:** A functional codebase in [Target Language] that accurately reflects the functionality and structure of the original [Source Language] codebase. -------------------------------------------------------------------------------- /prompt_library/improvement_refactoring.md: -------------------------------------------------------------------------------- 1 | # Codebase Refactoring for Improved Readability and Performance 2 | 3 | **Objective:** Refactor the provided codebase to enhance its readability, maintainability, and performance. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the attached code** and identify areas that can be improved in terms of code clarity, structure, and efficiency. 8 | 2. **Suggest specific code transformations and optimizations** to address the identified areas for improvement. 9 | 3. **Prioritize refactoring techniques** that improve code readability without introducing unnecessary complexity. 10 | 4. **Consider performance implications** of your suggested refactoring and aim for solutions that enhance efficiency without sacrificing clarity. 11 | 5. **Provide clear explanations** for each refactoring suggestion, justifying its benefits and potential impact. 12 | 13 | **Expected Output:** A set of actionable refactoring suggestions with detailed explanations of their benefits and potential impact on code quality and performance. -------------------------------------------------------------------------------- /prompt_library/jobs_to_be_done_analysis.md: -------------------------------------------------------------------------------- 1 | # Jobs to be Done (JTBD) Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase using the Jobs to be Done framework to understand the core user needs it addresses and identify potential improvements or new opportunities. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify key features and functionalities. 8 | 9 | 2. For each major feature or component, analyze: 10 | 11 | a. Functional Job: 12 | - What practical task does this code help the user accomplish? 13 | - How does it make a process more efficient or effective? 14 | 15 | b. Emotional Job: 16 | - How does this code make the user feel? 17 | - Does it reduce anxiety, increase confidence, or provide a sense of accomplishment? 18 | 19 | c. Social Job: 20 | - How does this code help the user in their social or professional context? 21 | - Does it improve status, strengthen relationships, or enhance reputation? 22 | 23 | 3. Identify the circumstances that trigger the use of each feature: 24 | - What situation prompts the user to engage with this functionality? 25 | - What are the user's goals and constraints in this moment? 26 | 27 | 4. Analyze the current solutions and workarounds: 28 | - How are users currently addressing these jobs without your code? 29 | - What are the limitations or frustrations with existing solutions? 30 | 31 | 5. Evaluate how well the code fulfills each identified job: 32 | - Does it fully satisfy the user's needs? 33 | - Are there aspects of the job that are not adequately addressed? 34 | 35 | 6. Identify potential improvements or new opportunities: 36 | - How could existing features be enhanced to better fulfill the jobs? 37 | - Are there unaddressed jobs that present new development opportunities? 38 | 39 | 7. Prioritize potential enhancements based on their importance to users and alignment with business goals. 40 | 41 | **Expected Output:** A comprehensive analysis of the codebase through the Jobs to be Done lens, highlighting how well it addresses user needs, identifying gaps, and suggesting prioritized improvements or new features to better fulfill user jobs. -------------------------------------------------------------------------------- /prompt_library/kano_model_analysis.md: -------------------------------------------------------------------------------- 1 | # Kano Model Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase and its associated product features using the Kano Model to prioritize development efforts based on their impact on customer satisfaction. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key features and functionalities it provides. 8 | 2. For each feature, analyze its potential impact on customer satisfaction using the Kano Model categories: 9 | 10 | a. Must-be (Basic) Features: 11 | - These are features that customers expect and take for granted. 12 | - Their absence leads to extreme dissatisfaction, but their presence does not increase satisfaction. 13 | 14 | b. One-dimensional (Performance) Features: 15 | - These features result in satisfaction when fulfilled and dissatisfaction when not fulfilled. 16 | - The level of satisfaction is proportional to the level of fulfillment. 17 | 18 | c. Attractive (Excitement) Features: 19 | - These features are not expected by customers but can lead to high satisfaction if present. 20 | - Their absence does not lead to dissatisfaction. 21 | 22 | d. Indifferent Features: 23 | - These features do not have a significant impact on customer satisfaction, whether present or absent. 24 | 25 | e. Reverse Features: 26 | - These features lead to dissatisfaction when present and satisfaction when absent. 27 | 28 | 3. Prioritize features based on their Kano Model classification and their alignment with business objectives. 29 | 4. Identify potential new features that could serve as Attractive (Excitement) features to delight customers. 30 | 5. Develop a roadmap for implementing and improving features based on their Kano Model prioritization. 31 | 32 | **Expected Output:** A comprehensive Kano Model analysis of the codebase and its associated features, including: 33 | - Classification of each feature into the Kano Model categories (Must-be, One-dimensional, Attractive, Indifferent, Reverse) 34 | - Prioritization of features based on their Kano Model classification and business alignment 35 | - Identification of potential new Attractive (Excitement) features 36 | - Roadmap for feature implementation and improvement based on Kano Model prioritization 37 | -------------------------------------------------------------------------------- /prompt_library/lean_canvas_analysis.md: -------------------------------------------------------------------------------- 1 | # Lean Canvas Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase using the Lean Canvas framework to evaluate its business potential and identify areas for improvement or pivot. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify key features and functionalities. 8 | 9 | 2. For each element of the Lean Canvas, analyze how the codebase contributes: 10 | 11 | a. Problem: 12 | - What user problems does the code address? 13 | - Are there existing alternatives or workarounds? 14 | 15 | b. Solution: 16 | - How does the code solve the identified problems? 17 | - What are the key features that address user needs? 18 | 19 | c. Unique Value Proposition: 20 | - What makes this code unique or innovative? 21 | - How does it differ from existing solutions? 22 | 23 | d. Unfair Advantage: 24 | - Does the code leverage any unique technologies or algorithms? 25 | - Are there any hard-to-replicate aspects of the implementation? 26 | 27 | e. Customer Segments: 28 | - Who are the target users for this code? 29 | - Are there different user groups with distinct needs? 30 | 31 | f. Key Metrics: 32 | - What metrics could be used to measure the success of this code? 33 | - Are there features for tracking user engagement or performance? 34 | 35 | g. Channels: 36 | - How could this code reach its target users? 37 | - Are there built-in distribution or marketing features? 38 | 39 | h. Cost Structure: 40 | - What are the main cost drivers in developing and maintaining this code? 41 | - Are there features aimed at optimizing costs? 42 | 43 | i. Revenue Streams: 44 | - How could this code generate revenue? 45 | - Are there monetization features implemented? 46 | 47 | 3. Identify potential gaps or inconsistencies in the Lean Canvas based on the codebase analysis. 48 | 49 | 4. Suggest improvements or new features that could enhance the overall business model. 50 | 51 | 5. Consider potential pivot opportunities if the current approach doesn't align well with the Lean Canvas analysis. 52 | 53 | **Expected Output:** A comprehensive analysis of the codebase using the Lean Canvas framework, highlighting how the code supports different aspects of a lean business model, identifying areas for improvement, and suggesting potential pivots or new directions for development. -------------------------------------------------------------------------------- /prompt_library/learning_algorithmic_storytelling.md: -------------------------------------------------------------------------------- 1 | # Algorithmic Storytelling 2 | 3 | **Objective:** Generate engaging narratives that explain the logic and flow of key algorithms in the codebase, making them more accessible and memorable for learners. 4 | 5 | **Instructions:** 6 | 1. Identify the most important or complex algorithms in the codebase. 7 | 2. For each algorithm, break down its steps and key decision points. 8 | 3. Create a narrative that personifies the algorithm, using characters, dialogue, and metaphors to represent its logic and flow. 9 | 4. Ensure the story accurately reflects the algorithm's behavior while being engaging and easy to follow. 10 | 5. Provide code snippets to illustrate how the story maps to the actual implementation. 11 | 12 | **Expected Output:** A collection of algorithmic stories that make the codebase's key algorithms more understandable and memorable, along with accompanying code snippets. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_backend_api_documentation.md: -------------------------------------------------------------------------------- 1 | # Backend API Documentation 2 | 3 | **Objective:** Generate documentation for backend APIs, including endpoints, request/response formats, and authentication requirements. 4 | 5 | **Instructions:** 6 | 1. Identify the main backend API endpoints in the codebase. 7 | 2. For each endpoint, document its HTTP method, URL path, and purpose. 8 | 3. Specify the expected request format, including headers, query parameters, and request body (if applicable). 9 | 4. Describe the response format, including the structure of the response data and any relevant status codes. 10 | 5. Detail any authentication or authorization requirements for accessing the endpoint. 11 | 6. Provide clear and concise code examples demonstrating how to interact with the API using popular tools or libraries. 12 | 13 | **Expected Output:** Comprehensive documentation for the backend APIs, including endpoints, request/response formats, authentication requirements, and code examples, ready to be integrated into the project's documentation system. 14 | -------------------------------------------------------------------------------- /prompt_library/learning_backend_code_analysis.md: -------------------------------------------------------------------------------- 1 | # Backend Code Analysis 2 | 3 | **Objective:** Analyze the backend codebase to identify best practices, potential improvements, and common pitfalls. 4 | 5 | **Instructions:** 6 | 1. Review the backend codebase, focusing on the architecture, design patterns, and libraries used. 7 | 2. Identify areas where best practices are followed and highlight them as examples of good code. 8 | 3. Spot potential improvements in code organization, performance, scalability, or maintainability, and provide specific suggestions. 9 | 4. Look for common pitfalls or anti-patterns in the backend code and offer alternative approaches. 10 | 5. Provide code snippets to illustrate your findings and recommendations. 11 | 12 | **Expected Output:** A detailed report on the backend codebase, including best practices, potential improvements, and common pitfalls, along with illustrative code snippets and recommendations. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_code_analogies_metaphors.md: -------------------------------------------------------------------------------- 1 | # Code-Inspired Analogies and Metaphors 2 | 3 | **Objective:** Generate analogies and metaphors inspired by the codebase to help explain complex technical concepts to non-technical stakeholders. 4 | 5 | **Instructions:** 6 | 1. Identify complex technical concepts, architectures, or design patterns in the codebase that may be difficult for non-technical stakeholders to understand. 7 | 2. For each concept, brainstorm analogies or metaphors that map the technical ideas to more familiar, real-world concepts. 8 | 3. Ensure the analogies and metaphors accurately capture the essential aspects of the technical concepts while being easy to grasp and remember. 9 | 4. Provide clear explanations of how the analogies or metaphors relate to the actual code, using snippets or diagrams where appropriate. 10 | 5. Test the effectiveness of the analogies and metaphors by presenting them to non-technical stakeholders and gathering feedback. 11 | 12 | **Expected Output:** A collection of code-inspired analogies and metaphors that can be used to bridge the gap between technical and non-technical understanding of the codebase. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_code_evolution_visualization.md: -------------------------------------------------------------------------------- 1 | # Code Evolution Visualization 2 | 3 | **Objective:** Create visualizations that illustrate how the codebase has evolved over time, highlighting key milestones, refactorings, and architectural changes. 4 | 5 | **Instructions:** 6 | 1. Analyze the version control history of the codebase to identify significant changes and milestones. 7 | 2. Design a timeline visualization that showcases the major events in the codebase's evolution, such as feature additions, refactorings, and architectural shifts. 8 | 3. Use color-coding, annotations, and icons to differentiate between different types of changes and their impact on the codebase. 9 | 4. Provide brief descriptions or links to relevant documentation for each milestone to give context and facilitate further exploration. 10 | 5. Consider creating interactive visualizations that allow users to zoom in on specific time periods or filter changes by type or author. 11 | 12 | **Expected Output:** A set of engaging and informative visualizations that help developers understand the historical context of the codebase and appreciate the work that has gone into its development. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_code_pattern_recognition.md: -------------------------------------------------------------------------------- 1 | # Code Pattern Recognition and Explanation 2 | 3 | **Objective:** Identify and explain design patterns, architectural patterns, and common coding idioms used in the codebase to facilitate understanding and knowledge sharing. 4 | 5 | **Instructions:** 6 | 1. Analyze the codebase to identify instances of design patterns, architectural patterns, and coding idioms. 7 | 2. For each identified pattern or idiom, provide a clear explanation of its purpose, benefits, and trade-offs. 8 | 3. Use code snippets from the codebase to illustrate how the pattern or idiom is implemented in practice. 9 | 4. Discuss how the use of these patterns and idioms contributes to the overall quality, maintainability, and performance of the codebase. 10 | 5. Suggest potential improvements or alternative approaches where applicable. 11 | 12 | **Expected Output:** A comprehensive report documenting the design patterns, architectural patterns, and coding idioms used in the codebase, along with explanations and illustrative code snippets. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_code_refactoring_exercises.md: -------------------------------------------------------------------------------- 1 | # Code Refactoring Exercises 2 | 3 | **Objective:** Generate code refactoring exercises based on the codebase to help engineers improve their refactoring skills. 4 | 5 | **Instructions:** 6 | 1. Identify areas in the codebase that could benefit from refactoring, such as duplicated code, long functions, or complex conditional statements. 7 | 2. For each identified area, create a refactoring exercise that challenges engineers to improve the code's design, readability, and maintainability. 8 | 3. Provide a clear problem statement, including the current code snippet and the desired outcomes of the refactoring exercise. 9 | 4. Include any necessary constraints or guidelines for the refactoring process. 10 | 5. Develop a set of test cases to help engineers validate the correctness of their refactored code. 11 | 12 | **Expected Output:** A collection of code refactoring exercises, each with a problem statement, code snippet, desired outcomes, constraints, and test cases, suitable for use in training or skill development sessions. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_code_review_checklist.md: -------------------------------------------------------------------------------- 1 | # Code Review Checklist Generation 2 | 3 | **Objective:** Generate a checklist of important points to consider during code reviews, based on the codebase's specific requirements and best practices. 4 | 5 | **Instructions:** 6 | 1. Review the codebase and identify the key aspects that should be considered during code reviews, such as code style, performance, security, and maintainability. 7 | 2. Organize the identified aspects into categories to create a structured checklist. 8 | 3. For each category, provide specific questions or points that reviewers should consider when evaluating the code. 9 | 4. Include references to the codebase's specific conventions, guidelines, or best practices, where applicable. 10 | 5. Ensure the checklist is comprehensive yet concise, and can be easily integrated into the team's code review process. 11 | 12 | **Expected Output:** A well-structured, codebase-specific code review checklist that helps reviewers consistently evaluate code quality, adherence to best practices, and potential issues. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_code_style_readability_analysis.md: -------------------------------------------------------------------------------- 1 | # Code Style and Readability Analysis 2 | 3 | **Objective:** Evaluate the codebase's overall style and readability, providing suggestions for improvement. 4 | 5 | **Instructions:** 6 | 1. Review the codebase and assess its adherence to a consistent code style and naming conventions. 7 | 2. Identify areas where the code's readability could be improved, such as through better variable names, comments, or function organization. 8 | 3. Provide specific suggestions for enhancing the code's style and readability, following industry best practices and standards. 9 | 4. Use code snippets to demonstrate your recommendations and show "before" and "after" examples. 10 | 11 | **Expected Output:** A report on the codebase's code style and readability, including specific suggestions for improvement and illustrative code snippets. 12 | -------------------------------------------------------------------------------- /prompt_library/learning_codebase_trivia_game.md: -------------------------------------------------------------------------------- 1 | # Codebase Trivia Game Generation 2 | 3 | **Objective:** Generate trivia questions and answers based on the codebase to gamify learning and encourage team engagement. 4 | 5 | **Instructions:** 6 | 1. Analyze the codebase to identify interesting facts, quirks, and historical details that could serve as the basis for trivia questions. 7 | 2. Create a diverse set of multiple-choice questions covering various aspects of the codebase, such as its architecture, design patterns, performance optimizations, and notable bug fixes. 8 | 3. Ensure the questions are challenging but not overly obscure, striking a balance between testing knowledge and promoting learning. 9 | 4. Provide clear and concise explanations for each answer to reinforce understanding and share knowledge. 10 | 5. Organize the questions into categories or difficulty levels to cater to different levels of expertise. 11 | 12 | **Expected Output:** A collection of codebase-specific trivia questions and answers that can be used to create engaging learning games for the development team. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_frontend_code_analysis.md: -------------------------------------------------------------------------------- 1 | # Frontend Code Analysis 2 | 3 | **Objective:** Analyze the frontend codebase to identify best practices, potential improvements, and common pitfalls. 4 | 5 | **Instructions:** 6 | 1. Review the frontend codebase, focusing on the structure, design patterns, and libraries used. 7 | 2. Identify areas where best practices are followed and highlight them as examples of good code. 8 | 3. Spot potential improvements in code organization, performance, or maintainability, and provide specific suggestions. 9 | 4. Look for common pitfalls or anti-patterns in the frontend code and offer alternative approaches. 10 | 5. Provide code snippets to illustrate your findings and recommendations. 11 | 12 | **Expected Output:** A detailed report on the frontend codebase, including best practices, potential improvements, and common pitfalls, along with illustrative code snippets and recommendations. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_frontend_component_documentation.md: -------------------------------------------------------------------------------- 1 | # Frontend Component Documentation 2 | 3 | **Objective:** Generate documentation for frontend components, including props, usage examples, and best practices. 4 | 5 | **Instructions:** 6 | 1. Identify the main frontend components in the codebase. 7 | 2. For each component, document its purpose, props (including their types and default values), and any relevant usage notes. 8 | 3. Provide clear and concise code examples demonstrating how to use the component in various scenarios. 9 | 4. Include best practices and tips for effectively utilizing and customizing the component. 10 | 5. Ensure the documentation is well-organized, easy to navigate, and follows a consistent format. 11 | 12 | **Expected Output:** Comprehensive documentation for the frontend components, including props, usage examples, and best practices, ready to be integrated into the project's documentation system. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_mini_lesson_generation.md: -------------------------------------------------------------------------------- 1 | # Code-Based Mini-Lesson Generation 2 | 3 | **Objective:** Create a comprehensive series of mini-lessons that explain the key concepts implemented within the provided codebase, suitable for developers of varying skill levels. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze and categorize the codebase:** 8 | * Identify major components (e.g., frontend, backend, data processing) 9 | * List key technologies and frameworks used 10 | 11 | 2. **Structure the mini-lessons:** 12 | * Create a lesson plan with 5-10 lessons 13 | * Ensure a logical progression from basic to advanced concepts 14 | * Aim for lessons that can be completed in 15-30 minutes each 15 | 16 | 3. **For each mini-lesson:** 17 | * **Title:** Provide a clear, concise title 18 | * **Learning Objectives:** List 2-3 specific learning outcomes 19 | * **Introduction:** Brief overview of the concept (2-3 sentences) 20 | * **Main Content:** 21 | - Explain the concept in detail 22 | - Use code examples from the application (minimum 2 per lesson) 23 | - Highlight best practices and potential pitfalls 24 | * **Hands-on Exercise:** Design a practical task related to the lesson 25 | * **Quiz:** Include 3-5 multiple-choice questions to test understanding 26 | * **Additional Resources:** Provide links to relevant documentation or articles 27 | 28 | 4. **Incorporate real-world context:** 29 | * Explain how each concept fits into the overall application architecture 30 | * Discuss practical applications beyond the current codebase 31 | 32 | 5. **Ensure accessibility and engagement:** 33 | * Use clear, jargon-free language (or explain technical terms) 34 | * Include diagrams or flowcharts where appropriate 35 | * Suggest points for class discussion or peer programming exercises 36 | 37 | **Expected Output:** 38 | 39 | 1. **Lesson Plan Overview:** 40 | * List of lessons with titles and brief descriptions 41 | * Estimated time for each lesson 42 | 43 | 2. **Individual Lessons:** 44 | * Structured as per the instructions above 45 | * Clearly formatted for easy reading (use markdown for code snippets) 46 | 47 | 3. **Supplementary Materials:** 48 | * Any additional diagrams, cheat sheets, or reference guides 49 | * Suggestions for further learning or advanced topics 50 | 51 | 4. **Instructor Notes:** 52 | * Tips for effectively delivering each lesson 53 | * Potential areas where students might struggle and how to address them 54 | 55 | **Additional Guidelines:** 56 | 57 | * Tailor explanations to an audience with basic programming knowledge but potentially unfamiliar with specific technologies used 58 | * Encourage critical thinking and problem-solving rather than rote memorization 59 | * Where possible, highlight connections between different parts of the codebase 60 | * Consider including optional 'deep dive' sections for more advanced learners 61 | 62 | **Deliverable Format:** Provide the lesson plan and all lessons in a single markdown document, with clear section dividers and a table of contents. -------------------------------------------------------------------------------- /prompt_library/learning_personal_development_recommendations.md: -------------------------------------------------------------------------------- 1 | # Personal Development Recommendations 2 | 3 | **Objective:** Analyze the codebase and provide personalized recommendations for areas where the engineer can improve their skills. 4 | 5 | **Instructions:** 6 | 1. Review the codebase and identify areas where the engineer's work is present. 7 | 2. Assess the engineer's code contributions in terms of design, implementation, and best practices. 8 | 3. Identify areas where the engineer excels and areas where there is room for improvement. 9 | 4. Provide specific, actionable recommendations for how the engineer can enhance their skills in the identified areas. 10 | 5. Suggest relevant resources, such as tutorials, books, or courses, that can support the engineer's learning journey. 11 | 12 | **Expected Output:** A personalized report for the engineer, outlining their strengths and areas for improvement, along with specific recommendations and resources for skill development. 13 | -------------------------------------------------------------------------------- /prompt_library/learning_socratic_dialogue_code_review.md: -------------------------------------------------------------------------------- 1 | # Socratic Dialogue Generation for Code Review 2 | 3 | **Objective:** Generate Socratic-style dialogues that explore the reasoning behind code design decisions and encourage critical thinking during code reviews. 4 | 5 | **Instructions:** 6 | 1. Select a code snippet or module that has recently undergone a code review. 7 | 2. Generate a dialogue between two fictional characters: a curious developer and an experienced mentor. 8 | 3. Have the curious developer ask probing questions about the code's design, performance, readability, and maintainability. 9 | 4. Let the experienced mentor provide thoughtful responses that explain the rationale behind the code's design and implementation. 10 | 5. Encourage the characters to explore alternative approaches and discuss their pros and cons. 11 | 6. Ensure the dialogue remains respectful, constructive, and focused on learning and improvement. 12 | 13 | **Expected Output:** A series of Socratic dialogues that stimulate critical thinking and encourage developers to reflect on code design decisions during the code review process. 14 | -------------------------------------------------------------------------------- /prompt_library/learning_user_story_reconstruction.md: -------------------------------------------------------------------------------- 1 | # Revised Prompt: Structured User Story Analysis for Software Development 2 | 3 | ## Objective 4 | Reconstruct and structure the user stories that likely served as the basis for the development of the provided codebase, and identify potential enhancements. 5 | 6 | ## Instructions 7 | 8 | 1. Analyze the attached code to identify the core functionalities of the application. 9 | 2. Infer the user needs that each functionality aims to address. 10 | 3. Categorize the functionalities into key areas (e.g., Core Features, User Interface, Data Processing, etc.). 11 | 4. For each category, formulate user stories using the following enhanced template: 12 | ``` 13 | User Role: [Specific role or type of user] 14 | Need: [What the user wants to accomplish] 15 | Functionality: [The feature or capability that addresses the need] 16 | Benefit: [The value or advantage gained by the user] 17 | ``` 18 | 5. Identify potential missing user stories, categorizing them similarly. 19 | 6. Suggest functionalities that could be added to the application to better meet user needs. 20 | 21 | ## Expected Output 22 | 23 | 1. **Reconstructed User Stories** 24 | * Organized by categories (e.g., Core Features, User Interface, etc.) 25 | * Each category should contain: 26 | - A brief description of the category 27 | - A numbered list of user stories in the enhanced template format 28 | 29 | 2. **Potential Missing User Stories** 30 | * Organized by categories (similar to reconstructed stories) 31 | * Each category should contain: 32 | - A brief description of why these stories might be valuable 33 | - A numbered list of potential user stories in the enhanced template format 34 | 35 | 3. **Enhancement Suggestions** 36 | * A brief overview of key areas for potential improvement 37 | * A prioritized list of suggested new functionalities or features, with a brief rationale for each 38 | 39 | ## Additional Guidelines 40 | 41 | * Aim for clarity and specificity in user roles and needs. 42 | * Ensure that each user story is distinct and non-redundant. 43 | * Consider various stakeholders (e.g., end-users, administrators, developers) when formulating stories. 44 | * For missing stories and enhancements, focus on additions that would significantly improve the application's value or usability. -------------------------------------------------------------------------------- /prompt_library/mckinsey_7s_analysis.md: -------------------------------------------------------------------------------- 1 | # McKinsey 7S Framework Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase and its associated product using the McKinsey 7S Framework to evaluate the internal factors that contribute to organizational effectiveness and identify areas for improvement. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key features and functionalities it provides. 8 | 2. Analyze each of the seven elements of the McKinsey 7S Framework in relation to the codebase and its product: 9 | 10 | a. Strategy: 11 | - What is the overall strategy and objectives for the product? 12 | - How does the codebase support and align with this strategy? 13 | 14 | b. Structure: 15 | - How is the team or organization responsible for the codebase structured? 16 | - Does the structure support effective development, maintenance, and growth of the product? 17 | 18 | c. Systems: 19 | - What processes, tools, and technologies are used in the development and management of the codebase? 20 | - Are these systems efficient, reliable, and scalable? 21 | 22 | d. Shared Values: 23 | - What are the core values, culture, and ethical standards that guide the team or organization responsible for the codebase? 24 | - How are these values reflected in the codebase and the product? 25 | 26 | e. Style: 27 | - What is the leadership and management style within the team or organization responsible for the codebase? 28 | - How does this style impact the development and success of the product? 29 | 30 | f. Staff: 31 | - What are the skills, capabilities, and experience of the team members working on the codebase? 32 | - Are there any gaps or areas for improvement in the team's expertise? 33 | 34 | g. Skills: 35 | - What are the key technical and non-technical skills required for the successful development and maintenance of the codebase? 36 | - How are these skills developed and maintained within the team? 37 | 38 | 3. Evaluate the alignment and consistency among the seven elements of the framework. 39 | 4. Identify areas of strength and weakness based on the analysis. 40 | 5. Develop recommendations for improving the internal factors to enhance the effectiveness of the team and the success of the product. 41 | 42 | **Expected Output:** A comprehensive McKinsey 7S Framework analysis of the codebase and its associated product, including: 43 | - Analysis of each of the seven elements and their impact on the product 44 | - Evaluation of the alignment and consistency among the elements 45 | - Identification of areas of strength and weakness 46 | - Recommendations for improving internal factors to enhance team effectiveness and product success 47 | -------------------------------------------------------------------------------- /prompt_library/okr_analysis.md: -------------------------------------------------------------------------------- 1 | # OKR (Objectives and Key Results) Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase to align its features and capabilities with potential business Objectives and Key Results (OKRs). 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify key features, functionalities, and architectural decisions. 8 | 9 | 2. Based on the codebase analysis, infer potential high-level business objectives that the code might support. For each objective: 10 | a. Formulate a clear, ambitious yet achievable objective statement. 11 | b. Identify 3-5 key results that would indicate progress towards this objective. 12 | c. Explain how specific aspects of the code contribute to these key results. 13 | 14 | 3. Consider the following categories of objectives: 15 | - User Acquisition and Growth 16 | - User Engagement and Retention 17 | - Revenue Generation 18 | - Operational Efficiency 19 | - Product Innovation 20 | - Market Expansion 21 | 22 | 4. For each set of OKRs: 23 | a. Evaluate how well the current codebase supports achieving the key results. 24 | b. Identify any gaps or limitations in the code that might hinder achieving the OKRs. 25 | c. Suggest potential code improvements or new features that could better support the OKRs. 26 | 27 | 5. Analyze the overall alignment of the codebase with the inferred OKRs: 28 | - Are there features that don't clearly contribute to any of the key results? 29 | - Are there important OKRs that lack sufficient support in the current codebase? 30 | 31 | 6. Propose a prioritized list of development initiatives that would improve the codebase's alignment with the most critical OKRs. 32 | 33 | **Expected Output:** A comprehensive analysis of how the codebase aligns with potential business OKRs, including: 34 | - A set of inferred Objectives and Key Results based on the codebase capabilities 35 | - An evaluation of how well the code supports each OKR 36 | - Identified gaps and limitations in the current implementation 37 | - Prioritized suggestions for code improvements or new features to better support critical OKRs 38 | 39 | This analysis should provide insights into how the technical implementation aligns with potential business goals and guide future development priorities. -------------------------------------------------------------------------------- /prompt_library/performance_bottleneck_identification.md: -------------------------------------------------------------------------------- 1 | #### Identify Performance Bottlenecks 2 | 3 | **Objective:** Analyze the codebase to pinpoint specific areas that negatively impact performance, such as inefficient algorithms, excessive database queries, or slow network requests. 4 | 5 | **Instructions:** 6 | 7 | 1. **Profile the codebase:** Use profiling tools to identify functions or code blocks with high execution time, excessive function calls, or significant resource consumption. 8 | 2. **Analyze algorithms:** Review algorithms for complexity and efficiency. Look for opportunities to use more optimal algorithms or data structures. 9 | 3. **Inspect database interactions:** 10 | - Identify queries that are executed frequently or take a long time to complete. 11 | - Analyze query plans to identify inefficient joins, missing indexes, or other database-related bottlenecks. 12 | 4. **Examine network communication:** 13 | - Analyze network requests to identify slow responses, excessive data transfer, or unnecessary round trips. 14 | - Look for opportunities to implement caching or optimize network communication patterns. 15 | 5. **Prioritize based on impact:** Categorize identified bottlenecks based on their potential impact on overall system performance. 16 | 17 | **Expected Output:** A prioritized list of performance bottlenecks with clear explanations of: 18 | 19 | - The specific code, query, or network operation causing the bottleneck. 20 | - The estimated impact on performance. 21 | - Potential solutions or optimization strategies. -------------------------------------------------------------------------------- /prompt_library/performance_code_optimization_suggestions.md: -------------------------------------------------------------------------------- 1 | #### Suggest Code Optimization Techniques 2 | 3 | **Objective:** Provide specific and actionable code optimization suggestions to address identified performance bottlenecks. 4 | 5 | **Instructions:** 6 | 7 | 1. **Review the analysis of performance bottlenecks:** Understand the nature of the bottlenecks (e.g., inefficient algorithms, slow database queries). 8 | 2. **Suggest targeted optimizations:** Based on the type of bottleneck: 9 | - **Algorithms and Data Structures:** 10 | - Recommend more efficient algorithms or data structures (e.g., using a hash table instead of linear search). 11 | - Suggest techniques like memoization or dynamic programming to avoid redundant computations. 12 | - **Database Optimization:** 13 | - Recommend optimizing database queries by adding indexes, rewriting inefficient joins, or using more efficient SQL constructs. 14 | - Suggest caching frequently accessed data to reduce database load. 15 | - **Network Communication:** 16 | - Recommend techniques like data compression or reducing the size of data payloads. 17 | - Suggest using asynchronous requests or persistent connections to minimize network latency. 18 | 3. **Prioritize suggestions:** Rank suggested optimizations based on their potential impact on performance and the effort required to implement them. 19 | 20 | **Expected Output:** A prioritized list of code optimization recommendations, each including: 21 | 22 | - A clear description of the optimization technique. 23 | - The specific code area where the optimization should be applied. 24 | - The expected performance benefit or gain. 25 | - The estimated effort or complexity of implementing the suggestion. -------------------------------------------------------------------------------- /prompt_library/performance_concurrency_synchronization_analysis.md: -------------------------------------------------------------------------------- 1 | #### Concurrency and Synchronization Analysis 2 | 3 | **Objective:** Analyze the codebase to identify potential issues related to concurrency, such as race conditions or deadlocks, and suggest solutions to improve thread safety and synchronization mechanisms. 4 | 5 | **Instructions:** 6 | 7 | 1. **Identify concurrent code:** Locate code sections that are executed by multiple threads or processes concurrently, especially those accessing shared resources. 8 | 2. **Check for race conditions:** Analyze code for potential scenarios where multiple threads access and modify shared data simultaneously, leading to unpredictable or incorrect results. 9 | 3. **Detect potential deadlocks:** Identify situations where two or more threads are blocked indefinitely, each waiting for the other to release the resources it needs. 10 | 4. **Review synchronization mechanisms:** 11 | - Analyze the use of locks, mutexes, semaphores, or other synchronization primitives for correctness and efficiency. 12 | - Look for potential issues like: 13 | - Deadlocks caused by incorrect locking order. 14 | - Performance bottlenecks due to excessive locking or contention. 15 | 5. **Suggest improvements:** Provide recommendations to fix or prevent concurrency issues: 16 | - Use appropriate synchronization mechanisms to protect shared resources. 17 | - Ensure correct locking order to avoid deadlocks. 18 | - Consider lock-free data structures or algorithms where applicable to minimize contention. 19 | - Implement strategies for efficient thread management and communication. 20 | 21 | **Expected Output:** A detailed report that: 22 | 23 | - Identifies potential concurrency issues in the codebase. 24 | - Explains the nature of each issue (race condition, deadlock, etc.) and its potential impact. 25 | - Suggests code-level solutions, refactoring recommendations, or design pattern implementations to enhance thread safety and prevent concurrency problems. 26 | -------------------------------------------------------------------------------- /prompt_library/performance_configuration_tuning.md: -------------------------------------------------------------------------------- 1 | **Objective:** Provide recommendations for optimal configuration settings of databases, application servers, or other infrastructure components to enhance performance. 2 | 3 | **Instructions:** 4 | 5 | 1. **Gather system information:** Identify the specific software versions and hardware specifications of the infrastructure components (database, application server, etc.). 6 | 2. **Understand performance goals:** Consider the desired performance targets for response times, throughput, or resource utilization. 7 | 3. **Research configuration parameters:** Refer to the documentation of each infrastructure component to understand the available configuration parameters and their impact on performance. 8 | 4. **Suggest optimized settings:** Based on best practices and the specific system context, recommend optimal values for key configuration parameters, such as: 9 | - **Database:** Connection pool size, buffer cache size, query cache size, indexing settings. 10 | - **Application Server:** Thread pool size, JVM heap size, garbage collection settings, session timeout. 11 | - **Web Server:** Keep-alive settings, caching configuration, number of worker processes. 12 | 5. **Explain the rationale:** Provide clear justifications for the recommended settings, explaining how they are expected to improve performance. 13 | 14 | **Expected Output:** A configuration tuning guide that includes: 15 | 16 | - A list of key configuration parameters for each relevant infrastructure component. 17 | - Recommended optimal values for those parameters. 18 | - Clear explanations of the rationale behind each suggestion and its potential impact on performance. 19 | - Cautions or considerations for applying the configuration changes (e.g., potential impact on other aspects of the system). 20 | 21 | -------------------------------------------------------------------------------- /prompt_library/performance_resource_usage_profiling.md: -------------------------------------------------------------------------------- 1 | #### Resource Usage Profiling 2 | 3 | **Objective:** Analyze the codebase to identify areas that excessively consume resources like CPU, memory, or disk I/O. Provide insights to guide optimization efforts for more efficient resource utilization. 4 | 5 | **Instructions:** 6 | 7 | 1. **Use profiling tools:** Employ resource profiling tools to monitor and analyze CPU usage, memory allocation, and disk I/O during application execution. 8 | 2. **Identify resource-intensive operations:** Pinpoint code blocks, functions, or processes that contribute most significantly to high CPU load, excessive memory consumption, or frequent disk accesses. 9 | 3. **Analyze memory management:** 10 | - Look for memory leaks, where objects are not properly released after they are no longer needed. 11 | - Investigate areas with high object creation rates or large object sizes. 12 | 4. **Examine I/O operations:** 13 | - Identify areas with frequent file system reads or writes. 14 | - Analyze if data can be cached or if I/O operations can be batched for better performance. 15 | 5. **Correlate resource usage with code:** Connect the identified resource-intensive areas back to specific code segments, functions, or modules to guide optimization efforts. 16 | 17 | **Expected Output:** A comprehensive report detailing: 18 | 19 | - Code areas with high CPU usage, including call graphs and execution times. 20 | - Memory allocation hotspots, including object sizes, allocation frequencies, and potential leaks. 21 | - Disk I/O intensive operations and recommendations for reducing or optimizing them. 22 | - Overall insights into the codebase's resource consumption patterns and areas for potential improvement. 23 | 24 | -------------------------------------------------------------------------------- /prompt_library/performance_scalability_analysis.md: -------------------------------------------------------------------------------- 1 | #### Scalability Analysis 2 | 3 | **Objective:** Assess the codebase's ability to handle increasing loads and identify potential limitations that might hinder scalability, suggesting improvements to enhance scalability. 4 | 5 | **Instructions:** 6 | 7 | 1. **Understand the current architecture:** Analyze the codebase's architecture to determine its components, their interactions, and data flow. 8 | 2. **Identify scaling bottlenecks:** Look for potential scaling limits in areas like: 9 | - Database: Analyze query performance under load, database connection pooling, and potential for sharding or replication. 10 | - Application Servers: Assess the capacity to handle concurrent requests, session management, and load balancing capabilities. 11 | - Network: Evaluate network bandwidth, latency, and capacity to manage increased traffic. 12 | - Caching: Determine if caching mechanisms are in place and if they can be optimized for scalability. 13 | 3. **Consider different scaling strategies:** Evaluate the suitability of: 14 | - Vertical scaling (upgrading hardware) 15 | - Horizontal scaling (adding more instances) 16 | 4. **Suggest architectural improvements:** Recommend changes to the codebase or infrastructure to address scalability limitations: 17 | - Introduce asynchronous processing or queuing mechanisms. 18 | - Optimize database interactions for concurrency. 19 | - Implement distributed caching solutions. 20 | - Consider microservices architecture for independent scaling of components. 21 | 22 | **Expected Output:** A detailed report covering: 23 | 24 | - An assessment of the codebase's current scalability. 25 | - Identification of potential bottlenecks and their impact. 26 | - Specific recommendations for architectural changes, code optimization, or infrastructure adjustments to improve scalability. 27 | -------------------------------------------------------------------------------- /prompt_library/performance_test_scenario_generation.md: -------------------------------------------------------------------------------- 1 | **Objective:** Create realistic performance test scenarios that can be used to simulate high load conditions and identify potential bottlenecks in the codebase. 2 | 3 | **Instructions:** 4 | 5 | 1. **Consider realistic user behavior:** Analyze typical user workflows and interactions with the system. 6 | 2. **Identify critical user flows:** Focus on simulating user actions that are most likely to stress the system under high load, such as: 7 | - User login/authentication 8 | - Searching for products or content 9 | - Adding items to a shopping cart 10 | - Placing orders 11 | 3. **Determine user load and distribution:** 12 | - Estimate the expected number of concurrent users during peak hours. 13 | - Define the geographic distribution of users, if relevant. 14 | 4. **Specify performance metrics:** Clearly define the key performance indicators (KPIs) to be measured during the tests, such as: 15 | - Response time 16 | - Throughput (transactions per second) 17 | - Error rate 18 | - Resource utilization (CPU, memory, network) 19 | 5. **Use a performance testing tool:** Structure the test scenarios in a format compatible with a performance testing tool like JMeter, Gatling, or Locust. 20 | 21 | **Expected Output:** A set of performance test scenarios, defined in a suitable format for a chosen testing tool, that: 22 | 23 | - Realistically simulate user behavior and load patterns. 24 | - Target critical user flows to stress the system under high load. 25 | - Include clear performance metrics and thresholds for evaluating system performance. 26 | -------------------------------------------------------------------------------- /prompt_library/pestel_analysis.md: -------------------------------------------------------------------------------- 1 | # PESTEL Analysis for Codebase 2 | 3 | **Objective:** Analyze the macro-environmental factors that may impact the codebase and its associated product using the PESTEL framework. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key features and functionalities it provides. 8 | 2. Analyze each of the PESTEL factors in relation to the codebase and its product: 9 | 10 | a. Political Factors: 11 | - Are there any government policies, regulations, or political stability issues that could impact the product? 12 | - Are there any upcoming changes in the political landscape that could affect the product? 13 | 14 | b. Economic Factors: 15 | - How do economic conditions (e.g., economic growth, inflation, exchange rates) affect the demand for the product? 16 | - Are there any economic trends or cycles that could impact the product's success? 17 | 18 | c. Social Factors: 19 | - What are the demographic trends, cultural attitudes, and lifestyle changes that could influence the adoption of the product? 20 | - Are there any social movements or shifts in consumer behavior that could impact the product? 21 | 22 | d. Technological Factors: 23 | - What are the technological advancements or disruptions that could affect the product or its market? 24 | - Are there any emerging technologies that could be leveraged to improve the product or create new opportunities? 25 | 26 | e. Environmental Factors: 27 | - Are there any environmental concerns, regulations, or trends that could impact the product or its perception? 28 | 29 | f. Legal Factors: 30 | - What are the relevant laws, regulations, and legal requirements that the product must comply with? 31 | - Are there any upcoming legal changes or potential legal risks that could affect the product? 32 | 33 | 3. Identify the key opportunities and threats for the codebase and its product based on the PESTEL analysis. 34 | 4. Develop strategies for leveraging opportunities and mitigating threats identified in the analysis. 35 | 5. Incorporate the insights from the PESTEL analysis into the product's development, marketing, and strategic planning. 36 | 37 | **Expected Output:** A comprehensive PESTEL analysis of the codebase and its associated product, including: 38 | - Analysis of each PESTEL factor and its potential impact on the product 39 | - Identification of key opportunities and threats based on the analysis 40 | - Strategies for leveraging opportunities and mitigating threats 41 | - Recommendations for incorporating PESTEL insights into product development, marketing, and strategic planning 42 | -------------------------------------------------------------------------------- /prompt_library/porters_five_forces_analysis.md: -------------------------------------------------------------------------------- 1 | # Porter's Five Forces Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase and its market environment using Porter's Five Forces framework to understand the competitive forces shaping the industry. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key features and functionalities it provides. 8 | 2. Analyze each of Porter's Five Forces in relation to the codebase: 9 | 10 | a. Threat of New Entrants: 11 | - How easy is it for new competitors to enter the market? 12 | - Are there significant barriers to entry (e.g., proprietary technology, high investment costs)? 13 | 14 | b. Bargaining Power of Suppliers: 15 | - How much bargaining power do suppliers (e.g., technology providers, data vendors) have? 16 | - Are there many suppliers or just a few dominant ones? 17 | 18 | c. Bargaining Power of Buyers: 19 | - How much bargaining power do customers have? 20 | - Are there many buyers or just a few large ones? 21 | - How easy is it for buyers to switch to alternative solutions? 22 | 23 | d. Threat of Substitute Products or Services: 24 | - Are there substitute products or services that could replace the codebase's functionality? 25 | - How likely are customers to switch to these substitutes? 26 | 27 | e. Rivalry Among Existing Competitors: 28 | - How intense is the competition among existing players in the market? 29 | - Are there many competitors or just a few dominant ones? 30 | - How do competitors differentiate themselves? 31 | 32 | 3. Identify the overall competitive intensity in the industry based on the analysis of the five forces. 33 | 4. Determine the codebase's competitive position and potential strategies for success within this competitive landscape. 34 | 35 | **Expected Output:** A comprehensive Porter's Five Forces analysis of the codebase and its market environment, including: 36 | - Assessment of each of the five forces and their impact on the codebase 37 | - Identification of the overall competitive intensity in the industry 38 | - Evaluation of the codebase's competitive position and potential strategies for success 39 | -------------------------------------------------------------------------------- /prompt_library/product_market_fit_analysis.md: -------------------------------------------------------------------------------- 1 | # Product/Market Fit Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase and its associated product to evaluate how well it meets the needs of its target market and identify opportunities for improving product/market fit. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key features and functionalities it provides. 8 | 2. Define the target market for the product: 9 | - Who are the ideal customers? 10 | - What are their characteristics, needs, and pain points? 11 | 3. Analyze how well the product addresses the needs of the target market: 12 | - Does the product solve a real problem for the target customers? 13 | - How well do the product's features and functionalities meet customer needs? 14 | - Is the product easy to use and understand for the target customers? 15 | 4. Evaluate the product's unique value proposition: 16 | - How does the product differentiate itself from competitors? 17 | - Does the product offer compelling benefits that are difficult for competitors to replicate? 18 | 5. Assess customer feedback and engagement: 19 | - What do customers say about the product in reviews, surveys, or other feedback channels? 20 | - Are customers actively using and engaging with the product? 21 | - Are there any common complaints or feature requests from customers? 22 | 6. Identify opportunities for improving product/market fit: 23 | - What changes could be made to the product to better meet customer needs? 24 | - Are there any unmet needs or underserved segments within the target market? 25 | - How could the product's value proposition be strengthened or clarified? 26 | 7. Develop a plan for iterating and improving the product based on the product/market fit analysis. 27 | 28 | **Expected Output:** A comprehensive Product/Market Fit analysis of the codebase and its associated product, including: 29 | - Definition of the target market and customer needs 30 | - Evaluation of how well the product meets customer needs and differentiates itself 31 | - Assessment of customer feedback and engagement 32 | - Identification of opportunities for improving product/market fit 33 | - Plan for iterating and improving the product based on the analysis 34 | -------------------------------------------------------------------------------- /prompt_library/quality_code_complexity_analysis.md: -------------------------------------------------------------------------------- 1 | # Code Complexity Analysis 2 | 3 | **Objective:** Analyze the codebase to identify areas with high cyclomatic complexity, deep nesting, or excessive method lengths, providing insights into potential readability and maintainability issues. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify areas with: 8 | - High cyclomatic complexity 9 | - Deep nesting 10 | - Excessive method lengths 11 | 12 | 2. For each identified issue, analyze: 13 | a. Location: 14 | - File path 15 | - Line number(s) 16 | 17 | b. Description: 18 | - Brief explanation of the complexity issue 19 | 20 | c. Impact: 21 | - Potential effects on code readability 22 | - Potential effects on code maintainability 23 | 24 | d. Refactoring Suggestions: 25 | - Propose methods to simplify or restructure the code 26 | - Suggest alternative approaches to reduce complexity 27 | 28 | 3. If no significant issues are found, provide a summary stating that the codebase has acceptable complexity levels. 29 | 30 | 4. Consider the overall complexity trends in the codebase: 31 | - Are there specific areas or modules that consistently show higher complexity? 32 | - Are there patterns in the types of complexity issues encountered? 33 | 34 | 5. Suggest general best practices or coding standards that could help prevent future complexity issues. 35 | 36 | **Expected Output:** A comprehensive analysis of the codebase's complexity, detailing specific issues found, their impact, and suggestions for improvement. The report should include: 37 | 38 | 1. An overview of the complexity analysis findings 39 | 2. Detailed breakdowns of each identified issue 40 | 3. General recommendations for maintaining code simplicity 41 | 4. If applicable, a summary of complexity trends or patterns observed in the codebase 42 | 43 | For each identified issue, use the following format: 44 | 45 | File: [file path] 46 | Line(s): [line number(s)] 47 | Issue: [brief description] 48 | Impact: [potential impact on readability and maintainability] 49 | Suggestions: 50 | - [refactoring suggestion 1] 51 | - [refactoring suggestion 2] -------------------------------------------------------------------------------- /prompt_library/quality_code_documentation_coverage_analysis.md: -------------------------------------------------------------------------------- 1 | # Code Documentation Coverage Analysis 2 | 3 | **Objective:** Analyze the codebase to determine the coverage and quality of code documentation, identifying areas lacking documentation or with insufficient explanations. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and assess the documentation coverage and quality. 8 | 9 | 2. For each file or module, analyze: 10 | 11 | a. Documentation Coverage: 12 | - Percentage of documented code elements (classes, functions, methods) 13 | - Identification of undocumented or poorly documented areas 14 | 15 | b. Documentation Quality: 16 | - Completeness of explanations 17 | - Clarity and readability of documentation 18 | - Consistency in documentation style 19 | 20 | c. Code Elements: 21 | - Classes: presence and quality of class-level documentation 22 | - Methods/Functions: presence and quality of method-level documentation 23 | - Variables: presence and quality of variable descriptions, especially for complex or non-obvious variables 24 | 25 | d. Special Documentation: 26 | - Presence and quality of module-level documentation 27 | - Inline comments for complex algorithms or logic 28 | - Usage examples or code snippets where applicable 29 | 30 | 3. Identify patterns or trends in documentation practices across the codebase. 31 | 32 | 4. Assess the overall documentation strategy and its effectiveness. 33 | 34 | 5. Suggest improvements for documentation coverage and quality, considering: 35 | - Priority areas based on code complexity and importance 36 | - Standardization of documentation practices 37 | - Tools or processes to enhance documentation efforts 38 | 39 | **Expected Output:** A comprehensive analysis of the codebase's documentation coverage and quality, including: 40 | 41 | 1. An overview of the documentation analysis findings 42 | 2. Detailed breakdowns for each file or module 43 | 3. General recommendations for improving documentation practices 44 | 4. If applicable, a summary of documentation trends or patterns observed in the codebase 45 | 46 | For each file or module, use the following format: 47 | 48 | File: [file path] 49 | Documentation Coverage: [percentage of documented code elements]% 50 | Quality Assessment: [brief assessment of documentation quality] 51 | Suggestions: 52 | - [improvement suggestion 1] 53 | - [improvement suggestion 2] 54 | - ... 55 | 56 | Conclude with an overall summary of the documentation coverage and quality across the entire codebase, including recommendations for prioritizing documentation efforts based on the importance and complexity of the code. 57 | -------------------------------------------------------------------------------- /prompt_library/quality_code_duplication_analysis.md: -------------------------------------------------------------------------------- 1 | # Code Duplication Analysis 2 | 3 | **Objective:** Analyze the codebase to identify duplicated code fragments, providing insights into potential maintainability issues and suggesting refactoring opportunities. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify instances of duplicated code. 8 | 9 | 2. For each identified duplication, analyze: 10 | 11 | a. Location: 12 | - File paths of affected files 13 | - Line numbers in each file 14 | 15 | b. Duplication Details: 16 | - Length of the duplicated code fragment (in lines of code) 17 | - Content or purpose of the duplicated code 18 | 19 | c. Impact Assessment: 20 | - Potential impact on code maintainability 21 | - Risks associated with the duplication (e.g., inconsistent updates) 22 | 23 | d. Refactoring Opportunities: 24 | - Suggestions for extracting duplicated code into reusable functions or classes 25 | - Potential design patterns or architectural changes to eliminate duplication 26 | 27 | 3. Identify patterns or trends in code duplication across the codebase. 28 | 29 | 4. Assess the overall impact of code duplication on the project's maintainability and scalability. 30 | 31 | 5. Suggest improvements to reduce code duplication, considering: 32 | - Priority areas based on the extent and impact of duplication 33 | - Refactoring strategies that align with the project's architecture 34 | - Tools or processes to prevent future code duplication 35 | 36 | **Expected Output:** A comprehensive analysis of the codebase's code duplication, including: 37 | 38 | 1. An overview of the duplication analysis findings 39 | 2. Detailed breakdowns for each identified duplication 40 | 3. General recommendations for reducing and preventing code duplication 41 | 4. If applicable, a summary of duplication trends or patterns observed in the codebase 42 | 43 | For each identified duplication, use the following format: 44 | 45 | Files: 46 | - [file path 1] 47 | - [file path 2] 48 | Line(s): 49 | - [file 1 line numbers] 50 | - [file 2 line numbers] 51 | Length: [number of duplicated lines] 52 | Impact: [potential impact on maintainability] 53 | Suggestions: 54 | - [refactoring suggestion 1] 55 | - [refactoring suggestion 2] 56 | - ... 57 | 58 | If no significant duplications are found, provide a summary stating that the codebase has minimal code duplication. 59 | 60 | Conclude with an overall assessment of the code duplication in the project, including recommendations for addressing the most critical instances and strategies for maintaining a DRY (Don't Repeat Yourself) codebase. -------------------------------------------------------------------------------- /prompt_library/quality_code_style_consistency_analysis.md: -------------------------------------------------------------------------------- 1 | # Code Style Consistency Analysis 2 | 3 | **Objective:** Conduct a thorough analysis of the codebase to evaluate consistency in code style, naming conventions, and formatting, identifying deviations from the project's style guide or industry best practices, and providing actionable recommendations for improvement. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the entire codebase, focusing on: 8 | - Naming conventions (variables, functions, classes, modules) 9 | - Code formatting (indentation, line length, whitespace usage) 10 | - Comment style and frequency 11 | - File organization and structure 12 | - Language-specific idioms and best practices 13 | 14 | 2. For each identified inconsistency or style issue, analyze: 15 | 16 | a. Location: 17 | - File path 18 | - Line number(s) or range 19 | 20 | b. Issue Details: 21 | - Type of inconsistency (e.g., naming, formatting, structure) 22 | - Description of the deviation from expected style 23 | - Comparison with the correct style (if applicable) 24 | 25 | c. Impact Assessment: 26 | - Effect on code readability 27 | - Potential for introducing bugs or maintenance issues 28 | - Impact on team collaboration and onboarding of new developers 29 | 30 | d. Correction Suggestions: 31 | - Specific recommendations for addressing the issue 32 | - Code snippets demonstrating the correct style (if applicable) 33 | - Explanation of the rationale behind the suggested changes 34 | 35 | 3. Identify patterns and trends in style inconsistencies across the codebase: 36 | - Are certain types of issues more prevalent? 37 | - Do inconsistencies cluster in specific modules or areas of the codebase? 38 | - Are there differences in style between different team members or over time? 39 | 40 | 4. Assess the overall adherence to the project's style guide or industry standards: 41 | - Percentage of code adhering to expected style 42 | - Areas of high compliance and areas needing improvement 43 | - Comparison with similar projects or industry benchmarks (if available) 44 | 45 | 5. Analyze the effectiveness of current style enforcement mechanisms: 46 | - Evaluate the use of linters, formatters, or other automated tools 47 | - Assess the consistency of code review practices related to style 48 | 49 | 6. Provide strategic recommendations for improving code style consistency: 50 | - Suggest updates or clarifications to the project's style guide 51 | - Recommend tools or processes to automate style enforcement 52 | - Propose training or knowledge-sharing initiatives to improve team awareness 53 | - Suggest a phased approach for addressing identified issues, prioritizing based on impact and effort 54 | 55 | **Expected Output:** A comprehensive analysis of the codebase's style consistency, including: 56 | 57 | 1. Executive summary of findings and key recommendations 58 | 2. Detailed analysis of style inconsistencies, grouped by category and severity 59 | 3. Statistical overview of style adherence across the codebase 60 | 4. In-depth discussion of patterns and trends in style issues 61 | 5. Evaluation of current style enforcement mechanisms 62 | 6. Strategic recommendations for improving overall code style consistency 63 | 7. Appendices with detailed examples and code snippets 64 | 65 | For each identified issue, use the following format: 66 | 67 | File: [file path] 68 | Line(s): [line number(s) or range] 69 | Issue Type: [naming/formatting/structure/etc.] 70 | Description: [detailed description of the inconsistency] 71 | Impact: 72 | - Readability: [low/medium/high] - [brief explanation] 73 | - Maintainability: [low/medium/high] - [brief explanation] 74 | - Collaboration: [low/medium/high] - [brief explanation] 75 | Correct Style: 76 | ```[language] 77 | [code snippet demonstrating correct style] 78 | ``` 79 | Suggestion: 80 | - [specific correction recommendation] 81 | - Rationale: [explanation of why this change improves consistency] 82 | 83 | Conclude with an overall assessment of the code style consistency in the project, including a roadmap for addressing identified issues and implementing long-term improvements in coding practices and team collaboration. -------------------------------------------------------------------------------- /prompt_library/quality_documentation_generation.md: -------------------------------------------------------------------------------- 1 | # Codebase Documentation Generation 2 | 3 | **Objective:** Generate comprehensive and user-friendly documentation for the provided codebase. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the attached code** and identify key components, functionalities, and APIs. 8 | 2. **Generate documentation that includes:** 9 | * API specifications with detailed descriptions of endpoints, parameters, and responses. 10 | * Function descriptions with clear explanations of their purpose, inputs, and outputs. 11 | * Usage examples demonstrating how to interact with the codebase effectively. 12 | 3. **Structure the documentation logically** and use a consistent format for clarity. 13 | 4. **Prioritize clarity, conciseness, and accuracy** in your documentation. 14 | 15 | **Expected Output:** Well-structured and informative documentation that facilitates understanding and utilization of the codebase by developers and other stakeholders. -------------------------------------------------------------------------------- /prompt_library/quality_error_analysis.md: -------------------------------------------------------------------------------- 1 | # Codebase Error and Inconsistency Analysis 2 | 3 | **Objective:** Identify potential errors and inconsistencies within the provided codebase. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the attached code** for the following: 8 | * Syntax errors and logical flaws. 9 | * Inconsistencies in variable and function naming conventions. 10 | * Code duplication. 11 | * Performance bottlenecks. 12 | * Violations of established coding best practices. 13 | 2. **Structure your analysis clearly**, pinpointing specific code snippets and providing detailed descriptions of the identified issues. 14 | 3. **Prioritize clarity and conciseness** in your explanations. 15 | 16 | **Expected Output:** A comprehensive report detailing errors and inconsistencies, organized by code section or error type, with actionable insights for improvement. -------------------------------------------------------------------------------- /prompt_library/quality_risk_assessment.md: -------------------------------------------------------------------------------- 1 | # Codebase Risk Assessment 2 | 3 | **Objective:** Identify code segments within the provided codebase that could potentially lead to future issues. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the attached code** with a focus on: 8 | * Code that is difficult to understand and maintain (code smells). 9 | * Fragments that might cause errors under specific conditions (edge cases). 10 | * Code that deviates from established coding standards. 11 | 2. **Provide detailed justifications for your concerns**, explaining the potential risks associated with each identified segment. 12 | 3. **Suggest potential solutions or mitigation strategies** to address the identified risks. 13 | 14 | **Expected Output:** A report highlighting potential risk areas within the codebase, with clear explanations of the risks and actionable recommendations for improvement. -------------------------------------------------------------------------------- /prompt_library/security_vulnerability_analysis.md: -------------------------------------------------------------------------------- 1 | # Security Vulnerability Analysis of Codebase 2 | 3 | **Objective:** Identify potential security vulnerabilities within the provided codebase. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the attached code** with a focus on identifying common security weaknesses such as: 8 | * SQL injection. 9 | * Cross-site scripting (XSS). 10 | * Cross-site request forgery (CSRF). 11 | * Authentication and authorization bypasses. 12 | * Data exposure. 13 | 2. **For each identified vulnerability, provide a detailed explanation** of: 14 | * The nature of the vulnerability. 15 | * The potential impact of exploitation. 16 | * Recommendations for mitigation using secure coding practices. 17 | 3. **Prioritize vulnerabilities based on their severity and potential impact.** 18 | 19 | **Expected Output:** A comprehensive security report highlighting potential vulnerabilities within the codebase, along with clear explanations of their risks and actionable recommendations for remediation. -------------------------------------------------------------------------------- /prompt_library/stakeholder_persona_generation.md: -------------------------------------------------------------------------------- 1 | # Codebase Stakeholder Persona Generation 2 | 3 | **Objective:** Infer potential stakeholder personas based on the functionalities present in the codebase. 4 | 5 | **Instructions:** 6 | 7 | 1. Analyze the codebase to identify distinct user roles and interactions. 8 | 2. For each identified role, create a stakeholder persona: 9 | * Name and role 10 | * Goals and motivations 11 | * Pain points and challenges 12 | * Key interactions with the system 13 | 3. Map specific code functionalities to each persona's needs. 14 | 4. Identify potential gaps in meeting stakeholder needs. 15 | 16 | **Expected Output:** A set of detailed stakeholder personas derived from the codebase, including their goals, challenges, and how the current system addresses their needs. -------------------------------------------------------------------------------- /prompt_library/swot_analysis.md: -------------------------------------------------------------------------------- 1 | # SWOT Analysis for Codebase 2 | 3 | **Objective:** Conduct a SWOT (Strengths, Weaknesses, Opportunities, Threats) analysis of the codebase to evaluate its current state and future potential. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase thoroughly, considering its architecture, features, and implementation. 8 | 9 | 2. Analyze the codebase according to the SWOT framework: 10 | 11 | a. Strengths: 12 | - What does the code do exceptionally well? 13 | - What unique features or efficient implementations stand out? 14 | - Are there any innovative algorithms or data structures? 15 | - How scalable or maintainable is the code? 16 | 17 | b. Weaknesses: 18 | - What are the limitations or shortcomings of the current implementation? 19 | - Are there any performance bottlenecks or scalability issues? 20 | - Are there areas where the code quality could be improved? 21 | - Are there missing features or incomplete implementations? 22 | 23 | c. Opportunities: 24 | - What market trends or user needs could the code capitalize on? 25 | - Are there potential new features or functionalities that could be added? 26 | - Could the code be adapted for new platforms or use cases? 27 | - Are there opportunities for integration with other systems or services? 28 | 29 | d. Threats: 30 | - Are there competing solutions that might make this code obsolete? 31 | - Are there potential security vulnerabilities or compliance issues? 32 | - Could changes in technology or standards negatively impact the code? 33 | - Are there dependencies on external libraries or services that pose risks? 34 | 35 | 3. For each point in the SWOT analysis, provide specific examples from the codebase to support your assessment. 36 | 37 | 4. Suggest strategies to: 38 | - Leverage strengths 39 | - Address weaknesses 40 | - Capitalize on opportunities 41 | - Mitigate threats 42 | 43 | **Expected Output:** A comprehensive SWOT analysis of the codebase, providing insights into its current state and future potential, with actionable recommendations for improvement and strategic direction. -------------------------------------------------------------------------------- /prompt_library/tech_adoption_lifecycle_analysis.md: -------------------------------------------------------------------------------- 1 | # Technology Adoption Lifecycle Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase and its associated product using the Technology Adoption Lifecycle model to understand its current market position and identify strategies for growth. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify the key features and functionalities it provides. 8 | 2. Determine the current stage of the product in the Technology Adoption Lifecycle: 9 | 10 | a. Innovators: 11 | - These are the first users to adopt a new technology or product. 12 | - They are willing to take risks and are often technology enthusiasts. 13 | 14 | b. Early Adopters: 15 | - These users are opinion leaders who embrace new technologies early but with more caution than innovators. 16 | - They are often visionaries seeking a competitive advantage. 17 | 18 | c. Early Majority: 19 | - These users adopt new technologies once they have been proven by early adopters. 20 | - They are pragmatists who seek reliable and cost-effective solutions. 21 | 22 | d. Late Majority: 23 | - These users are more conservative and risk-averse, adopting new technologies only after they have become mainstream. 24 | - They prioritize ease of use and low cost. 25 | 26 | e. Laggards: 27 | - These are the last users to adopt a new technology, often due to limited resources or resistance to change. 28 | - They may only adopt when they have no other choice. 29 | 30 | 3. Analyze the characteristics and needs of users in the current and adjacent stages of the lifecycle. 31 | 4. Identify potential strategies for moving the product through the lifecycle stages: 32 | - How can the product be positioned to appeal to the next stage of adopters? 33 | - What features, marketing messages, or support might be needed to facilitate this transition? 34 | 5. Develop a roadmap for evolving the product and its marketing based on the lifecycle analysis. 35 | 36 | **Expected Output:** A comprehensive Technology Adoption Lifecycle analysis of the codebase and its associated product, including: 37 | - Identification of the product's current stage in the lifecycle 38 | - Analysis of user characteristics and needs in the current and adjacent stages 39 | - Strategies for moving the product through the lifecycle stages 40 | - Roadmap for product evolution and marketing based on the lifecycle analysis 41 | -------------------------------------------------------------------------------- /prompt_library/testing_unit_test_generation.md: -------------------------------------------------------------------------------- 1 | # Unit Test Generation for Codebase 2 | 3 | **Objective:** Generate unit tests for the provided codebase to ensure code correctness and prevent regressions. 4 | 5 | **Instructions:** 6 | 7 | 1. **Analyze the attached code** and identify its core functions and methods. 8 | 2. **Generate unit tests** that cover a wide range of input values and expected outputs for each function/method. 9 | 3. **Follow best practices for unit testing**, including: 10 | * **Test one function/method per test case.** 11 | * **Use descriptive test names.** 12 | * **Assert expected outcomes clearly.** 13 | * **Keep tests independent and isolated.** 14 | 4. **Prioritize test coverage for critical functionalities** and edge cases. 15 | 16 | **Expected Output:** A comprehensive suite of unit tests that can be used to verify the correctness of the codebase and prevent regressions during future development. -------------------------------------------------------------------------------- /prompt_library/value_chain_analysis.md: -------------------------------------------------------------------------------- 1 | # Value Chain Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase to understand how it fits into and supports the larger value creation process of the business. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify key features, functionalities, and architectural components. 8 | 9 | 2. Map the codebase to the following primary activities of the value chain: 10 | 11 | a. Inbound Logistics: 12 | - How does the code handle data or resource inputs? 13 | - Are there features for data acquisition, validation, or initial processing? 14 | 15 | b. Operations: 16 | - What are the core processing or transformation functions in the code? 17 | - How does the code support the main business operations? 18 | 19 | c. Outbound Logistics: 20 | - How does the code manage output or delivery of results? 21 | - Are there features for data export, reporting, or product delivery? 22 | 23 | d. Marketing and Sales: 24 | - Does the code include features that support marketing efforts? 25 | - Are there components that facilitate sales processes or customer acquisition? 26 | 27 | e. Service: 28 | - How does the code support customer service or after-sales support? 29 | - Are there features for user feedback, issue tracking, or support ticket management? 30 | 31 | 3. Analyze how the code supports the following support activities: 32 | 33 | f. Procurement: 34 | - Does the code interface with systems for acquiring resources or services? 35 | - Are there features for managing suppliers or resources? 36 | 37 | g. Technology Development: 38 | - What innovative or unique technological aspects does the code implement? 39 | - How does the code leverage or advance technology in its domain? 40 | 41 | h. Human Resource Management: 42 | - Does the code support HR functions or employee management? 43 | - Are there features for performance tracking, training, or collaboration? 44 | 45 | i. Firm Infrastructure: 46 | - How does the code support overall business management and strategy? 47 | - Are there features for data analytics, reporting, or decision support? 48 | 49 | 4. For each value chain activity: 50 | - Identify the specific code components or features that support this activity. 51 | - Evaluate how effectively the code contributes to value creation in this area. 52 | - Suggest potential improvements or new features to enhance value creation. 53 | 54 | 5. Analyze the linkages between different activities: 55 | - How well does the code facilitate the flow between different value chain activities? 56 | - Are there any bottlenecks or inefficiencies in these linkages? 57 | 58 | 6. Identify opportunities for competitive advantage: 59 | - Which areas of the value chain does the code particularly excel in supporting? 60 | - Are there unique or innovative aspects of the code that provide a competitive edge? 61 | 62 | 7. Consider scalability and future growth: 63 | - How well does the current code architecture support scaling of value chain activities? 64 | - Are there areas where the code might limit future expansion or diversification? 65 | 66 | **Expected Output:** A comprehensive analysis of how the codebase supports and enhances the organization's value chain, including: 67 | - Detailed mapping of code components to value chain activities 68 | - Evaluation of the code's effectiveness in supporting each activity 69 | - Identified strengths, weaknesses, and opportunities for improvement 70 | - Suggestions for enhancing the code's contribution to the overall value chain 71 | 72 | This analysis should provide insights into how the codebase contributes to the organization's value creation process and guide decisions for future development to optimize this contribution. -------------------------------------------------------------------------------- /prompt_library/value_proposition_canvas_analysis.md: -------------------------------------------------------------------------------- 1 | # Value Proposition Canvas Analysis for Codebase 2 | 3 | **Objective:** Analyze the codebase using the Value Proposition Canvas to align technical features with user needs and benefits. 4 | 5 | **Instructions:** 6 | 7 | 1. Review the codebase and identify key features and functionalities. 8 | 2. For each main component of the Value Proposition Canvas, analyze the codebase: 9 | 10 | Customer Profile: 11 | a. Customer Jobs: 12 | - What tasks is the user trying to perform? 13 | - What problems is the user trying to solve? 14 | 15 | b. Pains: 16 | - What frustrations or challenges might the user face? 17 | - What risks is the user trying to avoid? 18 | 19 | c. Gains: 20 | - What benefits is the user seeking? 21 | - What would make the user's life easier or better? 22 | 23 | Value Map: 24 | d. Products and Services: 25 | - What specific features or services does the code provide? 26 | - How do these align with the customer jobs? 27 | 28 | e. Pain Relievers: 29 | - How does the code address user frustrations or challenges? 30 | - What features mitigate risks for the user? 31 | 32 | f. Gain Creators: 33 | - How does the code deliver benefits to the user? 34 | - What features exceed user expectations? 35 | 36 | 3. Evaluate the fit between the Customer Profile and the Value Map: 37 | - How well do the code's features address customer jobs, pains, and gains? 38 | - Are there any misalignments or gaps? 39 | 40 | 4. Identify opportunities for improvement: 41 | - Suggest new features or modifications to better address user needs. 42 | - Highlight any over-engineered features that may not provide significant value. 43 | 44 | **Expected Output:** A detailed analysis of how the codebase delivers value to users, identifying strengths, weaknesses, and opportunities for improvement based on the Value Proposition Canvas framework. -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | PyGithub 2 | twine 3 | packaging 4 | setuptools -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | certifi>=2024.8.30 2 | cffi>=1.17.1 3 | charset-normalizer>=3.3.2 4 | colorama>=0.4.6 5 | cryptography>=43.0.1 6 | Deprecated>=1.2.14 7 | idna>=3.10 8 | pycparser>=2.22 9 | PyGithub>=2.4.0 10 | PyJWT>=2.9.0 11 | PyNaCl>=1.5.0 12 | pyperclip>=1.9.0 13 | regex>=2024.9.11 14 | requests>=2.32.3 15 | tiktoken>=0.8.0 16 | typing_extensions>=4.12.2 17 | urllib3>=2.2.3 18 | wrapt>=1.16.0 19 | keyring -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | import os 3 | 4 | with open('VERSION') as f: 5 | version = f.read().strip() 6 | 7 | def read_requirements(filename='requirements.txt'): 8 | """Read the requirements from the given filename""" 9 | current_dir = os.path.dirname(os.path.abspath(__file__)) 10 | try: 11 | with open(os.path.join(current_dir, filename), encoding='utf-8') as f: 12 | return [line.strip() for line in f if line.strip() and not line.startswith('#')] 13 | except FileNotFoundError: 14 | return [] 15 | 16 | with open("README.md", "r", encoding="utf-8") as fh: 17 | long_description = fh.read() 18 | 19 | setup( 20 | name="codebase-digest", 21 | version=version, 22 | author="Kamil Stanuch", 23 | description="Consolidates and analyzes codebases for insights.", 24 | long_description=long_description, 25 | long_description_content_type="text/markdown", 26 | url="https://github.com/kamilstanuch/codebase-digest", 27 | packages=find_packages(exclude=["tests*"]), 28 | package_data={ 29 | "codebase_digest": ["prompt_library/*.md"], 30 | }, 31 | classifiers=[ 32 | "Development Status :: 3 - Alpha", 33 | "Intended Audience :: Developers", 34 | "Topic :: Software Development :: Libraries :: Python Modules", 35 | "Programming Language :: Python :: 3", 36 | "License :: OSI Approved :: MIT License", 37 | "Operating System :: OS Independent", 38 | ], 39 | keywords="code analysis, codebase, consolidation, visualization", 40 | install_requires=read_requirements(), 41 | extras_require={ 42 | 'dev': read_requirements('requirements-dev.txt'), 43 | }, 44 | entry_points={ 45 | "console_scripts": [ 46 | "cdigest=codebase_digest.app:main", 47 | ], 48 | }, 49 | python_requires='>=3.6', 50 | include_package_data=True, 51 | ) -------------------------------------------------------------------------------- /update_package.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import sys 4 | import re 5 | from github import Github 6 | from getpass import getpass 7 | from github.GithubException import GithubException 8 | import keyring 9 | from twine.commands.upload import upload 10 | from twine.settings import Settings 11 | from packaging import version 12 | 13 | def run_command(command): 14 | process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) 15 | output, error = process.communicate() 16 | if process.returncode != 0: 17 | print(f"Error: {error.decode('utf-8')}") 18 | return False 19 | return output.decode('utf-8').strip() 20 | 21 | def get_or_set_credential(service, credential_type, prompt): 22 | credential = keyring.get_password(service, credential_type) 23 | if not credential: 24 | credential = input(prompt) if credential_type == 'username' else getpass(prompt) 25 | save = input(f"Do you want to save the {service} {credential_type}? (y/n): ").lower().strip() == 'y' 26 | if save: 27 | keyring.set_password(service, credential_type, credential) 28 | return credential 29 | 30 | def github_login(max_attempts=3): 31 | for attempt in range(max_attempts): 32 | token = os.environ.get('GITHUB_TOKEN') or get_or_set_credential("github", "token", "Enter your GitHub personal access token: ") 33 | try: 34 | g = Github(token) 35 | user = g.get_user() 36 | print(f"Logged in as: {user.login}") 37 | return g 38 | except GithubException: 39 | print("GitHub login failed. Token might be expired or invalid.") 40 | keyring.delete_password("github", "token") 41 | if attempt < max_attempts - 1: 42 | print("Please try again.") 43 | else: 44 | print("Max attempts reached. Exiting.") 45 | sys.exit(1) 46 | 47 | def ensure_github_remote(github): 48 | remotes = run_command('git remote -v') 49 | if remotes is False: 50 | print("Failed to get git remotes. Please check your git installation.") 51 | sys.exit(1) 52 | 53 | if 'origin' not in remotes: 54 | repo_name = input("Enter the GitHub repository name: ") 55 | user = github.get_user() 56 | repo_url = f"https://github.com/{user.login}/{repo_name}.git" 57 | if run_command(f'git remote add origin {repo_url}') is False: 58 | print("Failed to add remote. Please check your git configuration.") 59 | sys.exit(1) 60 | 61 | remote_url = run_command('git remote get-url origin') 62 | if remote_url is False: 63 | print("Failed to get remote URL. Please check your git configuration.") 64 | sys.exit(1) 65 | 66 | repo_name = remote_url.split('/')[-1].replace('.git', '') 67 | print(f"GitHub remote 'origin' is set up for repository: {repo_name}") 68 | return repo_name 69 | 70 | def sync_with_remote(): 71 | print("Syncing with remote repository...") 72 | if run_command('git fetch origin') is False or run_command('git merge origin/main --allow-unrelated-histories --no-edit') is False: 73 | print("There might be merge conflicts. Please resolve them manually and run the script again.") 74 | sys.exit(1) 75 | 76 | def push_to_remote(): 77 | print("Pushing to GitHub...") 78 | if run_command('git push -u origin main') is False: 79 | print("Push failed. Please check your repository and try manually.") 80 | return False 81 | return True 82 | 83 | def upload_to_pypi(dist_files, max_attempts=3): 84 | for attempt in range(max_attempts): 85 | username = os.environ.get('PYPI_USERNAME') or get_or_set_credential("pypi", "username", "Enter your PyPI username: ") 86 | password = os.environ.get('PYPI_PASSWORD') or get_or_set_credential("pypi", "token", "Enter your PyPI token: ") 87 | 88 | settings = Settings( 89 | username=username, 90 | password=password, 91 | repository_url='https://upload.pypi.org/legacy/' 92 | ) 93 | 94 | try: 95 | upload(settings, dist_files) 96 | print("Successfully uploaded to PyPI") 97 | return True 98 | except Exception as e: 99 | print(f"Failed to upload to PyPI: {str(e)}") 100 | keyring.delete_password("pypi", "username") 101 | keyring.delete_password("pypi", "token") 102 | if attempt < max_attempts - 1: 103 | print("Please try again.") 104 | else: 105 | print("Max attempts reached. Please check your PyPI credentials and try manually.") 106 | return False 107 | 108 | def update_version(): 109 | with open('VERSION', 'r') as f: 110 | current_version = f.read().strip() 111 | 112 | print(f"Current version: {current_version}") 113 | while True: 114 | new_version = input("Enter new version number (e.g., 0.1.7): ") 115 | if re.match(r'^\d+(\.\d+){0,2}(\.?[a-zA-Z0-9]+)?$', new_version): 116 | try: 117 | version.parse(new_version) 118 | break 119 | except version.InvalidVersion: 120 | print("Invalid version format. Please use a valid version number.") 121 | else: 122 | print("Invalid version format. Please use a valid version number.") 123 | 124 | # Update VERSION file 125 | with open('VERSION', 'w') as f: 126 | f.write(new_version) 127 | 128 | # Update setup.py 129 | with open('setup.py', 'r') as f: 130 | content = f.read() 131 | 132 | updated_content = re.sub(r"version=['\"][\d.]+['\"]", f"version='{new_version}'", content) 133 | 134 | with open('setup.py', 'w') as f: 135 | f.write(updated_content) 136 | 137 | print(f"Updated VERSION file and setup.py with new version: {new_version}") 138 | return new_version 139 | 140 | def main(): 141 | if not os.path.exists('.git'): 142 | print("Error: Not in a git repository. Please run this script from your project's root directory.") 143 | sys.exit(1) 144 | 145 | github = github_login() 146 | repo_name = ensure_github_remote(github) 147 | sync_with_remote() 148 | new_version = update_version() 149 | change_description = input("Enter a brief description of the changes: ") 150 | 151 | if run_command('git add .') is False or run_command(f'git commit -m "Update to version {new_version}: {change_description}"') is False: 152 | print("Failed to commit changes. Please check your git configuration.") 153 | sys.exit(1) 154 | 155 | if push_to_remote() is False: 156 | print("Failed to push to GitHub. Aborting.") 157 | sys.exit(1) 158 | 159 | user = github.get_user() 160 | repo = user.get_repo(repo_name) 161 | try: 162 | repo.create_git_release(f"v{new_version}", f"Version {new_version}", change_description) 163 | print(f"GitHub release created for version {new_version}") 164 | except GithubException as e: 165 | print(f"An error occurred while creating the GitHub release: {str(e)}") 166 | print("Please create the release manually on the GitHub website.") 167 | sys.exit(1) 168 | 169 | print("Cleaning old distribution files...") 170 | if os.path.exists('dist'): 171 | for file in os.listdir('dist'): 172 | os.remove(os.path.join('dist', file)) 173 | 174 | print("Building distribution...") 175 | if run_command('python setup.py sdist bdist_wheel') is False: 176 | print("Failed to build distribution. Please check your setup.py and try manually.") 177 | sys.exit(1) 178 | 179 | print("Uploading to PyPI...") 180 | dist_files = [f for f in os.listdir('dist') if f.endswith(('.whl', '.tar.gz'))] 181 | dist_files = [os.path.join('dist', f) for f in dist_files] 182 | if upload_to_pypi(dist_files): 183 | print(f"Package updated to version {new_version} and pushed to GitHub and PyPI") 184 | # Update setup.py with the new version 185 | update_setup_py_version(new_version) 186 | else: 187 | print("Failed to upload to PyPI. Version in setup.py not updated.") 188 | sys.exit(1) 189 | 190 | def update_setup_py_version(new_version): 191 | with open('setup.py', 'r') as f: 192 | content = f.read() 193 | 194 | updated_content = re.sub(r"version='[\d.]+'", f"version='{new_version}'", content) 195 | 196 | with open('setup.py', 'w') as f: 197 | f.write(updated_content) 198 | 199 | print(f"Updated setup.py with new version: {new_version}") 200 | 201 | if __name__ == "__main__": 202 | main() --------------------------------------------------------------------------------