Skip to content

Claude Code Integration

Fresh

Overview

Graphify's Claude Code integration makes the knowledge graph always-on — Claude consults the graph automatically before answering architecture questions, without you having to mention it.

What Gets Installed

bash
graphify claude install

Installs two components:

ComponentLocationPurpose
CLAUDE.md directiveProject or global CLAUDE.mdTells Claude to check graph before architecture questions
PreToolUse hookClaude Code hooks configFires before every file-search tool call

How the Hook Works

sequenceDiagram
    participant You
    participant Claude Code
    participant PreToolUse Hook
    participant graph.json
    participant Files

    You->>Claude Code: "How does the payment flow work?"
    Claude Code->>PreToolUse Hook: About to search files
    PreToolUse Hook->>graph.json: Query payment-related subgraph
    graph.json-->>PreToolUse Hook: Payment community nodes + edges
    PreToolUse Hook-->>Claude Code: Inject: relevant nodes are PaymentService, StripeClient, OrderController
    Claude Code->>Files: Read PaymentService.py, StripeClient.ts, OrderController.py
    Files-->>Claude Code: File contents
    Claude Code-->>You: Accurate answer with full context

The key insight: the hook fires before Claude searches files, so the graph guides Claude to the right files — rather than Claude searching broadly and hoping to find the right ones.

Manual Installation

If graphify claude install is unavailable, add to your CLAUDE.md:

markdown
## Graphify Knowledge Graph

This project has an active Graphify knowledge graph at `graphify-out/graph.json`.

Before answering architecture questions, check:
1. `graphify-out/GRAPH_REPORT.md` for an overview of key nodes and communities
2. Use `/graphify query "..."` to find relevant nodes before reading files
3. Use `/graphify explain "NodeName"` for detailed node information
4. Use `/graphify path "NodeA" "NodeB"` to trace connections between components

Rebuilding the Graph

When your codebase changes:

bash
/graphify . --update    # Only reprocess changed files (fast)
/graphify .             # Full rebuild (slower, more thorough)

Uninstalling

bash
graphify claude uninstall

This removes the CLAUDE.md directive and the PreToolUse hook. Your graphify-out/ directory is untouched.

Verification Checklist

  • [ ] graphify claude install completed without error
  • [ ] CLAUDE.md contains a Graphify section
  • [ ] /graphify query "..." returns relevant results from your codebase
  • [ ] Claude Code references graph data when answering architecture questions

Token Efficiency

With the Claude Code integration active, complex architecture questions that previously required reading 20-30 files can often be answered by reading 3-5 targeted files guided by the graph. This translates to real cost savings on API calls.