Skip to content
Back to search

codemogger

Codemogger is a code indexing library and MCP server for AI coding agents

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/glommer--codemogger/badge.svg)](/listings/glommer--codemogger)

HTML

<a href="/listings/glommer--codemogger"><img src="/api/listings/glommer--codemogger/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

npm install -g codemogger

Or use `npx` to run without installing.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 215 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. <p align="center">
  2. <img src="codemogger.png" alt="codemogger" width="200">
  3. </p>
  4. # codemogger
  5. Code indexing library for AI coding agents. Parses source code with tree-sitter, chunks it into semantic units (functions, structs, classes, impl blocks), embeds them locally, and stores everything in a single SQLite file with vector + full-text search.
  6. No Docker, no server, no API keys. One `.db` file per codebase.
  7. ## Why
  8. Coding agents need to understand codebases. They need to find where things are defined, discover how concepts are implemented across files, and navigate unfamiliar code quickly. This requires both keyword search (precise identifier lookup) and semantic search (natural language queries when you don't know the exact names).
  9. As AI coding tools become more composable - agents calling agents, MCP servers plugging into different hosts - this capability needs to exist as a library that runs locally. No external servers, no API keys, no Docker containers. Just a function call that returns results.
  10. codemogger is that library. Embedded SQLite (via [Turso](https://turso.tech)) with FTS + vector search in a single `.db` file.
  11. ## Install
  12. ```bash
  13. npm install -g codemogger
  14. ```
  15. Or use `npx` to run without installing.
  16. ## Quick start
  17. ```bash
  18. # Index a project
  19. codemogger index ./my-project
  20. # Search
  21. codemogger search "authentication middleware"
  22. ```
  23. Add to your coding agent's MCP config (Claude Code, OpenCode, etc.):
  24. ```json
  25. {
  26. "mcpServers": {
  27. "codemogger": {
  28. "command": "npx",
  29. "args": ["-y", "codemogger", "mcp"]
  30. }
  31. }
  32. }
  33. ```
  34. The MCP server exposes three tools:
  35. - `codemogger_search` - semantic and keyword search over indexed code
  36. - `codemogger_index` - index a codebase for the first time
  37. - `codemogger_reindex` - update the index after modifying files
  38. Add the local db to `.gitignore`:
  39. ```gitignore
  40. # codemogger db
  41. .codemogger/
  42. ```
  43. ## SDK
  44. codemogger is also usable as a library. The SDK has no model dependency - you provide your own embedding function:
  45. ```typescript
  46. import { CodeIndex } from "codemogger"
  47. import { pipeline } from "@huggingface/transformers"
  48. // Load embedding model (runs locally, no API keys)
  49. const extractor = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2", { dtype: "q8" })
  50. const embedder = async (texts: string[]): Promise<number[][]> => {
  51. const output = await extractor(texts, { pooling: "mean", normalize: true })
  52. return output.tolist() as number[][]
  53. }
  54. const db = new CodeIndex({
  55. dbPath: "./my-project.db",
  56. embedder,
  57. embeddingModel: "all-MiniLM-L6-v2",
  58. })
  59. await db.index("/path/to/project")
  60. // Semantic: "what does this codebase do?"
  61. const results = await db.search("authentication middleware", { mode: "semantic" })
  62. // Keyword: precise identifier lookup
  63. const results = await db.search("BTreeCursor", { mode: "keyword" })
  64. await db.close()
  65. ```
  66. The MCP server and CLI ship with `all-MiniLM-L6-v2` by default.
  67. ## CLI
  68. ```bash
  69. # Install globally
  70. npm install -g codemogger
  71. # Index a directory
  72. codemogger index ./my-project
  73. # Search
  74. codemogger search "authentication middleware"
  75. # List indexed codebases
  76. codemogger list
  77. ```
  78. ## How it works
  79. 1. **Scan** - walk directory, respect `.gitignore`, detect language from extension
  80. 2. **Chunk** - parse each file with tree-sitter (WASM), extract top-level definitions (functions, structs, classes, impl blocks). Items >150 lines are split into sub-items.
  81. 3. **Embed** - encode each chunk with the provided embedding model (runs locally, no API)
  82. 4. **Store** - write chunks + embeddings to SQLite with FTS index
  83. 5. **Search** - vector cosine similarity (semantic) or FTS with weighted fields (keyword)
  84. Incremental: only changed files (by SHA-256 hash) are re-processed on subsequent runs.
  85. ## Languages
  86. Rust, C, C++, Go, Python, Zig, Java, Scala, JavaScript, TypeScript, TSX, PHP, Ruby.
  87. ## Benchmarks
  88. Benchmarked on 4 real-world codebases on an Apple M2 (8GB). Each project uses its own isolated database. Embeddings use `vector8` (int8 quantized, 395 bytes/chunk vs 1,536 for float32). Embedding model: `all-MiniLM-L6-v2` (q8 quantized, local CPU). Search times are p50 over 3 runs.
  89. ### Performance
  90. | Project | Language | Files | Semantic | Keyword | ripgrep |
  91. |---------|----------|------:|---------:|--------:|--------:|
  92. | [Turso](https://github.com/tursodatabase/turso) | Rust | 748 | 35 ms | 1 ms | 25 ms |
  93. | [Bun](https://github.com/oven-sh/bun) | Zig | 9,255 | 137 ms | 2 ms | 166 ms |
  94. | [TypeScript](https://github.com/microsoft/TypeScript) | TypeScript | 39,298 | 242 ms | 4 ms | 1,500 ms |
  95. | [Kubernetes](https://github.com/kubernetes/kubernetes) | Go | 16,668 | 617 ms | 12 ms | 731 ms |
  96. Keyword search is **25x-370x faster than ripgrep** and returns precise definitions instead of thousands of file matches.
  97. Indexing is a one-time cost dominated by embedding (~97% of time). Subsequent runs only re-embed changed files.
  98. ### Search quality: semantic search vs ripgrep
  99. The real advantage isn't speed - it's **finding the right code when you don't know the exact keywords**.
  100. **"write-ahead log replication and synchronization"** (Turso)
  101. | codemogger (top 5) | ripgrep |
  102. |---|---|
  103. | `impl LogicalLog` - core/mvcc/persistent_storage/logical_log.rs | 3 files matched |
  104. | `enum CommitState` - core/mvcc/database/mod.rs | (keyword: "write-ahead") |
  105. | `function new` - core/mvcc/database/checkpoint_state_machine.rs | |
  106. | `struct LogicalLog` - core/mvcc/persistent_storage/logical_log.rs | |
  107. | `function checkpoint_shutdown` - core/storage/pager.rs | |
  108. **"SQL statement parsing and compilation"** (Turso)
  109. | codemogger (top 5) | ripgrep |
  110. |---|---|
  111. | `function parse_and_build` - core/translate/logical.rs | 139 files matched |
  112. | `macro compile_sql` - core/incremental/compiler.rs | (keyword: "statement") |
  113. | `function parse_from_clause_opt` - parser/src/parser.rs | |
  114. | `function parse_from_clause_table` - core/translate/planner.rs | |
  115. | `function parse_table` - core/translate/planner.rs | |
  116. **"HTTP request parsing and response writing"** (Bun)
  117. | codemogger (top 5) | ripgrep |
  118. |---|---|
  119. | `function consumeRequestLine` - packages/bun-uws/src/HttpParser.h | 0 files matched |
  120. | `declaration ConsumeRequestLineResult` - packages/bun-uws/src/HttpParser.h | (keyword: "HTTP") |
  121. | `function llhttp__after_headers_complete` - src/bun.js/bindings/node/http/llhttp/http.c | |
  122. | `function llhttp_message_needs_eof` - src/bun.js/bindings/node/http/llhttp/http.c | |
  123. | `function shortRead` - packages/bun-uws/src/HttpParser.h | |
  124. **"scheduling pods to nodes based on resource requirements"** (Kubernetes)
  125. | codemogger (top 5) | ripgrep |
  126. |---|---|
  127. | `type Scheduling` - staging/src/k8s.io/api/node/v1beta1/types.go | 429 files matched |
  128. | `type Scheduling` - staging/src/k8s.io/api/node/v1/types.go | (keyword: "scheduling") |
  129. | `type SchedulingApplyConfiguration` - staging/.../node/v1/scheduling.go | |
  130. | `function runPodAndGetNodeName` - test/e2e/scheduling/predicates.go | |
  131. | `type createPodsOp` - test/integration/scheduler_perf/scheduler_perf.go | |
  132. **"container health check probes and restart policy"** (Kubernetes)
  133. | codemogger (top 5) | ripgrep |
  134. |---|---|
  135. | `type ContainerFailures` - test/utils/conditions.go | 1,652 files matched |
  136. | `variable _` - test/e2e/common/node/container_probe.go | (keyword: "container") |
  137. | `function checkContainerStateTransition` - pkg/kubelet/status/status_manager.go | |
  138. | `function TestDoProbe_TerminatedContainerWithRestartPolicyNever` - pkg/kubelet/prober/worker_test.go | |
  139. | `function proveHealthCheckNodePortDeallocated` - pkg/registry/core/service/storage/storage_test.go | |
  140. ripgrep matches thousands of files on common keywords. codemogger returns the 5 most relevant definitions.
  141. ## Dependencies note
  142. `@tursodatabase/database` is currently pinned to a pre-release version (`0.5.0-pre.14`). There is no stable `0.5.x` release yet; once one is published this should be updated. The pre-release is stable enough for development use but may have breaking changes before it reaches a final release.
  143. ## Architecture
  144. - **Bun/TypeScript** runtime
  145. - **tree-sitter (WASM)** for AST-aware chunking - 13 language grammars
  146. - **all-MiniLM-L6-v2** for local embeddings (384 dimensions, q8 quantized)
  147. - **Turso** for storage - embedded SQLite with FTS + vector search extensions
  148. - **Single DB file** stores multiple codebases with per-codebase FTS tables and global vector search
  149. ## License
  150. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.