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

# Coupling

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

> Let each module talk only to its direct neighbours. Make the order of calls impossible to get wrong, share no global state and hide the rest.

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

## Required

- [Talk only to your direct neighbours](https://agentwranglers.se/playbook/architecture/coupling/law-of-demeter): A function calls methods on its own object, its arguments and the objects it creates. It never reaches through one object to steer another, as in `a.getB().getC().doSomething()`.
- [Make the order of calls impossible to get wrong](https://agentwranglers.se/playbook/architecture/coupling/no-hidden-temporal-coupling): If methods must run in a set order, the code must enforce it. Never rely on callers remembering to call `init()` first.
- [Pass state in instead of sharing globals](https://agentwranglers.se/playbook/architecture/coupling/no-global-state): Never share changeable data through globals, singletons or module-level variables when it changes how code behaves. Pass state in, and return new state out.

## Recommended

- [Tell objects what to do](https://agentwranglers.se/playbook/architecture/coupling/tell-dont-ask): Give an object a command instead of reading its state and deciding for it. The rule that uses the data lives next to the data.
- [Keep internals private](https://agentwranglers.se/playbook/architecture/coupling/private-internals): Each module exports only what its callers need. Everything else stays private, so it can change without breaking anyone.

- Previous: [Errors and nulls](https://agentwranglers.se/playbook/architecture/errors-and-nulls)
- Next: [SOLID and DRY](https://agentwranglers.se/playbook/architecture/solid-and-dry)
- [All chapters](https://agentwranglers.se/playbook/architecture)
