Skip to content

feat: add cgc diff — CLI command to show graph changes between index snapshots #1312

Description

@DakshtaMethwani

Problem

There is currently no way to understand what changed in the code graph between two points in time — e.g. before and after a PR, or after a large refactor. Users must re-query manually to spot differences.

Issue #690 proposes a UI-level PR diff visualization, but there is no CLI-level tool for developers who want a quick, scriptable summary of graph changes.

Proposed solution

Add a cgc diff command that compares the current index state against a saved snapshot.

Example usage

cgc snapshot save --name before-refactor
# ... make code changes and re-index ...
cgc diff --against before-refactor

Example output

cgc diff — comparing current index vs snapshot "before-refactor"

+ FUNCTION  payment_service.validate_card         (new)
- FUNCTION  payment_service.check_card            (removed)
~ CALLS     checkout.process → payment_service.*  (target changed)
+ CLASS     billing.InvoiceBuilder                (new)
  5 nodes added · 2 nodes removed · 3 edges changed

Scope

  • cgc snapshot save [--name ] — serialise the current graph state as a lightweight snapshot (node/edge manifest, not full data)
  • cgc snapshot list — list saved snapshots
  • cgc diff [--against ] — print added/removed/changed nodes and edges
  • Optional --json flag for CI/scripting use
  • Snapshots stored in ~/.codegraphcontext/snapshots/

Why this is useful

  • PR reviews: see exactly what functions/classes a PR adds or removes before merging
  • Refactor validation: confirm a rename touched every expected call site
  • CI integration: fail a pipeline if unexpected functions were deleted
  • Watch mode complement: understand accumulated changes since the last full index

Related issues

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions