Count Matches
countTally matching lines or regex, literal, and AST occurrences without returning match content to gauge blast radius and save context tokens before searching or replacing.
Instructions
Count matching lines or occurrences of a regex, literal text, or AST pattern without returning match content. Use before 'search' or 'replace' to gauge blast radius and save context tokens.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>"
},
"name": "count"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | File or directory to count matches in (relative or absolute; default: '.'). | . |
| type | No | Counting engine: 'regex' (default), 'text' (literal), or 'ast' (structural pattern). | regex |
| query | Yes | Pattern to count (regex, literal text, or AST pattern). | |
| perFile | No | If true, returns match counts broken down per file. | |
| language | No | [ast only] Target language (e.g. 'typescript', 'python'). Recommended when 'path' is a directory. | |
| noIgnore | No | If true, include gitignored files. Default: false. | |
| filePattern | No | Glob pattern(s) to include, comma-separated, e.g. '*.{ts,tsx}'. | |
| caseSensitive | No | [regex/text] Force case-sensitive (true) or case-insensitive (false). Omitting uses smart-case (insensitive unless query has uppercase). | |
| includeHidden | No | If true, include hidden dotfiles and dot-directories (excludes .git unless noIgnore is true). Default: false. | |
| excludePattern | No | Comma-separated glob patterns to exclude, e.g. '**/dist/**,**/*.spec.ts'. |