codesearch-code-search
MANDATORY: Query CodeSearch BEFORE using grep, glob, find, or search. Performs 400x faster semantic and structural code search via SQL on indexed codebase. Use for finding functions, classes, patterns, callers, and implementations. Agents MUST query CodeSearch first; grep is only allowed after CodeSearch returns zero results.
Best use case
codesearch-code-search is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
MANDATORY: Query CodeSearch BEFORE using grep, glob, find, or search. Performs 400x faster semantic and structural code search via SQL on indexed codebase. Use for finding functions, classes, patterns, callers, and implementations. Agents MUST query CodeSearch first; grep is only allowed after CodeSearch returns zero results.
Teams using codesearch-code-search should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/cfn-codesearch/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How codesearch-code-search Compares
| Feature / Agent | codesearch-code-search | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
MANDATORY: Query CodeSearch BEFORE using grep, glob, find, or search. Performs 400x faster semantic and structural code search via SQL on indexed codebase. Use for finding functions, classes, patterns, callers, and implementations. Agents MUST query CodeSearch first; grep is only allowed after CodeSearch returns zero results.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# CodeSearch Local Semantic Code Search ## MANDATORY: QUERY CODESEARCH BEFORE GREP/GLOB **This is a PROTOCOL REQUIREMENT, not a suggestion. Failure to query CodeSearch first is a violation.** ### WHY THIS IS MANDATORY - CodeSearch SQL: 0.002s | grep: 0.8s (400x slower) - Agents using grep first waste tokens and time - Index already exists at `~/.local/share/codesearch/index_v2.db` ### ALWAYS USE CODESEARCH FIRST ```bash # Exact name lookup - 0.002s sqlite3 ~/.local/share/codesearch/index_v2.db "SELECT file_path, line_number FROM entities WHERE name = 'MyFunction';" # Fuzzy search - 0.004s sqlite3 ~/.local/share/codesearch/index_v2.db "SELECT file_path, line_number FROM entities WHERE name LIKE '%Store%' LIMIT 10;" # Semantic search /codebase-search "authentication middleware pattern" ``` ### GREP IS ONLY ALLOWED WHEN: - CodeSearch query returned zero results AND project confirmed not indexed - Searching literal strings (error messages, comments, config values) - Explicit user request for grep ### FOR CONCEPTUAL QUESTIONS: - "Where is X implemented?" → CodeSearch semantic search - "Find similar patterns" → CodeSearch embeddings - "How is feature Y built?" → CodeSearch first, then read files ## Quick Commands ### Semantic Search (V1 - Embeddings) ```bash # Natural language search /codebase-search "authentication middleware pattern" /cfn-codesearch-search "error handling in API routes" # CLI direct (global install preferred) local-codesearch query "user login flow" --max-results 5 ``` ### Structural Search (V2 - SQL on AST) ```bash # Find all callers of a function sqlite3 ~/.local/share/codesearch/index_v2.db \ "SELECT * FROM refs WHERE target_name = 'MyFunction';" # Find all functions in a file sqlite3 ~/.local/share/codesearch/index_v2.db \ "SELECT name, line_number FROM entities WHERE file_path LIKE '%myfile.rs' AND kind = 'function';" # Find entities by project (multi-project isolation) sqlite3 ~/.local/share/codesearch/index_v2.db \ "SELECT COUNT(*) FROM entities WHERE project_root = '/path/to/project';" ``` ## Installation **Global install (recommended for multi-project use):** ```bash # From claude-flow-novice project ./scripts/install-codesearch-global.sh # Verify local-codesearch --version ``` This installs to `~/.local/bin/local-codesearch` for access from any project. ## Prerequisites **OPENAI_API_KEY is REQUIRED for indexing.** Indexing will fail without a valid key. ```bash # Option 1: Export before running export OPENAI_API_KEY="sk-..." # Option 2: Add to shell profile (~/.bashrc or ~/.zshrc) echo 'export OPENAI_API_KEY="sk-..."' >> ~/.bashrc source ~/.bashrc # Option 3: Inline with command OPENAI_API_KEY="sk-..." ./local-codesearch index --path /project ``` **Verify key is set:** ```bash echo $OPENAI_API_KEY # Should show your key (not empty) ``` ## Index Management ```bash # Index a project (first time or full rebuild) local-codesearch index --path /path/to/project --types rs,ts,py # Incremental update (after code changes) /codebase-reindex # Check index stats sqlite3 ~/.local/share/codesearch/index_v2.db "SELECT project_root, COUNT(*) FROM entities GROUP BY project_root;" ``` ## Key Features - **Multi-project isolation**: Index multiple projects in single database without data collision - **Non-destructive**: Indexing one project never deletes data from other projects - **Centralized storage**: `~/.local/share/codesearch/index_v2.db` - **Dual search**: V1 semantic (embeddings) + V2 structural (SQL on AST) - **Fast**: Rust binary with SQLite backend ## Database Location ``` ~/.local/share/codesearch/index_v2.db ``` ## For Agents (MANDATORY PROTOCOL) **DO NOT use grep/glob until you have queried CodeSearch. This is enforced.** ```bash # STEP 1: Query CodeSearch FIRST (required) /codebase-search "relevant search terms" --top 5 # Or SQL: sqlite3 ~/.local/share/codesearch/index_v2.db "SELECT file_path, line_number FROM entities WHERE name LIKE '%keyword%';" # STEP 2: Query past errors/patterns ./.claude/skills/cfn-codesearch/query-agent-patterns.sh "description" # STEP 3: Only if CodeSearch returns nothing, then use grep ``` **Violation of this protocol wastes tokens and time. CodeSearch exists to prevent duplicated work.**
Related Skills
supabase-schema-sync
Introspects Supabase DB after migrations and updates project db-query skill with current schema. Run after any migration to keep agent context accurate.
commit
Stage, commit, and push changes using a background github-commit-agent. Accepts optional args for message override or push control.
cfn-vote-implement
MUST BE USED after cfn-dry-review or cfn-alpha-launch:manifest produces a manifest. Also the verification phase of /cfn-loop-task. Do not manually implement code review suggestions - always route through this skill. 3-agent specialized voting. Unanimous (3/3) auto-implemented with TDD. 2/3 routed to product-owner agent. 1/3 surfaced to user via AskUserQuestion (batched 4 per call, at end).
cfn-utilities
Reusable bash utility functions for CFN Loop - logging, error handling, retry, file operations. Use when you need structured logging, atomic file operations, retry logic with exponential backoff, or standardized error handling in bash scripts.
CFN Test Runner Skill
**Version:** 1.0.0
cfn-test-framework
Test execution, running, and webapp testing for CFN
cfn-task-planning
Classify tasks, initialize structured configs with scope boundaries, decompose complex tasks
Specialist Injection Skill
## Purpose
!/bin/bash
# cfn-task-intelligence.sh
Task Complexity Estimator
**Version:** 1.0.0
task-classifier
Analyzes task descriptions and classifies them into categories for agent selection
cfn-task-intelligence
Classify tasks (type/domain), estimate complexity/iterations, recommend specialists from feedback themes