---
title: semantic | CodeWeaver Docs
description: API reference for codeweaver.semantic
url: "https://docs.knitli.com/api/semantic"
type: static
generatedAt: "2026-04-17T17:21:09.525Z"
---

# semantic
       [Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[View in Markdown](/codeweaver/api/semantic.md)       [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F)[Share on X](https://x.com/intent/tweet?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F&text=semantic)[Share on Threads](https://threads.net/intent/post?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F&text=semantic)[Share on Bluesky](https://bsky.app/intent/compose?text=semantic%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F)[Share on Reddit](https://reddit.com/submit?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F&title=semantic)[Share on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F&t=semantic)[Share on Email](mailto:?subject=semantic&body=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F)[Share on WhatsApp](https://wa.me/?text=semantic%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F)[Share on Telegram](https://t.me/share/url?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2F&text=semantic)
# `codeweaver.semantic`
[Section titled “codeweaver.semantic”](#codeweaversemantic)
Semantic node classification and importance scoring system.

The semantic package provides tools, types, and utilities for analyzing and classifying [tree-sitter ↗](https://tree-sitter.github.io/tree-sitter/) grammars, which inform CodeWeaver’s code context intelligence features. Most of the package is focused on classifying grammars (grammars are the ‘what can be’ of a programming language, defining its idioms, syntax and structure) into semantic classes (the ‘what it means’ of a programming language, defining the intent and purpose of code constructs). It provides granular mapping of grammar nodes, which we call ‘things’, to semantic classifications, and assigns importance based on these classifications, combined with the task at hand, their context in the actual code, and other factors.

After some frustrating experiences with Tree-Sitter’s built-in node types, we decided to apply our own plain language descriptions and classifications to the structures. We hope this will help you understand and reason about code more effectively. For a complete overview of CodeWeaver’s system and differences in terminology, see the module comment in `codeweaver.semantic.grammar`. //LINK - src/codeweaver/semantic/grammar.py

The package also includes serializable wrappers around `Ast-Grep`’s core types, which we use for parsing and analyzing code. These wrappers provide a more user-friendly interface for working with ASTs, add additional functionality, like integration with our classification and scoring systems, and make for easy serialization and deserialization of ASTs.