agentleFS
boyterboyter/cs/CLAUDE.md

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

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 test

Linting:

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 channel

Query 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 to ConsoleSearch(), TUI (initialModel()), StartHttpServer(), or StartMcpServer() based on flags/args
  • config.go: Config struct with all CLI-configurable fields. DefaultConfig() provides sensible defaults
  • search.go: DoSearch() — orchestrates the full search pipeline: file walking, reading, binary/minified filtering, AST evaluation, and result streaming via channels. Uses SearchCache for prefix-based caching
  • console.go: ConsoleSearch() — collects results, ranks, and outputs in text/JSON/vimgrep format
  • tui.go: bubbletea TUI with lipgloss styling. Debounced search input, incremental result streaming, syntax-highlighted preview
  • http.go: HTTP server with embedded templates, search/display endpoints, theme support (dark/light/bare), custom template overrides
  • cache.go: SearchCache — LRU cache with TTL for query results; supports prefix matching for progressive refinement in TUI
  • syntax.go: Syntax highlighting with keyword tables for 80+ languages
  • language.go: Language detection via scc processor's language database
  • mcp.go: MCP (Model Context Protocol) server over stdio; exposes search as a tool for AI agents
  • templates.go: Template loading with //go:embed for built-in HTML templates; supports custom template paths

Subpackages

  • pkg/common/: FileJob struct — the core data type passed through the pipeline
  • pkg/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

Download now (ZIP)

Trending

Quiet since September.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 4 mentionsMar 2026: 2 mentionsApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 1 mentionSep 2026: 3 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the boyter/cs repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about boyter/cs

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

8 more on GitHub

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.