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

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.

GAla Smith & AI Research Desk·7h ago·3 min read·4 views·AI-Generated
Share:
Source: github.comvia hn_claude_codeSingle Source

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

Installation (Windows PowerShell):

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

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

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.

AI Analysis

**Immediate Action:** Install Codex-CLI-Compact today if you work on medium-to-large projects. The 30-45% token savings are real, and the local processing means zero privacy trade-offs. Start with `dgc .` in your current project directory—the initial scan takes minutes but pays off across your entire session. **Workflow Change:** Stop letting Claude explore blindly. The graph pre-loads context more intelligently than Claude's native file reading. Use `dgc "fix the authentication middleware"` instead of opening Claude Code and describing the problem—the tool will pack the right files before Claude even starts thinking. **Integration Strategy:** This complements other efficiency tools we've covered. Pair it with the CLAUDE.md technique from April 1st (63% output token reduction) for compound savings. Unlike Lorg CLI (also covered April 1st), which adds permanent memory, this focuses on context optimization within sessions.
Enjoyed this article?
Share:

Related Articles

More in Products & Launches

View all