Show HN: Mantic.sh – A structural code search engine for AI agents
Mantic A structural code search engine for AI agents. Provides sub-500ms file ranking across massive codebases without embeddings, vector databases, or external dependencies. What's New in v1.0.1...
Mantic
A structural code search engine for AI agents. Provides sub-500ms file ranking across massive codebases without embeddings, vector databases, or external dependencies.
What's New in v1.0.13
Environment Variables: Implemented all three documented environment variables that were previously non-functional
MANTIC_IGNORE_PATTERNS - Custom glob patterns to exclude files (comma-separated)
MANTIC_MAX_FILES - Limit number of files returned (default: 300)
MANTIC_TIMEOUT - Search timeout in milliseconds (default: 5000ms)
Bug Fixes: Fixed glob pattern matching regex that was preventing ignore patterns from working correctly
Performance: Added timeout wrapper to prevent hanging on extremely large repositories
Table of Contents
About the Project
Proprietary vs Mantic
Features
Installation (CLI & MCP)
CLI Installation
MCP Server Installation
Usage
Agent Rules
Performance
How It Works
License
About the Project
Mantic is an infrastructure layer designed to remove unnecessary context retrieval overhead for AI agents. It infers intent from file structure and metadata rather than brute-force reading content, enabling retrieval speeds faster than human reaction time.
Key Benefits
Speed: Retrieval is consistently under 500ms, even for large repositories.
Efficiency: Reduces token usage by up to 63% by filtering irrelevant files before reading.
Privacy: Runs entirely locally with zero data egress.
Proprietary vs Mantic (Cost Analysis)
For a team of 100 developers performing 100 searches per day:
Tool
Annual Cost
Per-Search Cost
Privacy
Mantic
$0
$0
Local-First
Vector Embeddings
$10,950
$0.003
Cloud
SaaS Alternatives
$109,500
$0.003
Cloud
Features
Sub-500ms retrieval on large monorepos (Chromium: 480k files).
Zero external dependencies (no API keys, no databases).
Git-native file scanning (prioritizes tracked files).
Deterministic scoring (consistent, predictable results).
Native MCP support (works with Claude Desktop, Cursor).
Impact analysis (identifies potential blast radius of changes).
Installation
CLI Installation
Quick Start (no installation required):
# Run directly with npx
npx mantic.sh@latest "your search query"
From Source:
git clone https://github.com/marcoaapfortes/Mantic.sh.git
cd Mantic.sh
npm install
npm run build
npm link
MCP Server Installation
Mantic works as an MCP (Model Context Protocol) server for Claude Desktop, Cursor, VS Code, and other MCP-compatible tools.
One-Click Install:
Install in Cursor
Install in VS Code
Manual Configuration (for Claude Desktop or other MCP clients):
Add this to your MCP settings file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mantic": {
"command": "npx",
"args": ["-y", "mantic.sh@latest", "server"]
}
}
}
Restart Claude Desktop, and Mantic will be available as the search_codebase tool.
For IDE Users (Cursor/VS Code):
If you're using Mantic in an IDE rather than Claude Desktop, you can also add the Agent Rules to your IDE's system prompt or "Rules for AI" section. This teaches the AI to automatically use Mantic before writing code. (Note: Agent Rules are for IDEs only, not needed for Claude Desktop)
Usage
Basic Search
Find files matching your intent:
mantic "stripe payment integration"
Returns JSON with ranked files, confidence scores, and token estimates.
CLI Options
mantic [options]
Options:
--code Only search code files (.ts, .js, etc)
--config Only search config files
--test Only search test files
--json Output as JSON (default)
--files Output as newline-separated file paths
--impact Include dependency analysis
--session Use session for context carryover
Agent Rules (Auto-Pilot)
Want Cursor or Claude to use Mantic automatically?
Copy the Agent Rules.
Paste them into your AI tool's system prompt or "Rules for AI" section.
The Agent will now automatically use mantic to find context before writing code.
Performance
Latency Benchmarks (M1 Pro)
Codebase
Files
Size
Mantic
Vector Search
Improvement
Cal.com
9,621
~500MB
0.32s
0.85s
2.7x faster
Chromium
480,000
59GB
0.46s
5-10s
11-22x faster
How It Works
Architecture Overview
User Query
↓
Intent Analyzer (categorizes: UI/backend/auth/etc)
↓
Brain Scorer (ranks files using metadata)
↓
File Classifier (filters by type: code/config/test)
↓
Impact Analyzer (calculates blast radius)
↓
Output (JSON/Files/Markdown/MCP)
Core Algorithm
Intent Recognition: Analyzes query to determine code category (e.g., "auth", "ui").
File Enumeration: Uses git ls-files for tracked files (significantly faster than standard traversals).
Structural Scoring: Ranks files based on:
Path relevance: packages/features/payments indicates high signal.
Filename matching: stripe.service.ts > stripe.txt.
Business logic awareness: .service.ts boosted over .test.ts.
Boilerplate penalties: index.ts or page.tsx ranked lower to reduce noise.
Confidence Scoring: Assigns a relevance score to each result.
Configuration
Mantic works out of the box with zero configuration for most projects.
Environment Variables
MANTIC_MAX_FILES=5000 # Maximum files to scan
MANTIC_TIMEOUT=5000 # Search timeout in ms
MANTIC_IGNORE_PATTERNS=... # Custom glob patterns to ignore
License
Mantic is licensed under the AGPL-3.0 License.
Usage Guidelines
Free for: Individual developers, open source projects, and internal business use.
License required for: Commercial embedding in products you sell or offering Mantic as a hosted service.
Commercial Inquiries: license@mantic.sh
See LICENSE file for full details.