GS/BS
← Standards directory
Code quality

ast-grep.

Match forbidden syntax structurally

Express a repository convention as a syntax-tree pattern. Keep a matching fixture and a near miss alongside the rule so equivalent formatting produces the same finding.

JavaScript / TypeScript / Rust / Go / Python

Community rubric · v1

The evidence

Evidence coverage5 / 8
5 supported · 3 unresolved

One point for each verified check. Unknown means we still need evidence. Contrary evidence records an observed result that goes against the criterion.

Latest evidence review ·

  • Definition

    Verified

    A rule selects syntax-tree nodes satisfying its specified fields. Node kinds and structural relationships constrain the match beyond surface text.

    Cited source ↗
  • Measurement

    Verified

    The test runner evaluates two lists: valid snippets must produce no match, and invalid snippets must trigger the rule.

    Cited source ↗
  • Conformance

    Verified

    The published no-await-in-loop example supplies valid and invalid snippets and expected rule behavior. It exercises that structural rule, not arbitrary user rules.

    Cited source ↗
  • CI enforcement

    Verified

    A match on a rule set to error makes ast-grep scan return nonzero. Warning and hint levels allow a team to distinguish advisory checks from build gates.

    Cited source ↗
  • Getting started

    Verified

    The quick start provides installation choices and a runnable search that finds a JavaScript pattern before demonstrating how to rewrite it.

    Cited source ↗
  • Real-world adoption

    Unknown

    No reviewed evidence is recorded for this dimension.

    Has another team put it to work? Contribute evidence ↗

  • Agent guidance

    Unknown

    No reviewed evidence is recorded for this dimension.

    Can an agent act on a specific finding? Contribute evidence ↗

  • Agent portability

    Unknown

    No reviewed evidence is recorded for this dimension.

    Does the practice work in two agent harnesses? Contribute evidence ↗

Use this standard

Run the check with the tool installed and configured for your project.

ast-grep scan

Agent prompt

Use ast-grep in this repository to meet this standard: Match forbidden syntax structurally. Express a repository convention as a syntax-tree pattern. Keep a matching fixture and a near miss alongside the rule so equivalent formatting produces the same finding. Inspect the repository configuration, record the baseline and exact reproduction steps, then add the smallest repeatable check that detects a regression.
Read the agent skill ↗

Primary source

ast-grep documentation ↗