AI context: @Codebase & rules
This course covers how to give an AI coding assistant a project's conventions before it writes code. It explains why a model with no project information falls back on the common shape of public Rails code. It then looks at CLAUDE.md, Cursor's .mdc rules and AGENTS.md, and compares rules files with on-demand codebase search. It walks through this project's MEMORY.md, shows how concrete and scoped rules are written, and explains why context files go stale and what context still cannot prevent.
What you'll learn
- ✓Why AI assistants default to generic Rails patterns without project context
- ✓How CLAUDE.md, Cursor's .mdc rules and AGENTS.md load project instructions
- ✓How a rules file differs from searching the codebase on demand
- ✓How to write rules as concrete code with clear permissions and narrow scope
- ✓Why context files drift from the code and how to keep them accurate
Why AI invents plausible, wrong conventions
AI safety: review before copying ended with a controller action that awarded XP directly inside publish. It was valid Ruby and idiomatic Rails, and wrong for this app, which keeps business logic in service objects. Nothing about that suggestion was a bug in the AI. It was working as trained, and…
Read the full lesson free →Curriculum
7 lessonsWhy AI invents plausible, wrong conventions
Why a model with no project information reproduces the dominant Rails pattern, such as a fat controller.
Project instruction files: CLAUDE.md and Cursor rules
How Claude Code reads CLAUDE.md each session and how Cursor's scoped .mdc rules replaced the legacy .cursorrules.
Searching the codebase for context
How a rules file differs from searching the codebase, and how Cursor moved from @codebase to grep-style search.
This project's MEMORY.md
A tour of this project's MEMORY.md, including its layer contract, service shape and namespaced form rule.
Writing rules an AI follows
Why rules shown as concrete code, with clear permissions and narrow scope, are easier for an AI to follow.
Keeping context files in sync with code
Why context files drift from the code, why a stale rule misleads, and how auto memory helps partly.
Putting it together: context before code
How the mechanisms fit together, and why project context changes the starting point without replacing review.