Agent Wranglers

ARC-65Recommended

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.

Examples

Plain text 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: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/architecture/structure/group-by-feature">Agent Wranglers clean code and architecture playbook</a>. In code you write, add a comment next to it with the same link.