Teach Your Coding Agent
TLDR: Don't lazily accept your agent's code without review. Review the code and teach the agent the proper way via CLAUDE.md, etc.
Your coding agent will inevitably make mistakes or break style guidelines. Say you're generating unit tests and this is your agent's output:
def test_concats_foo_bar(monkeypatch):
# Arrange
monkeypatch.setattr(MyStore, "get_foo", return_value="foo")
monkeypatch.setattr(MyStore, "get_bar", return_value="bar")
# Act
result = concat_foo_bar(MyStore())
# Assert
assert result == "foo bar"Claude, for example, likes to monkey-patch stuff in tests, but it breaks your guideline: "don't mock -- use production implementations with dummy data". A test without mocks would be more sound and useful:
def test_concats_foo_bar():
# Arrange
store = MyStore()
store.set_foo("foo")
store.set_bar("bar")
# Act
result = concat_foo_bar(store)
# Assert
assert result == "foo bar"And yet, the first test works fine. You might be tempted to accept it for the sake of speed. But if you don't correct your agent here, it will copy this error over and over, because it uses existing code as a reference. If you keep doing this, such uncorrected errors will pile up and multiply, and as a result the quality of your codebase will decline.
And it's not because you're using a coding agent: it's because you're using it lazily. You've given up thinking.
Don't just blindly accept LLM output. Instead, review it manually, find systemic errors, fix them, and have your agent commit these rules to some form of persistent context, be it CLAUDE.md, a skill, or memory.
* Avoid mocking. Prefer production implementations of a unit's dependencies with dummy data.As this knowledge accumulates, your collaboration with your coding agent will become much more productive. It will one-shot prompts that previously needed correction. It will comfortably handle a larger scope of work, because its code will require less review on your part.