Keeping coding agents aligned with a large codebase

A coding agent rebuilt a search input for a settings redesign. The repository already had a shared search component with an extension point for the keyboard hint the new input needed. The agent had done useful work inside the feature, including consolidating repeated headers. It had missed code that lived outside the files it was changing.

I wanted a way to catch that before merging. I use a review skill that asks the agent to look for shared components and helpers elsewhere in the repository and show why they fit the change. The generalised version includes installation instructions and project notes. Read the drift-review skill.

Good work within a narrow scope

The agent made navigation read from a shared model, removed unused code and fixed a shared utility directly.

It also recreated a segmented control and a small label component that already existed in shared folders.

The redesign now had its own implementations of behaviours that the shared components also maintained. A later fix to the shared search input, for example, would leave the local copy untouched.

In a large repository, that search involves more than finding similar source. Shared components evolve while older implementations remain in use. Related features can live in separate directories. An agent needs to establish which existing pattern is appropriate, including whether the nearby example is still current.

Nearby code can be the wrong reference

I saw new components inherit older typography patterns from adjacent files while newer components elsewhere used the replacement. An agent copied a helper from a sibling file even though more callers used a shared version.

An instruction to follow existing patterns leaves that choice unresolved during a migration. Both generations are existing code. The reviewer needs to compare equivalent surfaces and check which implementation the repository is moving towards.

Shared components can also be difficult to reuse when they almost fit. A label component that always changes text to uppercase is unsuitable for case-sensitive values. A copy button without a disabled state may encourage a local implementation.

Those gaps need investigation before calling the result unnecessary duplication. Extending the shared component may cover the requirement without creating another implementation. A feature-specific component may also be correctly placed in its own directory. Moving it into a shared folder needs a reason beyond its resemblance to something else.

Making consistency a separate review

The review skill starts by reading the target and taking a fresh inventory of shared components and utilities. It then investigates likely duplicates and helpers that have gained consumers outside their original feature. It also checks older patterns on the surfaces being changed.

The fresh inventory matters because a remembered list becomes incomplete as the repository changes. The reviewer needs to inspect what exists now and read the relevant interfaces. A matching filename supplies a place to investigate; it does not establish that a replacement fits.

For each proposed replacement, I want evidence:

  • Where is the existing component or helper?
  • Which parts of its interface cover this use case?
  • Where is it actually used?
  • Would adopting it preserve the required behaviour?

The last question matters beyond appearance. A locally built action can omit behaviour included in a shared component, such as analytics events. Separate formatters can display the same value differently. Copies of request-handling code can recognise different error responses.

Tests can catch those differences when the expected behaviour is encoded. Passing functional checks alone gives little evidence that an agent found the relevant shared implementation.

The review also records where the change follows existing patterns well. This helps distinguish useful local code from a missed opportunity for reuse. Extracting every similar block would create abstractions with little justification.

The same agent can find what it missed

Some useful reviews came from the agent that had just written the code. Asked to inspect its implementation for drift, it found duplicated components and inconsistent patterns it had missed during development.

That suggests the task framing matters. During implementation, the agent works towards the feature and its acceptance criteria. A dedicated review asks it to compare the implementation with code outside that task. These observations concern my own workflow; they do not establish an inherent limitation of every model or coding agent.

The small evaluation used while creating the skill also limits what I can claim. When explicitly asked to look for drift, the model without the skill found most of the same issues. The comparison did not establish a substantial detection advantage.

The practical value was in recording a method I could repeat: inspect shared code afresh and support findings with evidence. It also preserved judgement calls about when to extend a component and when to leave code local.

Checking the review's evidence

The reviewer can make mistakes. In one review, a search matched a term in comments and the agent treated those matches as component usage. It recommended a change based on adoption that did not exist.

A claim about adoption needs actual call sites and inspection of representative uses. The same evidence standard needs to apply when the agent reviews its own work. Confidence in a report cannot substitute for checking the cited implementation.

For the settings redesign, the review could point to the shared search component and the extension point that supported the keyboard hint. That gave me a specific change to ask for. I now look for that level of evidence before acting on a drift finding. The agent should show a real caller, explain how the shared code meets the requirement and identify any behaviour that would change.