---
title: "Keep code small enough for an agent to · Agent Wranglers"
url: https://agentwranglers.se/playbook/ai-assisted-development/setting-up-the-project/agent-sized-modules
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep code small enough for an agent to read

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

- Level: Required
- Chapter: [Setting up the project](https://agentwranglers.se/playbook/ai-assisted-development/setting-up-the-project)
- Rule: Keep files and functions small and well named, so an agent can read the code it changes in one pass.
- How: Set limits and enforce them with the linter, such as 300 lines per file and 50 lines per function. Split anything over the limit. Group code by feature, so one task touches one folder. Agents copy nearby patterns, so clean code produces more clean code. See [code that agents can parse](https://agentwranglers.se/playbook/architecture/code-review/readable-for-agents).
- Check: The linter fails on any file or function over the limit, for example ESLint `max-lines` and `max-lines-per-function` or Pylint `max-module-lines`. Every exception is listed with a reason.

**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 ai development playbook: https://agentwranglers.se/playbook/ai-assisted-development/setting-up-the-project/agent-sized-modules`.

- Previous: [Write one instructions file for agents](https://agentwranglers.se/playbook/ai-assisted-development/setting-up-the-project/instructions-file)
- Next: [Keep the project runnable from a clean checkout](https://agentwranglers.se/playbook/ai-assisted-development/setting-up-the-project/runnable-from-clean-checkout)
- [Setting up the project](https://agentwranglers.se/playbook/ai-assisted-development/setting-up-the-project)
