Skip to main content

Smart context manager for AI coding assistants — saves millions of tokens by building a local memory of your project

Project description

smartctx 🧠

Save millions of tokens per day by giving AI coding assistants smart, curated context instead of your whole codebase.

The Problem

Every time you start a Claude Code / Cursor / Copilot session, it reads your entire project — hundreds of files, thousands of lines. That's hundreds of thousands of tokens, every single session.

The Solution

smartctx builds a local memory of your project once, then gives AI tools only the files relevant to your current task.

Without smartctx:  Claude reads 500 files = ~800,000 tokens per session 😬
With smartctx:     Claude reads 8 files   = ~12,000 tokens per session  ✅

Savings: ~98% token reduction

Install

# npm
npm install -g smartctx

# pip
pip install smartctx

Quick Start

# 1. Set your API key (one time, saved globally)
smartctx config --api-key sk-ant-xxxxx

# 2. Initialize your project (one-time scan)
cd your-project
smartctx init

# 3. Before each AI session, query for your task
smartctx query "add authentication middleware"
# → generates CLAUDE.md with only the relevant files

# 4. Start Claude Code — it reads the lean CLAUDE.md
claude

Commands

Command Description
smartctx init First-time setup — scans and summarizes all files
smartctx sync Refresh changed files only (run daily/weekly)
smartctx query "task" Generate lean context file for your task
smartctx status Show index stats
smartctx config View/set configuration

Multi-AI Support

smartctx query "add auth" --for claude    # → CLAUDE.md
smartctx query "add auth" --for cursor    # → .cursorrules
smartctx query "add auth" --for copilot  # → .github/copilot-instructions.md
smartctx query "add auth" --for codex    # → AGENTS.md

How It Works

  1. init — Scans your project, calls Claude Haiku (cheapest model) once per file to generate a summary. Saves everything to .smartctx/index.json locally.

  2. sync — Detects changed files (by modification time) and only re-summarizes those. Free for unchanged files.

  3. query — Runs a local keyword search (zero API cost) over your summaries. Finds the top 10 most relevant files. Generates a lean context file.

  4. AI Session — Your AI tool reads a 5-15k token context file instead of your 500k+ codebase.

Cost

  • Init: ~$0.0004 per file (Claude Haiku pricing) — a 100-file project costs ~$0.04 total
  • Sync: Only pays for changed files — usually free
  • Query: $0.00 — runs locally
  • Daily use: $0.00

Works With

  • ✅ Node.js / TypeScript projects
  • ✅ Python projects
  • ✅ Go, Rust, Java, any language
  • ✅ Any file-based project

Configuration

smartctx config --api-key sk-ant-xxxxx    # Set API key
smartctx config --target cursor           # Default output format
smartctx config --schedule weekly         # Reminder schedule

.gitignore

Add .smartctx/ to your .gitignore (it's project-specific local data):

.smartctx/
CLAUDE.md

License

MIT

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

smartctx-0.1.2.tar.gz (13.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

smartctx-0.1.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

smartctx-0.1.2-cp310-cp310-win_amd64.whl (834.9 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file smartctx-0.1.2.tar.gz.

File metadata

  • Download URL: smartctx-0.1.2.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for smartctx-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3ed2d7b58b37030e37b2c28e29c76b18cad63d409be4a66b87c4c428f786dfda
MD5 c1f1e121597128586e7a12961160346a
BLAKE2b-256 27979a61ca36933f0272af209bc03c4e6bf4e3c22b495edf9c3bc0402fa6055f

See more details on using hashes here.

File details

Details for the file smartctx-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: smartctx-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for smartctx-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5c0bf351c24daa7d684fef9d65c313e674f6886d9d9fa948337e46556addd81d
MD5 aeb00b49d7f4ab82c800685126c336c8
BLAKE2b-256 480d1ff0e562ccf090b225a938a5b805c8c109c9dc097c713ac109bcbdfed883

See more details on using hashes here.

File details

Details for the file smartctx-0.1.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: smartctx-0.1.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 834.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for smartctx-0.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e4a34861f0e5cc2e0f8a1a4fbd105ad7c9a98c0a408e0b796449d76e120c6e45
MD5 191dd45d8765b7719880b858d50dc06e
BLAKE2b-256 69f6997adbbb486638a45b69777aceb31ebf026820c8cbc5792a4986bd66c843

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page