grafema-module-level-scope-matching

Fixes Grafema's scope chain resolution for module-level variables.

36|2|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/Disentinel/grafema --skill grafema-module-level-scope-matching
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: grafema-module-level-scope-matching
Source: https://github.com/Disentinel/grafema/tree/main/.claude/skills/grafema-module-level-scope-matching
Command: npx skills add https://github.com/Disentinel/grafema --skill grafema-module-level-scope-matching

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses a critical bug in Grafema's code analysis where module-level variables are not correctly resolved due to a mismatch between how scope paths are represented internally.

Core Features & Use Cases

  • Correct Scope Chain Resolution: Ensures that module-level variables are accurately identified and linked within Grafema's code graph.
  • Fixes Variable Lookup Failures: Resolves issues where scope-aware lookups return null for top-level variables.
  • Enables Accurate Mutation Tracking: Guarantees that mutations at the file or module level correctly associate with their target variables.
  • Use Case: When Grafema fails to trace data flow for variables declared at the top level of a JavaScript module, applying this fix ensures those connections are correctly established, allowing for complete code understanding.

Quick Start

Apply the Grafema module-level scope matching fix to ensure correct variable resolution.

Frequently Asked Questions about grafema-module-level-scope-matching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does Grafema scope resolution fail for module-level variables?

Grafema scope resolution fails for module-level variables due to a mismatch where the module-level scope path `[]` incorrectly compares against the semantic ID scope `['global']`, causing scope-aware lookups to return null.

How do I fix variable lookup failures for top-level TypeScript variables in Grafema?

You can fix top-level variable lookup failures in Grafema by adjusting the `resolveVariableInScope` function to correctly handle the empty scope path comparison for module-level variables.

How does Grafema track file-level mutations for module-level variables?

Grafema tracks file-level mutations by ensuring its scope chain resolution correctly links module-level variables to their target variables, fixing the previous mismatch where scope-aware lookups returned null for top-level declarations.

What causes Grafema code analysis to miss data flow tracing for top-level variables?

Grafema code analysis misses data flow tracing for top-level variables because the internal scope path representation for the module level does not match the semantic ID scope, breaking the variable resolution chain.

Does applying this Grafema scope matching fix require any specific dependencies?

No, applying this Grafema scope matching fix requires no external dependencies, directly modifying the `resolveVariableInScope` logic to ensure correct module-level scope chain resolution.