understand-codebase

Map codebase structure and call flows using sg, rg, and fd searches.

124|21|Updated Nov 21, 2015
One-click install
npx skills add https://github.com/vinta/hal-9000 --skill understand-codebase
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: understand-codebase
Source: https://github.com/vinta/hal-9000/tree/main/dotfiles/.claude/skills/understand-codebase
Command: npx skills add https://github.com/vinta/hal-9000 --skill understand-codebase

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers explore complex codebases, understand architecture, and trace call flows by using syntax-aware searches and fast text queries across languages and files.

Core Features & Use Cases

  • Code structure discovery: Find function/class definitions and relationships using sg (ast-grep) and fd for file discovery.
  • Pattern-based searches: Locate symbols, imports, and usage with rg and sg, across multiple languages.
  • Codebase mapping: Map entry points and call flows to understand how components interact in large repos.

Quick Start

Ask the AI to locate where a symbol is defined and where it is called in the current codebase, using rg/sg/fd as needed.

Frequently Asked Questions about understand-codebase

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I search for function definitions and call sites across a large codebase?

Use ast-grep (sg) for syntax-aware pattern matching to locate function definitions and calls, combined with rg for fast text searches across files. This finds symbol definitions and their usage points throughout the repository structure.

Can I trace how functions and classes connect in my codebase?

Yes. Use sg to map call flows by finding where functions are defined and invoked, then use rg to locate imports and dependencies. This reveals how components interact and traces execution paths through the system.

What's the best way to understand architecture and dependencies in an unfamiliar codebase?

Start with fd to discover file structure and entry points, then use sg for AST-level pattern searches to find class definitions and relationships, and rg to locate imports and cross-module dependencies. This builds a map of how the system is organized.

Does this work with multiple programming languages?

Yes. Both rg and sg support multiple languages. sg provides syntax-aware searching across language-specific AST patterns, while rg handles text-based searches uniformly, allowing codebase navigation regardless of the languages used.

How do I locate where a specific symbol is defined or used?

Use rg for fast text search to find all occurrences of the symbol name, then use sg for precise AST-based queries to distinguish definitions from usages. This pinpoints exact locations in files and reveals call relationships.

What are the limitations when searching large repositories?

While rg and sg are fast, extremely large codebases may require refined search patterns to reduce noise. AST-grep patterns must match the target language's syntax, and broad text searches can return many results—narrowing queries by file type or directory scope improves precision.