Adaptive Neural Knowledge System + PostToolUse compression hooks. Two-phase token optimization (retrieval + consumption) for Claude Code.
Project description
๐ง NeuralMind
Two-phase token optimization for Claude Code โ smart retrieval + tool-output compression in one package.
Most tools save tokens on what you fetch OR on what Claude sees back โ never both. NeuralMind v0.2.0 does both in one
pip install.
โก Two-phase optimization
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Phase 1: Retrieval โ what to fetch โ
โ neuralmind wakeup . โ ~365 tokens (vs 50K raw) โ
โ neuralmind query "?" โ ~800 tokens (vs 2,700 raw) โ
โ mcp: neuralmind_skeleton โ graph-backed file view โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Phase 2: Consumption โ what Claude actually sees โ
โ PostToolUse hooks compress Read/Bash/Grep output โ
โ File reads โ graph skeleton (~88% reduction) โ
โ Bash output โ errors + summary (~91% reduction) โ
โ Search results โ capped at 25 matches โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Combined effect: 5-10ร total reduction vs baseline Claude Code.
๐ฏ The Problem
You: "How does authentication work in my codebase?"
โ Traditional: Load entire codebase โ 50,000 tokens โ $0.15-$3.75/query
โ
NeuralMind: Smart context โ 766 tokens โ $0.002-$0.06/query
๐ฐ Real Savings
| Model | Without NeuralMind | With NeuralMind | Monthly Savings |
|---|---|---|---|
| Claude 3.5 Sonnet | $450/month | $7/month | $443 |
| GPT-4o | $750/month | $12/month | $738 |
| GPT-4.5 | $11,250/month | $180/month | $11,070 |
| Claude Opus | $2,250/month | $36/month | $2,214 |
Based on 100 queries/day. Pricing sources
๐ Quick Start
# Install
pip install neuralmind graphifyy
# Generate knowledge graph
cd your-project
graphify update .
# Build neural index
neuralmind build .
# (v0.2.0) Install PostToolUse hooks โ compresses Read/Bash/Grep
neuralmind install-hooks .
# Query your codebase
neuralmind query . "How does authentication work?"
# (v0.2.0) Skeleton view of a file without loading source
neuralmind skeleton tools/voiceover.py
โจ Key Features
| Feature | Description |
|---|---|
| 4-Layer Context | Progressive disclosure โ only loads what's relevant |
| Semantic Search | Finds code by meaning, not just keywords |
| Query-Aware | Different questions get different context |
| CLI Tool | Simple commands: build, query, wakeup, search |
| MCP Server | Direct integration with Claude Desktop & Cursor |
| Auto-Updates | Git hooks and scheduled maintenance |
๐ Benchmarks
| Project | Nodes | Avg Token Reduction |
|---|---|---|
| cmmc20 (React/Node) | 241 | 65.6x |
| mempalace (Python) | 1,626 | 46.0x |
๐ง How It Works
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 0: Project Identity (~100 tokens) - ALWAYS LOADED โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 1: Architecture Summary (~300 tokens) - ALWAYS LOADED โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 2: Relevant Modules (~300 tokens) - QUERY-SPECIFIC โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 3: Semantic Search (~300 tokens) - QUERY-SPECIFIC โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Total: ~800-1,100 tokens vs 50,000+ for full codebase
๐ Use Cases
- Daily Development โ Get context for AI coding questions
- New Developer Onboarding โ Generate project overviews
- Code Review โ Understand related code quickly
- Documentation โ AI-assisted docs from actual code
- CI/CD Integration โ Auto-update context files
- IDE Integration โ MCP server for Claude/Cursor
๐ See full use cases and examples in USAGE.md
๐ฅ๏ธ CLI Commands
| Command | Purpose |
|---|---|
neuralmind build . |
Build/rebuild neural index |
neuralmind query . "..." |
Query with natural language |
neuralmind wakeup . |
Get project overview |
neuralmind search . "..." |
Direct semantic search |
neuralmind benchmark . |
Measure token reduction |
neuralmind stats . |
Show index statistics |
neuralmind skeleton <file> |
v0.2.0 Compact graph-backed file view |
neuralmind install-hooks . |
v0.2.0 Install PostToolUse compression hooks (project) |
neuralmind install-hooks --global |
v0.2.0 Install hooks globally for all projects |
neuralmind install-hooks --uninstall |
v0.2.0 Remove hooks (preserves other tools' hooks) |
neuralmind init-hook . |
Install git post-commit hook (auto-rebuild on commit) |
๐ช PostToolUse Compression (v0.2.0)
NeuralMind ships with Claude Code hooks that compress tool outputs before the model sees them:
| Tool | Compression | Typical savings |
|---|---|---|
| Read | Replaces raw source with graph skeleton (functions, rationales, call graph) | ~88% |
| Bash | Keeps errors + last 3 lines + summary; drops routine output | ~91% |
| Grep | Caps at 25 matches + "N more hidden" pointer | varies |
Install per-project (recommended):
cd my-project
neuralmind install-hooks . # writes .claude/settings.json
Install globally (all projects):
neuralmind install-hooks --global # writes ~/.claude/settings.json
Bypass temporarily (for debugging):
NEURALMIND_BYPASS=1 claude-code ...
Uninstall cleanly (preserves other hooks):
neuralmind install-hooks --uninstall # project
neuralmind install-hooks --uninstall --global # global
The hook installer is idempotent and non-destructive โ existing hooks from other tools (Prettier, Black, etc.) are preserved.
Coming from Pith?
NeuralMind v0.2.0 provides full Pith-parity compression plus graph-backed retrieval โ both in one package. Migration:
# Remove Pith global hooks, then:
pip install neuralmind
neuralmind install-hooks --global
Unlike Pith's regex-based skeletonization, NeuralMind uses the semantic graph you've already built, so skeletons include rationales, call graphs, and cross-file edges that regex can't extract.
โฐ Scheduling Updates
Git Hook (Recommended)
# .git/hooks/post-commit
#!/bin/bash
graphify update . --quiet
neuralmind build . --quiet
Cron Job
# Daily at 6 AM
0 6 * * * cd /project && graphify update . && neuralmind build .
CI/CD
- run: pip install neuralmind graphifyy
- run: graphify update . && neuralmind build .
- run: neuralmind wakeup . > AI_CONTEXT.md
๐ See full scheduling guide in USAGE.md
๐ MCP Server Integration
For Claude Desktop or Cursor:
{
"mcpServers": {
"neuralmind": {
"command": "neuralmind-mcp",
"args": ["/path/to/project"]
}
}
}
Exposed MCP tools (v0.2.0):
| Tool | Purpose |
|---|---|
mcp__neuralmind__wakeup |
Minimal project overview (~365 tokens) |
mcp__neuralmind__query |
Natural language code query (~800 tokens) |
mcp__neuralmind__search |
Direct semantic search with scores |
mcp__neuralmind__skeleton |
v0.2.0 Compact file view (functions, rationales, calls) |
mcp__neuralmind__stats |
Index health |
mcp__neuralmind__benchmark |
Measure token reduction |
mcp__neuralmind__build |
Rebuild index |
Project-scoped auto-registration: drop a .mcp.json at your project root and Claude Code loads it on open:
{
"mcpServers": {
"neuralmind": {
"command": "neuralmind-mcp",
"args": ["."]
}
}
}
๐ Documentation
- USAGE.md โ Complete usage guide with examples
- Wiki โ Full documentation
- API Reference โ Python API docs
๐ค Contributing
See CONTRIBUTING.md for guidelines.
๐ License
MIT License โ see LICENSE for details.
โญ Star this repo if NeuralMind saves you money!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neuralmind-0.2.2.tar.gz.
File metadata
- Download URL: neuralmind-0.2.2.tar.gz
- Upload date:
- Size: 30.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be9782614692ef6860f69f5b117fe075758fddd73fef29b4a861a971b8a576c6
|
|
| MD5 |
84cfc826ca79388628cc4c12522ac4ef
|
|
| BLAKE2b-256 |
ad0d397321f62cd52f1f46f6721b8459398d8ec6e3a5865f336c4c8e46673990
|
Provenance
The following attestation bundles were made for neuralmind-0.2.2.tar.gz:
Publisher:
release.yml on dfrostar/neuralmind
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neuralmind-0.2.2.tar.gz -
Subject digest:
be9782614692ef6860f69f5b117fe075758fddd73fef29b4a861a971b8a576c6 - Sigstore transparency entry: 1339644762
- Sigstore integration time:
-
Permalink:
dfrostar/neuralmind@d00afff639f9c2871d117e3db72c0645953e7929 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/dfrostar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d00afff639f9c2871d117e3db72c0645953e7929 -
Trigger Event:
push
-
Statement type:
File details
Details for the file neuralmind-0.2.2-py3-none-any.whl.
File metadata
- Download URL: neuralmind-0.2.2-py3-none-any.whl
- Upload date:
- Size: 35.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e937db09820bda5ae26a1aabddb9162a877cfd4728b30ed53e425097a451ce82
|
|
| MD5 |
cc1d2c95886e3c344dce67c5ea54381e
|
|
| BLAKE2b-256 |
ec95d7b9916abd6eb69594c62567539df238ef25e91c4768dde8720b426ed501
|
Provenance
The following attestation bundles were made for neuralmind-0.2.2-py3-none-any.whl:
Publisher:
release.yml on dfrostar/neuralmind
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neuralmind-0.2.2-py3-none-any.whl -
Subject digest:
e937db09820bda5ae26a1aabddb9162a877cfd4728b30ed53e425097a451ce82 - Sigstore transparency entry: 1339644769
- Sigstore integration time:
-
Permalink:
dfrostar/neuralmind@d00afff639f9c2871d117e3db72c0645953e7929 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/dfrostar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d00afff639f9c2871d117e3db72c0645953e7929 -
Trigger Event:
push
-
Statement type: