CommunityCoding & Developmentgithub.com

Global Knowledge Graph (GKG)

Provides semantic code analysis tools for exploring and understanding codebases by indexing projects for fast symbol lookup, reference finding, and structural analysis.

What is Global Knowledge Graph (GKG)?

Global Knowledge Graph (GKG) is a skill that equips AI agents and developers with powerful semantic code analysis capabilities. It indexes entire codebases to enable rapid symbol lookup, reference finding, structural analysis, and dependency tracing. Key commands include listing indexed projects, rebuilding indexes, searching definitions, finding references, reading implementation details, generating repo maps, and analyzing import usage. This skill is particularly useful for refactoring impact analysis, understanding unfamiliar code, and tracing dependencies. It is designed to work via a CLI tool (`gkg.ts`) executed with Bun, accepting JSON parameters via the `--raw` flag. Supported by a detailed API reference in the `references/` directory, GKG makes it easy to navigate and comprehend large, complex codebases without manual searching.

Works with~Claude Code~Codex CLI~Cursor
npx skills add L-yifan/skills

Installed? Explore more Coding & Development skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

What does Global Knowledge Graph (GKG) do?

Overview

GKG provides semantic code analysis tools for exploring and understanding codebases. It indexes projects to enable fast symbol lookup, reference finding, and structural analysis.

Quick Start

Run from this skill directory. Use --raw with JSON for parameters:

bun ./scripts/gkg.ts <command> --raw '<json>'

Core Commands

list-projects

List all indexed projects in the knowledge graph.

bun ./scripts/gkg.ts list-projects

index-project

Rebuild the knowledge graph index for a project.

bun ./scripts/gkg.ts index-project \
  --raw '{"project_absolute_path":"/path/to/project"}'

search-codebase-definitions

Find functions, classes, methods, constants across the codebase.

bun ./scripts/gkg.ts search-codebase-definitions \
  --raw '{"search_terms":["functionName","ClassName"],"project_absolute_path":"/path/to/project"}'

get-references

Find all usages of a symbol across the codebase.

bun ./scripts/gkg.ts get-references \
  --raw '{"absolute_file_path":"/path/to/file.ts","definition_name":"myFunction"}'

read-definitions

Read complete implementation of definitions.

bun ./scripts/gkg.ts read-definitions \
  --raw '{"definitions":[{"names":["myFunc"],"file_path":"/path/to/file.ts"}]}'

get-definition

Go to definition for a symbol on a specific line.

bun ./scripts/gkg.ts get-definition \
  --raw '{"absolute_file_path":"/path/to/file.ts","line":"const result = myFunc()","symbol_name":"myFunc"}'

repo-map

Generate a compact API-style map of repository structure.

bun ./scripts/gkg.ts repo-map \
  --raw '{"project_absolute_path":"/path/to/project","relative_paths":["src","lib"]}'

import-usage

Analyze import usages across the project.

bun ./scripts/gkg.ts import-usage \
  --raw '{"project_absolute_path":"/path/to/project","packages":[{"import_path":"react"}]}'

Common Workflows

Refactoring Impact Analysis

  1. Use search-codebase-definitions to find the symbol
  2. Use get-references to find all usages
  3. Review each usage location before making changes

Understanding Unfamiliar Code

  1. Use repo-map to get project structure overview
  2. Use search-codebase-definitions to find relevant functions
  3. Use read-definitions to read implementations

Tracing Dependencies

  1. Use import-usage to find where packages are imported
  2. Use get-references to trace function call chains

Resources

scripts/

  • gkg.ts - CLI tool for all knowledge graph operations

references/

  • api_reference.md - Detailed parameter documentation for each command

Related Skills