---
title: "Structure · Agent Wranglers"
url: https://agentwranglers.se/playbook/architecture/structure
updated: 2026-10-20
licence: "All rights reserved"
---

# Structure

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

> Arrange code so dependencies point one way, folders follow features, files are easy to find, and no module depends on itself through a loop.

**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`.

## Required

- [Point dependencies inward](https://agentwranglers.se/playbook/architecture/structure/layers-point-inward): Business rules never import the web framework, the database or other outside services. Outer layers depend on inner ones, never the reverse.
- [Allow no dependency cycles](https://agentwranglers.se/playbook/architecture/structure/no-dependency-cycles): No module may depend on itself through a chain of imports. Cycles make code impossible to test, load or change on its own.
- [Format all code with one tool](https://agentwranglers.se/playbook/architecture/structure/one-formatter): Format every file with one automatic formatter, with its settings in the repository. Nobody formats by hand, and reviews never discuss layout.

## Recommended

- [Group code by feature](https://agentwranglers.se/playbook/architecture/structure/group-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/`.
- [Name files after what they hold](https://agentwranglers.se/playbook/architecture/structure/consistent-file-names): Use one naming style for files and folders, and name each file after its main export.

- Previous: [Dead code](https://agentwranglers.se/playbook/architecture/dead-code)
- [All chapters](https://agentwranglers.se/playbook/architecture)
