Get the FREE Ultimate OpenClaw Setup Guide →

Code Intelligence

Scanned
npx machina-cli add skill silvesterdivas/context-engineer/code-intelligence --openclaw
Files (1)
SKILL.md
2.4 KB

Code Intelligence & Navigation

Use the most efficient tool for each code navigation task. Structured code intelligence saves tokens compared to brute-force search.

Tool Selection Guide

Finding a Symbol Definition

Best: Grep with a precise pattern like ^(export )?(function|class|const|type|interface) SymbolName Also good: Glob to find likely files, then targeted Read with line ranges Avoid: Reading entire files hoping to stumble on the definition

Finding All Usages of a Symbol

Best: Grep with the symbol name, filtered by file type (e.g., glob: "*.ts") Avoid: Reading every file in the project

Understanding a File's Exports

Best: Grep for ^export in the specific file Avoid: Reading the entire file when only the API surface is needed

Navigating Imports

Best: Grep for from ['"].*moduleName to find who imports a module Also good: Grep for import.*SymbolName to find where a symbol is imported

Finding Related Files

Best: Glob with patterns like **/auth*.ts or **/*Controller* Avoid: ls -R or recursive directory reads

Understanding Type Hierarchies

Best: Grep for extends ClassName or implements InterfaceName Also good: Grep for the type name in .d.ts files

Token Cost Comparison

ActionApproximate Token Cost
Grep single pattern50-200 tokens
Glob file search50-150 tokens
Read specific lines100-500 tokens
Read full file (small)500-2000 tokens
Read full file (large)2000-10000 tokens
Investigator agent search500-1500 tokens (but uses Haiku)

Principles

  1. Pattern before content. Find the right location with Grep/Glob, then Read only what is needed.
  2. File type filters save tokens. Always use glob or type parameters in Grep to narrow scope.
  3. Line ranges are free wins. Read with offset and limit is dramatically cheaper than full file reads.
  4. Delegate broad searches. For broad searches spanning many files, use the investigator agent — it's cheap (Haiku) and keeps the results out of the main context.

Source

git clone https://github.com/silvesterdivas/context-engineer/blob/main/skills/code-intelligence/SKILL.mdView on GitHub

Overview

Code Intelligence helps you navigate unfamiliar codebases, locate symbol definitions and usages, and find related files without scanning entire files. It emphasizes using targeted tools (Grep, Glob) to keep token usage low while delivering fast results.

How This Skill Works

Choose the most efficient tool for each task: Grep with precise patterns to find definitions and usages, Glob to identify candidate files, and Read for only the needed line ranges. Avoid full-file reads whenever possible to save tokens, and delegate broad, cross-project searches to the investigator agent.

When to Use It

  • Find a symbol's definition fast in a new codebase
  • Find all usages of a symbol across multiple files
  • Understand a file's API surface by inspecting exports
  • Trace who imports a module or symbol
  • Locate related files like controllers or auth modules

Quick Start

  1. Step 1: Identify the task (definition, usages, imports, or related files)
  2. Step 2: Run Grep/Glob with precise patterns to narrow scope
  3. Step 3: Read only the necessary lines or range to verify

Best Practices

  • Pattern before content: use Grep/Glob to locate definitions first
  • Filter by file types using glob/type to narrow scope
  • Read only small line ranges instead of whole files
  • Avoid broad reads; delegate large searches to investigator agent
  • Leverage type hierarchies with Grep for extends/implements in TS/JS

Example Use Cases

  • Locate a TypeScript function definition using Grep with a pattern for function|class|const
  • Find all usages of 'SymbolName' in '*.ts' files
  • Check a file's API surface by Grep for '^export' within the file
  • Trace imports with Grep for 'from "moduleName"'
  • Find related files with Glob patterns like '**/auth*.ts' or '**/*Controller*'

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers