DEV Community

gentic news
gentic news

Posted on • Originally published at gentic.news

Codex-CLI-Compact: The Graph-Based Context Engine That Cuts Claude Code Costs 30-45%

A new local tool builds a semantic graph of your codebase to pre-load only relevant files into Claude's context, reducing token usage by 30-45% without quality loss.

What It Does — Semantic Graph Context Management

Codex-CLI-Compact (also called Dual Graph) is a local context engine that sits between you and Claude Code. Instead of letting Claude explore your codebase through expensive tool calls, it builds a semantic graph of your entire project first—extracting files, functions, classes, and import relationships. When you ask a question, the graph identifies the most relevant files and packs them into the prompt before Claude even sees it.

Why It Works — Token Economics and Local Processing

The magic happens in three stages:

  1. Project scanning: dgc /path/to/project scans your codebase and builds a local graph stored in <project>/.dual-graph/ (automatically gitignored)
  2. Context pre-loading: For each prompt, the graph ranks relevant files based on semantic relationships and includes them upfront
  3. Session memory: Files you've read or edited are prioritized in future turns, creating compounding token savings across a session

All processing is local—no code leaves your machine. The tool supports TypeScript, JavaScript, Python, Go, Swift, Rust, Java, Kotlin, C#, Ruby, and PHP.

How To Install and Use It — Commands That Save Tokens

Installation (macOS/Linux):

curl -sSL https://raw.githubusercontent.com/kunal12203/Codex-CLI-Compact/main/install.sh | bash
source ~/.zshrc  # or ~/.bashrc / ~/.profile
Enter fullscreen mode Exit fullscreen mode

Installation (Windows PowerShell):

irm https://raw.githubusercontent.com/kunal12203/Codex-CLI-Compact/main/install.ps1 | iex
Enter fullscreen mode Exit fullscreen mode

Basic usage:

dgc .                    # Scan current directory and launch Claude
dgc /path/to/project     # Scan specific project
dgc . "fix the login bug" # Start with initial prompt
Enter fullscreen mode Exit fullscreen mode

For Codex CLI users: Replace dgc with dg in all commands.

MCP Integration — Graph-Aware Tool Calls

When Claude needs to explore beyond the pre-loaded context, it can use graph-aware MCP tools:

  • graph_read: Read specific files with graph context
  • graph_retrieve: Retrieve related code based on graph connections
  • graph_neighbors: Find symbol relationships in the graph

These tools maintain the efficiency gains while allowing deep exploration when needed.

Benchmarks and Real-World Impact

The developer benchmarked across 80+ prompts at 5 complexity levels on a real-world full-stack app. Results:

  • Cost wins on 16 out of 20 prompts (80% success rate)
  • Quality equal or better on all complexity levels
  • 30-45% token reduction on average

These savings compound—each turn gets cheaper as the graph learns which files are relevant to your current task.

Configuration Options — Fine-Tune Your Workflow

All configuration is optional via environment variables:

  • Session continuity: Decisions, tasks, and facts persist in .dual-graph/context-store.json and re-inject at next session start
  • Global settings in ~/.dual-graph/
  • Project-specific graphs in each project's .dual-graph/ directory

When This Shines — Specific Use Cases

  1. Large refactoring tasks: The graph understands cross-file dependencies
  2. Bug hunting across modules: Semantic connections help identify related code
  3. Multi-session projects: Context memory reduces repetition
  4. Cost-sensitive development: Direct token savings translate to budget efficiency

This follows Claude Code's architecture built on Model Context Protocol (MCP), which we covered on March 30th—the graph tools integrate seamlessly with Claude's existing tool-calling infrastructure.


Originally published on gentic.news

Top comments (0)