Teaching AI Agents Taste Through Examples - Five Good, Five Bad

Fazm Team··3 min read

Teaching AI Agents Taste Through Examples - Five Good, Five Bad

Showing examples works better than abstract guidelines. Five good and five bad examples teach an AI agent more about your preferences than two pages of written rules ever will.

Why Abstract Guidelines Fail

"Write clean, maintainable code" means nothing to an AI agent. It is too vague to act on. Every model thinks its output is clean and maintainable. "Use descriptive variable names" is slightly better but still leaves enormous room for interpretation. What counts as descriptive? How long is too long?

Compare that to showing the agent five actual function names from your codebase that you consider good and five that you consider bad. Now it has a concrete reference point. It can pattern match against real examples rather than interpreting abstract advice.

The Five-and-Five Pattern

In your CLAUDE.md or project instructions, include concrete examples of what you want and what you do not want. This works for almost everything.

For code style, show five functions that exemplify your preferred patterns and five that violate them. For commit messages, show five good ones and five bad ones from your actual git history. For error handling, show five cases where the agent handled errors the way you like and five where it did not.

The agent does not need you to explain the pattern. It will extract the pattern from the examples. And its extracted pattern will often be more nuanced than what you could articulate in words.

Why This Works

Language models are fundamentally pattern-matching systems. They are better at learning from examples than from descriptions. This is the same reason children learn language from hearing sentences, not from studying grammar rules.

When you give an agent abstract guidelines, it has to interpret the guideline and then generate matching output - two steps where errors can enter. When you give it examples, it just needs to match the pattern - one step, less room for drift.

The Maintenance Cost

Examples need updating as your codebase evolves. A set of example functions from six months ago might no longer reflect your current style. Review your examples quarterly and swap in fresh ones that represent your current preferences.

More on This Topic

Fazm is an open source macOS AI agent. Open source on GitHub.

Related Posts