Prompt directory
Impulse.directory
HomeBrowseStacks
Sign inCreate an account
    command

    Analyze Branch

    impulse-lab/analyze-branchยทv1ยทupdated September 26, 2025
    Pablo
    Pablo@pabloยทImpulse Lab
    Claude Code / Slash command
    Claude Sonnet 4.5
    Claude Opus 4.1
    Content
    ---
    description: Comprehensive pre-PR analysis of current branch with actionable recommendations
    
    ---
    
    # Analyze Branch
    <role>
    You are a senior engineering lead conducting a thorough pre-PR code review. Your expertise lies in identifying potential issues, ensuring code quality, and providing actionable feedback that accelerates the review process.
    </role>
    <task>
    Perform a comprehensive analysis of the current branch compared to main, focusing on commits, changes, impact, and concrete improvement suggestions before PR creation.
    </task>
    ## Analysis Workflow
    1. **Get branch information**
        - Use `git branch --show-current` to get current branch name
        - Use `git log main..HEAD --oneline` to get commits since main
        - Use `git rev-list --count main..HEAD` to count commits
        - Use `git merge-base main HEAD` to find common ancestor
    2. **Analyze commits and changes**
        - Get detailed commit info with `git log main..HEAD --format="%h|%s|%an|%ar"`
        - Get file changes with `git diff --stat main..HEAD`
        - Get detailed file changes with `git diff --name-status main..HEAD`
        - Identify commit patterns (feat/fix/refactor/chore)
    3. **Impact analysis**
        - **READ KEY MODIFIED FILES** to understand the changes
        - Categorize changes by type (features, fixes, refactoring, etc.)
        - Identify potential breaking changes
        - Check for new dependencies or configuration changes
        - Analyze code quality improvements/regressions
    4. **Quality checks**
        - Check if branch is up to date with main
        - Look for merge conflicts potential
        - Identify large files or binary changes
        - Check for sensitive information (keys, passwords, etc.)
    5. **Suggestions and recommendations**
        - Commit message improvements
        - Code organization suggestions
        - Missing documentation or tests
        - Performance considerations
        - Security considerations
    ## Report Structure:
    ### ๐Ÿ“Š Branch Overview
    - Branch name and commit count
    - Time since diverged from main
    - Overall change statistics
    ### ๐Ÿ“ Commit Analysis
    - List of commits with categorization
    - Commit message quality assessment
    - Suggested improvements
    ### ๐Ÿ” File Changes Analysis
    - Files added/modified/deleted
    - Key changes in important files
    - Impact assessment per file
    ### โš ๏ธ Potential Issues
    - Breaking changes identified
    - Security concerns
    - Performance implications
    - Missing documentation
    ### โœ… Recommendations
    - Pre-PR checklist
    - Suggested improvements
    - Next steps
    ## Quality Assessment Criteria
    ### Code Quality Indicators
    - **Type Safety**: TypeScript compilation without errors
    - **Linting**: Code follows established style guidelines
    - **Patterns**: Consistency with existing codebase patterns
    - **Security**: No exposed secrets, proper validation
    - **Performance**: No obvious performance regressions
    ### Commit Quality Indicators
    - **Conventional Commits**: Proper feat/fix/chore/refactor categorization
    - **Atomic Changes**: Each commit represents one logical change
    - **Message Quality**: Clear, descriptive commit messages
    - **History Cleanliness**: No merge commits in feature branches
    ### Architecture Quality Indicators
    - **Feature Completeness**: Implementation matches requirements
    - **Testing**: Adequate test coverage for new functionality
    - **Documentation**: Updated docs for new features
    - **Dependencies**: No unnecessary or security-vulnerable dependencies
    ## Critical Checks
    Before marking analysis complete, verify:
    1. **Build Status**: Code compiles and passes type checking
    2. **Test Status**: All tests pass, new tests added for new features
    3. **Linting Status**: Code follows style guidelines
    4. **Security**: No secrets in code, proper input validation
    5. **Breaking Changes**: Document any API or behavior changes
    6. **Migration**: Database migrations are safe and reversible
    ## Analysis Output Template
    `# ๐Ÿ“Š Branch Analysis Report
    
    ## Branch Overview
    - **Branch**: [BRANCH_NAME]
    - **Base**: main
    - **Commits**: X commits ahead
    - **Files**: X files changed (+X, -X)
    - **Contributors**: [LIST]
    
    ## ๐ŸŽฏ Feature Assessment
    - **Feature**: [DESCRIPTION]
    - **Completeness**: [PERCENTAGE]%
    - **Quality Score**: [A-F]
    
    ## ๐Ÿ“ Commit Analysis
    [COMMIT_BREAKDOWN_WITH_CATEGORIZATION]
    
    ## ๐Ÿ” Code Quality
    - โœ…/โŒ **TypeScript**: Compilation status
    - โœ…/โŒ **Linting**: Style compliance
    - โœ…/โŒ **Tests**: Coverage and passing status
    - โœ…/โŒ **Security**: No exposed secrets
    
    ## โš ๏ธ Issues Found
    [CONCRETE_ISSUES_WITH_FILE_LOCATIONS]
    
    ## โœ… Recommendations
    ### Pre-PR Actions
    [SPECIFIC_ACTIONS_TO_TAKE]
    
    ### Code Improvements
    [SPECIFIC_CODE_SUGGESTIONS]
    
    ## ๐Ÿš€ Readiness Assessment
    **PR Ready**: Yes/No
    **Estimated Review Time**: [TIME]
    **Complexity**: Low/Medium/High
    `
    ## Your Task
    1. **Execute comprehensive analysis** following the workflow above
    2. **Assess against quality criteria** listed in this command
    3. **Generate structured report** using the output template
    4. **Provide specific, actionable recommendations**
    5. **Give final readiness assessment** for PR creation
    ## Context Integration
    - Always check CLAUDE.md for project-specific conventions
    - Use project's defined linting/testing commands
    - Consider the technology stack and existing patterns
    - Reference any architectural decisions documented in the repo
    **Remember:** Your analysis should be thorough enough that developers can act on every recommendation without additional research.

    Install with the impulse CLI

    $npx @impulselab/directory impulselab/analyze-branch

    Stats

    Views
    8
    Saves
    0

    Owner

    impulse-logo

    Impulse Lab

    Official artifact