[GH-ISSUE #461] # Feature Request: Add ignore patterns support for stats command #166

Closed
opened 2026-03-02 04:12:30 +03:00 by kerem · 1 comment
Owner

Originally created by @txf0096 on GitHub (Feb 5, 2026).
Original GitHub issue: https://github.com/git-ai-project/git-ai/issues/461

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?

Originally created by @txf0096 on GitHub (Feb 5, 2026). Original GitHub issue: https://github.com/git-ai-project/git-ai/issues/461 # 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) ```bash 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`: ```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: ```bash $ git-ai stats HEAD you ████████░░░░░░░░░░░░ ai 65% 35% # Includes 5000 lines from package-lock.json ``` After: ```bash $ 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?
kerem 2026-03-02 04:12:30 +03:00
Author
Owner

@svarlamov commented on GitHub (Feb 17, 2026):

Closing this as we added support via .gitattributes (the same way that GitHub supports marking auto-generated files): https://github.com/git-ai-project/git-ai/pull/462#issuecomment-3902305980

<!-- gh-comment-id:3917519963 --> @svarlamov commented on GitHub (Feb 17, 2026): Closing this as we added support via `.gitattributes` (the same way that GitHub supports marking auto-generated files): https://github.com/git-ai-project/git-ai/pull/462#issuecomment-3902305980
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#166
No description provided.