← Back to archive

Repo of the Day

brandondocusen/CntxtJS

Published: Nov 27, 2024

Open repository ↗

JavaScript / TypeScript codebase analyzer that generates a knowledge graph for your project that is optimized for LLM context windows | AI code understanding | LLM context enhancement | Code structure visualization | Static analysis for AI | Large Language Model tooling

Summary

CntxtJS is a Python command-line tool that scans a JavaScript or TypeScript project and emits a single JSON knowledge graph describing its files, classes, functions, React components and hooks, and import/export relationships. The README frames the graph as a compact reference for LLM prompts, so a developer can ask a model about a codebase without pasting every source file. The project is released under the MIT license.

What it is useful for

CntxtJS addresses a recurring situation: asking an LLM about a JS/TS codebase normally requires either pasting large amounts of source into the context window or relying on retrieval. The tool produces a pre-digested structural map that the LLM can read once and then query. The README's example prompts show concrete uses — explaining an authentication flow from component to function, tracing the user experience from a landing page through core-experience components, identifying state-management stores and their interactions, listing error-handling patterns, and listing third-party libraries from the dependency map.

The tool also renders a matplotlib graph image of the same data, suitable for architecture diagrams or onboarding documents. Documented limitations: Vue and Svelte support, deeper TypeScript type analysis, interactive web visualizations, custom export formats, and IDE integrations are listed as future goals rather than current features.

How engineers can use it

The Quick Start in the README runs the tool with these commands:

git clone https://github.com/brandondocusen/CntxtJS.git
cd CntxtJS
pip install networkx matplotlib
python CntxtJS.py

When executed, the script prompts for the path to the target JS/TS codebase. It then writes js_code_knowledge_graph.json and offers to render the matplotlib visualization. That JSON can be uploaded to an LLM alongside one of the README's prompt templates, such as: "Based on the knowledge graph, explain how the authentication flow works in this application, including which components and functions are involved in the process."

The README only documents this interactive flow. No CLI flags, config file, or programmatic API are described, so engineers planning to run CntxtJS in CI or as part of a scripted pipeline should confirm the script's behavior against the source before relying on it.