AI-powered semantic code search tool for your local repositories. Find code by describing what you're looking for in natural language.
Example: "Where did I implement Microsoft Teams notifications?" or "Show me authentication logic using OAuth"
- π Semantic Search: AI-powered understanding of code intent, not just keyword matching
- π¬ Interactive Chat: Multi-turn conversation mode for exploratory code discovery
- π¦ Local Indexing: SQLite database with semantic chunking of functions and classes
- π CLI Interface: Terminal-based interaction for quick searches
- π¨ Web GUI: Next.js dashboard (coming in Phase 5)
- π VS Code Integration: Click files to open directly in VS Code
- β‘ Fast: Two-stage search (keyword pre-filter + semantic analysis) for speed
- π Technology Detection: Automatically identifies tech stack in your repositories
- Node.js 20+ and pnpm (or npm)
- ANTHROPIC_API_KEY (Claude API key) in
.env - VS Code (optional, for file opening)
-
Clone and install dependencies:
cd codescan pnpm install -
Create
.envfile with your API key:cp .env.example .env # Edit .env and add your ANTHROPIC_API_KEY=sk-ant-... -
Build packages:
pnpm build
To use codescan command directly instead of pnpm cli, link the CLI globally:
# Link CLI to system PATH
cd packages/cli
pnpm link --global
# Now you can use codescan from anywhere:
codescan init
codescan index
codescan search "your query"
codescan server startIf using npm instead of pnpm:
cd packages/cli
npm linkTo unlink later:
pnpm unlink --global
# or: npm unlink -g codescanThe CLI commands need the backend API server running. Start it in one terminal:
If using global CLI (recommended):
codescan server startOr if using pnpm directly:
pnpm server
# Or: pnpm cli server startServer runs on http://localhost:3000
Configure which directories to search:
With global CLI:
codescan init /path/to/your/code "My Code"Or with pnpm:
pnpm cli init /path/to/your/code "My Code"You'll be prompted to add directories. Example:
? Enter directory path: /Users/yourusername/projects
? Include subdirectories? Yes
? Add another directory? No
Index your repositories (one-time or periodic):
With global CLI:
codescan indexOr with pnpm:
pnpm cli indexThis scans files, extracts functions/classes, and builds the semantic search index. First run takes a minute or two depending on code volume.
Search from command line:
With global CLI:
codescan search "Microsoft Teams notifications"
codescan search "authentication logic" --tech teams-sdk
codescan search "React hooks" --repo my-web-app --max 10Or with pnpm:
pnpm cli search "Microsoft Teams notifications"
pnpm cli search "authentication logic" --tech teams-sdk
pnpm cli search "React hooks" --repo my-web-app --max 10Options:
--tech <technology>- Filter by tech (e.g., "react", "teams-sdk")--repo <repository>- Search specific repository--lang <language>- Filter by language (e.g., "typescript", "python")--max <number>- Maximum results (default: 20)
For exploratory searching with follow-ups:
With global CLI:
codescan chatOr with pnpm:
pnpm cli chatExample session:
> Find code using OAuth
π Searching repositories...
Found 5 matches:
[auth-service] src/lib/oauth.ts - Login implementation
[web-app] src/auth/provider.ts - OAuth provider setup
...
> Show me the first one in detail
[Full code displayed with syntax highlighting]
> How does it integrate with the API?
[AI responds and searches for related code...]
View indexing progress and statistics:
With global CLI:
codescan statusOr with pnpm:
pnpm cli statusShows:
- Index status (indexing, ready)
- Total repositories, files, chunks
- Database size
- Recent searches
See all indexed repositories:
With global CLI:
codescan reposOr with pnpm:
pnpm cli reposShows repository name, path, file count, tech stack, and last indexed time.
CodeScan stores configuration in your home directory: ~/.config/codescan/config.json
Auto-created on first run with defaults. You can edit manually or use codescan init to reconfigure.
Example configuration:
{
"searchPaths": [
{
"path": "/Users/yourusername/projects",
"name": "My Projects",
"exclude": ["node_modules", "dist", ".git"]
}
],
"search": {
"maxResults": 20,
"minRelevanceScore": 50
},
"ai": {
"model": "claude-3-5-sonnet-20241022",
"maxTokens": 4096
}
}Monorepo structure with three packages:
-
packages/api- Express backend server with:- SQLite semantic indexing
- Two-stage search engine
- Claude API integration for semantic analysis
- RESTful API endpoints
- Chat session management
-
packages/cli- Terminal interface:- Commands for indexing, searching, chatting
- Interactive prompts with Inquirer
- Formatted output with syntax highlighting
- VS Code integration links
-
packages/web- Next.js GUI (in development):- Dashboard with statistics
- Search interface with filters
- Interactive chat
- Code preview with Monaco Editor
- Repository management
-
packages/shared- Shared TypeScript types used by all packages
-
Stage 1 - Keyword Pre-filtering (fast):
- SQLite FTS5 full-text search
- Filters ~100-1000 candidate code chunks in <100ms
- Cheap (no API calls)
-
Stage 2 - Semantic Analysis (accurate):
- Send top candidates to Claude API
- AI scores relevance (0-100)
- Explains why each result matches
- Ranks by multiple signals: semantic score, keyword quality, recency, code simplicity, tech match
- Scan configured directories for source code
- Parse files using tree-sitter AST parser (TypeScript, JavaScript, Python, etc.)
- Extract functions, classes, methods as semantic chunks
- Detect technology stack (package.json, imports)
- Store in SQLite with full-text search indexes
- Watch for file changes (upcoming feature)
Available npm scripts:
# Start everything
pnpm dev # Runs API + CLI in watch mode
# Run packages individually
pnpm api # Just start API server
pnpm cli # CLI commands in watch mode
pnpm web # Start Next.js dev server (Phase 5)
# Build
pnpm build # Build all packages
pnpm clean # Remove dist/ folders
# Monorepo
pnpm turbo:run <task> # Run task across all packages with TurborepoCreate .env in project root:
# Required
ANTHROPIC_API_KEY=sk-ant-...
# Optional (defaults shown)
NODE_ENV=development
API_PORT=3000
DB_PATH=~/.config/codescan/index.db
LOG_LEVEL=info- CLI commands too long? Use global CLI installation (see above) to use
codescancommand directly - First indexing slow? That's normal. Depends on your code volume. 1000 files β 30 seconds.
- API key cost? Semantic search uses Claude API. Cost depends on query complexity (~$0.01-$0.10 per search).
- Want to re-index? Just run
codescan indexorpnpm cli indexagain. It detects changes. - API not running? Start it in another terminal with
codescan server startorpnpm server - Something not working? Check logs with
LOG_LEVEL=debug pnpm apifor detailed output.
- Phase 5: Web GUI with dashboard and visual search interface
- Real-time file watching for incremental index updates
- Support for more languages (Go, Rust, Java)
- Code diff analysis and git blame integration
- Export search results to various formats
MIT