checkfor

Non-recursive multi-directory search

Go Search & Replace GitHub

Search files across multiple directories with compact JSON output. Designed for AI-optimized, token-efficient verification during refactoring workflows.

Features

  • Multi-directory search in single-depth scans
  • Compact JSON output - 41% smaller than pretty-printed
  • Per-directory results with relative paths
  • Exclude filtering with statistics
  • File extension, case-insensitive, and whole-word matching
  • Context lines before/after matches
  • Multi-line search via \n in search string

Install

go install github.com/hegner123/checkfor@latest

The Problem: Verifying a refactor across packages

# Using grep  - verbose, unstructured, token-heavy
$ grep -rn "oldFunctionName" ./pkg/handlers ./pkg/models ./pkg/services
./pkg/handlers/user.go:42:  result := oldFunctionName()
./pkg/handlers/user.go:87:  // calls oldFunctionName for processing
./pkg/handlers/auth.go:15:  oldFunctionName(ctx)
./pkg/models/user.go:23:  return oldFunctionName(db)
./pkg/services/notify.go:56:  oldFunctionName(msg)

Solution

$ checkfor --cli --dir "./pkg/handlers,./pkg/models,./pkg/services" --search "oldFunctionName" --ext .go

Output

{"directories":[{"dir":"./pkg/handlers","matches_found":3,"files":[{"path":"user.go","matches":[{"line":42,"content":"  result := oldFunctionName()"},{"line":87,"content":"  // calls oldFunctionName for processing"}]},{"path":"auth.go","matches":[{"line":15,"content":"  oldFunctionName(ctx)"}]}]},{"dir":"./pkg/models","matches_found":1,"files":[{"path":"user.go","matches":[{"line":23,"content":"  return oldFunctionName(db)"}]}]},{"dir":"./pkg/services","matches_found":1,"files":[{"path":"notify.go","matches":[{"line":56,"content":"  oldFunctionName(msg)"}]}]}]}

Comparison

MetricValue
Token reduction vs Read tool95%
Token reduction vs Grep tool77%
Compact JSON savings41%
Path data reduction (relative paths)68%
Response time improvement3-5x faster