Agent Wranglers

Structure Recommended

Group code by feature

Put the code for one feature together, such as orders/ or invoices/, instead of spreading it across folders named controllers/, models/ and services/.

How to do it

Give each feature folder its own types, rules, storage and tests. Share code between features only through each folder's public entry point. A change to one feature then touches one folder.

Example

Bad                          Good
src/controllers/Order.ts     src/orders/OrderController.ts
src/models/Order.ts          src/orders/Order.ts
src/services/Order.ts        src/orders/placeOrder.ts
src/tests/Order.test.ts      src/orders/placeOrder.test.ts

How to check

In review, a change to one feature touches at most one feature folder plus shared code. An import rule blocks imports of another feature's internal files.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/structure/group-by-feature.