<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Beatrix</title>
    <description>The latest articles on DEV Community by Beatrix (@milesyam).</description>
    <link>https://dev.to/milesyam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3907174%2Fe868821c-0d0c-47a4-8605-83073713aefc.jpeg</url>
      <title>DEV Community: Beatrix</title>
      <link>https://dev.to/milesyam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/milesyam"/>
    <language>en</language>
    <item>
      <title>Stop watching your AI hallucinate because it doesn't know your codebase. Here's the context-stuffing workflow that actually works.</title>
      <dc:creator>Beatrix</dc:creator>
      <pubDate>Mon, 04 May 2026 10:21:39 +0000</pubDate>
      <link>https://dev.to/milesyam/stop-watching-your-ai-hallucinate-because-it-doesnt-know-your-codebase-heres-the-oj3</link>
      <guid>https://dev.to/milesyam/stop-watching-your-ai-hallucinate-because-it-doesnt-know-your-codebase-heres-the-oj3</guid>
      <description>&lt;p&gt;If you've ever heard "I don't have enough context about your project" from an AI assistant, you know the frustration. Your AI writes perfectly reasonable code that would work great—in a completely different codebase with different conventions, dependencies, and patterns.&lt;/p&gt;

&lt;p&gt;The problem isn't the AI. It's that you're not giving it enough to work with.&lt;/p&gt;

&lt;p&gt;I used to paste in 3-4 files and hope for the best. Now I routinely stuff 10x more context into my prompts, and the difference is night and day. Here's my workflow.&lt;/p&gt;

&lt;p&gt;The Context Triangle&lt;br&gt;
Good AI context comes from three sources:&lt;/p&gt;

&lt;p&gt;Project context — Architecture, conventions, patterns&lt;br&gt;
Code context — Relevant files, imports, dependencies&lt;br&gt;
Task context — What you're actually trying to accomplish&lt;br&gt;
Most devs only give #3 and maybe a bit of #2. That's why the AI hallucinates.&lt;/p&gt;

&lt;p&gt;Step 1: Create a Context Manifest&lt;br&gt;
Create a CONTEXT.md in your project root. This is your project's cheat sheet for AI:&lt;/p&gt;
&lt;h1&gt;
  
  
  Project Context for AI Assistants
&lt;/h1&gt;
&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Type: [microservice/monolith/library/frontend]&lt;/li&gt;
&lt;li&gt;Main language: [TypeScript/Python/etc]&lt;/li&gt;
&lt;li&gt;Framework: [Next.js/FastAPI/etc]&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Brief description of how things fit together]&lt;/li&gt;
&lt;li&gt;[Key directories and their purposes]&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Coding Conventions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;File naming: [kebab-case/PascalCase/etc]&lt;/li&gt;
&lt;li&gt;Component structure: [describe pattern]&lt;/li&gt;
&lt;li&gt;State management: [how you handle state]&lt;/li&gt;
&lt;li&gt;Error handling: [your approach]&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Important Patterns
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Pattern 1]: [when to use it]&lt;/li&gt;
&lt;li&gt;[Pattern 2]: [when to use it]&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Gotchas
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Thing that breaks if you change it]&lt;/li&gt;
&lt;li&gt;[Legacy code you can't touch]&lt;/li&gt;
&lt;li&gt;[Performance considerations]
You write this once, then reference it in every prompt. It's like giving your AI a project onboarding document.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Step 2: Use a Context Dumper Script&lt;br&gt;
Instead of manually pasting files, use a script that dumps relevant context in a structured way:&lt;/p&gt;
&lt;h1&gt;
  
  
  !/bin/bash
&lt;/h1&gt;
&lt;h1&gt;
  
  
  dump-context.sh
&lt;/h1&gt;

&lt;p&gt;echo "# Project Context"&lt;br&gt;
cat CONTEXT.md&lt;/p&gt;

&lt;p&gt;echo -e "\n# Relevant Files"&lt;br&gt;
echo "## File: src/types/user.ts"&lt;br&gt;
cat src/types/user.ts&lt;/p&gt;

&lt;p&gt;echo -e "\n## File: src/services/auth.ts"&lt;br&gt;
cat src/services/auth.ts&lt;/p&gt;

&lt;p&gt;echo -e "\n# Package Dependencies (relevant)"&lt;br&gt;
cat package.json | grep -A 20 '"dependencies"'&lt;br&gt;
Run this before complex tasks, and pipe the output into your AI prompt. You get consistent, comprehensive context every time.&lt;/p&gt;

&lt;p&gt;Step 3: Smart File Selection&lt;br&gt;
Don't dump everything. Prioritize:&lt;/p&gt;

&lt;p&gt;Types/interfaces — These define your data structures&lt;br&gt;
Utility functions — Shared logic the AI should reuse&lt;br&gt;
Similar existing implementations — Show, don't tell&lt;br&gt;
Configuration files — Build tools, linters, formatters&lt;br&gt;
Skip:&lt;/p&gt;

&lt;p&gt;Generated files (node_modules, build output)&lt;br&gt;
Tests (unless writing tests)&lt;br&gt;
Massive config files (grab only relevant sections)&lt;br&gt;
Step 4: Structured Prompting&lt;br&gt;
Organize your context so the AI can parse it:&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
[Paste CONTEXT.md or project overview]&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
[Paste type definitions]&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
[Paste similar code that works]&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
[What you want, with constraints]&lt;br&gt;
&lt;br&gt;
XML-style tags work surprisingly well. Most AI assistants are trained to recognize structured context.&lt;/p&gt;

&lt;p&gt;Step 5: The "Context Budget" Mindset&lt;br&gt;
AI models have token limits. Budget them like you would financial resources:&lt;/p&gt;

&lt;p&gt;High-value context: Types, conventions, patterns (30%)&lt;br&gt;
Code examples: Relevant implementations (40%)&lt;br&gt;
Task description: Clear requirements (20%)&lt;br&gt;
Constraints: What NOT to do (10%)&lt;br&gt;
If you're hitting limits, strip out verbose comments and logs before pasting code. Keep the signal, lose the noise.&lt;/p&gt;

&lt;p&gt;Real-World Example&lt;br&gt;
Before (what I used to do):&lt;/p&gt;

&lt;p&gt;"Add a function to validate email addresses in my user service"&lt;/p&gt;

&lt;p&gt;After (what I do now):&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
From CONTEXT.md: We use a microservice architecture with TypeScript.&lt;br&gt;
Validation happens in the service layer. We return custom ValidationErrors.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
interface ValidationError {&lt;br&gt;
  field: string;&lt;br&gt;
  message: string;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;interface User {&lt;br&gt;
  email: string;&lt;br&gt;
  // ... other fields&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
function validateUsername(username: string): ValidationError[] {&lt;br&gt;
  const errors: ValidationError[] = [];&lt;br&gt;
  if (!username || username.length &amp;lt; 3) {&lt;br&gt;
    errors.push({ field: 'username', message: 'Too short' });&lt;br&gt;
  }&lt;br&gt;
  return errors;&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
Create a validateEmail function following the same pattern as validateUsername.&lt;br&gt;
Return ValidationError[] with field: 'email'.&lt;br&gt;
Check for: empty, invalid format, already taken (call checkEmailExists).&lt;br&gt;
&lt;br&gt;
The result? Code that actually integrates with my existing patterns instead of fighting them.&lt;/p&gt;

&lt;p&gt;Tools That Help&lt;br&gt;
Some tools make this easier:&lt;/p&gt;

&lt;p&gt;Cursor IDE: Has a @codebase feature that automatically includes relevant files&lt;br&gt;
Cline: Good at understanding project structure when you point it at the right directory&lt;br&gt;
Aider: Lets you add files to context with /add and shows token usage&lt;br&gt;
But honestly, the bash script + CONTEXT.md combo works everywhere and costs nothing.&lt;/p&gt;

&lt;p&gt;The Tradeoffs&lt;br&gt;
This isn't magic. Downsides:&lt;/p&gt;

&lt;p&gt;Setup time: Takes 10-15 minutes to create your CONTEXT.md&lt;br&gt;
Token costs: More context = more tokens (but fewer iterations)&lt;br&gt;
Maintenance: Keep CONTEXT.md updated as your project evolves&lt;br&gt;
For me, the time saved on back-and-forth with the AI pays for itself within the first few complex tasks.&lt;/p&gt;

&lt;p&gt;Your Turn&lt;br&gt;
Start with a minimal CONTEXT.md for your current project. Add to it as you notice patterns or conventions you want the AI to follow.&lt;/p&gt;

&lt;p&gt;Within a week, you'll have a comprehensive context document that makes every AI interaction more productive.&lt;/p&gt;

&lt;p&gt;And honestly? That "I don't know your codebase" response will become a rare annoyance instead of a daily blocker.&lt;/p&gt;

&lt;p&gt;What's your approach to context management? Drop a comment if you've found techniques that work better—I'm always looking to improve this workflow.&lt;/p&gt;

&lt;p&gt;Tags: #ai #productivity #tools #workflow #developerexperience&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
