{"slug": "agents-and-directory-structure", "title": "Agents and Directory Structure", "summary": "Pyn restructured its codebase from a Rails-style MVC layout into an app-based, domain-centric directory structure to support AI agents shipping 200 pull requests on a normal day, according to the company's account of the change. Pyn says the layout gives agents clear lanes to work in, reduces merge conflicts because agents in different apps don't touch the same files, adds an index.md to each package for clickable navigation, and provides template apps agents can copy. Pyn advises teams adapting a codebase for agents to start with directory structure.", "body_md": "If you are loop engineering, your repository just got a lot busier. If engineers (and others!) are shipping 100+ PRs a day that inevitably leads to an air traffic control problem. This presents in many ways, but merge conflicts, a growing PR backlog, and aging PRs are some of the clearest signals.\n\nI’m going to talk about one the crudest and most effective first solutions: Your directory structure.\n\nYour directory structure used to be to help software engineers navigate your codebase. Whilst that isn’t out the window, you now need to accommodate a whole new set of participants.\n\nAt [Pyn](https://www.pyn.ai) we structure our codebase by \"app\", and I think that structure matters more now that agents are doing the work. An app is a discrete domain (a single integration, say) with everything needed to realize it.\n\nOur old layout more philosophically aligned to classic Rails MVC, with models in one tree, controllers in another and views in a third. This type of separation helps when the tech and concerns are all co-located. The simplest example is frontend belongs with frontend.\n\nHowever, to complete one feature - you needed to navigate multiple trees. Flipping that was [one of my first big changes](https://jonathannen.com/building-towards-100-prs-a-day/#restructuring-the-codebase) for AI.\n\nThe app “domain-centric” structure pays off in four ways.\n\n(1) **Clear lanes for agents**. I can tell an agent \"work on this directory\" and what it needs is there. Otherwise it wanders the codebase and copies whatever it finds<sup>[\\[1\\]](#fn1)</sup>.\n\n(2) **Fewer merge conflicts, and so faster merges**. Agents working in different apps aren't touching the same files. When PRs collide you're [back to working sequentially](https://jonathannen.com/infinite-monkeys/), however many agents you have running.\n\n200 PRs is [a normal day](https://jonathannen.com/my-current-ai-workflow-revisited/) now, with a [hard cap on open PRs](https://jonathannen.com/the-importance-of-backpressure/), so a PR stuck on a conflict is taking up one of those slots. Shared code is where work can still collide. Keep it discrete and handle it the right way and it's a non-issue.\n\n(3) **Navigation that follows the file structure**. Each package has an `index.md`, which gives clickable navigation through the codebase<sup>[\\[2\\]](#fn2)</sup>.\n\n(4) **Gold templates to copy**. I get one app into good shape, point an agent at it and ask for \"another one of those\". You do end up with some duplication, which is fine within limits. Refactoring is easy with AI, so make it a separate loop.\n\nIf you're adapting a codebase for agents, I'd start here.", "url": "https://wpnews.pro/news/agents-and-directory-structure", "canonical_source": "https://jonathannen.com/agents-and-directory-structure/", "published_at": "2026-11-26 00:00:00+00:00", "updated_at": "2026-11-27 01:13:27.197540+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Pyn"], "also_reported_by": [], "takeaway": "Restructure the codebase into discrete app domains with an index.md per package so agents work within one directory, cutting merge conflicts that force sequential PR handling.", "recommendation": {"advice": "Scope each agent to a single domain-centric app directory with its own index.md, and keep shared code minimal so parallel agent PRs don't collide on the same files.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/agents-and-directory-structure", "markdown": "https://wpnews.pro/news/agents-and-directory-structure.md", "text": "https://wpnews.pro/news/agents-and-directory-structure.txt", "jsonld": "https://wpnews.pro/news/agents-and-directory-structure.jsonld"}}