Skip to main content

Ask questions about any codebase using AI — your code stays private

Project description

askmycode

Ask questions about any codebase in plain English. Your code never leaves your machine.

$ askmycode ask "how does authentication work?"

Authentication is handled in src/auth/middleware.py (lines 12–45).
The require_auth decorator validates a JWT from the Authorization header,
looks up the user in the session store (Redis), and attaches the user object
to the request context. Unauthenticated requests are rejected with a 401...

demo

PyPI version Python 3.9+ License: MIT


Why askmycode?

Most AI coding tools send your entire codebase to a remote server. askmycode doesn't.

  • Your code stays local. Only the question + a few relevant snippets reach the AI.
  • Works on any codebase — Python, Go, TypeScript, Rust, Java, and more.
  • No more grepping. Ask "where is the rate limiter?" instead of grep -r "rate" .
  • Onboarding superpower. New to a repo? Ask questions instead of reading every file.
  • Multi-provider. Gemini (free tier), OpenAI, Claude, or fully offline via Ollama.

How it works

Your code  ──►  chunked locally  ──►  embedded locally  ──►  stored in local vector DB
                                                                        │
Your question ──► embed locally ──► find top chunks ──► send to AI ──► Answer
                                         ↑
                           only ~500 lines of relevant code
                           travel to the AI, not your whole repo

Embeddings run on your machine via sentence-transformers. Only the retrieved snippets and your question are sent to the LLM.


Install

pip install askmycode

Or from source:

git clone https://github.com/NewtYao/askmycode
cd askmycode
pip install -e .

Quick start

1. Set your API key

askmycode config set-key YOUR_GEMINI_KEY   # get a free key at aistudio.google.com

2. Initialise your project (optional — sets up .gitignore and suggests starter questions)

cd your-project/
askmycode init .

3. Index your codebase (run once; re-run after big changes)

askmycode index .

4. Ask questions

askmycode ask "where is the database connection configured?"
askmycode ask "how does the retry logic work?"
askmycode ask "what does UserService do?"

Commands

askmycode ask

askmycode ask "your question"
  --sources, -s       Show which files and lines were used to answer
  --results, -n INT   Chunks to retrieve (default: 8)
  --provider TEXT     gemini | openai | anthropic | ollama
  --model TEXT        Model name override
  --project, -p PATH  Path to indexed project (default: .)
# Show sources alongside the answer
askmycode ask "how is caching implemented?" --sources

# Use a different provider for one question
askmycode ask "what does this codebase do?" --provider openai

askmycode chat

Multi-turn conversation — follow-up questions remember previous answers.

askmycode chat

You: how does auth work?
Assistant: ...

You: what about the refresh token flow?   # remembers the previous answer
Assistant: ...

askmycode index

askmycode index .                 # index current directory
askmycode index /path/to/project  # index a specific path

Re-indexing is incremental — only changed files are re-embedded.

askmycode stats

askmycode stats

Files indexed:  42
Total chunks:   187
Last indexed:   2026-05-23 14:30:01
Index location: /your/project/.askmycode

askmycode init

askmycode init .

Detects your project type (Python, Go, Node, Rust...), adds .askmycode/ to .gitignore, and prints suggested first questions.

askmycode config

askmycode config set-key   YOUR_API_KEY
askmycode config set-provider  gemini      # gemini | openai | anthropic | ollama
askmycode config set-model     gpt-4o      # optional model override
askmycode config show

Multiple providers

Provider Command Notes
Gemini (default) config set-provider gemini Free tier at aistudio.google.com
OpenAI config set-provider openai Requires OPENAI_API_KEY
Claude config set-provider anthropic Requires ANTHROPIC_API_KEY
Ollama config set-provider ollama 100% offline, no API key

Fully offline with Ollama

# 1. Install Ollama: https://ollama.com
# 2. Pull a model
ollama pull llama3

# 3. Use it
askmycode config set-provider ollama
askmycode config set-model llama3
askmycode ask "how does this work?"   # zero internet required

Per-project config

Commit an .askmycode.toml to share settings with your team:

[askmycode]
provider = "gemini"
model = "gemini-2.5-flash-lite"
n_results = 10

GitHub Action

Add AI-powered Q&A directly to your pull requests. Team members comment /ask <question> and get an instant answer.

Setup:

  1. Add your API key as a repository secret: GEMINI_API_KEY
  2. Create .github/workflows/askmycode.yml (see example)

Usage in a PR:

/ask where is error handling for the payment flow?

The bot replies with the answer + source file references, inline in the PR.


Privacy

What happens Where it goes
Your full codebase Stays on your machine
Embeddings (vector index) Stored in .askmycode/ in your project
Your question + ~500 lines of relevant code Sent to the LLM API

Use --provider ollama for zero data leaving your machine.


Supported file types

Python · JavaScript · TypeScript · Go · Rust · Java · C/C++ · Ruby · PHP · Swift · Kotlin · Scala · Shell · SQL · YAML · JSON · TOML · Markdown · HTML · CSS · Vue · Svelte

Python files are chunked at function and class boundaries using AST parsing, giving higher-quality retrieval than fixed-size splitting.


How retrieval works (technical)

  1. Index: Files are chunked (AST-aware for Python, sliding window for others), embedded with all-MiniLM-L6-v2, and stored in a local ChromaDB.
  2. Query: Your question is embedded. The top n × 3 candidates are fetched by cosine similarity, then re-ranked with a cross-encoder (ms-marco-MiniLM-L-6-v2) for higher precision.
  3. Answer: The top N chunks + a project file tree are sent to the LLM with a developer-focused system prompt. The answer streams back in real time.

Roadmap

  • VS Code extension
  • Watch mode (auto re-index on file save)
  • Semantic diff Q&A (askmycode ask about uncommitted changes)
  • Kotlin / Swift AST chunking
  • Web UI

Contributing

PRs welcome. Run the tool against itself to test:

askmycode index .
askmycode ask "how does the indexer work?"

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

askmycode-0.1.0.tar.gz (150.8 kB view details)

Uploaded Source

Built Distribution

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

askmycode-0.1.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file askmycode-0.1.0.tar.gz.

File metadata

  • Download URL: askmycode-0.1.0.tar.gz
  • Upload date:
  • Size: 150.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for askmycode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 87e49f92de466ba4cd18c6e698c285ac77684403a9155be4a8afbb5ae6120290
MD5 1b8c3dcb76da87bb88831bbc7ea59f79
BLAKE2b-256 8284688c2c17bca584890b1477af99813abe7ed7cee27a6de422572055c73a6b

See more details on using hashes here.

File details

Details for the file askmycode-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: askmycode-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for askmycode-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47f72e12ba75d540116502543da005ba63b32f1ed733009c1a20054e129f07c4
MD5 e893cc564395403e7d6abdf535e906e4
BLAKE2b-256 3d7b8929b4b4be6c9d7e0ffbc16f9b90e309478811e9a43ef6c45145322f1ad6

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