# picomatch — card for AI agents

Fast glob pattern matching library for file paths with full Bash glob feature support.

Category: Utilities · npm package `picomatch` · latest version 4.0.7 (checked 2026-11-01)
Install: `npm install picomatch`
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: 62.1 (#862 of all tools, 101 of 408 in its category)
- Used in 20 public projects set up for AI coding agents (0.3%)
- Downloads last week: 743,236,414 (as of 2026-11-24), +38.4% over 4 weeks
- GitHub stars: 1,338 (as of 2026-11-24)
- Last push: 2026-10-08

## Often used with
Zod 90.0%, Vitest 75.0%, yaml 60.0%, Biome 55.0%, Model Context Protocol SDK (JavaScript) 50.0%, esbuild 50.0%

## Checked alternatives (same job)
- glob: https://agentgid.com/tools/glob/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/picomatch/
- Homepage: https://github.com/micromatch/picomatch
- Repository: https://github.com/micromatch/picomatch


## picomatch: check file paths against glob patterns

picomatch is a small free JavaScript library that answers one question: does this file path match a pattern like src/**/*.js? You give it a pattern once and get back a quick yes-or-no check. It only compares names you already have; it does not search your disk.

### Where to use it
- React only to files that matter: A file watcher or build script hears about every changed file; one reused pattern check decides which ones should trigger a rebuild.
- Skip tests and hidden files: A deploy script picks every JavaScript file except tests, and leaves hidden files like .env out unless you ask for them.
- Accept only some upload types: An upload form lets through names ending in png, jpg or webp in any letter case, as a quick first filter before a real file check. (idea, not from the official pages)
- Paths from Windows users: Paths typed on Windows use backslashes; turn on the Windows option so src\ui\button.js is seen as a file inside a folder.
- Find where a pattern starts: Split a pattern like src/**/*.js into the fixed folder (src) and the wildcard part, so your tool only reads the folder it needs.
- Pattern rules in admin settings: Let editors type rules like docs/** or *.pdf in a settings page to decide which stored files are public. (idea, not from the official pages)

### How to start
- Install it into your project.

```
npm install --save picomatch
```

- Make a matcher from a pattern once, then call it on each path.

```
const pm = require('picomatch');
const isMatch = pm('*.js');

console.log(isMatch('abcd')); //=> false
console.log(isMatch('a.js')); //=> true
console.log(isMatch('a.md')); //=> false
console.log(isMatch('a/b.js')); //=> false
```

- Outside Node.js (a browser or an edge worker), load picomatch/posix, which has no operating-system check.

```
const picomatch = require('picomatch/posix');
```


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

### Good to know
- It does not list or read files. To find files on disk, use a tool such as glob or tinyglobby; picomatch only checks names.
- A single * stays inside one folder. To reach files in subfolders, use ** in the pattern.
- Hidden files that start with a dot, like .env, are skipped unless you turn on the dot option.
- Version 4.0.4 fixed a slowdown attack through crafted patterns. Use 4.0.4 or newer if patterns come from users.
- Very long input strings are refused with an error; the default limit is 65,536 characters.

Checked 2026-11-10 against: https://github.com/micromatch/picomatch/blob/master/README.md, https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md, https://github.com/micromatch/picomatch/blob/master/LICENSE, https://github.com/micromatch/picomatch, https://github.com/micromatch/picomatch/releases, https://registry.npmjs.org/picomatch, https://registry.npmjs.org/picomatch/4.0.7

### Mistakes to avoid
- Don't: picomatch('*.js') to find .js files in subfolders → Do: picomatch('**/*.js'), or {basename: true} to match only the file name (A single * stops at a slash; in our run '*.js' gave false for 'a/b.js' and true with basename: true.)
- Don't: Matching Windows paths like 'src\ui\a.js' with picomatch(pattern) and no options → Do: Pass {windows: true}, or turn backslashes into slashes first (Since 3.0 a call without options uses forward slashes only; in our demo the backslash path matched '*.js' as one name and missed 'src/**/*.js'.)
- Don't: Expecting src/** to include src/.env or .github files → Do: Add {dot: true} when hidden files should count (Dotfiles are skipped by default; our demo shows src/.env matched only with dot: true.)
- Don't: Using picomatch to get the list of files in a folder → Do: List files with glob or tinyglobby, then use picomatch to filter names you already have (picomatch never touches the disk.)
- Don't: A lockfile still pinning picomatch below 2.3.2, 3.0.2 or 4.0.4 while users can type patterns → Do: Update to 4.0.7 (or at least 2.3.2 / 3.0.2 on old major lines) (4.0.4 fixed a ReDoS (CVE-2026-33671) from crafted nested extglobs, and the fix was backported to 2.3.2 and 3.0.2.)

### Questions
- Can it find files in a folder? No. It only checks path strings you give it; no library in its comparison table does file system work.
- Why does *.js not match src/app.js? A single star does not cross folders. Use **/*.js, or the basename option to match only the file name.
- Does it treat backslashes as folder separators on Windows? Only with windows: true. A call without options uses forward slashes; with an options object, picomatch() checks the platform.
- Can I use it in the browser? Yes. The picomatch/posix entry has no dependencies and skips the operating-system check.
- Can I use it in a paid product? Yes, it is MIT licensed; keep its license notice in copies you ship.

---
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.
