VS Code Extensions
C

Commit Size Checker

by cb-jarunmadhesh

Warns developers when committing too many lines of code at once

Downloads

8

Rating

— (0)

Version

1.0.4

Last updated

Apr 29, 2026

An extension that shows warning popups when your branch has too many lines compared to the primary branch, encouraging smaller, more reviewable PRs.

Features

  • Branch Comparison: Compares your current branch to the primary branch (main/master)
  • Warning Popup: Shows warning when your branch exceeds the line limit
  • Real-time Status Bar: Shows current lines added vs. your limit with color coding
  • Exclude Files: Exclude files by regex patterns (e.g., lock files, generated code)
  • Configurable via File: Uses .commitsizecheck.json in your repo (shareable with team)
  • Smart Line Counting: Only counts meaningful lines (excludes imports, comments, empty lines)

How It Works

  1. Branch Diff: The extension compares your current branch to the configured primary branch (default: main) using git diff origin/<primaryBranch>...HEAD

  2. Status Bar: Shows live count with color:

    • Normal: Within limit
    • Red: Limit exceeded
    • Shows "On main" when you're on the primary branch
  3. Warnings: Get notified when your branch has too many changes

What Counts as a "Meaningful" Line?

The extension intelligently filters out non-essential lines:

  • Import/package statements (import, package)
  • Comments (//, #, /* */, Javadoc *)
  • Auto-generated comments (// Generated, // AUTO-GENERATED)
  • Empty lines

Only actual code logic is counted toward your limit!

Configuration

The extension uses a config file in your repository root: .commitsizecheck.json

Create Config File

Run command: Commit Size Check: Create Config File

Or manually create .commitsizecheck.json in your repo root:

{
  "lineLimit": 250,
  "primaryBranch": "main",
  "excludePatterns": [
    "package-lock\\.json$",
    "yarn\\.lock$",
    "\\.min\\.js$",
    "\\.generated\\."
  ]
}

Config Options

Option Default Description
lineLimit 250 Maximum meaningful lines allowed per PR
primaryBranch "main" Branch to compare against (supports env variables)
excludePatterns [] Array of regex patterns for files to exclude

Environment Variables in primaryBranch

You can use environment variables in the primaryBranch config using the ${VAR_NAME} syntax:

{
  "primaryBranch": "develop/${SQUAD_NAME}"
}

The recommended way is via Cursor/VS Code User Settings:

  1. Open Settings: Cmd + , (Mac) or Ctrl + , (Windows/Linux)
  2. Click the { } icon (top right) to open settings.json
  3. Add your variables:
{
  "commitSizeCheck.envVariables": {
    "SQUAD_NAME": "payments"
  }
}

Benefits:

  • Set once globally (applies to all workspaces)
  • Works immediately (no restart needed)
  • Syncs across machines via Settings Sync
  • No system-level configuration needed

The extension resolves variables in this order:

  1. Cursor/VS Code Settings (commitSizeCheck.envVariables)

This is useful for teams where different developers work on different feature branches based on their squad/team.

Exclude Patterns

Use regex patterns to exclude files from the line count. Common examples:

{
  "excludePatterns": [
    "package-lock\\.json$",
    "yarn\\.lock$",
    "pnpm-lock\\.yaml$",
    "\\.min\\.js$",
    "\\.min\\.css$",
    "\\.generated\\.",
    "dist/",
    "build/",
    "__snapshots__/",
    "\\.test\\.ts$",
    "\\.spec\\.ts$"
  ]
}

Note: Patterns are JavaScript regex. Remember to escape special characters like . → \\.

Default Behavior

If no .commitsizecheck.json exists, the extension uses these defaults:

  • lineLimit: 250
  • primaryBranch: "main"
  • excludePatterns: [] (none excluded)

Share with Team

Commit .commitsizecheck.json to your repo so the whole team uses the same settings!

Commands

  • Commit Size Check: Check Lines Before Commit - Manually check branch diff
  • Commit Size Check: Create Config File - Create .commitsizecheck.json with defaults
  • Commit Size Check: Open Config File - Open the config file for editing

Status Bar

The extension adds a status bar item showing:

  • $(git-commit) Lines: X/Y - Within limit (shows lines in your branch vs primary)
  • $(error) Lines: X/Y - Limit exceeded (red background)
  • $(git-commit) On main - You're on the primary branch

Click it to manually trigger a check.

Why Smaller PRs?

  • Easier Code Reviews: Reviewers can focus on smaller changes
  • Better Git History: Atomic commits are easier to understand and revert
  • Reduced Merge Conflicts: Smaller changes mean fewer conflicts
  • Faster Reviews: Large PRs often get delayed or rubber-stamped
  • Improved Quality: Encourages incremental development

Compatibility

Works with:

  • VS Code
  • Cursor
  • Any VS Code-based editor

License

MIT

Related extensions