Live data from Hacker News

Ask HN: How do you keep AI coding agents aligned with your codebase standards?

news.ycombinator.com

1–2 of 2 posts

Ask HN: How do you keep AI coding agents aligned with your codebase standards?

#1
Our team heavily uses Claude Code. The problem we have is that agents write code that works but ignores existing patterns. They'll create a new database query instead of using the service class my team already built. They'll put logic in the wrong layer, etc.

Each fix is small, but across a team of 8 engineers, it adds up, making the codebase drift over time.

We've tried shared CLAUDE.md and multiple markdown doc files but they go stale fast and don't scale well.

How is everyone else handling this? Has anyone found something that actually works at scale?

Re: Ask HN: How do you keep AI coding agents aligned with your codebase standards?

#2
Two things that help:

Scope instructions to file patterns (services/* → "use ServiceFoo, no raw queries"). The agent only loads rules relevant to the code it's touching, and a small scoped file is easier to notice is wrong than line 47 of a monolithic doc.

Add a post-edit agent hook that asks the agent "does this change mean the scoped instructions need updating?" — turns maintenance from a chore someone forgets into part of the edit loop. Haven't battle-tested this at scale yet but the mechanism is there in Claude Code and Copilot.

For bootstrapping the initial instructions, check out microsoft/agentrc — it can generate and evaluate scoped instruction files so you're not writing them from scratch.