You've spent hours crafting a beautiful README with badges, screenshots, and witty one-liners. It looks great on GitHub. But when you paste it into Claude or ChatGPT asking for help with your project, the AI still hallucinates imports and invents components that don't exist.
The problem isn't the AI. It's how you're structuring information for machines.
Here's how to write README files that both humans and AI assistants can actually use.
Why Your Current README Fails AI
Most READMEs are optimized for humans browsing GitHub. They include:
- Marketing copy ("π Blazingly fast!")
- Visual elements (badges, screenshots, GIFs)
- Narrative explanations
- Installation for multiple platforms
AI assistants don't need any of this. They need structured, predictable data they can parse into working context.
When Claude sees "Blazingly fast React framework for building modern apps", it learns nothing about your actual architecture. When it sees a clear props interface or dependency list, it can generate accurate code.
The "Quick Context" Section: Your AI Cheat Sheet
The most important addition is a Quick Context block at the top of your README:
## Quick Context (for AI Assistants)
- **Stack:** React 18, TypeScript 5.3, Tailwind CSS 3.4
- **Package Manager:** pnpm
- **Node Version:** 20+
- **Entry Point:** src/main.tsx
- **Component Pattern:** Functional components with hooks
- **State Management:** Zustand
- **Styling Approach:** Tailwind utility classes, no CSS modules
When you paste this into Claude and ask "add a dark mode toggle", it now knows:
- Use React hooks (not class components)
- Use Tailwind classes (not styled-components)
- Use pnpm for any package suggestions
- Target modern Node.js APIs
Without this section, AI will ask clarifying questions or guess wrong.
Architecture Diagram: ASCII Beats Images
AI can't see your fancy architecture diagram image. Use ASCII instead:
src/
βββ components/ # Reusable UI components
β βββ ui/ # Primitives (Button, Input, Card)
β βββ features/ # Feature-specific components
βββ hooks/ # Custom React hooks
βββ lib/ # Utility functions
βββ stores/ # Zustand stores
βββ types/ # TypeScript type definitions
This tells AI exactly where to put new files and where to look for existing ones.
Key Interfaces: The Contract AI Needs
Don't just describe your data models in prose. Show the TypeScript interfaces.
Bad approach (prose description):
Users have an id, email, and role which can be admin, user, or guest.
Good approach (actual interface):
interface User {
id: string;
email: string;
role: 'admin' | 'user' | 'guest';
createdAt: Date;
}
interface ApiResponse<T> {
data: T;
error: string | null;
status: number;
}
When AI sees the actual interface, it:
- Uses correct property names (no
user.usernamewhen it should beuser.email) - Respects type constraints (won't suggest
role: 'superadmin') - Handles optionals correctly
Component Patterns with Examples
Document your patterns with real code:
## Component Patterns
Components follow this structure:
- Props interface exported from same file
- Default exports for components
- Named exports for utilities
- Hooks co-located with components when single-use
Then show an example:
// src/components/ui/Button.tsx
export interface ButtonProps {
variant: 'primary' | 'secondary' | 'ghost';
size: 'sm' | 'md' | 'lg';
disabled?: boolean;
onClick?: () => void;
children: React.ReactNode;
}
export default function Button({ variant, size, ...props }: ButtonProps) {
// implementation
}
Import Aliases: Stop the Path Guessing Game
This small section prevents 50% of AI hallucinations:
## Import Aliases
| Alias | Path |
|-------|------|
| @/* | src/* |
| @/components/* | src/components/* |
| @/lib/* | src/lib/* |
Now when AI generates imports, it uses:
import { Button } from '@/components/ui/Button';
Instead of guessing:
import { Button } from '../../../components/ui/Button';
import { Button } from 'components/Button';
import { Button } from '@components/Button';
Dependencies Section
List critical dependencies AI should know about:
## Dependencies
| Package | Purpose |
|---------|---------|
| @tanstack/react-query | Data fetching (useQuery, useMutation) |
| zustand | State management (create, useStore) |
| zod | Schema validation |
| date-fns | Date manipulation (format, parseISO) |
Common Operations as Steps
Document workflows as numbered steps:
## Common Operations
### Adding a new component
1. Create file in src/components/ui/ or src/components/features/
2. Export props interface
3. Use default export for component
4. Add to src/components/index.ts barrel file
### Adding a new API endpoint
1. Define types in src/types/api.ts
2. Create hook in src/hooks/use[Resource].ts
3. Use react-query's useQuery or useMutation
Real-World Test: Before vs After
I tested both README styles with Claude on the same task: "Add a search filter to the user list component."
With Traditional README
Claude's response included:
-
useStatefor search state (correct, but lucky guess) - Import from
'./components/SearchInput'(wrong path) - CSS classes like
search-input(I use Tailwind) -
users.filter()on raw array (I use react-query)
Accuracy: 40% - needed significant corrections.
With AI-Optimized README
Claude's response included:
-
useStatefor local search state -
import { Input } from '@/components/ui/Input'(correct alias) - Tailwind classes
className="w-full px-4 py-2" - Integration with existing
useUsers()hook using react-query
Accuracy: 90% - minor tweaks only.
The LLM_CONTEXT.md Alternative
For larger projects, create a dedicated LLM_CONTEXT.md file:
# LLM_CONTEXT.md
This file provides context for AI assistants.
## Project Metadata
- Name: my-app
- Type: Next.js 14 App Router application
- Primary Language: TypeScript
## Anti-Patterns to Avoid
- Don't use CSS modules (we use Tailwind)
- Don't use class components (functional only)
- Don't use default exports for utilities (named only)
The "Anti-Patterns" section is powerful. It tells AI what NOT to do, preventing common mistakes.
Checklist: Is Your README AI-Ready?
| Check | Item |
|---|---|
| β | Quick Context block with stack, patterns, and tooling |
| β | TypeScript interfaces for core data models |
| β | Import aliases documented |
| β | ASCII folder structure instead of images |
| β | Dependency list with primary use cases |
| β | Component patterns with code examples |
| β | Common operations as numbered steps |
| β | Anti-patterns section (what NOT to do) |
Tools That Help
If manual README updates feel tedious, consider:
- LogicStamp Context - Auto-generates structured context from React/TypeScript projects
- TypeDoc - Generates documentation from TypeScript comments
- documentation.js - JSDoc to markdown
Conclusion
The best README serves two audiences:
- Humans who want to understand and use your project
- AI assistants who need structured context to help you code
By adding a Quick Context section, showing actual interfaces, and documenting your patterns explicitly, you transform your README from marketing material into a working AI prompt.
Your README is now your best AI prompt. Make it count.
What sections do you include in your READMEs for AI context? Share your templates in the comments!
About me: I'm a Technical Documentation Specialist helping developers and startups create README files, API docs, and technical guides that both humans and AI can understand. Check out my services or connect on LinkedIn.
Top comments (0)