DEV

Tree-sitter and abstract syntax trees unlock a smarter kind of AI code analysis — one that understands structure, not just text. This episode walks through building a static AI code assistant that works across languages and scales to real production codebases.

Show Notes

Inheriting a messy, multi-language codebase is one of those challenges that used to mean hours of manual archaeology. This episode of Development explores a more intelligent approach: a static AI code assistant powered by abstract syntax trees (ASTs) and Tree-sitter. The discussion is grounded in this practical deep-dive on building a static AI code assistant, and it covers everything from the foundational concepts to real-world deployment in a CI/CD pipeline.
Here's what the episode walks through:
  • Why text-based search falls short: Regex and keyword searches can't distinguish a "return" statement from the word "return" in a comment — ASTs solve this by representing code as a hierarchy of meaningful, structured nodes.
  • What Tree-sitter brings to the table: An incremental, language-agnostic parsing system already battle-tested inside popular editors, with out-of-the-box support for Python, JavaScript, Go, Rust, and many more via community grammars.
  • Querying ASTs instead of writing traversals: Tree-sitter's pattern-matching query syntax lets you ask sophisticated questions — find every function returning a boolean, flag methods with too many parameters — without drowning in low-level tree recursion.
  • Feeding structure to AI, not raw text: Rather than dumping whole files into a language model prompt, the assistant extracts targeted AST nodes (a function, its parameters, its return type) so the model can reason about code in context rather than as a block of characters.
  • Multi-language and cross-language analysis: Tree-sitter's modular parser architecture makes it straightforward to handle polyglot projects, and a unified AST pipeline can even start to map how back-end Python functions are ultimately consumed by front-end JavaScript components.
  • Scaling up and plugging into CI/CD: Incremental parsing keeps performance manageable on large repos; once mature, the assistant runs automatically on every pull request — surfacing style issues, complexity flags, and security concerns while the code is still fresh in the author's mind.
The episode closes by framing the bigger picture: ASTs give an AI assistant something genuinely meaningful to reason about — structure, relationships, and intent — rather than a flat stream of characters. For more from the show on pushing AI into production environments, check out the episode Synthetic Data and GANs: The Edge ML Playbook You Actually Need.
DEV

What is DEV?

Software and web development from the side that has to ship it and then live with it. Architecture decisions with a cost attached, scoping, technical debt, hiring and vendor selection, and the AI tooling question every engineering team is now answering whether they planned to or not.

Each episode takes one decision — rewrite or refactor, framework choice, build versus buy, how to scope a fixed-bid project honestly — and works through the tradeoffs, including the ones that only show up in year two. Written for engineering leads, technical founders and the people who fund them. Five or six minutes, no hand-waving.

Topics include rewrite versus refactor, build versus buy, scoping fixed-bid work honestly, technical debt you should keep, framework and platform choices, hiring and vendor selection, code review culture, and where AI tooling actually helps.

Produced by DEV.co, web and software development. Full details, services and further reading at https://dev.co