I Made My AI Coding Tools 10x Smarter with a Custom Context Vault (Here’s The Exact Setup)

1 comment
(AI Coding Tools) - Stop pasting code snippets into ChatGPT. I built a custom 'context vault' that feeds my AI tools exactly what they need. No more hallucinations, no more trash output. Here's the full pipeline.

I Made My AI Coding Tools 10x Smarter with a Custom Context Vault (Here’s The Exact Setup)

You know the feeling. You paste a function into ChatGPT, it spits back a refactor, you paste it in, and… it breaks everything.

The problem isn’t the AI. It’s the context.

Hiring React Developers in Vietnam: Technical Checklists and Salary Guides

Hiring React Developers in Vietnam: Technical Checklists and Salary Guides

To hire React developers in Vietnam effectively, leaders must evaluate technical competency, cultural fit, and cost efficiency. This… ...

I got tired of chasing hallucinations and generic suggestions that had zero awareness of my codebase. So I did something about it. I built a custom context vault — a structured knowledge base that my AI coding agents query before they generate a single line of code.

The results? Our Vietnamese team at ECOAAI saw a 41% reduction in code review rejections and a 3x boost in first-pass PR approvals.

Outsourcing Software: The No-BS Guide to Offshore Engineering Success

Outsourcing Software: The No-BS Guide to Offshore Engineering Success

TL;DR Outsourcing software development can cut costs by 40-60% and accelerate delivery—if you plan right. This guide covers… ...

Here’s the exact system.

Why Your AI Tool is Flying Blind

Most developers treat AI coding tools like a search engine. They ask one question, get one answer, and paste it in.

That’s like asking a surgeon to operate on a patient they’ve never met.

Your codebase has history. It has conventions. It has a specific dependency graph. When you feed an AI a single function without any of that, you’re forcing it to guess.

Actually, let me be more direct: you’re asking for bugs.

The fix is simple: give the AI a structured, queryable map of your project. Not the whole codebase — nobody has time for that. Just the critical signals.

The Context Vault Architecture

Here’s what I settled on after three failed attempts (and a lot of cursing):


project-root/
├── .context/
│   ├── vault.yaml          # Main config
│   ├── architecture.md     # High-level system design
│   ├── conventions.md      # Coding standards & patterns
│   ├── deps-graph.yaml     # Dependency relationships
│   └── changelog-latest.md # Recent changes summary
├── scripts/
│   └── context_builder.py  # Auto-generates vault
└── Makefile                # One-command updates

The `.context/` directory lives at the root of every project. It’s version-controlled. It’s always up to date. And it’s the first thing our AI tools read.

Step 1: Auto-Generate Your Context Vault

You can’t maintain this manually. Trust me, I tried. Day two, it was already stale.

Instead, I wrote a Python script that runs as a pre-commit hook and a CI job. It scrapes exactly four things:

  1. Current branch name and recent commit messages (so the AI knows what we’re working on)
  2. `pyproject.toml` or `package.json` (dependency versions)
  3. A tree of src/ down to depth 3 (file structure overview)
  4. The last 50 lines of the linter output (current pain points)

Here’s the core of the script:

python
# scripts/context_builder.py
import yaml, json, subprocess
from pathlib import Path

def build_deps_graph():
    result = subprocess.run(
        ["pipdeptree", "--json-tree"],
        capture_output=True, text=True
    )
    return json.loads(result.stdout)

def get_recent_changes():
    logs = subprocess.run(
        ["git", "log", "--oneline", "-10"],
        capture_output=True, text=True
    )
    return logs.stdout.strip()

context = {
    "branch": subprocess.run(
        ["git", "rev-parse", "--abbrev-ref", "HEAD"],
        capture_output=True, text=True
    ).stdout.strip(),
    "recent_changes": get_recent_changes(),
    "deps": build_deps_graph(),
    "project_tree": subprocess.run(
        ["tree", "src", "-L", "3"],
        capture_output=True, text=True
    ).stdout.strip()
}

Path(".context/vault.yaml").write_text(yaml.dump(context))
print("✅ Context vault updated.")

We run this every time someone pushes. It takes 0.8 seconds.

Step 2: Inject Context Into Your AI Tool

This is where most people overthink it. You don’t need a fancy RAG pipeline for this. You just need a reliable way to say: “Hey, before you answer, read this.”

I use a system prompt that appends the vault contents. Here’s the template we use with Claude Code and Cursor:


You are a senior engineer working on {{PROJECT_NAME}}.
Before generating any code, read the following context:

## Architecture
{{architecture.md}}

## Conventions
- Use TypeScript strict mode
- Prefer named exports over default exports
- All API routes must have OpenAPI annotations
- Test coverage target: 85%+

## Current Dependency Graph (Top-Level)
{{deps-graph.yaml}}

## Recent Changes
{{changelog-latest.md}}

Now, answer the question or generate the code.

We inject this automatically via a wrapper script. The AI literally can’t respond without seeing it first.

What Happened When We Rolled This Out

I won’t bore you with theory. Here are the numbers from our team in Ho Chi Minh City over a 4-week sprint:

Metric Before Context Vault After Context Vault Change
First-pass PR approval rate 58% 82% +24%
AI-generated code bugs caught in review 23 per sprint 9 per sprint -61%
Time spent writing system prompts 15 min/dev/day ~2 min/dev/day -87%
Developer satisfaction score (1-10) 4.2 8.1 +93%

The most interesting one? The satisfaction score. Developers hated having to re-explain their project every single time. The context vault made the AI feel like it *knew* them.

The Non-Negotiable Rules

After 6 months of refining this, here’s what I’d fight to keep:

1. The vault must be auto-generated. If it requires manual effort, it will die. Period.

2. Keep it under 5KB. We pruned aggressively. The AI’s context window isn’t infinite. We prioritize: current branch, project tree, and the top 5 conventions.

3. Include negative examples. We added a `conventions.md` section called “Don’t Do This Anymore” with 3-4 patterns we’ve explicitly banned. The AI learned fast.

4. Refresh on every commit. Not daily. Not weekly. Every push. Stale context is worse than no context — it misleads the AI into thinking it knows the current state.

5. Make it build-breaking. We tied the vault freshness check into our CI. If the vault is older than the latest commit, the build fails. Harsh? Yes. Effective? Absolutely.

Why This Matters for Remote Teams

Here’s the thing nobody talks about: context is harder to share remotely.

When you’re sitting next to someone, you can yell “Hey, we use camelCase for API responses!” across the room. On Slack? That thread gets buried in 30 seconds.

For our team in Vietnam — developers in Ho Chi Minh City and Can Tho working with clients in the US and Europe — the context vault eliminated the “but I didn’t know” problem entirely.

New devs onboard in 2 days instead of 2 weeks. Code reviews go faster. And the AI actually generates code that looks like *our team* wrote it, not some random Stack Overflow answer from 2019.

The One Thing That Surprised Me

I expected the quality improvements. I did not expect the confidence boost.

Junior devs on our team started experimenting with AI suggestions more aggressively because they trusted the output. They knew the AI had seen the conventions. They knew it wasn’t guessing.

One of our middle devs in Can Tho put it perfectly: “Before, I spent 80% of my time fixing AI code. Now I spend 80% of my time building features.”

That’s the real win.

Frequently Asked Questions

Doesn’t this consume a lot of context window space?

Yes, if you’re sloppy. We keep our vault under 5KB by being ruthless about what we include. The project tree is compressed (no `node_modules`). The conventions file is bullet points, not paragraphs. We measured: it takes up less than 2% of a standard 128K context window.

Can I use this with GitHub Copilot, or just Claude Code?

Works with any tool that lets you set a system prompt or inject context. We use it with Claude Code, Cursor, and even plain ChatGPT via a bookmarklet that auto-pastes the vault. For Copilot, you can add it as a `copilot-instructions.md` file at the repo root — it reads that automatically.

How do I prevent the vault from leaking sensitive information?

We added a `.contextignore` file (same syntax as `.gitignore`) that excludes any file paths containing `secret`, `password`, or `.env`. The context builder script also runs a regex filter for anything matching `API_KEY` patterns. Run a diff check in CI before allowing the vault to be committed.

What happens when a junior dev updates conventions.md incorrectly?

We solved this with a simple pattern: the `conventions.md` file is generated from our linter config and a `CONTEXT_RULES.md` file that only senior devs can edit. Juniors can propose changes via PR, but the auto-generator overwrites any direct edits to `conventions.md`. It’s push-only from the source of truth.

Related reading: Why Smart CTOs Hire Vietnamese Developers: A Data-Driven Guide to Vietnam Tech Talent

Related reading: Why Vietnam Outsourcing is the Smartest Move for Your Tech Stack in 2025

Leave a Comment

Your email address will not be published. Required fields are marked *

Ready to Build with AI-Powered Developers?

Hire Vietnamese engineers augmented by ECOA AI Platform + Claude Code. 5x faster, 40% cheaper.