# ignore — card for AI agents

Parse and filter .gitignore rules programmatically, used by ESLint and build tools.

Category: Utilities · npm package `ignore` · latest version 7.0.14 (checked 2026-11-01)
Install: `npm install ignore`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 57.2 (#1151 of all tools, 131 of 406 in its category)
- Used in 27 public projects set up for AI coding agents (0.4%)
- Downloads last week: 434,404,652 (as of 2026-11-17), +14.1% over 4 weeks
- GitHub stars: 508 (as of 2026-11-17)
- Last push: 2026-11-17

## Often used with
Model Context Protocol SDK (JavaScript) 74.1%, Zod 85.2%, Vitest 77.8%, chalk 70.4%, diff 70.4%, Anthropic SDK 66.7%

## Links
- AgentGid page: https://agentgid.com/tools/ignore/
- Homepage: https://github.com/kaelzhang/node-ignore#readme
- Repository: https://github.com/kaelzhang/node-ignore


## ignore: apply .gitignore rules in JavaScript

ignore is a small free JavaScript library that answers one question: would this .gitignore file leave this file out? Tools use it to skip build folders, installed packages and secret files the same way git does. You give it the rules and a list of file paths; it does not look at your disk itself.

### Where to use it
- Skip ignored files when packing: Your tool zips or uploads a project and leaves out what the project's .gitignore already excludes, such as builds and secrets.
- Your own .ignore file for a tool: Your app or script lets people list files to skip in its own ignore file, written the same way as .gitignore, like ESLint does.
- Explain why a file is skipped: Someone asks why a file never shows up; your tool names the exact rule that hides it, as git check-ignore -v does.
- Match git's answers exactly: Your tool and git agree on which files count, so nobody sees a file in one place and not the other.
- Keep secrets away from an AI helper: Before an AI assistant or code indexer reads a project, drop .env files and folders the project already hides. (idea, not from the official pages)

### How to start
- Add the package to your JavaScript project.

```
npm i ignore
```

- Create a checker and add rules, either a list or the whole text of a .gitignore file.

```
ignore()
.add(fs.readFileSync(filenameOfGitignore).toString())
.filter(filenames)
```

- Pass paths relative to the folder of the .gitignore, without a leading ./ or /.

### License
Free to use in any project, including paid and closed-source apps, under the MIT license. Keep its copyright and license notice if you ship its files.

### Good to know
- It only checks names you give it. It does not list folders, find .gitignore files or read git settings.
- Paths must be relative to the folder of the rules. A path starting with ./ or / stops your code with an error.
- It ignores upper and lower case by default, unlike git on Linux. Pass ignorecase: false to match git there.
- It cannot tell a folder from a file. Add a slash to folder names, like config/, or folder rules will not match.
- It is the wrong tool for .npmignore files, which follow different rules.

Checked 2026-11-10 against: https://github.com/kaelzhang/node-ignore/blob/master/README.md, https://github.com/kaelzhang/node-ignore/blob/master/LICENSE-MIT, https://github.com/kaelzhang/node-ignore/blob/master/index.js, https://registry.npmjs.org/ignore, https://registry.npmjs.org/ignore/7.0.14, https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz

### Mistakes to avoid
- Don't: ig.ignores('./src/app.js') or ig.ignores('/src/app.js') → Do: ig.ignores('src/app.js'), using path.relative(rootDir, file) (Since 5.0 such paths throw; our run got: path should be a `path.relative()`d string.)
- Don't: ignore({ allowRelative: true }) (the name the upgrade notes use) → Do: ignore({ allowRelativePaths: true }) (In 7.0.14 the option is allowRelativePaths; in our run allowRelative still threw.)
- Don't: ig.ignores('config') for a folder rule config/ → Do: ig.ignores('config/') with a trailing slash for folders (It never looks at the disk, so a name without a slash counts as a file (our run: false vs true).)
- Don't: Relying on the default on a Linux server → Do: ignore({ ignorecase: false }) or the repository's core.ignorecase value (Default matching ignores case, so *.png also hides Photo.PNG while git on Linux would keep it.)
- Don't: Using minimatch to apply .gitignore rules → Do: Use ignore for .gitignore, minimatch for .npmignore and plain patterns (minimatch does not follow the gitignore rules.)

### Questions
- Can I use it in a paid, closed-source app? Yes. It is MIT-licensed; keep the copyright and license notice with its files.
- Does it work in the browser? Yes. The code checks for Node.js only to handle Windows paths; our demo ran it in a browser page.
- Why does ig.ignores('./src/app.js') throw an error? Since version 5 paths must be relative and clean. Drop the ./ (path.relative() gives the right form).
- Is it exactly the same as git? Almost. The README lists a few known differences, such as letter case and some non-English characters.
- Is it still maintained? Yes. Version 7.0.14 came out on 23 October 2026.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
