{
  "video": {
    "id": "dRmWYHuIJxM",
    "title": "We Cut 94% of AI Coding Tokens With a Local Code Index - Rajkumar Sakthivel, Tesco",
    "duration": 643,
    "upload_date": null,
    "channel": "AI Engineer",
    "source": "AI Engineer",
    "event_format": "Online"
  },
  "analysis": {
    "video_id": "dRmWYHuIJxM",
    "title": "We Cut 94% of AI Coding Tokens With a Local Code Index - Rajkumar Sakthivel, Tesco",
    "one_liner": "Two developers hit by a surprise AI coding bill found that ~90% of the cost is input context, so they built a local hybrid code index (CCE) that cut a FastAPI benchmark from 83K to 4.9K tokens per question — 94% less — while still finding the right code 90% of the time.",
    "summary": "Raj and his friend Foss watched their AI coding bill explode with no change in usage pattern, and traced it to context: a typical query on their project sent 45,000 tokens when only ~5,000 mattered. He argues the fix is not prompt wording, model settings, or output compression — input is ~90% of spend and output only ~10%, so cutting output 75% saves ~8% total while cutting input 94% saves ~61%. They built a local search layer that sits between the codebase and the AI: chunk by function/class/method, run semantic and keyword search in parallel, shrink results to signatures, follow call relationships, and score-gate everything, all on-machine. He is unusually honest about the limits — the 94% is a worst-case full-file baseline, and recall collapsed on a 396-file mixed codebase.",
    "key_points": [
      "A typical query on their project sent 45,000 tokens of context when only about 5,000 was relevant — they paid for the other 40,000 on every single query.",
      "Three things they tried first and why two failed: prompting for short/relevant code (the 45K was already sent before the model read the prompt), changing max tokens/temperature (that changes output, not input), and output compression (worked — cut output 75% — but output is only ~10% of cost, so ~8% total savings).",
      "The cost split slide: ~90% of AI cost is input (files, search results, context sent in), ~10% is output; cutting input by 94% saves about 61% overall.",
      "The index works in five steps: chunk code into functions/classes/methods (not random chunks); run meaning-based and word-based search simultaneously and combine; shrink a 50-line function to ~5 lines of name plus description; track which function calls which so connected code is findable; score every result and drop the low scorers so no bad context is sent. Everything runs locally, nothing goes to the cloud.",
      "Why two searches: semantic search misses exact names (searching 'authenticate user' returns a different auth function), keyword search misses related ideas ('login flow' misses 'sign in'). Alone each misses about 1 in 4 results; together about 1 in 10.",
      "Relevance ranking is a hand-tuned formula — 50% meaning score, 30% keyword score, 20% code recency, with an adaptive threshold — running in 0.4 ms with no extra AI calls. They rejected LLM-as-judge (added 2-3 seconds every time) and a fixed score cutoff (short questions score low even on perfect matches).",
      "Public benchmark on FastAPI, 53 files, 20 real developer questions: 83K tokens/question without the tool vs 4.9K with it (94% less), or 523 tokens/question with extra compression on top, still finding the right code 90% of the time.",
      "Stated limits: the 94% is the worst case of reading full files every time, and real tools like Claude Code are already smarter, so real savings are lower; on a 396-file mixed codebase recall dropped almost to zero (works when each file does one thing); they chose a small fast search model (re-index under a second) over a bigger, more accurate one.",
      "One shared index plus persistent memory across Claude Code, Cursor and Copilot, so you explain the codebase once instead of to three tools that each start fresh.",
      "Real-project savings report: 247 queries, 12.4 million tokens saved, nearly $186 not spent — 84% of the saving from the search layer, the rest from compression; measured per query against what would have been sent, times the model price."
    ],
    "takeaways": [
      "Attack the input, not the output — before optimizing prompts or asking for terser answers, measure what fraction of your token spend is context you send in versus code the model writes back.",
      "Replace whole-file context with a retrieval layer that returns function-level chunks, and run semantic and keyword search together rather than picking one; each alone misses about a quarter of results.",
      "Gate retrieved context by score and drop low scorers — bad context produces a confident wrong answer, which is worse than no answer.",
      "Prefer the simple, cheap ranking formula over an LLM judge or a heavier model: a weighted score with an adaptive threshold ran in 0.4 ms and beat the complex options.",
      "Instrument your own spend: run the tool on your project for a week and compare what would have been sent against what was sent, instead of arguing over Opus vs Sonnet — the model may be 30% of the cost."
    ],
    "topics": [
      "ai-coding-tools",
      "context-engineering",
      "token-costs",
      "code-search",
      "hybrid-retrieval",
      "local-first",
      "benchmarking",
      "agent-memory"
    ],
    "tools": [
      "CCE",
      "Claude Code",
      "Cursor",
      "GitHub Copilot",
      "Codex",
      "FastAPI",
      "Opus",
      "Sonnet",
      "Tesco",
      "AI Engineer"
    ],
    "quotes": [
      {
        "text": "It's like ordering a pizza and paying for extra nine pizzas you don't eat every time.",
        "at": "01:40",
        "url": "https://www.youtube.com/watch?v=dRmWYHuIJxM&t=100s"
      },
      {
        "text": "This is the most important slide. 90% of your AI cost is input.",
        "at": "02:46",
        "url": "https://www.youtube.com/watch?v=dRmWYHuIJxM&t=166s"
      },
      {
        "text": "The lesson we learned, simple formula beats the complex model most of the time.",
        "at": "06:26",
        "url": "https://www.youtube.com/watch?v=dRmWYHuIJxM&t=386s"
      },
      {
        "text": "The answer was not a better model. The answer was sending less.",
        "at": "10:10",
        "url": "https://www.youtube.com/watch?v=dRmWYHuIJxM&t=610s"
      }
    ],
    "words": 1548
  },
  "summary_url": "/#dRmWYHuIJxM",
  "transcript": {
    "html": "/transcripts/dRmWYHuIJxM.html",
    "txt": "/transcripts/dRmWYHuIJxM.txt",
    "vtt": "/transcripts/dRmWYHuIJxM.vtt"
  }
}