Skip to content

Instantly share code, notes, and snippets.

@dsandor
Created November 4, 2025 20:14
Show Gist options
  • Select an option

  • Save dsandor/1e05d630f80611a995d22da2dddca2c2 to your computer and use it in GitHub Desktop.

Select an option

Save dsandor/1e05d630f80611a995d22da2dddca2c2 to your computer and use it in GitHub Desktop.
Overview of AI Coding Tools' Behind-the-Scenes Processes

Overview of AI Coding Tools' Behind-the-Scenes Processes

AI coding tools like Cursor, Claude Code, Windsurf, and Visual Studio Code (with Copilot) enhance productivity by integrating user prompts (e.g., "Refactor this function to use async/await and improve readability") with codebase context. At their core, they rely on Retrieval-Augmented Generation (RAG) or similar mechanisms to fetch relevant code snippets, documentation, or patterns from a vector database or indexed store. This context is then augmented into the prompt sent to a Large Language Model (LLM) like Claude 3.5 Sonnet or GPT-4o.

The general flow is:

  1. Indexing/Ingestion: Codebase is chunked (e.g., by functions or AST nodes) and embedded into vectors.
  2. Retrieval: User's prompt is embedded and queried against the vector DB for similar chunks.
  3. Augmentation: Retrieved context (e.g., related files, git history) is injected into the LLM prompt.
  4. Generation: LLM produces refactored code, which the tool applies (with diffs/previews).
  5. Iteration: Feedback loops (e.g., tests) refine results.

Differences arise from indexing strategies (e.g., semantic vs. keyword), context windows (e.g., 128K vs. 200K tokens), model routing, and UI/integration (e.g., auto vs. manual context). This leads to varying accuracy, speed, and refactor quality—e.g., one tool might overlook distant dependencies due to shallow retrieval, while another excels at multi-file changes.

Below, I'll break it down per tool, drawing from their architectures. I'll describe key "diagrams" (flowcharts or inferred visuals from docs) as step-by-step processes, since direct images aren't embedded here but can be visualized from sources.

General RAG Diagram: Foundation for All Tools

A standard RAG architecture (adaptable to coding) is visualized as a linear flowchart with branching for retrieval:

[User Query (e.g., "Refactor async function")] 
    ↓ (Embed Query via Model like text-embedding-ada-002)
[Vector Database (e.g., Pinecone/Chroma)] ← [Stored Embeddings of Code Chunks + Metadata (file paths, line nums)]
    ↓ (Cosine Similarity Search: Retrieve Top-K Chunks, e.g., related modules)
[Prompt Augmentation: Query + Retrieved Context (e.g., "Based on this dependency graph [chunk1], refactor...")]
    ↓ (Send to LLM like Claude/GPT)
[Generation: Refactored Code + Explanations]
    ↓ (Optional: Citation/Feedback Loop to Re-Rank Retrieval)
  • Why for Coding? Chunks are semantic (e.g., function boundaries via AST parsing) to capture dependencies. Retrieval ranks by relevance (e.g., "event loop" near "async/await"). Augmentation prevents hallucinations by grounding in your codebase. This baseline explains variances: Tools with advanced chunking (e.g., AST) retrieve better context, yielding cleaner refactors.

Cursor: Distributed RAG with AST-Driven Chunking

Cursor (forked from VS Code) uses a multi-layered, distributed RAG system for deep codebase awareness, emphasizing real-time editing. It stores embeddings in Turbopuffer (a serverless vector DB) for scalability—20x cheaper than alternatives like Pinecone, with on-demand loading to avoid cold starts.

Key Diagram: Inferred Multi-Layered Context Flowchart

From architecture breakdowns, visualize this as a tiered pyramid flowchart:

[User Prompt in Composer/Tab] 
    ↓ (Local AST Chunking via Tree-sitter)
[Layer 1: Immediate (Cursor pos + Local vars)] 
    ↓ + 
[Layer 2: Semantic (AST deps + Symbol refs)] 
    ↓ + 
[Layer 3: Project RAG (Turbopuffer Similarity Search: Embed chunks → Retrieve top files/modules)] 
    ↓ + 
[Layer 4: Historical (Git diffs/commits via Merkle trees)] 
    ↓ (KV Cache Optimization + Multi-Model Route: e.g., Claude Sonnet for reasoning)
[Augmented Prompt to LLM] → [Speculative Decode: Draft tokens → Verify] → [Inline Diffs + Apply]
    ↓ (Agent Loop: Run Tests → Fix if Broken)
  • Vector DB Role: Embeddings (generated via multi-models, e.g., one for docs vs. code) include metadata (lines/files) but no raw text (privacy-focused). Chunking follows AST boundaries for semantic accuracy—e.g., retrieving a full class for refactoring.
  • Prompt Submission Flow: On refactor prompt, local parsing grabs immediate code; RAG pulls cross-file context (e.g., imported utils). Prompt is cache-optimized to reuse attention states, reducing latency. Results: Precise, multi-file refactors but can lag on huge repos due to indexing (every 10 mins via Merkle diffs).

Claude Code: Agentic Full-Context Without Heavy RAG

Anthropic's Claude Code is terminal-first (CLI with IDE plugins), prioritizing agentic workflows over vector-heavy RAG. It uses a 200K token context window for "full codebase ingestion" via agentic search (scans/maps files dynamically), bypassing traditional vector DBs for simpler, reliable large-scale reasoning. No explicit RAG, but it mimics it with parallel sub-agents for retrieval.

Key Diagram: Agentic Workflow Branching Flow

Visualize as a parallel-branch tree:

[CLI Prompt (e.g., "Refactor module async, fix dups")] 
    ↓ (Agentic Parse: Map codebase via search—no manual files)
[Branch 1: Read/Retrieve (Sub-agent scans files/branches, 200K tokens full load)] 
    ↓ + 
[Branch 2: Analyze (Sub-agent IDs issues: deps, readability)] 
    ↓ + 
[Branch 3: Edit/Test (Parallel: Generate diffs → Run tests → Auto-fix)] 
    ↓ (Merge Branches into Augmented Prompt)
[LLM (Claude 3.5): Generate Refactor + Structured Diffs] → [Apply Changes (Batch/Multi-File)]
    ↓ (No KV Cache; Relies on Consistent Window)
  • Context/Vector Handling: Loads entire project into context (no DB needed), using natural-language search for relevance. For refactoring, agents parallelize: one retrieves deps, another tests. Prompt augmentation is implicit via agent outputs.
  • Flow: Prompt triggers auto-scan; context is "retrieved" via agents (e.g., git-aware). Excels at vague prompts but lacks visual diffs (terminal-only).

Windsurf: Auto-Indexing RAG with M-Query

Windsurf (VS Code-based, agentic IDE) uses LLM-driven RAG with "M-Query techniques" for codebase retrieval—no manual file picks. It auto-indexes on load, storing in a lightweight vector store (details proprietary, but hybrid keyword + semantic). Defaults to agentic mode via "Cascade" agent for flow-state coding.

Key Diagram: Auto-Context Pipeline (Inferred Linear with Feedback)

As a streamlined loop:

[Prompt in Agent Chat] 
    ↓ (Auto-Index: Semantic chunks → Embed → Local/Cloud Vector Store)
[RAG Retrieval (M-Query: LLM-guided similarity + Keywords, e.g., fetch related funcs)] 
    ↓ (Augment: Inject chunks + Git history)
[Prompt to LLM (Claude 3.5 Sonnet)] → [Generate Code] → [Write to Disk (Preview Diff on Demand)]
    ↓ (Cascade Agent Loop: Iterate if Tests Fail)
  • Vector DB Role: Hybrid store for embeddings; M-Query refines retrieval (e.g., LLM ranks chunks for relevance). Context auto-pulls (e.g., deps for refactor), but limited by 500-request cap on base plan.
  • Flow: On submit, agent indexes/retrieves silently; prompt includes auto-context. Writes changes to disk for real-time preview, aiding iteration.

Visual Studio Code (with Copilot): Semantic Indexing + #-Mentions

Copilot uses workspace indexing (local/remote semantic vectors) for RAG-like retrieval, integrated via GitHub's embedding model. No full vector DB exposed; relies on cloud indexing for large repos. Context is hybrid: implicit (active file) + explicit (#-mentions for files/symbols/#codebase).

Key Diagram: Context Picker Flowchart

As a hub-and-spoke with UI screenshots:

[Chat Prompt] 
    ↓ (Implicit: Active file + Selection)
[Hub: #-Mentions Picker (#file, #codebase, #githubRepo)] 
    ↓ (Semantic Search: Embed query → Retrieve from Local/Remote Index)
[Augment: Outline/Full Chunks if < Limit; Exclude if Too Large] 
    ↓ + (Tools: #fetch Web/#terminal Output)
[Prompt to LLM (GPT-4o)] → [Generate Inline Completions/Edits]
    ↓ (Agent Mode: Auto-#codebase if Needed)
  • Vector Handling: Embeddings via GitHub model for code search; retrieves symbols/files. For refactoring, #codebase pulls project-wide context (e.g., "Find async patterns").
  • Flow: Prompt auto-includes active file; user adds via # for precision. Strong for daily edits but weaker on deep multi-file refactors vs. agentic tools.

Why They Produce Different Results & Why One IDE May Be Better

Results vary due to retrieval granularity (e.g., Cursor's AST chunks catch subtle deps better than VS Code's basic indexing, leading to fewer breakage-prone refactors) and augmentation depth (Claude Code's full 200K context handles vague prompts holistically, while Windsurf's auto-RAG might miss edge cases without manual tweaks). Model choice matters: Cursor/Claude/Windsurf lean on Claude (strong reasoning), VS Code on GPT (faster but less nuanced). Workflow diffs amplify this—e.g., Windsurf's disk-writes enable quick previews, reducing "blind" errors vs. Cursor's approval gates.

Superiority Depends on Use Case:

  • Cursor Best For: Complex, large-scale refactors (robust RAG + rules for consistency); beats others on precision but lags on perf.
  • Claude Code Best For: Automated, multi-file overhauls (agentic full-context shines for vague tasks; 2x better instruction-following than Cursor).
  • Windsurf Best For: Mid-sized/front-end (auto-context + clean UI for flow; edges Cursor on simplicity but caps limit heavy use).
  • VS Code Copilot Best For: Daily/affordable workflows (versatile integration; most generous free tier, but least agentic for deep refactors).

For visuals, check source links (e.g., Cursor's inferred chart or RAG guides) or prompt me to sketch one in text/Mermaid if you'd like confirmation for generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment