ck - Semantic Grep by Embedding
ck (seek) finds code by meaning, not just keywords. It's a drop-in replacement for grep that understands what you're looking for — search for "error handling" and find try/catch blocks, error returns, and exception handling code even when those exact words aren't present.
# Find error handling patterns (finds try/catch, Result types, etc.)
# Traditional grep-compatible search still works
# Combine both: semantic relevance + keyword filtering
Why ck?
For Developers: Stop hunting through thousands of regex false positives. Find the code you actually need by describing what it does.
For AI Agents: Get structured, semantic search results in JSON format. Perfect for code analysis, documentation generation, and automated refactoring.
For Teams: Works exactly like grep with the same flags and behavior, but adds semantic intelligence when you need it.
Quick Start
# Build from source
# Index your project for semantic search
# Search by meaning
# Use all the grep features you know
Core Features
🔍 Semantic Search
Find code by concept, not keywords. Searches understand synonyms, related terms, and conceptual similarity.
# These find related code even without exact keywords:
# Get complete functions/classes containing matches (NEW!)
⚡ Drop-in grep Compatibility
All your muscle memory works. Same flags, same behavior, same output format.
🎯 Hybrid Search
Combine keyword precision with semantic understanding using Reciprocal Rank Fusion.
🤖 Agent-Friendly Output
Perfect JSON output for LLMs, scripts, and automation.
|
|
|
📁 Smart File Filtering
Automatically excludes cache directories, build artifacts, and system files.
# These are excluded by default:
# .git, node_modules, target/, .fastembed_cache, __pycache__
# Override defaults:
How It Works
1. Index Once, Search Many
# Create semantic index (one-time setup)
# Now search instantly by meaning
2. Three Search Modes
--regex(default): Classic grep behavior, no indexing required--sem: Pure semantic search using embeddings (requires index)--hybrid: Combines regex + semantic with intelligent ranking
3. Relevance Scoring
# [0.847] ./ai_guide.txt: Machine learning introduction...
# [0.732] ./statistics.txt: Statistical learning methods...
# [0.681] ./algorithms.txt: Classification algorithms...
Advanced Usage
Search Specific Files
# Glob patterns work
# Multiple files
# Quoted patterns prevent shell expansion
Threshold Filtering
# Only high-confidence semantic matches
# Low-confidence hybrid matches (good for exploration)
# Get complete code sections instead of snippets (NEW!)
Top-K Results
# Limit results for focused analysis
# Great for AI agent consumption
|
Directory Management
# Check index status
# Clean up and rebuild
# Add single file to index
File Support
| Language | Indexing | Tree-sitter Parsing | Semantic Chunking |
|---|---|---|---|
| Python | ✅ | ✅ | ✅ Functions, classes |
| JavaScript | ✅ | ✅ | ✅ Functions, classes, methods |
| TypeScript | ✅ | ✅ | ✅ Functions, classes, methods |
| Haskell | ✅ | ✅ | ✅ Functions, types, instances |
| Rust | ✅ | ❌ | ❌ Generic text chunks |
| Go | ✅ | ❌ | ❌ Generic text chunks |
| Java | ✅ | ❌ | ❌ Generic text chunks |
| C/C++ | ✅ | ❌ | ❌ Generic text chunks |
| C# | ✅ | ❌ | ❌ Generic text chunks |
| Ruby | ✅ | ❌ | ❌ Generic text chunks |
| PHP | ✅ | ❌ | ❌ Generic text chunks |
| Swift | ✅ | ❌ | ❌ Generic text chunks |
| Kotlin | ✅ | ❌ | ❌ Generic text chunks |
| Scala | ✅ | ❌ | ❌ Generic text chunks |
| Dart | ✅ | ❌ | ❌ Generic text chunks |
| Julia | ✅ | ❌ | ❌ Generic text chunks |
| Groovy | ✅ | ❌ | ❌ Generic text chunks |
| Clojure | ✅ | ❌ | ❌ Generic text chunks |
| F# | ✅ | ❌ | ❌ Generic text chunks |
| Erlang | ✅ | ❌ | ❌ Generic text chunks |
| Elixir | ✅ | ❌ | ❌ Generic text chunks |
Text Formats: Markdown, JSON, YAML, TOML, XML, HTML, CSS, shell scripts, SQL, and plain text.
Smart Exclusions: Automatically skips .git, node_modules, target/, build/, dist/, __pycache__/, .fastembed_cache, .venv, venv, and other common build/cache/virtual environment directories.
Installation
📦 Pre-built Binaries (Recommended)
Download for your platform:
- Linux (x86_64):
ck-linux-x86_64.tar.gz - Linux (ARM64):
ck-linux-aarch64.tar.gz - macOS (Intel):
ck-macos-x86_64.tar.gz - macOS (Apple Silicon):
ck-macos-aarch64.tar.gz - Windows (x64):
ck-windows-x86_64.zip
Get the latest release: https://github.com/BeaconBay/ck/releases/latest
# Example: Linux x86_64
|
🦀 Via Cargo
🔨 From Source
🍺 Package Managers (Planned)
# Coming soon:
Architecture
ck uses a modular Rust workspace:
ck-cli- Command-line interface and argument parsingck-core- Shared types, configuration, and utilitiesck-search- Search engine implementations (regex, BM25, semantic)ck-index- File indexing, hashing, and sidecar managementck-embed- Text embedding providers (FastEmbed, API backends)ck-ann- Approximate nearest neighbor search indicesck-chunk- Text segmentation and language-aware parsingck-models- Model registry and configuration management
Index Storage
Indexes are stored in .ck/ directories alongside your code:
project/
├── src/
├── docs/
└── .ck/ # Semantic index (can be safely deleted)
├── embeddings.json
├── ann_index.bin
└── tantivy_index/
The .ck/ directory is a cache — safe to delete and rebuild anytime.
Examples
Finding Code Patterns
# Find authentication/authorization code
# Find error handling strategies
# Find performance-related code
Integration Examples
# Git hooks
|
# CI/CD pipeline
|
# Code review prep
# Documentation generation
|
Team Workflows
# Find related test files
# Identify refactoring candidates
# Security audit
Configuration
Default Exclusions
# View current exclusion patterns
|
# These directories are excluded by default:
# .git, .svn, .hg # Version control
# node_modules, target, build # Build artifacts
# .cache, __pycache__, .fastembed_cache # Caches
# .vscode, .idea # IDE files
Custom Configuration (Planned)
# .ck/config.toml
[]
= "hybrid"
= 0.05
[]
= ["*.log", "temp/"]
= 512
= 64
[]
= "BAAI/bge-small-en-v1.5"
Performance
- Indexing: ~1M LOC in under 2 minutes (with smart exclusions and optimized embedding computation)
- Search: Sub-500ms queries on typical codebases
- Index size: ~2x source code size with compression
- Memory: Efficient streaming for large repositories with span-based content extraction
- File filtering: Automatic exclusion of virtual environments and build artifacts
- Output: Clean stdout/stderr separation for reliable piping and scripting
Testing
Run the comprehensive test suite:
# Full test suite (40+ tests)
# Quick smoke test (14 core tests)
Tests cover grep compatibility, semantic search, index management, file filtering, and more.
Contributing
ck is actively developed and welcomes contributions:
- Issues: Report bugs, request features
- Code: Submit PRs for bug fixes, new features
- Documentation: Improve examples, guides, tutorials
- Testing: Help test on different codebases and languages
Development Setup
Roadmap
Current (v0.3+)
- ✅ grep-compatible CLI with semantic search and file listing flags (
-l,-L) - ✅ FastEmbed integration with BGE models
- ✅ File exclusion patterns and glob support
- ✅ Threshold filtering and relevance scoring with visual highlighting
- ✅ Tree-sitter parsing and intelligent chunking (Python, TypeScript, JavaScript, Haskell)
- ✅ Complete code section extraction (
--full-section) - ✅ Enhanced indexing strategy with v3 semantic search optimization
- ✅ Clean stdout/stderr separation for reliable scripting
- ✅ Incremental index updates with hash-based change detection
Near-term (v0.4-0.5)
- 🚧 Configuration file support
- 🚧 Package manager distributions
Medium-term (v0.4-0.6)
- 🔮 Multiple embedding model support
- 🔮 Advanced ranking algorithms
- 🔮 Plugin architecture for custom chunkers
- 🔮 Distributed/remote index support
Long-term (v1.0+)
- 🔮 IDE integrations (VS Code, IntelliJ, etc.)
- 🔮 Git integration (semantic diffs, blame)
- 🔮 Web interface for team usage
- 🔮 Multi-language semantic understanding
FAQ
Q: How is this different from grep/ripgrep/silver-searcher?
A: ck includes all the features of traditional search tools, but adds semantic understanding. Search for "error handling" and find relevant code even when those exact words aren't used.
Q: Does it work offline?
A: Yes, completely offline. The embedding model runs locally with no network calls.
Q: How big are the indexes?
A: Typically 1-3x the size of your source code, depending on content. The .ck/ directory can be safely deleted to reclaim space.
Q: Is it fast enough for large codebases?
A: Yes. Indexing is a one-time cost, and searches are sub-second even on large projects. Regex searches require no indexing and are as fast as grep.
Q: Can I use it in scripts/automation?
A: Absolutely. The --json flag provides structured output perfect for automated processing. Use --full-section to get complete functions for AI analysis.
Q: What about privacy/security?
A: Everything runs locally. No code or queries are sent to external services. The embedding model is downloaded once and cached locally.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Credits
Built with:
- Rust - Systems programming language
- FastEmbed - Fast text embeddings
- Tantivy - Full-text search engine
- clap - Command line argument parsing
Inspired by the need for better code search tools in the age of AI-assisted development.
Start finding code by what it does, not what it says.