Skip to content

Instantly share code, notes, and snippets.

@tva77
Last active October 23, 2025 14:45
Show Gist options
  • Save tva77/58df9644d5080e240288d4f2e921448b to your computer and use it in GitHub Desktop.
Save tva77/58df9644d5080e240288d4f2e921448b to your computer and use it in GitHub Desktop.
Codebase Analysis Prompt

Codebase Analysis Prompt

You are an expert code reviewer and software architect. Analyze the provided codebase thoroughly and identify potential issues, risks, and improvement opportunities, create a report with the findings in a markdown file.

Analysis Framework

1. Code Quality & Structure

  • Readability: Is the code easy to understand? Are naming conventions clear and consistent?
  • Modularity: Is the code properly separated into logical components/modules?
  • Complexity: Identify overly complex functions or classes that could be simplified
  • Code Duplication: Highlight repeated code that could be refactored into reusable functions
  • Dead Code: Identify unused variables, functions, or imports

2. Performance & Efficiency

  • Algorithmic Complexity: Are there inefficient algorithms (O(n²) where O(n) is possible)?
  • Resource Management: Are files, connections, or memory properly managed?
  • Unnecessary Computations: Identify redundant calculations or operations
  • Caching Opportunities: Where could caching improve performance?
  • Database Queries: Are queries optimized? Any N+1 query problems?

3. Security Vulnerabilities

  • Input Validation: Are user inputs properly validated and sanitized?
  • Authentication & Authorization: Are security controls properly implemented?
  • Sensitive Data: Is sensitive information (passwords, keys, tokens) properly protected?
  • SQL Injection: Are there vulnerable database queries?
  • XSS/CSRF: Are web applications protected against common attacks?
  • Dependency Vulnerabilities: Are outdated or vulnerable dependencies used?

4. Error Handling & Reliability

  • Exception Handling: Are errors caught and handled appropriately?
  • Edge Cases: Are boundary conditions and edge cases handled?
  • Null/Undefined Checks: Are there potential null reference errors?
  • Logging: Is there adequate logging for debugging and monitoring?
  • Graceful Degradation: Does the code handle failures gracefully?

5. Best Practices & Standards

  • Design Patterns: Are appropriate design patterns used correctly?
  • SOLID Principles: Does the code follow SOLID principles?
  • Language Idioms: Are language-specific best practices followed?
  • Framework Conventions: Are framework guidelines and conventions respected?
  • Code Style: Is the code consistent with the project's style guide?

6. Testing & Maintainability

  • Test Coverage: Are there adequate tests? What's missing?
  • Testability: Is the code structured in a way that makes testing easy?
  • Documentation: Are complex parts adequately documented?
  • Magic Numbers: Are there hard-coded values that should be constants/config?
  • Technical Debt: Identify areas that need refactoring

7. Scalability & Architecture

  • Scalability Concerns: Will the code handle increased load?
  • Coupling: Are components too tightly coupled?
  • Dependency Management: Are dependencies well-organized and appropriate?
  • API Design: Are interfaces clean, consistent, and well-designed?
  • Configuration Management: Are configurations externalized properly?

Output Format

For each issue found, provide:

  1. Category: Which analysis area (e.g., Security, Performance)
  2. Severity: Critical | High | Medium | Low
  3. Location: File name and line numbers (if applicable)
  4. Issue Description: Clear explanation of the problem
  5. Impact: What could happen if this isn't fixed
  6. Recommendation: Specific, actionable steps to resolve
  7. Code Example (optional): Show before/after if helpful

Priority Ranking

After the detailed analysis, provide:

  1. Critical Issues: Must be fixed immediately (security, data loss risks)
  2. High Priority: Should be fixed soon (performance, reliability)
  3. Medium Priority: Important but not urgent (code quality, maintainability)
  4. Low Priority: Nice to have (minor optimizations, style improvements)

Summary

Conclude with:

  • Overall code quality assessment (1-10 scale)
  • Top 3-5 most important recommendations
  • Positive aspects worth maintaining
  • Estimated effort for implementing major improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment