cs
CLAUDE.md1.1k starsChanged 6 years agoMITView on GitHub
cs (codespelunker) is a command-line code search tool written in Go. It searches files recursively using boolean queries, regex, and fuzzy matching, with relevance ranking (BM25/TF-IDF). Four modes: console output, interactive TUI, HTTP server, and MCP server. Root package main plus subpackages under pkg/. The search pipeline is orchestrated by DoSearch() in search.go: Queries are parsed into an AST and evaluated against each file: See pkg/search/README.md for detailed query syntax documentation. - Dependencies are vendored (vendor/ directory) - SPDX license…
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
cs (codespelunker) is a command-line code search tool written in Go. It searches files recursively using boolean queries, regex, and fuzzy matching, with relevance ranking (BM25/TF-IDF). Four modes: console output, interactive TUI, HTTP server, and MCP server.
Build & Test Commands
go build -o cs # Build binary
go test ./... # Run all tests
go test -v ./... # Verbose tests
go test -run TestPreParseQuery ./... # Run a single testLinting:
golangci-lint run --enable=gofmt ./...
gofmt -s -w -l .Architecture
Root package main plus subpackages under pkg/. The search pipeline is orchestrated by DoSearch() in search.go:
FileWalker → [read + filter files] → AST query evaluation → matched FileJobs channelQuery Pipeline (pkg/search/)
Queries are parsed into an AST and evaluated against each file:
Lexer → Parser → Transformer → Planner → Executor- Lexer (
lexer.go): tokenizes query string (terms, quotes, regex, operators, fuzzy markers) - Parser (
parser.go): builds AST with boolean logic (AND/OR/NOT), quoted phrases, regex/pattern/, fuzzy~1/~2 - Transformer (
transformer.go): semantic rewrites (e.g.complexity=high) - Planner (
planner.go): query optimization - Executor (
executor.go): evaluates AST against file content, returns match locations - Extractor (
extractor.go): extracts matched terms for highlighting - AST (
ast.go): AST node type definitions (AndNode, OrNode, NotNode, KeywordNode, PhraseNode, RegexNode, FuzzyNode, FilterNode) - Document (
document.go): Document and SearchResult structs
See pkg/search/README.md for detailed query syntax documentation.
Core Root Files
main.go: Cobra CLI entry point. Routes toConsoleSearch(), TUI (initialModel()),StartHttpServer(), orStartMcpServer()based on flags/argsconfig.go:Configstruct with all CLI-configurable fields.DefaultConfig()provides sensible defaultssearch.go:DoSearch()— orchestrates the full search pipeline: file walking, reading, binary/minified filtering, AST evaluation, and result streaming via channels. UsesSearchCachefor prefix-based cachingconsole.go:ConsoleSearch()— collects results, ranks, and outputs in text/JSON/vimgrep formattui.go: bubbletea TUI with lipgloss styling. Debounced search input, incremental result streaming, syntax-highlighted previewhttp.go: HTTP server with embedded templates, search/display endpoints, theme support (dark/light/bare), custom template overridescache.go:SearchCache— LRU cache with TTL for query results; supports prefix matching for progressive refinement in TUIsyntax.go: Syntax highlighting with keyword tables for 80+ languageslanguage.go: Language detection via scc processor's language databasemcp.go: MCP (Model Context Protocol) server over stdio; exposes search as a tool for AI agentstemplates.go: Template loading with//go:embedfor built-in HTML templates; supports custom template paths
Subpackages
pkg/common/:FileJobstruct — the core data type passed through the pipelinepkg/ranker/:RankResults()— BM25 (default), TF-IDF, or simple ranking with location-based boosting. Includes declaration detection (declarations.go), deduplication (dedup.go), and stopword filtering (stopwords.go)pkg/snippet/: Snippet extraction (sliding window) and line-based extraction; auto-selects mode by file type
Key Conventions
- Dependencies are vendored (
vendor/directory) - SPDX license headers on all source files (MIT)
- TUI uses bubbletea + bubbles (text input) + lipgloss (styling)
- Releases via GoReleaser (
.goreleaser.yaml) - Go 1.25.2, module:
github.com/boyter/cs
Trending
Quiet since September.about the whole repository
Who's talking about boyter/cs
- A Hacker News story“Show HN: Codespelunker – A command line search tool with TUI and HTTP modes”Hacker News · Jun 5, 2023 · 71 points
- A Hacker News story“Show HN: CS – indexless code search that understands code, comments and strings”Hacker News · Feb 22, 2026 · 15 points
- chenrui333/homebrew-tap“codespelunker 3.2.0”GitHub · Sep 23, 2026 · 1 reactions
- A Hacker News story“Code search tool that understands code structure and ranks results by relevance”Hacker News · May 8, 2026 · 1 points
- aquaproj/aqua-registry“feat(boyter/cs): add boyter/cs”GitHub · Sep 15, 2026
The biggest 5 of 16 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 16
Talked about on GitHub and Hacker News (16 times).
On GitHub · 13
- Sep 23, 2026codespelunker 3.2.0 — chenrui333/homebrew-tap1 reaction · 2 comments
- Sep 15, 2026feat(boyter/cs): add boyter/cs — aquaproj/aqua-registry0 reactions · 1 comment
- Sep 11, 2026codespelunker: 3.1.0 -> 3.2.0 — NixOS/nixpkgs0 reactions
- Aug 24, 2026scc 4.0.0 — Homebrew/homebrew-core0 reactions · 1 comment
- Jun 6, 2026content(mcp): add Searchcode MCP Server — JSONbored/awesome-claude0 reactions · 3 comments
8 more on GitHub
- Mar 5, 2026codespelunker: 3.0.0 -> 3.1.0 — NixOS/nixpkgs0 reactions
- Mar 5, 2026codespelunker 3.1.0 — chenrui333/homebrew-tap0 reactions
- Feb 22, 2026codespelunker 3.0.0 — chenrui333/homebrew-tap0 reactions
- Feb 17, 2026codespelunker 2.0.0 — chenrui333/homebrew-tap0 reactions
- Feb 17, 2026codespelunker: 1.4.0 -> 2.0.0 — NixOS/nixpkgs0 reactions
- Aug 23, 2023codespelunker: 1.3.0 -> 1.4.0 — NixOS/nixpkgs0 reactions
- Jul 29, 2023codespelunker: 1.2.0 -> 1.3.0 — NixOS/nixpkgs0 reactions
- Jun 13, 2023codespelunker: 1.0.0 -> 1.2.0 — NixOS/nixpkgs0 reactions
On Hacker News · 3
- Jun 5, 2023Show HN: Codespelunker – A command line search tool with TUI and HTTP modes71 points · 8 comments
- Feb 22, 2026Show HN: CS – indexless code search that understands code, comments and strings15 points · 2 comments
- May 8, 2026Code search tool that understands code structure and ranks results by relevance1 point
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

