{"slug": "codetalk-recover-why-ai-written-code-was-written-quoted-from-git-zero-llm", "title": "CodeTalk – recover why AI-written code was written, quoted from Git (zero-LLM)", "summary": "CodeTalk, a new developer tool, recovers the rationale behind AI-written code by grounding explanations in real git commit history and session transcripts, using zero-LLM deterministic lookup. The tool addresses widespread distrust in AI-generated code, citing a Stack Overflow survey where 46% of developers distrust AI output and a blind test showing AI explanations missed real decisions in 5/5 cases. CodeTalk offers local-first, verifiable citations via MCP, CLI, and VS Code integration.", "body_md": "**Zero-LLM core · Real citations · Local cache · MCP / CLI / VS Code**\n\n**AI writes your code. Three months later, nobody knows why it was written that way.**\n\nCodeTalk grounds \"why\" in real commit history — verbatim citations you can click and verify, not AI confabulation. Zero-LLM, local-only, pure stdlib.\n\n**Trust is collapsing.** 46% of developers actively distrust AI output; only 3% highly trust it.*(Stack Overflow 2025, N=33,244)***AI \"explanations\" are fabricated.** We blind-tested 5 real commits: AI inferred \"why\" from diffs alone —**5/5 missed the real decisions, 2/5 completely wrong.***(This repo, reproducible:*— or run the shareable A/B blind test on your own repo and judge for yourself:`python3 scripts/blind_test.py . 5`\n\n)`python3 scripts/trust_ab_demo.py . 5`\n\n(real records vs diff-only inference, side by side, reveal at the end; add`--html demo.html`\n\nfor an interactive shareable page).**Your chat history is fragile.** Multiple bug reports across Cursor, Claude Code, and Copilot describe conversations silently vanishing — data still on disk, UI can't surface it. One confirmed Cursor case (~175 agent chats hidden while intact on disk) is written up in`docs/moat-real-records-vs-inference.md`\n\n.\n\n| AI inference (Cursor/Copilot) | CodeTalk | |\n|---|---|---|\n| Source | current diff | real commit + session transcript |\n| Method | LLM guesses from code | zero-LLM deterministic lookup by SHA |\n| Verifiable | no — plausible but ungrounded | yes — click SHA to see original |\n| Data | sent to cloud | local-first; LLM calls opt-in (`--no-llm` for zero egress) |\n\nCodeTalk is a local evidence pipeline. It reads git history and AI coding\nsession files, parses them defensively, aligns sessions to commits, stores\nredacted evidence in a local SQLite cache, then exposes deterministic tools for\n`ask`\n\n, `blame`\n\n, `search`\n\n, `review`\n\n, `drift`\n\n, `graph`\n\n, `prompts`\n\n, and `adr-export`\n\n.\nLLM synthesis is optional and sits behind the evidence layer.\n\n**Decision notes**(called breadcrumbs internally) are two optional lines in a git commit message:`Vibe-Decision: ...`\n\nfor the reason behind a change, and`Vibe-Watch: ...`\n\nfor a risk to check later. They are stored in git, can be written by a person, a git hook, or an AI coding agent, and CodeTalk reads them in`blame`\n\n,`ask`\n\n,`graph`\n\n, and`digest`\n\n.is optional backfill for old commits. It asks an LLM to read a commit plus nearby local session snippets, then stores a redacted narrative in`enrich`\n\n`~/.codetalk/cache.db`\n\nunder that commit SHA. Use it when old commits do not already have decision notes.**Grounding evidence** is the material CodeTalk can cite: commit messages,`Vibe-Decision`\n\n/`Vibe-Watch`\n\nlines, and local session transcript excerpts. If there is no evidence, CodeTalk should fall back to listing what it found, not inventing an answer.**Zero-LLM / zero egress** means CodeTalk only does local deterministic lookup.`--no-llm`\n\nalso disables optional model calls, so project data stays on your machine.**Time capsule** means a`Vibe-Watch`\n\nline is brought back in a future report so you can check whether the risk actually happened.**MCP** is the protocol CodeTalk uses to expose its commands inside AI coding clients such as Claude Code, Cursor, and Codex.**Understanding debt** is CodeTalk's priority list of files or decisions that deserve a reread because they changed recently, carried risks, or have not been reviewed.\n\nHonest boundaries:Blind test is N=5, this repo only, human-judged — not a population claim. Coverage depends on decision notes +`enrich`\n\n: a fresh clone of this repo reproduces~59% real grounding (114/194 commits — verbatim breadcrumbs + session anchors only, excluding LLM-generated narratives, measured 2026-07-02)— run`python3 scripts/grounding_hitrate.py .`\n\nfor the live number (it stars the real-grounding rate; the LLM-narrative-inclusive upper bound is printed below it and isnotused as a trust claim). After a full`codetalk enrich`\n\nbackfill the looser coverage reaches ~100%. A separate 605-commit repowithoutenrich starts at 0.3%, reaching ~100% after`codetalk enrich`\n\n. Without enrich or decision notes, blame shows commit subjects only — similar to`git log`\n\n. Run`grounding_hitrate.py`\n\non your own repo to measure. CodeTalk finds \"what was actually said and decided\", not \"whether the code is correct\" — source records themselves may be wrong. Coverage numbers are reproducible with`grounding_hitrate.py`\n\non any repo; blind-test method:`python3 scripts/blind_test.py`\n\n; moat comparison write-up:`docs/moat-real-records-vs-inference.md`\n\n.\n\n```\ngit clone https://github.com/HUKAIR/CodeTalk && cd CodeTalk && pip install -e .\n\n# This repo uses CodeTalk on itself — most commits carry decision notes\n# (Vibe-Decision / Vibe-Watch lines in the commit message; 101/183 so far).\n# No API key, no config, no enrich:\ncodetalk doctor\n\n# Then inspect real decisions straight from git history:\ncodetalk blame codetalk/cache.py\n```\n\nFor every commit that carries decision notes, you'll see: the **why**, the **decisions made**, the **alternatives rejected** — verbatim from the commit record, zero LLM. Commits without notes show their subject only. That's the whole pitch in one command.\n\n`codetalk console --serve`\n\ngives the same grounding as a local, click-to-drill web view (this screenshot is CodeTalk dogfooding itself):\n\n```\n# Step 0 — see coverage, local session availability, and the best next command:\ncodetalk doctor --project /path/to/repo\n\n# Step 1 — decision notes already in your history? blame works immediately, zero key:\ncodetalk blame yourfile.py --project /path/to/repo\n\n# Step 2 — for full narratives on a repo without decision notes (needs an LLM key):\ncodetalk init                              # write config, fill your API key\ncodetalk enrich --project /path/to/repo    # backfill decision narratives from git+sessions\n\n# Step 3 — make future commits self-document (zero extra effort, no key):\ncodetalk install-agent-seed --project .    # your AI agent leaves Vibe-Decision notes\n```\n\n**Honest cold-start:** a repo with no decision notes and no `enrich`\n\nshows commit subjects only — like `git log`\n\n. The value comes from decision notes (free, in git) or `enrich`\n\n(needs a key). This repo has both, which is why the 30-second demo above is rich. Yours starts empty and fills as you use it.\n\n```\npip install -e .                 # Core: pure standard library, zero third-party dependencies\npip install -e \".[anthropic]\"    # Optional: only needed for the anthropic provider\n```\n\nRequires Python ≥ 3.11. After installing you get the `codetalk`\n\ncommand (equivalent to `python3 -m codetalk`\n\n).\n\nExpose the zero-LLM grounding capability to MCP clients such as Claude Code / Cursor / Codex, so you can ask \"why was this code written this way\" right inside your agent workflow. CodeTalk is pure standard library with zero third-party dependencies, so it packs into a single `.mcpb`\n\n(a zip of `manifest.json`\n\n+ source), giving you a **one-click install and a single build that covers every client**. It runs on the `python3`\n\nyou already have installed and **does not bundle an interpreter**:\n\n```\npython3 -m scripts.build_mcpb     # produces codetalk.mcpb\n```\n\nDrag `codetalk.mcpb`\n\ninto your client's extension-install entry point, and pick a project root during installation. It exposes **7 tools** (all marked `readOnlyHint: true`\n\n, so Claude Code / Cursor can auto-approve them without a confirmation prompt):\n\n| Tool | Purpose | LLM |\n|---|---|---|\n`codetalk_ask` |\nGrounded question \"why was this written\" | Uses LLM if a key is set; falls back to deterministic without one |\n`codetalk_blame` |\nLine-level decision provenance | Zero LLM |\n`codetalk_graph` |\nDecision-impact graph (timeline DAG) | Zero LLM |\n`codetalk_search` |\nTopic-level \"why\" retrieval | Zero LLM |\n`codetalk_drift` |\nDrift self-check: files AI changed but never committed | Zero LLM |\n`codetalk_prompts` |\nInstruction recall: what you told the AI to do | Zero LLM |\n`codetalk_adr` |\nADR export: MADR / Nygard / CycloneDX (AIBOM) | Zero LLM |\n\nStep-by-step install, self-check, and troubleshooting per client:\n\n. Spec-driven workflow integrations (GitHub Spec Kit / AWS Kiro / OpenSpec / Antigravity):`docs/mcp-install.md`\n\n.`docs/spec-kit-integration.md`\n\nFoldable decision CodeLens + hover cards — see **why** a line was written that way, with real commit citations. Like GitLens but for decisions, not just authorship.\n\n```\ncd vscode-codetalk\nnpm install && npm run build                        # build\nnpx @vscode/vsce package --no-dependencies          # package the .vsix\n```\n\nInstall (pick one):\n\n```\ncursor --install-extension vscode-codetalk-0.2.0.vsix   # Cursor\ncode --install-extension vscode-codetalk-0.2.0.vsix      # VS Code\n# Windsurf: Extensions → Install from VSIX → pick the file\n```\n\nAfter installing, run Cmd+Shift+P → **Reload Window**, then open a project that has a CodeTalk cache to see the expandable decision CodeLens; hover a line to view the full card.\n\n| Setting | Default | Description |\n|---|---|---|\n`codetalk.enabled` |\n`true` |\nMaster switch |\n`codetalk.pythonPath` |\n`\"python3\"` |\nPath to the Python interpreter that has CodeTalk installed |\n\nDetailed install + troubleshooting + configuration:\n\n.`vscode-codetalk/README.md`\n\nA local-first interactive web page: hold a multi-turn discussion with an LLM about \"why was this code written this way\", but on every turn it **first runs a zero-LLM retrieval over your project's real records** (commit narratives / decision notes / verbatim session transcripts), feeds that real evidence to the model, and puts **side-by-side verifiable citations** next to the answer. The discussion itself is redacted before being stored, feeding back into future `ask`\n\n/ `search`\n\n. **Self-hosted = your data stays on your own machine; we sell software, not a service.**\n\n```\npip install -e \".[web]\"                            # optional web extra (FastAPI/uvicorn; CLI/MCP stay pure stdlib)\ncodetalk web --project /path/to/repo              # binds 127.0.0.1, auto-opens the browser, verbatim streaming\ncodetalk web --project /path/to/repo --no-llm     # zero egress: falls back to a zero-LLM grounded listing\n```\n\n**Grounded and verifiable**: answers are anchored to real commits / decisions / verbatim session transcripts, and the citation next to each conclusion can be clicked to verify — this is the line that separates it from a \"chat wrapper\";**the model won't answer when detached from real material**(empty material → the model isn't called, just a deterministic listing). Each commit citation carries abutton that opens the real`diff ▾`\n\n`git show`\n\nin-browser (zero-LLM, local) — the \"click the SHA to verify\" loop, now in the web UI.**All views are browser-reachable**: besides`/`\n\n(chat), the server serves`/console`\n\n(unified console),`/tunnel`\n\n(timeline),`/graph`\n\n(decision-impact DAG), and`/course`\n\n(evolution course) — the same rich views the CLI writes as static files. A header**EN / 中文** toggle switches the whole UI language (persisted locally; defaults to the browser language).**Privacy red lines**: by default it only binds`127.0.0.1`\n\n, never phones home (except the LLM call), redacts before going out to the network and before persisting, and the frontend has zero external links (CSP`connect-src 'self'`\n\n; static artifacts are guarded by`scripts/check_static_no_external.py`\n\n); the backend rejects non-loopback Host and cross-Origin requests, preventing other web pages from using localhost to trigger local retrieval / LLM calls.**Self-host for customers**: single-image Docker (see`Dockerfile`\n\n:`docker build -t codetalk .`\n\n→`docker run`\n\n).- The first frontend release is a zero-build single-file vanilla-JS; React/Vite comes only if the chat UX truly needs it (streaming already exists; message management later if required).\n\n```\ncodetalk init        # write a config template to ~/.codetalk/config.json (auto chmod 600)\n```\n\n`~/.codetalk/config.json`\n\n:\n\n```\n{\n  \"vault_path\": \"/path/to/obsidian/vault/folder\",\n  \"provider\": \"deepseek\",\n  \"model\": \"deepseek-v4-pro\",\n  \"diff_token_budget\": 3000,\n  \"output_lang\": \"中文\",\n  \"providers\": {\n    \"deepseek\":  {\"base_url\": \"https://api.deepseek.com/v1\", \"api_key\": \"sk-...\"},\n    \"openai\":    {\"base_url\": \"https://api.openai.com/v1\", \"api_key\": \"\"},\n    \"qwen\":      {\"base_url\": \"https://dashscope.aliyuncs.com/compatible-mode/v1\", \"api_key\": \"\"},\n    \"kimi\":      {\"base_url\": \"https://api.moonshot.cn/v1\", \"api_key\": \"\"},\n    \"doubao\":    {\"base_url\": \"https://ark.cn-beijing.volces.com/api/v3\", \"api_key\": \"\"},\n    \"glm\":       {\"base_url\": \"https://open.bigmodel.cn/api/paas/v4\", \"api_key\": \"\"},\n    \"grok\":      {\"base_url\": \"https://api.x.ai/v1\", \"api_key\": \"\"},\n    \"gemini\":    {\"base_url\": \"https://generativelanguage.googleapis.com/v1beta/openai\", \"api_key\": \"\"},\n    \"anthropic\": {\"api_key\": \"\"},\n    \"ollama\":    {\"base_url\": \"http://localhost:11434/v1\", \"api_key\": \"ollama\", \"local\": true}\n  }\n}\n```\n\nTo switch models: change the top-level `provider`\n\nto any of the above and set the matching `model`\n\n(e.g. kimi→`kimi-k2-0905-preview`\n\n, glm→`glm-4.6`\n\n, grok→`grok-4`\n\n, gemini→`gemini-2.5-pro`\n\n, doubao→endpoint ID or `doubao-seed-1-6`\n\n). The API key can also come from the environment variable `<PROVIDER>_API_KEY`\n\n(e.g. `DEEPSEEK_API_KEY`\n\n/ `KIMI_API_KEY`\n\n/ `GLM_API_KEY`\n\n/ `GROK_API_KEY`\n\n/ `GEMINI_API_KEY`\n\n/ `DOUBAO_API_KEY`\n\n/ `ANTHROPIC_API_KEY`\n\n). Except for anthropic, which goes through the official SDK (json_schema structured output + prompt caching), everything else uses the OpenAI-compatible protocol (stdlib urllib, zero extra dependencies; DeepSeek context caching kicks in automatically).\n\n**Zero-egress local inference**: set `provider`\n\nto `ollama`\n\n(or any OpenAI-compatible endpoint that is `local: true`\n\n/ points at `localhost`\n\nor `127.0.0.1`\n\n, such as LM Studio / llama.cpp / vLLM), and the synthesis runs on your own machine — **even that single network exception, the \"LLM call\", stays off the network** (no key needed locally). Local 32B-class code models are already closing in on the cloud for generation-style tasks; position them as \"local polishing/explanation after grounding\", while agentic / complex synthesis is still better on the cloud. Together with `--no-llm`\n\n(never call an LLM at all), this forms a two-tier privacy gradient.\n\n| Command | What it does | Example |\n|---|---|---|\n`doctor` |\nFirst-run diagnosis: evidence coverage, session sources, LLM config status, and next-step suggestions (pure local, zero LLM) |\n`codetalk doctor --project .` |\n`digest` |\nEnrich a span of commits + sessions into a change-narrative daily report (anti-hallucination, letter style, embedded time capsules) |\n`codetalk digest --since \"3 days ago\"` |\n`brief` |\nKickoff brief: where you left off + top 3 understanding debts (pure local, zero LLM); `--all` gives a cross-project overview (across all projects: those with due capsules + those with the highest understanding debt, ordered by urgency) |\n`codetalk brief` · `codetalk brief --all` |\n`graph` |\nDecision-impact graph: which decision drove which later changes (timeline DAG, zero LLM; `--canvas` exports an Obsidian Canvas) |\n`codetalk graph --canvas` |\n`course` |\nEvolution course: how the project grew into what it is, step by step (chaptered + plain-language + scenario quizzes, single-file HTML) |\n`codetalk course` |\n`ask` |\nAsk about a piece of code, with answers wired to project memory (narratives + decision notes), citing real commits |\n`codetalk ask codetalk/llm.py:72-78 \"why written this way\"` |\n`console` |\nUnified console (web entry): kickoff overview / timeline / decision graph / understanding debt — four views on one page, overview-first with click-to-drill, no more full-page dumps (zero LLM; `--serve` writes capsules back) |\n`codetalk console --serve` |\n`tunnel` |\nTimeline: a linear commit timeline, newest on top, grouped by day, click to read the narrative (`--serve` writes capsule answers back instantly) |\n`codetalk tunnel` |\n`install-hook` |\nInstall a git hook: when hand-writing a commit, prompt in the editor to leave `Vibe-Decision` /`Vibe-Watch` decision notes |\n`codetalk install-hook` |\n`install-agent-seed` |\nPlant the decision-capture convention into the project `CLAUDE.md` + `AGENTS.md` , so an AI coding agent (Claude / others) automatically leaves decision notes on commit (capture-at-write-time > inferring from the diff afterward) |\n`codetalk install-agent-seed` |\n\n`digest`\n\noutput: `<vault>/YYYY-MM-DD-<project>.md`\n\n— a-year-ago-today / a-month-ago-today reflowed → today's overview (letter style) + today's decisions → due time capsules (to backfill) → per-commit narratives → an open-loop summary → run stats. Time capsules seal each risk for 21 days and, when due, bring it back in front of you in the daily report, closing the \"predict → verify\" loop.\n\nWhen you make a key technical tradeoff, leave a line in the commit message body:\n\n```\nVibe-Decision: Used urllib instead of a third-party lib — M0 forbids third-party deps\nVibe-Watch:    Living with this for now; concurrency safety still unverified\n```\n\n`digest`\n\nfolds `Vibe-Decision`\n\ninto that commit's decisions and `Vibe-Watch`\n\ninto its risks (sealed into a verifiable capsule on due date); `ask`\n\nuses them to ground its answers, and `graph`\n\nuses them to connect decision-impact edges. You already write code with AI — let it leave a trail while it's at it. Matched exactly at line start, case-sensitive.\n\nCommitters who hand-write commits (without `-m`\n\n) can run `codetalk install-hook`\n\nonce to install the `prepare-commit-msg`\n\nhook, and the editor will auto-prompt these two lines — fill them in and they stay in the commit message; leave them blank and git strips them. Git hooks aren't version-controlled with the repo, so **install once per clone**.\n\n- Commit narratives are cached by SHA in\n`~/.codetalk/cache.db`\n\nand**never recomputed**; re-running the same day's digest is 0 LLM calls and sub-second.`graph:`\n\n/`course:`\n\n/`ask:`\n\nderived results are cached in the same table under prefixed keys. - Session parsing is incrementally cached by (session_id, mtime, size); every run's parameters are appended to\n`~/.codetalk/usage.log`\n\n. **Data does not leave your machine**(except LLM API calls);** before**writing the cache / writing the vault / injecting HTML, common secret patterns (API key / token / JWT / private key / Google / Stripe / Slack …) are always redacted.: turn off even that \"LLM call\" exception to`no_llm`\n\nhard switch**guarantee zero egress**. Any of three ways takes effect, applying globally (including the MCP`ask`\n\ntool): set`\"no_llm\": true`\n\nin config.json, set the environment variable`CODETALK_NO_LLM=1`\n\n, or pass`--no-llm`\n\nto`digest`\n\n/`ask`\n\n/`course`\n\n. Once on, blame/graph/search/brief/prompts work as usual, ask/course/MCP ask fall back to deterministic retrieval, and digest — which must use an LLM — exits directly (clearly stated, never silent).\n\n- The session source is not a complete audit log: Claude main sessions and\n`*/subagents/**/agent-*.jsonl`\n\nare included, but side files like journal/meta are not collected; Cursor / Codex local session sources are opt-in and depend on unofficial local formats. - Session-to-commit alignment is a soft association (±30-minute time window + file intersection), targeting 80% accuracy, annotated with high/low confidence —\n**not guaranteed to be all correct**. - Once a commit is amended / rebased and its SHA changes, it's treated as a new commit; the old SHA's cache becomes dead data.\n`graph`\n\n's file-level edges get dense on very small projects and are suppressed with sparse nodes; line-level precision is deferred as a non-goal.- The local session formats of Claude Code / Cursor / Codex are all unofficial, non-stable APIs; a version upgrade may break parsing — the parser ignores unknown fields and degrades on missing ones, worst-case falling back to pure-git mode.\n\n```\ncli → gitlog (commit/diff/line history/decision notes) ─┐\n      sessions (Claude/Cursor/Codex, fault-tolerant) ─┼→ align (soft assoc.) → enrich (LLM, SHA cache) → report → vault\n      cache (SQLite single source of truth)          ─┘\nZero-LLM tools: brief / debt / graph read cache + git directly, bypassing enrich/llm.\nUnified LLM wrapper: llm.py (multi-provider / retry / token log / prompt caching / anti-hallucination + style discipline).\n```\n\nThe core CLI/MCP surface stays on standard library + anthropic SDK (optional); LangGraph / vector DBs / heavy frontend chains are **forbidden**. `codetalk web`\n\nis an optional web extra — only that surface allows FastAPI / uvicorn, and it's lazily imported so it doesn't pollute the core dependencies. Modules stay <300 lines; parsing external data is always fault-tolerant, degrading on failure and never crashing. Behavioral guidelines are in `CLAUDE.md`\n\n(Karpathy coding discipline: think before writing / simplicity first / surgical changes / goal-driven).\n\n- Pre-release checks:\n`RELEASE_CHECKLIST.md`\n\n- Change log:\n`CHANGELOG.md`\n\n- Contribution constraints:\n`CONTRIBUTING.md`\n\n- Security reports:\n`SECURITY.md`", "url": "https://wpnews.pro/news/codetalk-recover-why-ai-written-code-was-written-quoted-from-git-zero-llm", "canonical_source": "https://github.com/HUKAIR/CodeTalk", "published_at": "2026-07-08 11:00:17+00:00", "updated_at": "2026-07-08 11:30:13.218129+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-safety", "ai-ethics", "large-language-models"], "entities": ["CodeTalk", "Stack Overflow", "Cursor", "Claude Code", "Copilot", "Codex", "MCP", "VS Code"], "alternates": {"html": "https://wpnews.pro/news/codetalk-recover-why-ai-written-code-was-written-quoted-from-git-zero-llm", "markdown": "https://wpnews.pro/news/codetalk-recover-why-ai-written-code-was-written-quoted-from-git-zero-llm.md", "text": "https://wpnews.pro/news/codetalk-recover-why-ai-written-code-was-written-quoted-from-git-zero-llm.txt", "jsonld": "https://wpnews.pro/news/codetalk-recover-why-ai-written-code-was-written-quoted-from-git-zero-llm.jsonld"}}