sincecutoff.com
← all changes

ast-grep supports the :not selector

Introduced 2026-03-16 · score 0.92

HOW TO USE IT

When a query needs to exclude nodes matching a selector, use ast-grep’s `:not` selector in `--kind` to search the repository. The selector negates its inner selector.

ast-grep run --kind 'expression_statement:not(:has(> call_expression))' <path>
ast-grep run --kind 'identifier:not(number)' <path>

WHY THIS HELPS

Query repository code while excluding nodes that match a selector condition.

REQUIREMENTS AND LIMITATIONS

  • Version: 0.42.0
  • --kind <KIND> (required): AST kind or ESQuery-style selector to match. Use `:not(selector)` to negate the inner selector.
  • [PATHS]...: Paths to search; defaults to `.`. Multiple paths may be separated by spaces.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card