Skip to content

# Feature Request: Add ignore patterns support for stats command #461

@txf0096

Description

@txf0096

Feature Request: Add ignore patterns support for stats command

Problem

Currently, git-ai stats includes all files when calculating AI vs human code statistics, including:

  • Lock files (package-lock.json, Cargo.lock, go.sum, etc.)
  • Minified/bundled files (*.min.js, *.bundle.js)
  • Generated code (protobuf files, GraphQL generated files, etc.)
  • Build artifacts that are committed to repos

This makes statistics inaccurate because these files are auto-generated and shouldn't count towards "real coding work".

Proposed Solution

Add support for ignoring file patterns in stats calculations, with three configuration levels:

1. CLI flag (highest priority)

git-ai stats --ignore "*.lock" "*.min.js" "dist/**"
git-ai stats HEAD --ignore "*.generated.*"

2. Project-level config (team shared)

Create .git-ai-ignore in repository root (gitignore syntax):

# Lock files
*.lock
go.sum

# Build artifacts  
*.min.js
*.bundle.js

# Generated code
*.generated.*
*_pb.go

3. Global config (user defaults)

In ~/.git-ai/config.json:

{
  "stats_ignore_patterns": [
    "*.lock",
    "*.min.js",
    "*.generated.*"
  ]
}

All three levels merge together (additive).

Use Cases

Monorepo with multiple languages: Each team can define their own .git-ai-ignore committed to the repo.

Personal preferences: Users can set global defaults without modifying each project.

Ad-hoc filtering: Quick one-off stats with --ignore flag.

Implementation Notes

The ignore logic should:

  • Only affect git-ai stats command (not checkpoint, blame, diff)
  • Use glob pattern matching (like .gitignore)
  • Skip entire files from statistics (both AI and human lines)
  • Work with both stats <commit> and stats <range> modes

Benefits

✅ More accurate AI/human code ratio
✅ Exclude noise from lock files and generated code
✅ Team consistency via committed .git-ai-ignore
✅ Flexible: global defaults + per-project overrides

Example

Before:

$ git-ai stats HEAD
you  ████████░░░░░░░░░░░░ ai
     65%              35%
# Includes 5000 lines from package-lock.json

After:

$ git-ai stats HEAD
you  ████████████████░░░░ ai
     80%              20%  
# package-lock.json excluded via .git-ai-ignore

Would this be a useful addition to git-ai?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions