Reviewing AGENTS.md Is Just as Important as Reviewing Code
DEV Community

Reviewing AGENTS.md Is Just as Important as Reviewing Code

Before diving into building more visual components, I spent some time refining the internal functionality of the frontend for Simple Orders Tracker. The application has two main custom hooks that manage data fetching, normalize API errors, transform response data, and update state:

  • orders -> useOrders
  • reports -> useReports

The Architectural Issue

While reviewing the code, I realized that useReports was fetching all "orders" within the selected date range and performing the reporting calculations on the frontend to derive metrics such as total sales, total orders, and outstanding balances.

That design worked, but it wasn't the right architectural choice. Those computations belong on the server, with the frontend simply requesting the aggregated results and rendering them, as goes with the concept of thin client / fat server.

Keeping business logic and heavier calculations on the backend:

  • Reduces unnecessary data transfer
  • Simplifies the client's browser load
  • Keeps the frontend quick and focused on presentation

Root Cause

The root cause turned out to be a small instruction in my AGENTS.md file that unintentionally encouraged frontend-side calculations. It was a good reminder that even a single generic instruction may gradually steer AI-generated code away from the architecture you intended.

One lesson I learnt is to review my AGENTS.md files carefully before letting AI agents loose on a codebase. Small instructions can have surprisingly large architectural consequences.

Explore the changes here: https://github.com/Rinidh/simple-orders-tracker/commit/8638e12d628687edd8382a7311cc8793df0f1b1e

Comments

No comments yet. Start the discussion.