Scan any computer, hard drive, or file server and automatically generate its data handbook: a searchable data catalog and data dictionary in plain English.
DataCodex is an AI agent that reads every file (Excel, CSV, PDF including scanned, Word, PowerPoint, text, code, images), works out what each one contains, what every column means, which column is the unique key, and how files relate to each other. You get a data catalog (what exists and where), a data dictionary (what every column means), and a search engine over all of it.
Keywords: data catalog generator, automated data dictionary, data inventory, metadata discovery, data documentation, data discovery, file system analysis, legacy data migration, inherited computer, Excel primary key detection, schema detection, PDF OCR, Persian OCR, multilingual document search, LLM agent, Claude, Ollama, SQLite FTS5, e-discovery, project handover.
In one sentence: point it at an unfamiliar system, run one command, and get a spreadsheet that documents all the data on it.
| Capability | How it works |
|---|---|
| Full-disk crawl | Scans one folder, several roots, or every local drive (--all-drives). Walks the tree, skips system/dependency folders, records path, type, size, mtime. |
| Duplicate detection | SHA-256 per file (sampled head/middle/tail for files > 256 MB). Each unique file is analyzed once. |
| Spreadsheet intelligence | Auto-detects the real header row, profiles every column (type, uniqueness ratio, samples), finds the unique key column, and asks an LLM for a per-column data dictionary. |
| Cross-file relations | Inverted index over sampled column values finds foreign-key-like links (file A.key -> file B.column) with overlap percentage, no schema needed. |
| PDF -> Markdown (local) | Sampled pages (first N, middle, last) are converted to Markdown by PyMuPDF4LLM, so headings, tables and structure survive; scanned pages go through local OCR (Tesseract fas+eng). No LLM is involved in conversion. |
| Everything else | Word, PowerPoint, TXT/JSON/XML/HTML, source code, ZIP listings, and images (local OCR; vision is opt-in). Text decoding handles UTF-8/16 and Windows-1256 (legacy Persian/Arabic). |
| English output | Source content in any language is translated; original-script titles are preserved in a separate field. |
| Ask interface (agent-ready) | After the scan, ask in any language: where is X? The agent returns the nearest files with full paths, can open them, or e-mail them to an address you give. Built for Claude Cowork / Claude Code (SKILL.md included) and usable by hand (chat). |
| Focus | Tell the agent what to look for (--focus); default is everything. Matches get their own Focus Results sheet. |
| SQL databases | Profiles Postgres/MySQL/MariaDB/MSSQL/Oracle alongside files: schema, real primary keys, row counts, a small sample, and the same LLM classification and relation detection as spreadsheets (a DB table can link to an Excel file by shared IDs, and vice versa). |
| Agent-to-agent | serve exposes a small local API (/find, /ask, /file, optional /send) so another AI agent can query this computer's catalog and fetch specific files directly, with an API key and an access log. |
| Search engine | SQLite FTS5 (BM25) + optional multilingual embeddings (BGE-M3), fused with Reciprocal Rank Fusion. Query in Persian, find English-described files, and vice versa. |
| Deliverables | data_codex.xlsx (5 sheets) and report.md with an executive summary and recommended first steps. |
+---------------------------+
root folder --> | 1. Crawler + SHA-256 dedupe|
+-------------+-------------+
|
+----------+-----------+-----------+-----------+
| | | | |
spreadsheets PDF Word/PPT images text/code/zip
header detect PDF->MD+OCR parsers local OCR decoders
key detection (local)
| | | | |
+----------+-----------+-----------+-----------+
|
+-------------v-------------+
| 2. Rules -> family dedupe | zero-token paths first,
| -> batched LLM (sampled)| cheap model, 10 files/request,
+-------------+-------------+ strong model once (summary)
|
+--------------------+--------------------+
| | |
3. Relation finder 4. SQLite cache 5. Search index
(value-overlap graph) (hash -> result) (FTS5 + embeddings)
| | |
+--------------------+--------------------+
|
+-------------v-------------+
| 6. Excel data codex + |
| Markdown report |
+---------------------------+
- Post-acquisition / M&A data room triage. Map an acquired company's file shares in hours, flag high-sensitivity documents, and locate the master datasets.
- ERP / legacy data migration. Discover which spreadsheets are effectively tables, their primary keys, and how they join, before designing the target schema.
- Project handover and turnover packages (construction, EPC, pipelines, commissioning). Index contracts, inspection reports, personnel lists, drawings, and forms from a departing team and link records across them by shared IDs (personnel number, tag number, form number).
- Digital forensics and e-discovery pre-screening. Cheap, read-only triage to prioritize what human reviewers should open first.
- Compliance and data mapping (GDPR-style). The
sensitivityfield and--redactmode help build an inventory of where personal and financial data lives. - Inventorying forgotten SQL databases. Finds servers left reachable with no password set and catalogs what's actually stored on them, as part of normal data-governance hygiene.
- RAG bootstrapping. The SQLite index and per-file summaries are a ready corpus for a retrieval-augmented assistant over the same data.
- Disaster recovery audits. Duplicate and low-confidence reports show what is redundant, orphaned, or unreadable.
DataCodex is built to spend as few LLM tokens as possible. Everything deterministic runs locally; the LLM only labels what a file is.
| Technique | Effect |
|---|---|
| Local first | Hashing, duplicate detection, PDF -> Markdown, OCR, header-row detection, column profiling, unique-key detection and relation detection use zero tokens. |
| Rules for the obvious | Source code, executables, archives, legacy .doc, tiny text files and text-less photos are labeled by rules (extension, filename, first comment line). Zero tokens. |
| Sampling | At most --max-chars (default 1500) per file, taken as 60% head / 20% middle / 20% tail. Spreadsheets send only column names, type and one sample value for the 3 largest sheets. |
| Compression | Markdown noise, blank, duplicate, and number-only lines are stripped before sending. Headings are extracted separately and sent first. |
| Batching | Up to 10 files per request (--batch-size, --batch-chars), so the instruction prompt is paid once per batch, not once per file. |
| Family deduplication | Files with the same table headers, or the same form template (same folder, filename pattern, first lines), are classified once; the rest inherit the answer and column dictionary. 500 monthly timesheets cost the same as 1. |
| Cheap model for bulk work | Only the fast model touches files. The strong model runs once at the end for the system summary (--strong-tables opts spreadsheets in). |
| Compact I/O | Short JSON keys, hard word limits on every field, and column meanings only for non-obvious columns keep output tokens low. |
| Hash cache | Re-runs cost nothing for unchanged files. |
| Opt-in expensive paths | Vision calls (--vision) and LLM analysis of source code (--llm-code) are off by default. |
| Usage report | LLM calls and input/output tokens are printed and written to the report, with a per-file Method column (llm, family, rules). |
| Task | Default | Why |
|---|---|---|
| All bulk classification (batched) | claude-haiku-5-5 |
Cheapest capable model; inputs are small sampled excerpts. |
| Final system summary (1 call) | claude-sonnet-5-5 |
One short call where reasoning quality matters. |
| Fully offline / confidential mode | Ollama: qwen2.5:14b (text), qwen2.5vl:7b (vision) |
No data leaves the machine, zero API tokens. |
| PDF -> Markdown | PyMuPDF4LLM (local) | Structure-preserving, no model needed. |
| OCR | Tesseract (fas+eng) |
Local and free. |
| Embeddings | BAAI/bge-m3 (local) |
Strong cross-lingual retrieval (Persian <-> English). |
Override with --model, --fast-model, --vision-model, or the DD_MODEL / DD_FAST_MODEL environment variables. Model names change over time; check your provider's current list.
git clone https://github.com/<you>/data-codex && cd data-codex pip install -r requirements.txt # OCR (optional but recommended): install Tesseract + the 'fas' language pack export ANTHROPIC_API_KEY=sk-... # cloud mode python data_codex.py scan "D:/inherited_drive" -o out --redact --embed # scan EVERY local drive in one run (Windows: C:, D:, E: ...; macOS/Linux: /) python data_codex.py scan --all-drives -o out --redact # or pick several drives / folders explicitly python data_codex.py scan C:/ D:/ "E:/Projects" -o out # fully local / confidential python data_codex.py scan "D:/inherited_drive" -o out --provider ollama # no LLM at all (inventory, duplicates, key detection, relations, FTS search) python data_codex.py scan "D:/inherited_drive" -o out --provider none # focus on something specific (default is everything) python data_codex.py scan --all-drives -o out --focus "contracts and personnel lists" # ask later, in any language python data_codex.py find "butane propane contract" -o out
| Flag | Default | Meaning |
|---|---|---|
roots |
(none) | One or more folders or drives to scan (C:/ D:/ ...) |
--all-drives |
off | Scan every local drive in a single run and produce one combined map (paths are prefixed with the drive, e.g. D/Projects/...) |
--focus |
(everything) | What to look for; adds a Focus Results sheet |
--provider |
auto | anthropic if ANTHROPIC_API_KEY is set, otherwise none; also ollama |
--workers |
4 | Parallel file workers (LLM calls are I/O bound) |
--max-chars |
1500 | Sampled excerpt size per file (head/middle/tail) |
--batch-size / --batch-chars |
10 / 14000 | Files and characters per LLM request |
--vision |
off | Allow vision calls for photos/scans without OCR text |
--llm-code |
off | Also classify source code with the LLM |
--strong-tables |
off | Use the strong model for spreadsheets |
--no-summary |
off | Skip the final LLM summary call |
--max-pdf-pages |
4 | Pages converted to Markdown per PDF (plus middle and last) |
--max-mb |
100 | Files above this get metadata-only analysis |
--redact |
off | Mask e-mails, phone numbers, and long IDs before any LLM call |
--embed |
off | Build the multilingual semantic index |
--reanalyze |
off | Ignore the cache |
Typical flow when a Cowork-style agent drives the tool (full playbook in SKILL.md):
- The agent asks what to look for. No answer means everything.
- It scans (
scan --all-drives --focus "...") and reports the headline findings. - You ask follow-ups: "where is the Asaluyeh contract?" It answers with the closest matches and their addresses.
- You say "open the second one" or "send 1 and 3 to [email protected]".
# where is it? (any language; --json for agents) python data_codex.py find "قرارداد بوتان پروپان عسلویه" -o out -k 5 python data_codex.py find "welding inspection reports" -o out --json # open a result, or its folder python data_codex.py open 2 -o out python data_codex.py open 2 --folder -o out # e-mail results (always confirm recipients and files with the user first) python data_codex.py send 1,3 --to [email protected] --subject "Requested files" --yes -o out python data_codex.py send 1 --to [email protected] --dry-run -o out # or do everything interactively python data_codex.py chat -o out # let another AI agent query this catalog over HTTP DD_API_KEY=secret python data_codex.py serve -o out
How "nearest" works: BM25 full-text over titles, summaries, keywords, project names and extracted text, fused with multilingual embeddings when --embed was used, plus a fuzzy fallback so you always get the closest candidates. For Persian (or any non-English) questions, one tiny LLM call expands the query into English keywords (--no-expand disables it; without an LLM, use --embed for cross-language matching).
E-mail setup: set DD_SMTP_HOST, DD_SMTP_PORT, DD_SMTP_USER, DD_SMTP_PASS, DD_SMTP_FROM. Without them, send saves a ready-to-send .eml draft in out/outbox/. Optional DD_ALLOWED_RECIPIENTS (addresses or @domain) restricts who can receive files. --zip bundles large attachments; the default limit is 20 MB per message.
Safety rails for sending and opening:
- Only files that are in the index can be opened or sent, so a prompt hidden inside a document cannot make the agent mail arbitrary files.
sendrefuses to run without--yes(or an interactive "y"); the agent must get the user's explicit confirmation first.- Recipient, file list, total size and high-sensitivity warnings are printed before sending.
- File contents are treated as untrusted data in the agent playbook.
# with credentials (keep secrets out of shell history: use --db-config or DD_DB_URLS) python data_codex.py scan /srv/data -o out --db-scan \ --db-url "postgresql+psycopg2://readonly_user:[email protected]:5432/erp" # a config file instead of inline URLs python data_codex.py scan -o out --db-scan --db-config db.json # db.json: [{"engine":"mysql","host":"10.0.0.9","user":"analyst","password":"...","database":"hr"}] # no credentials: probe specific hosts you own, try only the engine's default # admin account with an EMPTY password (never a password list, never brute force) python data_codex.py scan -o out --db-scan --db-hosts 10.0.0.9 10.0.0.12:3306 # a private subnet you are authorized to audit python data_codex.py scan -o out --db-scan --db-network 10.0.0.0/24
- Supports Postgres, MySQL/MariaDB, MSSQL and Oracle through SQLAlchemy; install the driver you need from
requirements.txt. - Structure comes from the database's own metadata (zero query cost). Each table's real primary key is read from the database when declared, with the usual uniqueness heuristic as a fallback.
- Only a small sample is read per table (
--db-sample-rows, default 300) and at most--db-max-tablestables per schema, within a--db-time-budgetper server, so scanning never turns into an unbounded data export. - DB tables are classified exactly like spreadsheets (same LLM batching, family de-duplication, Excel Tables sheet) and take part in the same relation detection, so a database table and an Excel file sharing an ID column show up linked.
- Every table gets a small cached CSV sample (≤50 rows) used by
open/send, so those commands never re-query a production server and still work if it's later offline or the credentials rotate. - Only scan hosts, servers and networks you own or are explicitly authorized to test. Credentialless discovery tries one well-known default admin account with an empty password per engine — this flags databases left wide open, the same thing a routine internal security audit would check; it never guesses or brute-forces passwords, and
--db-networkrefuses public IP ranges unless you pass--db-allow-public.
DataCodex can act as a small service that other AI agents talk to directly, not just a tool one agent runs from the command line. Start it once after a scan:
export DD_API_KEY=some-long-random-string # required unless --no-auth python data_codex.py serve -o out --port 8765
Any other agent (a separate Claude instance, a teammate's assistant, an internal bot) can then:
curl http://host:8765/manifest # what this server can do curl -H "X-API-Key: $DD_API_KEY" -X POST http://host:8765/find \ -d '{"query":"butane propane contract"}' curl -H "X-API-Key: $DD_API_KEY" -X POST http://host:8765/ask \ -d '{"question":"where is the personnel list for Marvdasht?"}' curl -H "X-API-Key: $DD_API_KEY" "http://host:8765/file?path=<path from /find>" -o file.xlsx
/findreturns the nearest files/tables for a question (any language, files + database tables together)./askdoes the same and adds a short natural-language answer, grounded only in the matched files./filestreams one indexed file (or a database table's cached sample) back to the calling agent — so if another agent asks "give me the file about X," DataCodex can hand it over automatically, no human in the loop, as long as the file is in the index./send(opt-in with--allow-send) lets another agent request an e-mail be sent, but only to addresses inDD_ALLOWED_RECIPIENTS— there is no interactive confirmation step when a server, not a person, is asking.- Every request needs
X-API-Key(unless you explicitly pass--no-authfor a trusted local network) and is written toout/agent_access.logfor an audit trail. - A calling agent only ever reaches the index — never the live file system or the live database — so the same safety rails (indexed-only access, read-only by default) apply automatically.
This is also what SKILL.md documents for a Cowork/Claude Code agent running DataCodex directly: it describes both roles — driving the tool yourself, and exposing it over serve so a different agent's requests get fulfilled automatically.
data_codex.xlsx
- Focus Results (only with
--focus): the nearest files with full paths. - Inventory: path, English title, document type, 2-sentence summary, project/context, keywords, language, sensitivity, confidence, method (
llm/family/rules), duplicate-of. - Tables: per sheet, row count, detected unique key and why, purpose, and a column dictionary.
- Relations:
source file.key -> target file.column, matched values, overlap %. - Duplicates & Issues: duplicates, encrypted/unreadable files, low-confidence classifications.
- System Summary: token usage, overview, main areas, key datasets, risks, recommended first steps, folder statistics.
report.md is a human-readable version of the summary. codex.db is the reusable index and cache.
A column is a key candidate when it is at least 90% non-null and at least 98% unique across rows. Candidates are ranked by name hints (id, code, tag, serial, and Persian equivalents such as شماره / کد / شناسه / پرسنلی), then by text type. The LLM is shown the profile and explains the choice, but the decision itself is deterministic and reproducible.
For every table with a key, key values are looked up in an inverted index of all other tables' column values (3,000-value samples, minimum length 4 to avoid noise like 1, 2, 3). A relation is reported when at least 3 values match and overlap is at least 50% of the smaller set.
- Hash cache: each unique file is analyzed once; re-runs only process new or changed files.
- Local extraction runs in parallel; LLM batches run in parallel.
- PDFs are sampled by page, spreadsheets by value sample, text by excerpt.
- OCR short-circuit: vision is never used when local text is usable.
- Read-only: the agent never modifies, moves, or deletes source files. Output goes to its own folder, which is excluded from the crawl.
- Prompt-injection aware: file content is labeled untrusted in the system prompt, and model output is parsed as data, never executed.
- Data minimization: only a short excerpt per file leaves the machine in cloud mode; use
--redactto mask identifiers, or--provider ollamato keep everything local. - Review your organization's policy before sending confidential material to any cloud API.
- Database connections are read-only queries (
SELECT, metadata calls); DataCodex never writes to a database. - Credentialless database discovery tries exactly one well-known default admin username with an empty password per engine, never a password list — it is a hygiene check, not a penetration-testing tool. Only point it at hosts and networks you own or are explicitly authorized to test; unauthorized scanning may be illegal where you are.
- The
serveAPI only ever reaches the index (never the live file system or a live database), requires an API key by default, and logs every request toagent_access.log.
- Legacy
.docis reported but not parsed (convert to.docx). Password-protected files are flagged, not opened. - Relation detection finds value overlap, not guaranteed semantic joins; always review high-impact links.
- Very large spreadsheets are fully loaded into memory by pandas.
- Classification is based on a small sample, so it identifies a file's nature, not every detail. Each row shows its
Method(llm,family,rules) andconfidence; low-confidence LLM rows are listed for review. - Family inheritance assumes files with identical headers/templates mean the same thing; project names are only inherited within the same folder.
- Database profiling reads a sample, not the whole table; very wide or extremely large tables may need a higher
--db-sample-rowsor a narrower--db-configto be well understood. open/sendon a database table use the cached sample captured at scan time, not a live query.
- Incremental watch mode and diff reports between scans
.doc/.xlsbinary parsing via LibreOffice headless- Entity graph export (Neo4j / GraphML)
- Web UI on top of
codex.db - Email (
.pst,.eml) and database file support
MIT