<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Manoj Reddy on Medium]]></title>
        <description><![CDATA[Stories by Manoj Reddy on Medium]]></description>
        <link>https://medium.com/@manojreddy_83742?source=rss-1edc4ac8256c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gzm6VQCE9jjLQOBe.</url>
            <title>Stories by Manoj Reddy on Medium</title>
            <link>https://medium.com/@manojreddy_83742?source=rss-1edc4ac8256c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:30:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manojreddy_83742/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I Built an MCP Server So Claude Writes Code Like My Team, Not Like a Tutorial]]></title>
            <link>https://medium.com/@manojreddy_83742/i-built-an-mcp-server-so-claude-writes-code-like-my-team-not-like-a-tutorial-4d7adfc21587?source=rss-1edc4ac8256c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d7adfc21587</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[mcp-protocol]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Manoj Reddy]]></dc:creator>
            <pubDate>Thu, 19 Feb 2026 05:59:48 GMT</pubDate>
            <atom:updated>2026-02-19T18:06:28.922Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How function-level indexing and pattern metadata turned Claude into a team-aware code generator</em></p><p>I asked Claude to build a microservice with three API endpoints. It generated 20 hours of work in minutes. Then came the PR review: <strong>15 comments, 6 revision commits, 12 hours of rework.</strong> We deleted 1,843 of the lines Claude wrote.</p><p>Not a single comment was about bugs. They were all about patterns.</p><p>Used gorm in path names when our team uses mysql. Reinvented an HTTP client when we already have an internal library. Verb-based REST URIs when we use resource-based ones. A 45-line service layer that should have been 12.</p><p>This wasn’t a one-off. Every Claude-generated PR got 15–20 pattern comments. The <em>“AI-assisted”</em> projects barely saved time over writing code by hand.</p><p><strong>The problem isn’t Claude’s code quality. The problem is that every conversation starts at zero.</strong> Claude doesn’t know your team exists.</p><h3>What “starting at zero” actually looks like</h3><p>Ask Claude to “add telemetry tracing to my Go service.” You’ll get something like this:</p><pre>exporter, _ := jaeger.New(jaeger.WithCollectorEndpoint(<br>    jaeger.WithEndpoint(&quot;http://localhost:14268/api/traces&quot;),<br>))<br>tp := sdktrace.NewTracerProvider(sdktrace.WithBatcher(exporter))</pre><p>Valid code. Would compile. Would never pass review at my company.</p><p>We use OTLP, not Jaeger. Our telemetry goes to telemetry.internal.acme.com, not localhost. Every service needs TeamLabel and CostCenter fields for compliance and billing. Claude doesn’t know any of this, so it generates the tutorial version.</p><p>This happens with every cross-cutting concern: auth, database access, error handling, HTTP clients. Anywhere your team has made deliberate choices, Claude defaults to generic.</p><h3>The fix: a pattern-aware code search</h3><p>I built an MCP server that indexes your team’s repositories at the function level, detects design patterns and frameworks, and gives Claude a search_code tool with metadata filtering.</p><p>After connecting the MCP server, the same “add telemetry” prompt produces:</p><pre>tp, err := telemetry.NewTracer(telemetry.AcmeTracerConfig{<br>    ServiceName: &quot;order-service&quot;,<br>    TeamLabel:   &quot;payments&quot;,<br>    CostCenter:  &quot;CC-2847&quot;,<br>    Environment: &quot;production&quot;,<br>    SampleRate:  0.1,<br>})</pre><p>It found our NewTracer factory, saw the required compliance fields, and generated code that matches how we actually do it. First try.</p><p>The project is open source: <a href="https://github.com/Manojred22/codebase-patterns-mcp">github.com/Manojred22/codebase-patterns-mcp</a></p><h3>How it works</h3><p><strong>Indexing (one-time, ~40 seconds for 2,000 functions):</strong> tree-sitter parses every function across Go, Java, Python, JavaScript, and TypeScript. Each function gets classified — factory, decorator, singleton — then embedded into a vector and stored in ChromaDB with all that metadata.</p><p><strong>At query time (~500ms):</strong> Claude calls search_code(“telemetry tracing”, language=”go”, pattern=”factory”). The query gets embedded, vector similarity plus metadata filtering finds the most relevant functions, and Claude gets back full source code with context.</p><p>The MCP server is about 400 lines of Python. No SDK — just JSON-RPC 2.0 over STDIO.</p><h3>Why not existing tools?</h3><p>There are good MCP servers for code search already — claude-context, CodeGrok, Serena, and others. They answer: “Find me code that looks like this query.”</p><p>My problem was different. I didn’t need Claude to find similar code. I needed it to find code that follows specific patterns — our factory functions, our decorator-based auth middleware, our service conventions.</p><p>The key differences: function-level granularity instead of file-level chunks, metadata that includes design pattern and framework classification, and filtering by language plus pattern plus framework — not just by repo or file path.</p><h3>What I learned building this</h3><p><strong>Ground truth matters more than the model.</strong> I spent time comparing embedding models when the real leverage was in defining what “good results” means. Writing 8 test queries with expected function IDs was the single most useful thing I did. 8 queries is a starting point, not a comprehensive eval — but it caught real issues.</p><p><strong>The cheapest embedding model won.</strong> I tested OpenAI’s small and large models against Voyage’s voyage-code-3 (which outperforms OpenAI by ~13% on public benchmarks). On my data, text-embedding-3-small at $0.02/1M tokens beat both. Public leaderboards didn’t predict this. Always benchmark on your own data.</p><p><strong>Start with curated examples, not everything.</strong> I initially indexed 9 entire repos — 2,139 functions. Most were noise. 20–30 carefully selected files covering your core patterns would be more effective and index in seconds.</p><p><strong>Function-level beats file-level for patterns.</strong> File-level chunking gives Claude a wall of code and hopes it finds the right part. Function-level indexing means Claude gets exactly the factory function or middleware decorator it needs.</p><p><strong>tree-sitter has a byte offset trap.</strong> tree-sitter returns byte offsets, but Python strings use character offsets. One em dash in a docstring silently corrupted every function name that followed. If you build on tree-sitter: always extract text from the byte representation, never from the Python string.</p><p><strong>The proactive search is what makes it useful.</strong> By default, Claude only searches when you explicitly ask. The real shift happens when you add a CLAUDE.md file telling Claude to always search before writing auth, telemetry, database code. Developers don’t need to know the MCP server exists — Claude just starts writing better code.</p><h3>Costs and limitations</h3><p>API costs are negligible: $0.04 to index 2,000 functions, $0.0001 per search. A hundred searches a day costs about $3/month.</p><p>It’s only as good as what you index. Indexes go stale when your team adopts new patterns — no automatic sync yet. Pattern detection is heuristic, not ML. And this isn’t a replacement for code review. The goal is reducing pattern comments from 15 per PR to a handful, not to zero.</p><p><em>The question isn’t whether AI should write your code. It’s whether the AI knows how your team writes code.</em></p><pre>git clone https://github.com/Manojred22/codebase-patterns-mcp.git<br>cd codebase-patterns-mcp<br>bash demo/setup_demo.sh</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d7adfc21587" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>