Skip to content

feat(core): Add .ignore file support#938

Merged
yamadashy merged 9 commits intomainfrom
feat/ignore
Nov 8, 2025
Merged

feat(core): Add .ignore file support#938
yamadashy merged 9 commits intomainfrom
feat/ignore

Conversation

@yamadashy
Copy link
Owner

This PR adds support for .ignore files, which are used by tools like ripgrep and the silver searcher. This allows users to maintain a single .ignore file that works across multiple tools instead of maintaining separate ignore files.

Changes

  • Added ignore.useDotIgnore configuration option (default: true)
  • Added --no-dot-ignore CLI flag to disable .ignore file usage
  • Updated ignore file priority order:
    1. Custom patterns
    2. .repomixignore
    3. .ignore (new)
    4. .gitignore
    5. Default patterns
  • Added comprehensive tests for .ignore file handling
  • Updated documentation to reflect new .ignore file support

Benefits

  • Single ignore file: Users can use one .ignore file that works with ripgrep, ag, and repomix
  • Reduced maintenance: No need to maintain multiple tool-specific ignore files
  • Backward compatible: Existing .gitignore and .repomixignore files continue to work
  • Configurable: Can be disabled via ignore.useDotIgnore: false or --no-dot-ignore flag

Checklist

  • Run npm run test
  • Run npm run lint

Resolves #937

This PR adds support for .ignore files, which are used by tools like ripgrep and the silver searcher. This allows users to maintain a single .ignore file that works across multiple tools instead of maintaining separate ignore files.

Changes:
- Add ignore.useDotIgnore config option (default: true)
- Add --no-dot-ignore CLI flag to disable .ignore file usage
- Update ignore file priority: .repomixignore > .ignore > .gitignore > default patterns
- Add comprehensive tests for .ignore file handling
- Update documentation to reflect new .ignore file support

The .ignore file is enabled by default but can be disabled via configuration or CLI flag, maintaining backward compatibility.

Resolves #937
Copilot AI review requested due to automatic review settings November 8, 2025 06:52
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 8, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This PR adds support for .ignore files as an ignore source in Repomix, alongside .gitignore and .repomixignore. A new --no-dot-ignore CLI flag controls whether .ignore patterns are applied during file filtering.

Changes

Cohort / File(s) Change Summary
CLI Configuration Layer
src/cli/cliRun.ts, src/cli/types.ts, src/cli/actions/defaultAction.ts
Introduces --no-dot-ignore CLI option and routes dotIgnore setting through config builder, mirroring existing --no-gitignore behavior.
Configuration Schema
src/config/configSchema.ts, website/client/src/public/schemas/...
Adds optional useDotIgnore boolean field to ignore configuration, with default value true in base and merged schemas.
Core Ignore Logic
src/core/file/fileSearch.ts
Conditionally includes .ignore patterns when config.ignore.useDotIgnore is true; reorders pattern precedence to .repomixignore (first), .ignore (conditional), then .gitignore/.git/info/exclude.
Tests
tests/config/configSchema.test.ts, tests/core/file/fileSearch.test.ts
Updates test cases to exercise useDotIgnore flag and verify correct pattern ordering and inclusion based on ignore configuration state.
Documentation
README.md
Updates references to ignore handling to mention .ignore support alongside .gitignore and .repomixignore; documents new --no-dot-ignore flag.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI Layer
    participant Config as Config Schema
    participant Search as File Search
    participant Patterns as Ignore Patterns

    CLI->>Config: User sets --no-dot-ignore or useDotIgnore: false
    Config->>Search: Config object with useDotIgnore flag
    Search->>Patterns: getIgnoreFilePatterns()
    alt useDotIgnore === true
        Patterns->>Patterns: Add **/.repomixignore (first)
        Patterns->>Patterns: Add **/.ignore (conditional)
        Patterns->>Patterns: Add **/.gitignore / .git/info/exclude
    else useDotIgnore === false
        Patterns->>Patterns: Add **/.repomixignore (first)
        Patterns->>Patterns: Add **/.gitignore / .git/info/exclude
    end
    Patterns-->>Search: Ordered ignore file patterns
    Search-->>CLI: Filtered file list
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Patterns are consistent and repetitive across multiple files (new boolean field added to config, CLI, and tests following established conventions)
  • Core logic change is straightforward: reordering and conditional inclusion of .ignore patterns mirrors existing .gitignore handling
  • Well-isolated feature: changes don't intersect with unrelated systems
  • Areas requiring attention during review:
    • Verify ignore pattern ordering in src/core/file/fileSearch.ts matches expected precedence (.repomixignore → .ignore → .gitignore)
    • Confirm test cases in tests/core/file/fileSearch.test.ts cover all combinations of useDotIgnore and useGitignore flags
    • Check that CLI option integration in src/cli/actions/defaultAction.ts properly routes the dotIgnore flag to config

Possibly related PRs

Suggested reviewers

  • yamadashy

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(core): Add .ignore file support' clearly and concisely summarizes the main change: adding support for .ignore files to the core functionality.
Description check ✅ Passed The PR description is comprehensive, covering changes, benefits, and including completed checklist items. It exceeds the minimal template requirements with detailed context.
Linked Issues check ✅ Passed The PR fully implements the objective from issue #937: adding .ignore file support with default true configuration, allowing users to use one file across ripgrep, silver searcher, and repomix without maintaining multiple ignore files.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing .ignore file support: configuration schema updates, CLI flag additions, file search logic modifications, tests, and documentation updates are all in scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 8, 2025

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: e003ec6
Status: ✅  Deploy successful!
Preview URL: https://9636e7ac.repomix.pages.dev
Branch Preview URL: https://feat-ignore.repomix.pages.dev

View logs

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yamadashy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the file exclusion mechanism by integrating support for '.ignore' files, which are commonly used by tools like ripgrep and The Silver Searcher. This change aims to streamline the user experience by enabling a single, unified ignore file across multiple tools, thereby reducing maintenance effort and improving consistency in file exclusion. It introduces new configuration options and CLI flags for granular control, while maintaining backward compatibility with existing '.gitignore' and '.repomixignore' setups.

Highlights

  • .ignore file support: Introduced support for '.ignore' files, allowing users to consolidate ignore patterns used by various tools like ripgrep and The Silver Searcher.
  • Configuration options: Added a new 'ignore.useDotIgnore' configuration option (defaulting to 'true') and a '--no-dot-ignore' CLI flag to provide granular control over '.ignore' file usage.
  • Ignore priority update: The ignore file priority order has been updated to include '.ignore' files, placing them between '.repomixignore' and '.gitignore' for consistent exclusion behavior.
  • Documentation updates: The 'README.md' has been updated to reflect the new '.ignore' file support, the associated CLI flag, and the revised ignore pattern priority.
  • Test coverage: Comprehensive tests have been added and updated to ensure the correct handling and configuration of '.ignore' files.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for .ignore files to Repomix's file filtering mechanism. The .ignore file format is compatible with tools like ripgrep and the silver searcher, allowing users to maintain a single ignore file across multiple tools.

  • Added useDotIgnore configuration option (defaults to true)
  • Updated ignore file priority order to include .ignore files
  • Added CLI option --no-dot-ignore to disable .ignore file support

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
website/client/src/public/schemas/latest/schema.json Added useDotIgnore boolean property to the JSON schema
website/client/src/public/schemas/1.8.0/schema.json Added useDotIgnore boolean property to the version-specific schema
tests/core/file/fileSearch.test.ts Updated tests to include useDotIgnore in mock configs and added test for .ignore file exclusion
tests/config/configSchema.test.ts Updated expected default config to include useDotIgnore: true
src/core/file/fileSearch.ts Modified getIgnoreFilePatterns to conditionally add .ignore file pattern
src/config/configSchema.ts Added useDotIgnore property to config schema with default value true
src/cli/types.ts Added dotIgnore optional property to CLI options interface
src/cli/cliRun.ts Added --no-dot-ignore CLI option
src/cli/actions/defaultAction.ts Added logic to handle dotIgnore CLI option
README.md Updated documentation to mention .ignore file support and priority order
Comments suppressed due to low confidence (6)

tests/core/file/fileSearch.test.ts:155

  • The test 'should return default patterns when useDefaultPatterns is true' is missing the useDotIgnore property in the mock config. Since createMockConfig uses defaults from defaultConfig where useDotIgnore is true, this test should explicitly set useDotIgnore: true for consistency with other tests in the file and to make the test's intent clear.
      const mockConfig = createMockConfig({
        ignore: {
          useGitignore: true,
          useDefaultPatterns: true,
          customPatterns: [],
        },
      });

tests/core/file/fileSearch.test.ts:170

  • The test 'should include custom patterns' is missing the useDotIgnore property in the mock config. This should be explicitly set to maintain consistency with updated tests and make the test's configuration clear.
      const mockConfig = createMockConfig({
        ignore: {
          useGitignore: true,
          useDefaultPatterns: false,
          customPatterns: ['*.custom', 'temp/'],
        },
      });

tests/core/file/fileSearch.test.ts:184

  • The test 'should combine default and custom patterns' is missing the useDotIgnore property in the mock config. This should be explicitly set for consistency with the updated test patterns in this file.
      const mockConfig = createMockConfig({
        ignore: {
          useGitignore: true,
          useDefaultPatterns: true,
          customPatterns: ['*.custom', 'temp/'],
        },
      });

tests/core/file/fileSearch.test.ts:200

  • The test 'should include patterns from .git/info/exclude when useGitignore is true' is missing the useDotIgnore property in the mock config. This should be explicitly set for consistency with the updated test suite.
      const mockConfig = createMockConfig({
        ignore: {
          useGitignore: true,
          useDefaultPatterns: false,
          customPatterns: [],
        },
      });

tests/core/file/fileSearch.test.ts:271

  • The test 'should call globby with correct parameters' is missing the useDotIgnore property in the mock config. Since this test verifies the ignoreFiles parameter passed to globby, it should explicitly set useDotIgnore and update the expected array on line 283 to include **/.ignore for completeness.
      const mockConfig = createMockConfig({
        include: ['**/*.js'],
        ignore: {
          useGitignore: true,
          useDefaultPatterns: false,
          customPatterns: ['*.custom'],
        },
      });

tests/core/file/fileSearch.test.ts:300

  • The test 'Honor .gitignore files in subdirectories' is missing the useDotIgnore property in the mock config. This should be explicitly set for consistency with the updated test patterns throughout the file.
      const mockConfig = createMockConfig({
        include: ['**/*.js'],
        ignore: {
          useGitignore: true,
          useDefaultPatterns: false,
          customPatterns: [],
        },
      });

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for .ignore files, which is a great feature for improving compatibility with tools like ripgrep. The changes are well-structured across documentation, configuration, and implementation. I've found a potential issue with the priority order of ignore files in the core logic, which also affects the tests. My review includes suggestions to correct this to align with the documented behavior. Otherwise, the implementation is solid.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
README.md (1)

937-937: LGTM! Accurate MCP tool documentation.

The ignorePatterns parameter descriptions correctly explain that patterns supplement .gitignore, .ignore, and built-in exclusions. The documentation is clear and helpful for MCP tool users.

Note: Static analysis flagged a minor markdown indentation preference on these lines. If you'd like to address the linter warning, adjust the list indentation from 4 spaces to 2 spaces:

     - `includePatterns`: (Optional) Specify files to include using fast-glob patterns. Multiple patterns can be comma-separated (e.g., "**/*.{js,ts}", "src/**,docs/**"). Only matching files will be processed.
-    - `ignorePatterns`: (Optional) Specify additional files to exclude using fast-glob patterns. Multiple patterns can be comma-separated (e.g., "test/**,*.spec.js", "node_modules/**,dist/**"). These patterns supplement .gitignore, .ignore, and built-in exclusions.
+  - `ignorePatterns`: (Optional) Specify additional files to exclude using fast-glob patterns. Multiple patterns can be comma-separated (e.g., "test/**,*.spec.js", "node_modules/**,dist/**"). These patterns supplement .gitignore, .ignore, and built-in exclusions.

Also applies to: 955-955

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68c3c4b and 8365478.

📒 Files selected for processing (10)
  • README.md (8 hunks)
  • src/cli/actions/defaultAction.ts (1 hunks)
  • src/cli/cliRun.ts (1 hunks)
  • src/cli/types.ts (1 hunks)
  • src/config/configSchema.ts (2 hunks)
  • src/core/file/fileSearch.ts (1 hunks)
  • tests/config/configSchema.test.ts (2 hunks)
  • tests/core/file/fileSearch.test.ts (1 hunks)
  • website/client/src/public/schemas/1.8.0/schema.json (1 hunks)
  • website/client/src/public/schemas/latest/schema.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-01-27T08:22:19.918Z
Learnt from: boralg
Repo: yamadashy/repomix PR: 318
File: src/config/defaultIgnore.ts:136-138
Timestamp: 2025-01-27T08:22:19.918Z
Learning: In Rust projects, `cargo-timing*.html` files are generated within the `target/` directory, so they're automatically covered by the `**/target/**` ignore pattern.

Applied to files:

  • README.md
🧬 Code graph analysis (1)
tests/core/file/fileSearch.test.ts (2)
tests/testing/testUtils.ts (1)
  • createMockConfig (15-45)
src/core/file/fileSearch.ts (1)
  • getIgnoreFilePatterns (295-309)
🪛 markdownlint-cli2 (0.18.1)
README.md

937-937: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


955-955: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (19)
src/core/file/fileSearch.ts (1)

295-309: LGTM! Clean implementation of .ignore file support.

The conditional inclusion of **/.ignore follows the existing pattern for .gitignore and maintains the correct priority order. The logic is clear and straightforward.

website/client/src/public/schemas/1.8.0/schema.json (1)

126-128: LGTM! Schema addition is correct.

The useDotIgnore property is properly defined as a boolean type and positioned logically alongside other ignore configuration options.

website/client/src/public/schemas/latest/schema.json (1)

126-128: LGTM! Consistent with versioned schema.

The schema addition matches the 1.8.0 version, maintaining proper schema continuity.

src/config/configSchema.ts (2)

59-59: LGTM! Base schema addition is consistent.

The optional useDotIgnore field follows the same pattern as useGitignore.


115-115: LGTM! Default value is appropriate.

Setting useDotIgnore to default true enables the feature by default, which aligns with the PR objective of reducing maintenance by sharing ignore files across tools.

tests/config/configSchema.test.ts (2)

129-129: LGTM! Test correctly includes the new field.

The addition of useDotIgnore: true ensures the default schema validation includes the new ignore configuration option.


234-234: LGTM! Merged schema test updated consistently.

The test correctly validates that useDotIgnore is properly handled in the merged configuration schema.

src/cli/cliRun.ts (1)

148-148: LGTM! CLI option is well-placed and consistent.

The --no-dot-ignore flag follows the same pattern as --no-gitignore and is properly positioned in the File Selection Options group with a clear description.

src/cli/types.ts (1)

35-35: LGTM! Type definition is clean and consistent.

The dotIgnore optional boolean is properly defined and positioned alongside the related gitignore option.

src/cli/actions/defaultAction.ts (1)

130-133: LGTM! CLI override handling is consistent and correct.

The dotIgnore handling exactly mirrors the gitignore pattern above it (lines 126-129), only applying the override when explicitly set to false. This preserves config file values while allowing CLI overrides, which is the correct behavior for Commander.js --no-* flags.

README.md (6)

86-86: LGTM! Clear feature documentation.

The Git-Aware feature description accurately reflects the new .ignore file support alongside existing .gitignore and .repomixignore files.


498-498: LGTM! Accurate JSON format example.

The notes field correctly documents that files may be excluded based on .ignore rules in addition to .gitignore and .repomixignore.


640-640: LGTM! Well-documented CLI flag.

The --no-dot-ignore flag is clearly documented alongside the related --no-gitignore flag, making it easy for users to discover and understand.


1212-1212: LGTM! Clear configuration documentation.

The ignore.useDotIgnore configuration option is well-documented with a clear description and correct default value (true).


1328-1328: LGTM! Comprehensive feature explanation.

The .ignore file documentation is thorough and explains:

  • What the feature does
  • Which tools respect it (ripgrep, silver searcher)
  • The benefit (reduced maintenance burden)
  • How to configure it (both config file and CLI)

This provides excellent context for users adopting the feature.


1337-1344: LGTM! Accurate priority order documentation.

The updated priority order correctly reflects the new .ignore file support:

  1. Custom patterns (highest priority)
  2. .repomixignore (Repomix-specific)
  3. .ignore (shared with ripgrep/ag, when enabled)
  4. .gitignore and .git/info/exclude (when enabled)
  5. Default patterns (lowest priority)

This order makes logical sense: user overrides → tool-specific → tool-shared → VCS → defaults.

tests/core/file/fileSearch.test.ts (3)

56-68: LGTM! Comprehensive test for both flags enabled.

The test correctly verifies that when both useGitignore and useDotIgnore are true, all three ignore file patterns are returned in the expected priority order: .repomixignore.ignore.gitignore.


70-82: LGTM! Correct test for selective flag usage.

The test correctly verifies that when useDotIgnore is true but useGitignore is false, the result includes .repomixignore and .ignore but excludes .gitignore. This validates the independent control of each ignore source.


84-96: LGTM! Essential test for the new flag.

This new test correctly verifies that when useDotIgnore is false, the .ignore file patterns are excluded from the result, even when useGitignore is true. This ensures users can opt out of .ignore support if needed.

The test completes the coverage matrix for the new feature and validates the backward compatibility path for users who don't want this behavior.

Fixed the priority order of ignore files to match the intended behavior:
- .gitignore (lowest priority)
- .ignore (medium priority)
- .repomixignore (highest priority)

The previous implementation had .repomixignore at the lowest priority,
which was incorrect. Repomix-specific ignore rules should take precedence
over generic ignore files.

This ensures that:
1. .repomixignore can override .ignore and .gitignore rules
2. .ignore can override .gitignore rules
3. The priority order documented in README is correctly implemented
@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.62%. Comparing base (68c3c4b) to head (e003ec6).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #938      +/-   ##
==========================================
+ Coverage   89.52%   89.62%   +0.10%     
==========================================
  Files         111      111              
  Lines        7830     7839       +9     
  Branches     1499     1501       +2     
==========================================
+ Hits         7010     7026      +16     
+ Misses        820      813       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ignoreFilePatterns.push('**/.ignore');
}

ignoreFilePatterns.push('**/.repomixignore');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Issue: Incorrect Priority Order

The current implementation adds .repomixignore last to the ignoreFilePatterns array, which means it has the lowest priority when globby processes the ignore files. However, according to the README documentation (line 1338-1342), the intended priority order is:

  1. Custom patterns (highest)
  2. .repomixignore
  3. .ignore
  4. .gitignore (lowest)

Why this is a problem:
When globby processes ignoreFiles, it typically applies them in order, with later files overriding earlier ones in terms of priority. By placing .repomixignore last, it ends up with the highest priority among the ignore files, which is correct. However, the ordering here is confusing.

Actually, I need to verify this: Looking at globby's behavior, ignore files are typically additive (patterns accumulate), not override-based. The priority should actually be controlled by the order patterns are added to the main ignore array in getIgnorePatterns, not the ignoreFiles array.

The Real Issue:
The priority ordering is actually handled correctly here for globby's ignoreFiles option (which just tells globby which files to read patterns from). The actual priority is determined by the order patterns are added in getIgnorePatterns() function (lines 311-357).

However, there's still a documentation inconsistency: The code adds .repomixignore last (line 306), but this doesn't reflect the documented priority since globby reads all ignore files and merges their patterns.

Recommendation:
For clarity and to match the documented priority, consider reordering to:

// Add in reverse priority order (highest priority last for clarity)
if (config.ignore.useGitignore) {
  ignoreFilePatterns.push('**/.gitignore');
}

if (config.ignore.useDotIgnore) {
  ignoreFilePatterns.push('**/.ignore');
}

ignoreFilePatterns.push('**/.repomixignore');

This way, the code visually reflects the intended priority order even though globby treats all ignoreFiles equally by reading and merging their patterns.

cliConfig.ignore = { ...cliConfig.ignore, useGitignore: options.gitignore };
}
// Only apply dotIgnore setting if explicitly set to false
if (options.dotIgnore === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good: Consistent with existing patterns

This implementation correctly mirrors the handling of gitignore and defaultPatterns options. The pattern of only applying when explicitly set to false allows config file values to take precedence unless overridden via CLI.

Minor suggestion: Consider adding a comment explaining this behavior for future maintainers:

// Only apply dotIgnore setting if explicitly set to false
// This allows config file values to take precedence when the flag is not specified
if (options.dotIgnore === false) {
  cliConfig.ignore = { ...cliConfig.ignore, useDotIgnore: options.dotIgnore };
}

});
const filePatterns = await getIgnoreFilePatterns(mockConfig);
expect(filePatterns).toEqual(['**/.gitignore', '**/.repomixignore']);
expect(filePatterns).toEqual(['**/.gitignore', '**/.ignore', '**/.repomixignore']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage Issue: Order Matters

While this test verifies that all three ignore file patterns are included, it should also verify the order to ensure the priority is correct.

Consider updating to:

expect(filePatterns).toEqual(['**/.gitignore', '**/.ignore', '**/.repomixignore']);
// Or better yet, add a comment explaining why order matters:
// Order should reflect priority: .gitignore (lowest) -> .ignore -> .repomixignore (highest)

However, I need to verify if globby's ignoreFiles option respects order or just merges all patterns. If it merges, order doesn't matter for this array, and the test is fine as-is.

@@ -1323,6 +1325,7 @@ Repomix offers multiple methods to set ignore patterns for excluding specific fi
process:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation Enhancement Suggestion

Great addition of .ignore file support documentation! Consider adding a note about compatibility/precedence when files conflict:

- **.ignore**: You can use a `.ignore` file in your project root, following the same format as `.gitignore`. This file is respected by tools like ripgrep and the silver searcher, reducing the need to maintain multiple ignore files. Patterns in `.ignore` take precedence over `.gitignore` but are overridden by `.repomixignore`. This behavior can be controlled with the `ignore.useDotIgnore` setting or the `--no-dot-ignore` cli option.

This clarifies what happens when the same pattern appears in multiple files.

@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Code Review Summary

Great work on implementing .ignore file support! This is a valuable feature that improves compatibility with popular tools like ripgrep and The Silver Searcher. The implementation follows the project's conventions well and is mostly solid.

Strengths

  1. Consistent Implementation: The CLI flag handling (--no-dot-ignore) correctly mirrors existing patterns
  2. Comprehensive Documentation: README updates clearly explain the new feature
  3. Good Test Coverage: Added tests cover the main scenarios
  4. Backward Compatibility: Default value of true enables the feature while maintaining compatibility
  5. Schema Updates: Both versioned and latest schema files are properly updated

Key Findings

Medium Priority - Priority Order Clarity (src/core/file/fileSearch.ts:295-309): The current implementation adds ignore files but doesn't clearly reflect the documented priority order. While globby may treat all ignoreFiles equally by merging their patterns, the code should be reordered for clarity to match the documentation.

Low Priority - Enhanced Documentation: Consider clarifying what happens when patterns conflict across different ignore files.

Low Priority - Test Coverage: Consider adding integration tests for conflicting patterns across multiple ignore files.

Premortem Analysis

  1. Priority Order Confusion: Users may not understand precedence. Mitigation: Clarify in documentation with examples.
  2. Breaking Change: Some users might have .ignore files they don't want repomix to respect. Mitigation: Already handled via --no-dot-ignore flag.
  3. Performance Impact: Negligible - using globby's built-in ignoreFiles option is efficient.
  4. Cross-Platform: Already handled by existing parseIgnoreContent function.

Recommendations

Before Merge:

  1. Verify globby behavior regarding ignoreFiles order
  2. Add comment documenting the priority behavior in getIgnoreFilePatterns function

Future Enhancements:

  1. Add debug logging showing which patterns came from which ignore file
  2. Consider integration tests with actual file scenarios

Overall Assessment

Verdict: Approve with minor suggestions

This is a well-implemented feature that adds real value. The code quality is good, tests are comprehensive, and documentation is thorough. The priority order issue is primarily about code clarity rather than a functional bug.

The feature successfully achieves the goal stated in issue 937: allowing users to maintain a single .ignore file across multiple tools.

Great work!

Updated English and Japanese documentation to include:
- ignore.useDotIgnore configuration option
- --no-dot-ignore CLI flag
- .ignore file explanation and priority order
- Benefits of using .ignore file with ripgrep and ag tools

Other languages will be updated separately to maintain consistency
across all locales.
@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Code Review Summary

This PR successfully adds .ignore file support to Repomix, which is a valuable feature for users of tools like ripgrep and the silver searcher. The implementation is mostly well-structured with proper configuration options, CLI flags, comprehensive tests, and documentation updates.

However, I've identified one critical issue that needs to be addressed before merging.


Critical Issue: Ignore File Priority Order Mismatch

The implementation order in src/core/file/fileSearch.ts does not match the documented priority order in the README and documentation.

Documented Priority (README.md:1339-1343):

  1. Custom patterns
  2. .repomixignore
  3. .ignore
  4. .gitignore
  5. Default patterns

Actual Implementation (fileSearch.ts:298-306):
The getIgnoreFilePatterns function adds files in this order: .gitignore → .ignore → .repomixignore

This is backwards from the documented priority.

Impact:

  • User Expectations: Users expect .repomixignore to override .ignore, which should override .gitignore
  • Tests verify the incorrect order
  • Breaks documented behavior

Action Required: Please verify how globby processes the ignoreFiles array order and ensure the implementation matches the documented priority. The order in the array matters for pattern precedence.


Positive Aspects

Code Quality:

  • Consistent pattern following existing useGitignore implementation
  • Proper TypeScript types throughout
  • Good test coverage with new test cases
  • Backward compatible

Documentation:

  • Thorough README updates across multiple sections
  • Multi-language support (EN/JA)
  • JSON schemas updated (versioned and latest)
  • CLI help text updated

Premortem Analysis

Potential Failure Scenarios:

  1. Priority Order Confusion (Critical)

    • Risk: .repomixignore patterns might not override .ignore patterns as expected
    • Mitigation: Fix implementation order
  2. Performance Impact (Low risk)

    • Risk: Additional ignore file could impact performance on large repos
    • Mitigation: Already configurable via --no-dot-ignore
  3. Nested .ignore Files (Medium risk)

    • Risk: Users might expect nested .ignore files to work
    • Current: Pattern **/.ignore should handle this
    • Mitigation: Already handled correctly
  4. Pattern Conflicts (Medium risk)

    • Risk: Conflicts between .gitignore and .ignore might confuse users
    • Mitigation: Clear priority documentation (already provided)

Minor Suggestions

  1. Add trace logging when .ignore patterns are loaded
  2. Consider integration test with actual .ignore files
  3. Add concrete .ignore file example in README

Checklist Before Merge

  • Critical: Verify and fix ignore file priority order
  • Critical: Update test expectations if order changes
  • Verify tests pass: npm run test
  • Verify linting passes: npm run lint

Conclusion

This is a well-implemented feature that addresses a real user need (issue #937). The code follows project conventions and has good coverage. The only blocker is resolving the priority order discrepancy.

Once the critical issue is addressed, this PR will be ready to merge. Great work! 👍

}

if (config.ignore.useDotIgnore) {
ignoreFilePatterns.push('**/.ignore');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Critical: Verify priority order matches documentation

The array order here determines how globby processes ignore files. Please verify that this order matches the documented priority in README.md:

Documented priority (highest to lowest):

  1. .repomixignore
  2. .ignore
  3. .gitignore

Current implementation adds:

  1. .gitignore (if enabled)
  2. .ignore (if enabled) ← this line
  3. .repomixignore

If globby processes ignoreFiles such that later entries override earlier ones, then .repomixignore being last is correct. However, if earlier entries take precedence, this order needs to be reversed.

Please verify and add a comment explaining the order, e.g.:

// Order matters: globby processes these files in order,
// with later files overriding earlier ones

Updated documentation for all supported languages to include:
- ignore.useDotIgnore configuration option
- --no-dot-ignore CLI flag
- .ignore file explanation and priority order
- Benefits of using .ignore file with ripgrep and ag tools

Also updated test files to include useDotIgnore in mock configs
to satisfy TypeScript type checking after adding the new
configuration option.

Languages updated:
- zh-cn (Simplified Chinese)
- zh-tw (Traditional Chinese)
- ko (Korean)
- vi (Vietnamese)
- id (Indonesian)
- hi (Hindi)
- fr (French)
- de (German)
- es (Spanish)
- pt-br (Brazilian Portuguese)
Added explanatory comment in getIgnoreFilePatterns function to document that files added later in the array have higher priority, following the behavior of tools like ripgrep and fd.
@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Code Review - PR #938: Add .ignore file support

I've completed a thorough review of this PR. The implementation is well-structured and follows best practices, with comprehensive test coverage and documentation updates across all languages. Below is my feedback focusing on areas not already covered by other reviewers.


Strengths

1. Excellent Implementation Quality
  • Clean architecture: The feature follows the existing pattern for gitignore handling, making it intuitive and maintainable
  • Proper dependency injection: Configuration flows correctly from CLI → config schema → core logic
  • Type safety: All TypeScript types are properly updated, including test mock configs
  • Comprehensive documentation: All 11 supported languages have been updated with clear, consistent messaging
  • Backward compatibility: Default value true ensures existing workflows continue working seamlessly
2. Strong Test Coverage

The test suite covers:

  • ✅ Basic functionality (when useDotIgnore is true/false)
  • ✅ Integration with other ignore settings (useGitignore)
  • ✅ File pattern generation
  • ✅ CLI option handling
  • ✅ Config schema validation with defaults

All test mock configs have been properly updated to include useDotIgnore: true.

3. Clear User Communication

Documentation clearly explains:

  • The purpose (compatibility with ripgrep/ag)
  • The benefit (single ignore file across tools)
  • Configuration options (both config file and CLI flag)
  • Priority order (showing where .ignore fits)

🔍 Areas for Improvement

1. Missing Integration Test Coverage (Medium Priority)

Details

While unit tests are comprehensive, there's no integration test demonstrating the actual .ignore file being read and respected during file search.

Suggestion: Add an integration test in tests/integration-tests/ that:

  1. Creates a temporary directory with a .ignore file
  2. Runs the packager
  3. Verifies files matching .ignore patterns are excluded

This would catch issues like:

  • File parsing problems
  • Priority order bugs
  • Edge cases with special characters or complex patterns

Example structure:

test('should respect .ignore file patterns', async () => {
  // Create temp dir with .ignore file containing "*.log"
  // Create test.log and test.js files
  // Run pack
  // Verify test.log is excluded, test.js is included
});

2. Documentation: Priority Order Clarity (Low Priority)

Details

The documented priority order states:

  1. Custom patterns
  2. .repomixignore
  3. .ignore
  4. .gitignore
  5. Default patterns

However, in fileSearch.ts:295-308, the getIgnoreFilePatterns function adds patterns in order: .gitignore, .ignore, .repomixignore.

While globby likely processes these in reverse order (last wins), this could be confusing for future maintainers.

Suggestion: Add a code comment in getIgnoreFilePatterns explaining that globby processes these in reverse order, so the last file added has highest priority:

export const getIgnoreFilePatterns = async (config: RepomixConfigMerged): Promise<string[]> => {
  const ignoreFilePatterns: string[] = [];
  
  // Note: These are added in reverse priority order because globby processes
  // them last-to-first, giving later files higher precedence
  if (config.ignore.useGitignore) {
    ignoreFilePatterns.push('**/.gitignore');  // Lowest priority
  }
  
  if (config.ignore.useDotIgnore) {
    ignoreFilePatterns.push('**/.ignore');     // Medium priority
  }
  
  ignoreFilePatterns.push('**/.repomixignore'); // Highest priority
  
  return ignoreFilePatterns;
};

3. Edge Case: Both --no-gitignore and --no-dot-ignore (Low Priority)

Details

When a user runs:

repomix --no-gitignore --no-dot-ignore --no-default-patterns

Only .repomixignore and custom patterns would be used. While this is technically correct behavior, it might be surprising for users.

Suggestion: Consider adding a warning in the CLI output when all ignore sources are disabled, letting users know they may be including sensitive files. This could be added in defaultAction.ts after config building.


🚨 Premortem Analysis: Potential Failure Scenarios

Scenario 1: Conflicting Patterns Between .gitignore and .ignore

Risk: Users might have !important.log in .ignore (negation pattern to include) but *.log in .gitignore.

Current Behavior: Due to priority order, .ignore patterns should override .gitignore.

Mitigation: ✅ Already handled by priority system. Could be mentioned in docs as a feature.

Scenario 2: Performance with Large .ignore Files

Risk: Some projects might have very large .ignore files (hundreds of patterns).

Current Behavior: globby handles this efficiently, same as .gitignore.

Mitigation: ✅ No action needed - existing architecture handles this well.

Scenario 3: .ignore File with Invalid Syntax

Risk: Malformed patterns in .ignore could cause unexpected behavior.

Current Behavior: globby/minimatch will likely ignore invalid patterns or throw errors.

Mitigation: Consider wrapping the file reading with better error handling and logging in future iterations. Not critical for this PR.

Scenario 4: Migration from .gitignore-only Setup

Risk: Users upgrading might be confused if they have an old .ignore file from another tool that excludes too much.

Current Behavior: .ignore is enabled by default, so it will be used immediately.

Mitigation: ✅ Release notes should mention this. The --no-dot-ignore flag provides an escape hatch. Consider mentioning this in the upgrade guide or changelog.


📊 Performance Considerations

Details

Impact: ✅ Negligible

  • Reading one additional ignore file per directory is minimal overhead
  • Pattern matching performance is identical to existing .gitignore handling
  • No new I/O operations beyond the file reads
  • globby efficiently handles multiple ignore file sources

Conclusion: No performance concerns.


🔒 Security Considerations

Details

Impact: ✅ Positive

  • Helps users exclude sensitive files more consistently across tools
  • No new attack surface introduced
  • File reading uses existing secure patterns
  • Pattern injection not a concern (patterns are treated as literals by minimatch)

Conclusion: This feature enhances security by enabling better file exclusion practices.


Final Recommendations

  1. ✅ Approve with suggestions: The PR is ready to merge. The suggestions above are nice-to-haves for follow-up.

  2. Consider for follow-up PR:

    • Add integration test for .ignore file handling
    • Add code comments clarifying priority order in getIgnoreFilePatterns
    • Mention .ignore file upgrade consideration in changelog/release notes
  3. Changelog Entry Suggestion:

    ### Added
    - Support for `.ignore` files (compatible with ripgrep and the silver searcher)
    - New `ignore.useDotIgnore` configuration option (default: `true`)
    - New `--no-dot-ignore` CLI flag to disable `.ignore` file usage
    
    ### Changed
    - Ignore file priority order updated to: Custom patterns > .repomixignore > .ignore > .gitignore > Default patterns
    
    ### Notes
    - If you have an existing `.ignore` file in your project, it will now be respected by default. Use `--no-dot-ignore` or set `ignore.useDotIgnore: false` to disable.

🎯 Summary

Overall Assessment: ⭐⭐⭐⭐⭐ Excellent work!

This is a high-quality implementation that:

The suggestions above are minor improvements that could be addressed in follow-up work. The PR is ready to merge as-is.

Great job @yamadashy! 🎉

@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Code Review Summary

I've completed a thorough review of this PR. Overall, this is a well-implemented feature that adds .ignore file support in a clean, backward-compatible way. The implementation follows established patterns in the codebase and includes comprehensive test coverage.

✅ Strengths

  1. Excellent backward compatibility - Default value of true ensures existing workflows continue unchanged
  2. Consistent implementation pattern - Mirrors the existing useGitignore pattern perfectly
  3. Comprehensive test coverage - All new functionality is properly tested
  4. Complete documentation - Multi-language docs, README, and schema updates
  5. Follows project conventions - Matches CLAUDE.md guidelines for code structure and commit messages

🔍 Key Review Findings

1. Priority Order Documentation vs Implementation Mismatch

Issue: There's a discrepancy between the documented priority order and the actual implementation.

Documentation says (README.md, line 1340-1342):

1. Custom patterns
2. .repomixignore
3. .ignore
4. .gitignore
5. Default patterns

Implementation does (src/core/file/fileSearch.ts:295-313):

// Comment says: Priority order (low to high): .gitignore -> .ignore -> .repomixignore
// Array order: [.gitignore, .ignore, .repomixignore]

Analysis: The code comment at line 298-301 correctly explains that "files added later in the array have higher priority." This means the actual priority is:

  • .gitignore (lowest)
  • .ignore (middle)
  • .repomixignore (highest)

This contradicts the README documentation which states .repomixignore should come before .ignore.

Impact: This could cause unexpected behavior where .ignore patterns override .repomixignore patterns, which is counter-intuitive since .repomixignore is tool-specific and should have the highest priority.

Recommendation: Either:

  • Fix the implementation to match docs: ['.ignore', '.gitignore', '.repomixignore']
  • Fix the docs to match implementation (less desirable)

I believe the documentation intent is correct - tool-specific files should have priority over general-purpose files.

2. Missing Integration Test

Observation: While unit tests are comprehensive, there's no integration test demonstrating actual .ignore file behavior in a real directory structure.

Suggestion: Consider adding a test in tests/integration-tests/ that:

  1. Creates a temporary directory with actual .ignore, .gitignore, and .repomixignore files
  2. Verifies correct priority/override behavior
  3. Tests the --no-dot-ignore flag end-to-end

This would catch issues like the priority order problem mentioned above.

3. Schema Version Consideration

Question: The schema files updated are:

  • website/client/src/public/schemas/1.8.0/schema.json
  • website/client/src/public/schemas/latest/schema.json

Should this change introduce a new schema version (e.g., 1.9.0) since it adds a new configuration field? This depends on your versioning policy for schemas.

🎯 Premortem Analysis: Potential Failure Scenarios

Click to expand
  1. Conflicting ignore patterns 🔴 HIGH RISK

    • Scenario: User has conflicting patterns in .ignore and .repomixignore
    • Current behavior: Due to priority issue, .ignore may override .repomixignore unexpectedly
    • Mitigation: Fix priority order as mentioned above
  2. Performance with large .ignore files 🟡 MEDIUM RISK

    • Scenario: Projects with very large .ignore files (thousands of patterns)
    • Current behavior: All patterns loaded into memory
    • Mitigation: Already handled by existing globby implementation; no additional risk
  3. Migration confusion 🟡 MEDIUM RISK

    • Scenario: Users upgrading don't realize .ignore is now auto-detected
    • Current behavior: .ignore files are silently activated
    • Mitigation: Consider adding to migration guide or changelog release notes
  4. Cross-platform .ignore differences 🟢 LOW RISK

    • Scenario: .ignore files with platform-specific patterns
    • Current behavior: Same as .gitignore handling
    • Mitigation: Already handled by underlying glob library
  5. .ignore in subdirectories 🟢 LOW RISK

    • Scenario: Multiple .ignore files in nested directories
    • Current behavior: Pattern **/.ignore will match all of them
    • Mitigation: This matches ripgrep behavior; working as intended

📝 Minor Observations

  1. CLI option consistency: The --no-dot-ignore flag follows the established pattern perfectly ✅
  2. Type safety: All TypeScript types properly updated ✅
  3. Error handling: No new error scenarios introduced ✅
  4. Dependency injection: Properly maintained for testability ✅

🚀 Recommendations

Must address before merge:

  • Fix priority order - Decide whether implementation or documentation is correct, then fix the mismatch

Nice to have:

  • Add integration test demonstrating actual file exclusion
  • Clarify in PR description whether schema versioning is needed
  • Consider adding a note in release notes about automatic .ignore detection

Overall Assessment: This is high-quality work that's almost ready to merge. The priority order issue needs resolution, but otherwise the implementation is solid. Great job maintaining consistency with existing patterns! 👍

@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Correction to Previous Review

I apologize for the confusion in my previous comment. After re-reading the code more carefully, I need to correct my analysis:

✅ Priority Order is Actually Correct!

The implementation in src/core/file/fileSearch.ts is correct and matches the documentation.

How it works:

  • The code comment (line 298-301) states: "Files added later in the array have higher priority"
  • Array order: [.gitignore, .ignore, .repomixignore]
  • This gives priority (low to high): .gitignore.ignore.repomixignore

Documentation states (README line 1340-1342):

  1. Custom patterns (highest)
  2. .repomixignore
  3. .ignore
  4. .gitignore
  5. Default patterns (lowest)

Wait, there IS still a mismatch!

According to the docs, the order should be:

  • .repomixignore (priority 2)
  • .ignore (priority 3)
  • .gitignore (priority 4)

But the code gives:

  • .repomixignore (highest of the three) ✅
  • .ignore (middle) ✅
  • .gitignore (lowest) ✅

Actually, the numbering in the docs can be confusing. Let me clarify:

  • Lower numbers = HIGHER priority in the docs
  • Later in array = HIGHER priority in the code

So:

The implementation IS correct! ✅

Please disregard my previous concern about the priority order - there is no bug here. My apologies for the confusion!

The PR is well-implemented and ready to merge after addressing the minor suggestions (integration tests, schema versioning clarification).

@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Final Review Summary - Corrected Analysis ✅

After careful review and re-analysis, I can confirm this PR is well-implemented and ready to merge.

Priority Order Analysis - RESOLVED ✅

I initially flagged a potential priority mismatch, but after deeper analysis, the implementation is correct:

Code behavior (src/core/file/fileSearch.ts:295-313):

  • Array: [.gitignore, .ignore, .repomixignore]
  • Per globby/fast-glob: Files later in the ignoreFiles array have higher precedence
  • Effective priority: .repomixignore > .ignore > .gitignore

Documentation (README:1340-1342):

  • Lists in descending priority order (1=highest, 5=lowest)
  • Priority: Custom (1) > .repomixignore (2) > .ignore (3) > .gitignore (4) > Default (5) ✅

Conclusion: Documentation and implementation are aligned. The tool-specific .repomixignore correctly overrides the general-purpose .ignore file, which in turn overrides .gitignore. This is the expected and desired behavior.

Security Review ✅

  • No security vulnerabilities introduced
  • Pattern matching delegated to well-tested globby library
  • No new file system operations that could cause path traversal issues
  • Secretlint integration unaffected

Performance Review ✅

  • Minimal performance impact (one additional file pattern check)
  • Consistent with existing .gitignore and .repomixignore handling
  • No additional I/O operations beyond what's already done

Test Coverage ✅

  • Unit tests comprehensive
  • All edge cases covered (flag enabled/disabled combinations)
  • Mock configurations properly updated across test suite

Suggestions for Future Enhancement (Optional)

  1. Integration test: Add a test with actual .ignore file to verify end-to-end behavior
  2. Release notes: Mention automatic .ignore detection in upgrade notes so users are aware
  3. Examples: Consider adding example .ignore file to documentation

Recommendation: ✅ APPROVE AND MERGE

This is clean, well-tested code that follows project conventions perfectly. The feature addresses issue #937 completely and maintains full backward compatibility.

Great work @yamadashy! 🎉

Corrected the comment in getIgnoreFilePatterns to accurately reflect how globby's ignoreFiles option works:
- Priority is determined by directory hierarchy (deeper directories have higher priority)
- Multiple ignore files in the same directory are merged together
- The order in the ignoreFiles array does not affect priority

This fixes the misleading comment that suggested array order determines priority, when in fact globby uses fast-glob to find all matching files and merges them regardless of the array order.
@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Code Review - PR #938: Add .ignore file support

Summary

This PR successfully adds support for .ignore files to Repomix, providing compatibility with tools like ripgrep and the silver searcher. The implementation is clean, well-tested, and follows the project's coding conventions.

✅ Strengths

Implementation Quality
  1. Excellent consistency: The implementation mirrors the existing --no-gitignore pattern perfectly (src/cli/actions/defaultAction.ts:126-133)
  2. Proper configuration architecture: New useDotIgnore field correctly added to schema with true default (src/config/configSchema.ts:59, 115)
  3. Clean integration: The .ignore file is properly integrated into globby's ignoreFiles array alongside existing ignore files (src/core/file/fileSearch.ts:309-311)
  4. Comprehensive test coverage: Tests cover all configuration combinations and edge cases (tests/core/file/fileSearch.test.ts:56-96)
  5. Documentation excellence: README, CLI help, and website docs all updated consistently across multiple languages
Best Practices Followed
  • ✅ Follows Conventional Commits specification
  • ✅ Maintains backward compatibility (opt-out via --no-dot-ignore)
  • ✅ Consistent with existing useGitignore implementation
  • ✅ All tests pass (verified in PR description)
  • ✅ Proper dependency injection pattern maintained
  • ✅ Type safety preserved throughout

🔍 Code Analysis

Priority Order Verification (src/core/file/fileSearch.ts:295-316)
The implementation correctly handles ignore file priority. While .repomixignore is always added last to the array, the actual priority is determined by globby/directory depth, not array order. The inline comment at line 298-303 correctly explains this behavior.

CLI Integration (src/cli/actions/defaultAction.ts:130-133)
The dotIgnore option correctly follows the Commander.js negation pattern - only applying when explicitly false to allow config file values to take precedence.

🎯 Premortem Analysis

Potential Failure Scenarios & Mitigations

1. User Confusion: Ignore File Priority

Risk: Users may not understand how .ignore, .gitignore, and .repomixignore interact
Likelihood: Medium
Mitigation:

  • ✅ Already addressed: README clearly documents priority order (lines 1338-1343)
  • ✅ Good inline comments explaining globby behavior (fileSearch.ts:298-303)
  • 💡 Suggestion: Consider adding a note about nested directory behavior to the config documentation

2. Migration Impact: Existing .ignore Files

Risk: Users who already have .ignore files (for ripgrep) might unexpectedly exclude files from Repomix output
Likelihood: Low-Medium
Impact: Medium (files unexpectedly excluded)
Mitigation:

  • ✅ Feature defaults to true, maintaining consistency with tool expectations
  • ✅ Easy opt-out via --no-dot-ignore or config
  • 💡 Suggestion: Consider mentioning this in release notes as a "what's new" item

3. Performance: Multiple Ignore File Processing

Risk: Reading three ignore files instead of two could impact performance
Likelihood: Low
Impact: Negligible (globby handles this efficiently)
Mitigation: Already optimal - globby processes these concurrently

4. Edge Case: Conflicting Patterns

Risk: .ignore and .gitignore have conflicting patterns (one includes, other excludes)
Likelihood: Low
Impact: Low (patterns are merged, most restrictive wins)
Mitigation:

  • ✅ Globby's default behavior handles this correctly
  • ✅ Documentation explains priority order

5. Integration Risk: MCP Server

Risk: MCP server documentation needs .ignore references
Likelihood: High
Impact: Low (documentation inconsistency)
Mitigation: ✅ Already addressed in README lines 937, 955

🚀 Suggestions for Enhancement

Non-blocking improvements
  1. Integration Test: Consider adding an integration test that verifies .ignore files actually exclude files during packing (similar to existing gitignore tests)

  2. Schema Validation: The JSON schemas are correctly updated, but consider adding a schema version bump to track this feature addition

  3. Performance Monitoring: Since this adds another file to read, consider adding a trace log for .ignore file reading time (similar to other ignore files)

🔒 Security Assessment

  • ✅ No security concerns identified
  • ✅ Pattern parsing uses existing parseIgnoreContent function (well-tested)
  • ✅ No new attack surface introduced
  • ✅ Follows same security model as .gitignore

📊 Performance Considerations

  • ✅ Minimal performance impact (one additional file read, processed in parallel)
  • ✅ Globby efficiently handles multiple ignore files
  • ✅ No algorithmic complexity changes

✅ Final Verdict

This is a high-quality PR that:

  • Implements a useful feature with clear user value
  • Maintains excellent code quality and consistency
  • Includes comprehensive test coverage
  • Provides thorough documentation
  • Follows all project conventions

Recommendation: ✅ Approve and merge after addressing any inline comments from other reviewers.

The implementation is production-ready and the premortem analysis reveals only minor, low-probability risks that are already well-mitigated.


Great work on this feature! The consistency with existing patterns and attention to documentation detail is exemplary. 🎉

Updated priority order documentation in README.md and all website configuration guides (12 languages) to accurately reflect how globby handles ignore files:

- Merged items 2-4 into a single "Ignore files" category
- Clarified that directory hierarchy determines priority (deeper directories win)
- Explained that files in the same directory are merged in no particular order
- This reflects globby's actual behavior where fast-glob returns files in filesystem order

The previous documentation incorrectly implied a fixed priority order between .repomixignore, .ignore, and .gitignore files, when in fact they are all merged together at the same level with priority determined by directory depth only.
@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Code Review Summary

I've reviewed this PR and overall it's a solid implementation that adds .ignore file support to Repomix. The feature is well-implemented with good test coverage and comprehensive documentation across all supported languages.

However, I've identified some important issues that should be addressed before merging, particularly around test coverage completeness and potential edge cases.


Critical Issues

1. Incomplete Test Coverage for useDotIgnore Property

Several test files are missing the useDotIgnore property in their mock configurations. While these tests may still pass due to default values, this creates implicit dependencies on defaults and makes the tests less maintainable.

Files affected:

  • tests/core/file/fileSearch.test.ts (lines 150-155, 164-170, 177-184, 193-200, 264-271, 293-300)

Risk: If the default value for useDotIgnore changes in the future, these tests won't explicitly verify the intended behavior.

Recommendation: Add useDotIgnore: true explicitly to all mock configs in test files for consistency and clarity.


Code Quality Observations

Positive Aspects ✅

  1. Excellent commit history: Clear, descriptive commit messages following Conventional Commits format
  2. Comprehensive documentation: Updated across 12 languages, showing attention to detail
  3. Well-structured implementation: Follows existing patterns for similar features
  4. Good test coverage: Added specific tests for the new .ignore file functionality
  5. Backward compatibility: Feature is opt-in by default, won't break existing workflows
  6. Clear code comments: Added helpful documentation explaining ignore file priority order

Areas for Improvement 🔧

  1. Test consistency: Some tests don't explicitly set useDotIgnore
  2. Test for ignore file priority: Consider adding an integration test verifying actual priority order when multiple ignore files exist
  3. Missing test scenario: No test verifying behavior when useGitignore: false AND useDotIgnore: false (both disabled)

Security & Performance

No security concerns identified
No significant performance concerns - negligible performance impact


Recommendations

Must Fix Before Merge 🔴

  1. Add useDotIgnore property explicitly to all test mock configs for consistency

Should Consider 🟡

  1. Add integration test for nested .ignore file priority behavior
  2. Add test for combined flag usage (--no-gitignore --no-dot-ignore)
  3. Add test for edge case when both useGitignore and useDotIgnore are false

Nice to Have 🟢

  1. Add example .ignore file to the repository demonstrating recommended usage

Conclusion

This is a well-implemented feature that adds genuine value. The code quality is high, and the documentation is excellent. With the minor test improvements suggested above, this will be ready to merge.

Estimated Risk Level: Low
Recommendation: Approve with minor changes

Great work @yamadashy! 🎉

@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Premortem Analysis: Potential Failure Scenarios

As requested, here's a detailed analysis of potential failure scenarios and suggested mitigations:

1. Conflicting Patterns Across Ignore Files

Scenario: User has contradictory patterns in .ignore, .gitignore, and .repomixignore in the same directory

Example:

  • .gitignore contains: build/
  • .ignore contains: !build/important.js
  • .repomixignore contains: build/temp/

Risk: Unexpected file inclusion/exclusion due to pattern merging behavior

Likelihood: Medium - users transitioning from other tools may have different patterns

Mitigation:

  • ✅ Already addressed: Documentation clearly explains that files in same directory are merged with no particular order
  • 📝 Consider: Add a warning in docs about potential conflicts and suggest using .repomixignore for Repomix-specific overrides
  • 📝 Consider: Add troubleshooting section to docs showing how to debug which files are being excluded
2. Migration Confusion for Existing Users

Scenario: Users who already have .ignore files for other tools may be surprised by Repomix suddenly respecting them after upgrade

Example: A user has .ignore file for ripgrep that excludes test files. After upgrading Repomix, their test files are suddenly not included in the pack, breaking their workflow.

Risk: Files that were previously included may now be excluded, potentially breaking automated workflows

Likelihood: Medium-High for repos already using .ignore files

Mitigation:

  • ✅ Already addressed: Feature is enabled by default (follows principle of least surprise for users of ripgrep/ag)
  • ✅ Already addressed: Can be disabled via --no-dot-ignore flag
  • 📝 Must do: Mention in release notes that this may change behavior for repos with existing .ignore files
  • 📝 Consider: Add migration guide showing how to audit what's being excluded
  • 📝 Consider: Log info message on first run if .ignore file is found
3. Nested Directory Priority Complexity

Scenario: Deep directory structure with multiple .ignore files at different levels

Risk: Users may not understand which patterns take precedence, leading to confusion about why files are excluded

Likelihood: Low-Medium - most projects don't have deeply nested ignore files

Mitigation:

  • ✅ Already addressed: Clear documentation about deeper directories having higher priority
  • ⚠️ Missing: No integration test verifying this nested behavior works correctly
  • 📝 Recommendation: Add integration test with nested .ignore files to verify priority order
  • 📝 Consider: Add debug flag that shows which ignore file excluded each file
4. CLI Flag Interaction Edge Cases

Scenario: User specifies --no-gitignore and --no-dot-ignore but has .repomixignore

Risk: Unclear whether all ignore files are disabled or just specific ones

Likelihood: Low - most users use defaults

Mitigation:

  • ✅ Already addressed: Each flag controls its specific ignore file independently
  • ✅ Tests verify individual flags work correctly
  • ⚠️ Missing: Test verifying behavior when multiple flags are combined
  • 📝 Recommendation: Add test for --no-gitignore --no-dot-ignore combination
5. Deployment/CI Pipeline Impact

Scenario: CI/CD pipeline relies on specific files being included in Repomix output. After upgrade, .ignore file causes those files to be excluded.

Risk: Automated pipelines break after Repomix upgrade

Likelihood: Low - but high impact if it occurs

Mitigation:

  • ✅ Can be disabled via config or CLI flag
  • 📝 Must do: Clearly document this as a breaking change in release notes
  • 📝 Consider: Pin configuration in CI: ignore.useDotIgnore: false if needed

Summary of Action Items

Critical (Must Address)

  1. Add migration notes to release documentation
  2. Fix incomplete test coverage for useDotIgnore property

High Priority (Should Address)

  1. Add integration test for nested .ignore file behavior
  2. Add test for combined flag usage
  3. Document pattern syntax compatibility

Medium Priority (Nice to Have)

  1. Add debug/verbose logging showing which ignore file excluded each file
  2. Add troubleshooting guide for debugging exclusions
  3. Add example .ignore file to repository

Overall Risk Assessment: Low-Medium

The implementation is solid and follows good patterns. The main risks are around user migration and documentation. With proper release notes and the suggested test improvements, the risk becomes very low.

@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Detailed Code Review: File-by-File Analysis

src/core/file/fileSearch.ts:295-316

✅ Excellent implementation

The code follows the existing pattern perfectly and includes helpful comments explaining the priority behavior. The comment on lines 298-303 is particularly valuable for future maintainers.

Minor suggestion: Consider adding a code example in the comment showing actual file paths to make it even clearer:

// Example: src/.ignore patterns override ./.ignore patterns
//   ./.ignore: *.log (applies to root)
//   ./src/.ignore: !important.log (overrides for src/, allows important.log)

src/cli/actions/defaultAction.ts:130-133

✅ Consistent with existing patterns

The implementation correctly mirrors the gitignore flag handling. Good use of explicit false check to avoid overriding with undefined.

No issues found.


src/config/configSchema.ts:59,115

✅ Proper schema definition

The useDotIgnore property is correctly added to both the base schema (optional) and default schema (with default value true).

No issues found.


tests/core/file/fileSearch.test.ts

⚠️ Needs improvement

While the PR adds good test coverage for the new .ignore functionality (lines 56-96), several existing tests were not updated to include the new useDotIgnore property in their mock configs.

Tests missing useDotIgnore:

  • Line 150-155: "should return default patterns when useDefaultPatterns is true"
  • Line 164-170: "should include custom patterns"
  • Line 177-184: "should combine default and custom patterns"
  • Line 193-200: "should include patterns from .git/info/exclude when useGitignore is true"
  • Line 264-271: "should call globby with correct parameters"
  • Line 293-300: "Honor .gitignore files in subdirectories"

Impact: These tests will pass because useDotIgnore defaults to true, but they're relying on implicit behavior rather than explicit configuration. This makes the tests fragile and harder to understand.

Recommendation: Add useDotIgnore: true explicitly to all mock configs for consistency and maintainability.


README.md & Documentation Files

✅ Excellent documentation coverage

The documentation has been comprehensively updated across:

  • English, Japanese, Chinese (Simplified & Traditional), Korean, Vietnamese, Indonesian, Hindi, French, German, Spanish, Portuguese

Particularly good:

  • Clear explanation of priority order (lines 1339-1343 in README.md)
  • Explanation that files in same directory are merged with no particular order
  • CLI flag documentation is clear and consistent

Minor suggestions:

  1. Consider adding a "Migration Guide" section for users upgrading from previous versions
  2. Add troubleshooting section: "If files are unexpectedly excluded, check your .ignore file"

Schema Files (website/client/src/public/schemas/)

✅ Correctly updated

Both latest and version-specific (1.8.0) schema files have been updated with the useDotIgnore property.

No issues found.


Code Style & Best Practices Compliance

✅ Follows CLAUDE.md Guidelines

  1. Commit messages: Perfect adherence to Conventional Commits format
  2. File size: All modified files remain well under 250 lines
  3. Comments: Comments are in English and add value
  4. Testing: Tests provided for new features
  5. Dependencies: Proper dependency injection pattern maintained

✅ TypeScript Best Practices

  1. Type safety maintained throughout
  2. Proper use of optional properties
  3. Zod schema validation correctly configured

✅ Airbnb Style Guide Compliance

No style violations detected in the implementation.


Test Coverage Analysis

Coverage added:

  • ✅ Test for .ignore file inclusion when useDotIgnore is true
  • ✅ Test for .ignore file exclusion when useDotIgnore is false
  • ✅ Test verifying correct file patterns returned

Coverage gaps:

  • ⚠️ No integration test for nested .ignore files in subdirectories
  • ⚠️ No test for combined flags (--no-gitignore --no-dot-ignore)
  • ⚠️ No test for edge case: both useGitignore and useDotIgnore set to false
  • ⚠️ Existing tests not explicitly setting useDotIgnore property

Performance Analysis

Impact: Negligible

The changes add:

  • 1 boolean check: if (config.ignore.useDotIgnore)
  • 1 array push operation: ignoreFilePatterns.push('**/.ignore')

These operations are O(1) and occur once per run during initialization. No performance concerns.


Conclusion

This is a high-quality implementation that demonstrates good engineering practices. The main area for improvement is test coverage completeness. Once the test coverage gaps are addressed, this PR will be in excellent shape for merging.

Recommendation: Approve with minor test improvements

Added unit tests for buildCliConfig function to cover --no-gitignore,
--no-dot-ignore, and --no-default-patterns flags. These tests ensure
proper handling of ignore configuration options and improve test coverage
to meet the 80% threshold.

This addresses the Codecov coverage gap where src/cli/actions/defaultAction.ts
lines 131-132 were not covered by tests.
@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Code Review Summary

I've reviewed PR #938 which adds .ignore file support to Repomix. The implementation is well-structured and follows the project's conventions. Below is my incremental feedback focusing on areas not covered by previous reviewers.

Strengths

  1. Excellent backward compatibility: The default useDotIgnore: true ensures existing workflows aren't disrupted while providing new functionality
  2. Consistent CLI patterns: The --no-dot-ignore flag follows the established pattern of --no-gitignore and --no-default-patterns
  3. Comprehensive test coverage: Tests cover all combinations of the new flag with existing ignore options
  4. Clear documentation: The README and website docs are thoroughly updated with the new feature

🔍 Code Quality Observations

Configuration Schema

The schema changes in src/config/configSchema.ts are minimal and well-integrated:

  • useDotIgnore is properly added to both base and default schemas
  • Default value of true is appropriate for this feature
  • Follows the same pattern as useGitignore

Code reference: src/config/configSchema.ts:59, src/config/configSchema.ts:115

CLI Integration

The CLI handling in src/cli/actions/defaultAction.ts:130-133 correctly implements the Commander.js --no-* flag pattern:

if (options.dotIgnore === false) {
  cliConfig.ignore = { ...cliConfig.ignore, useDotIgnore: options.dotIgnore };
}

This ensures the config file value is respected when the flag isn't used.

Code reference: src/cli/actions/defaultAction.ts:130-133

⚠️ Concerns & Suggestions

1. Ignore File Priority Documentation vs Implementation

I've left an inline comment on src/core/file/fileSearch.ts:313 about .repomixignore always being included without a configuration option. This raises questions about:

  • Whether .repomixignore should be configurable like other ignore files
  • The ordering in the code vs documented priority

2. Premortem Analysis - Potential Failure Scenarios

Edge Cases & Integration Risks

A. Conflicting Patterns Across Multiple Ignore Files

Scenario: User has contradictory patterns in .gitignore, .ignore, and .repomixignore

# .gitignore
!important.log

# .ignore  
*.log

# .repomixignore
# (empty)

Risk: Users may be confused about which file takes precedence when patterns conflict
Mitigation:

  • The current implementation merges all patterns from files in the same directory, which is correct
  • Consider adding a troubleshooting section in docs explaining pattern precedence
  • The comment in fileSearch.ts:298-303 is excellent but only visible in code

B. Performance Impact with Multiple Ignore Files

Scenario: Large monorepo with deeply nested directories, each containing .gitignore, .ignore, and .repomixignore

Risk: Globby must now process 3 ignore files per directory instead of 2 (or 1 with --no-gitignore)
Mitigation:

  • This is likely negligible for most repos
  • Users experiencing performance issues can disable with --no-dot-ignore
  • Consider adding performance notes to docs for very large repositories

C. Migration from ripgrep/ag Workflows

Scenario: Users migrating from ripgrep workflows may have .ignore files with patterns incompatible with globby

Risk: Some advanced glob patterns may behave differently between tools
Mitigation:

  • Document any known pattern differences between ripgrep and globby
  • Consider adding examples in docs showing common .ignore patterns

D. .ignore File Creation Confusion

Scenario: Users create .ignore expecting it to work like .gitignore but with subtle differences

Risk: The .ignore format is the same as .gitignore, but users may not know this
Mitigation: ✅ Already addressed - README clearly states "following the same format as .gitignore"

Deployment & Integration Risks

E. CI/CD Pipeline Impacts

Scenario: CI systems that generate .ignore files dynamically for ripgrep

Risk: These files will now be picked up by Repomix, potentially excluding files unexpectedly
Mitigation:

  • Document that .ignore is enabled by default in migration guide
  • Ensure --no-dot-ignore flag is discoverable in help text ✅ (already done)

F. MCP Server Integration

Scenario: MCP server doesn't expose useDotIgnore config option

Risk: ✅ No risk - Checking the diff, I don't see MCP-specific changes needed as the configuration is already exposed through the standard config schema

3. Test Coverage Analysis

The test coverage is strong, but I notice a few tests weren't updated with useDotIgnore:

Tests missing explicit useDotIgnore setting

Several tests in tests/core/file/fileSearch.test.ts rely on the default value from createMockConfig() rather than explicitly setting useDotIgnore. While this works due to the default, explicit configuration would make tests more maintainable and self-documenting:

  • Line 155: 'should return default patterns when useDefaultPatterns is true'
  • Line 170: 'should include custom patterns'
  • Line 184: 'should combine default and custom patterns'
  • Line 200: 'should include patterns from .git/info/exclude when useGitignore is true'
  • Line 271: 'should call globby with correct parameters'
  • Line 300: 'Honor .gitignore files in subdirectories'

Note: This is a minor style issue - the tests are functionally correct.

🎯 Security Considerations

No new security concerns introduced. The .ignore file handling follows the same secure pattern as .gitignore processing:

  • Files are read from the repository being processed
  • Patterns are parsed identically to .gitignore (using existing parseIgnoreContent())
  • No arbitrary code execution risk

🚀 Performance Considerations

The performance impact should be minimal:

  • One additional glob pattern (**/.ignore) in the ignoreFiles array
  • Existing globby infrastructure handles this efficiently
  • Users can opt-out with --no-dot-ignore if needed

📝 Documentation Quality

The documentation updates are comprehensive:

  • ✅ README updated with feature explanation
  • ✅ CLI help text includes new flag
  • ✅ Configuration table updated
  • ✅ Ignore file priority order clearly documented
  • ✅ Multi-language docs updated (EN, DE, ES)

🎬 Recommendations

  1. Address the inline comment about .repomixignore priority/ordering
  2. Consider adding a troubleshooting section to docs for pattern conflicts across multiple ignore files
  3. Optional: Add an integration test that verifies behavior with all three ignore files present (.gitignore, .ignore, .repomixignore) to demonstrate the merging behavior
  4. Optional: Consider explicitly setting useDotIgnore in all test cases for clarity (not blocking)

Overall Assessment

This is a high-quality PR that adds a useful feature with minimal complexity. The implementation is clean, well-tested, and follows established patterns. The backward compatibility story is excellent with useDotIgnore: true as the default.

Recommendation: Approve after addressing the inline comment about .repomixignore ordering/priority.


Great work on this feature! The consistency with ripgrep and ag workflows will be valuable for users.

@yamadashy yamadashy merged commit 2df5ab7 into main Nov 8, 2025
50 checks passed
@yamadashy yamadashy deleted the feat/ignore branch November 8, 2025 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use .ignore file file content to ignore files.

2 participants