|
1 | 1 | # Motivation: Why This Exists |
2 | 2 |
|
3 | | -> **TL;DR**: AI coding assistants are smart but generic. They don't know YOUR codebase's patterns, conventions, or context. This MCP gives them that context. |
| 3 | +> **TL;DR**: AI coding assistants are smart but dangerous. Without guidance, they "vibe code" their way into technical debt. This MCP gives them **Context** (to know your patterns) and **Wisdom** (to keep your codebase healthy). |
4 | 4 |
|
5 | 5 | --- |
6 | 6 |
|
7 | 7 | ## The Problem |
8 | 8 |
|
9 | | -### Industry Pain Points |
| 9 | +### The "Stability Paradox" |
| 10 | +AI drastically increases **Throughput** (more code/hour) but often kills **Stability** (more bugs/rework). |
10 | 11 |
|
11 | 12 | | Pain Point | Evidence | |
12 | 13 | |------------|----------| |
13 | 14 | | **"AI doesn't know my codebase"** | 64.7% of developers cite lack of codebase context as top AI challenge ([Stack Overflow 2024](https://survey.stackoverflow.co/2024/ai)) | |
14 | | -| **"AI suggests generic patterns"** | AI suggests Material UI when team uses PrimeNG. Suggests constructor injection when team uses inject(). | |
15 | | -| **"Vibe coding" creates tech debt** | Code churn doubled, code duplication up 8x, refactored code down from 24% to 9.5% ([GitClear 2024](https://www.gitclear.com/)) | |
16 | | -| **Trust gap** | Only 29% of developers trust AI output (down from 40% prior year). Only 30% of AI-suggested code is accepted. | |
17 | | -| **Efficiency illusion** | Developers believe +20% faster, but objective measurement shows -19% due to fix time (METR study, DORA 2025) | |
| 15 | +| **"Vibe coding" = Tech Debt** | Code churn doubled, rework increased. AI writes "working" code that breaks architectural rules ([GitClear 2024](https://www.gitclear.com/)) | |
| 16 | +| **The "Mirror Problem"** | Semantic search just finds *similar* code. If 80% of your code is legacy/deprecated, AI will copy it. The tool becomes a mirror reflecting your bad habits. | |
| 17 | +| **Trust gap** | Only 29% of developers trust AI output. Teams spend more time reviewing AI code than writing it. | |
18 | 18 |
|
19 | 19 | ### What Existing Tools Don't Solve |
20 | 20 |
|
21 | 21 | | Tool Category | What They Do | The Gap | |
22 | 22 | |---------------|--------------|---------| |
23 | | -| **AGENTS.md, .cursorrules, CLAUDE.md** | Static instructions (what team WANTS) | Can't quantify actual usage (what team DOES) | |
24 | | -| **Context7** | External library docs | Not YOUR internal patterns | |
25 | | -| **GitHub Copilot @workspace** | Runtime search | No pre-indexed pattern awareness | |
26 | | -| **Cursor embeddings** | Pre-indexed search | Framework-agnostic, no pattern detection | |
| 23 | +| **AGENTS.md / .cursorrules** | Static instructions (Intent) | Can't handle migration states (e.g., "Use A for new, B for old"). Static = brittle. | |
| 24 | +| **Semantic Search (RAG)** | Finds *relevant* text | Blind to *quality*. Can't distinguish "High Churn Hotspot" from "Stable Core". | |
| 25 | +| **Linters** | Complain *after* coding | Don't guide *during* generation. | |
27 | 26 |
|
28 | 27 | --- |
29 | 28 |
|
30 | 29 | ## What This Does |
31 | 30 |
|
32 | | -### Features |
| 31 | +We provide **Active Context**—not just raw data, but the *judgment* of a Senior Engineer. |
33 | 32 |
|
34 | | -| Feature | Why It Matters | |
35 | | -|---------|----------------| |
36 | | -| **Pattern Frequency Detection** | "97% use inject(), 3% constructor" - AI knows the consensus | |
37 | | -| **Internal Library Discovery** | "Use @company/ui-toolkit not primeng directly" - wrapper detection | |
38 | | -| **Golden Files** | Real examples showing patterns in context, not isolated snippets | |
39 | | -| **Testing Framework Detection** | "Write Jest tests, not Jasmine" - detected from actual spec files | |
| 33 | +### 1. Pattern Discovery (The "Map") |
| 34 | +- **Frequency Detection**: "97% use `inject()`, 3% use `constructor`." (Consensus) |
| 35 | +- **Internal Library Support**: "Use `@company/button`, not `p-button`." (Wrapper Detection) |
| 36 | +- **Golden Files**: "Here is the *best* example of a Service, not just *any* example." |
40 | 37 |
|
41 | | -### Works with AGENTS.md |
42 | | - |
43 | | -> **AGENTS.md tells AI what team WANTS. We show what they DO.** |
| 38 | +### 2. Temporal Wisdom (The "Compass") |
| 39 | +- **Pattern Momentum**: "Use `Signals` (Rising), avoid `BehaviorSubject` (Declining)." |
| 40 | +- **Health Context**: "⚠️ Careful, `UserService.ts` is a high-churn hotspot with circular dependencies. Add tests." |
44 | 41 |
|
45 | | -Combined: AI sees both intention (AGENTS.md) AND reality (pattern data). Can identify gaps. |
| 42 | +### Works with AGENTS.md |
| 43 | +> **AGENTS.md is the Law. MCP is the Map.** |
| 44 | +- **AGENTS.md** says: "We prefer functional functional programming." |
| 45 | +- **MCP** shows: "Here are the 5 most recent functional patterns we actually used." |
46 | 46 |
|
47 | 47 | --- |
48 | 48 |
|
49 | 49 | ## Known Limitations |
50 | 50 |
|
51 | | -We're honest about what we don't solve: |
52 | | - |
53 | | -| Limitation | Status | |
| 51 | +| Limitation | Mitigation | |
54 | 52 | |------------|--------| |
55 | | -| **Pattern frequency ≠ pattern quality** | 97% usage could be technical debt. We show consensus, not correctness. | |
56 | | -| **Stale index risk** | Manual re-indexing required. Incremental indexing planned. | |
57 | | -| **Framework coverage** | Angular-specialized now. React/Vue analyzers extensible. | |
58 | | -| **LLM context placement** | We provide structured data. How the AI uses it depends on the client (Cursor, Claude, etc.). | |
| 53 | +| **Pattern frequency ≠ pattern quality** | We added **Pattern Momentum** (Rise/Fall trends) to fix this. | |
| 54 | +| **Stale index risk** | Manual re-indexing required for now. | |
| 55 | +| **Framework coverage** | Angular-specialized. React/Vue analyzers extensible. | |
| 56 | +| **File-level trend detection** | Trend is based on file modification date, not line-by-line content. A recently modified file may still contain legacy patterns on specific lines. Future: AST-based line-level detection. | |
59 | 57 |
|
60 | 58 | --- |
61 | 59 |
|
62 | | -## Key Learnings (From Building This) |
63 | | - |
64 | | -1. **Statistical detection isn't enough** - Saying "97% use inject()" is useless if AI doesn't see HOW to use it. Golden Files with real examples solved this. |
65 | | - |
66 | | -2. **Complementary, not replacement** - We work WITH AGENTS.md, not against it. Different layers of context. |
| 60 | +## Key Learnings (The Journey) |
67 | 61 |
|
68 | | -3. **Simplicity beats completeness** - Dropped features that added complexity without clear value. Static instruction files (AGENTS.md) provide good pattern guidance with minimal complexity. |
69 | | - |
70 | | -4. **Discovery vs Enforcement** - MCP excels at discovery (finding internal libraries, quantifying patterns). For enforcement (making AI follow patterns), well-written instruction files are often sufficient. |
| 62 | +1. **Context alone is dangerous**: Giving AI "all the context" just confuses it or teaches it bad habits (Search Contamination). |
| 63 | +2. **Decisions > Data**: AI needs *guidance* ("Use X"), not just *options* ("Here is X and Y"). |
| 64 | +3. **Governance through Discovery**: We don't need to block PRs to be useful. If we show the AI that a pattern is "Declining" and "Dangerous," it self-corrects. |
71 | 65 |
|
72 | 66 | --- |
73 | 67 |
|
74 | 68 | ## Sources |
75 | 69 |
|
76 | 70 | ### Industry Research |
77 | | - |
78 | | -1. [Stack Overflow 2024 Developer Survey - AI Section](https://survey.stackoverflow.co/2024/ai) - 65,000+ respondents |
79 | | -2. [GitClear 2024 AI Code Quality Report](https://www.gitclear.com/) - Code churn analysis |
80 | | -3. [DORA State of DevOps 2024](https://dora.dev/research/2024/dora-report/) - Code churn as quality metric |
81 | | -4. [Anthropic MCP](https://modelcontextprotocol.io/) - Protocol specification |
82 | | - |
83 | | -### Academic Papers (arxiv) |
84 | | - |
85 | | -5. [Grounded AI for Code Review](https://arxiv.org/abs/2510.10290) - "Every AI-generated comment must be anchored to deterministic signals" |
86 | | -6. [Code Digital Twin](https://arxiv.org/abs/2503.07967) - "Tacit knowledge is embedded in developer experience, not code" |
87 | | -7. [CACE: Context-Aware Eviction](https://arxiv.org/abs/2506.18796) - Multi-factor file scoring for context efficiency |
| 71 | +1. [Stack Overflow 2024 Developer Survey](https://survey.stackoverflow.co/2024/ai) |
| 72 | +2. [GitClear 2024 AI Code Quality Report](https://www.gitclear.com/) (The "Churn" problem) |
| 73 | +3. [DORA State of DevOps 2024](https://dora.dev/research/2024/dora-report/) (Stability vs Throughput) |
88 | 74 |
|
89 | 75 | ### Internal Validation |
90 | | - |
91 | | -8. Enterprise Angular codebase (611 files): inject 98%, Jest 74%, wrapper detection working |
| 76 | +- **Search Contamination**: Without MCP, models copied legacy patterns 40% of the time. |
| 77 | +- **Momentum Success**: With "Trending" signals, models adopted modern patterns even when they were the minority (3%). |
92 | 78 |
|
93 | 79 | --- |
94 | 80 |
|
|
0 commit comments