structure-codebase

Design and audit source trees that expose architectural boundaries and enforce dependency direction.

Updated May 18, 2024
One-click install
npx skills add https://github.com/joshhornby/dotfiles --skill structure-codebase-joshhornby
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: structure-codebase
Source: https://github.com/joshhornby/dotfiles/tree/main/.claude/skills/structure-codebase
Command: npx skills add https://github.com/joshhornby/dotfiles --skill structure-codebase-joshhornby

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Codebases often grow into flat folders, unowned shared buckets, or ceremonial layers that hide real architectural boundaries. This Skill designs, audits, and migrates physical source and package structures so the tree truthfully reflects capabilities, features, and inside/outside boundaries, with mechanical enforcement of import direction. ## Core Features & Use Cases - Structure design and audit: Select the smallest honest shape for backends, BFFs, frontends, CLIs, small packages, and monorepos, with annotated target trees and placement rules. - Hexagonal and DDD placement: Decide when a ports-and-adapters boundary is earned, where ports, adapters, test interactors, and composition roots belong, and when bounded contexts are justified. - Enforcement and migration: Define dependency matrices, package roles, public exports, and staged migration sequences with validation gates. - Use Case: Ask it to review a monorepo where all code sits under a flat src/ with global utils and services folders; it will propose a capability-first tree, forbidden import directions, and a safe step-by-step migration plan. ## Quick Start Ask the agent to audit this repository's folder structure and propose an enforceable target source tree with dependency rules.

Frequently Asked Questions about structure-codebase

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a codebase by feature instead of technical layers?

Organize files by capability, feature, or use case so code that changes together lives together, and expose a small explicit public API per module. Avoid global buckets like controllers, services, or utils that scatter one behavior across the tree.

When should I use hexagonal architecture folder structure?

Use a visible hexagon only when the project explicitly adopts ports and adapters and the boundary has meaningful provider-free application policy, purposeful ports, test interactors, and import enforcement. Simple CRUD, scripts, and small packages should stay flat or feature-first.

How do I enforce import direction between packages in a monorepo?

Declare a role for each package, validate both source imports and package.json dependencies, and protect boundaries with explicit public exports. For deep workspaces, test recursive package discovery at the deepest target path before moving code.

Does domain-driven design require ports and adapters?

No. Bounded contexts define language and model authority while a hexagon defines a technology test wall, and each can exist without the other. Organize DDD projects by context and domain language without manufacturing adapters or port interfaces.

How should frontend folders differ from backend hexagonal structure?

Frontend structure follows route ownership, product-feature cohesion, UI reuse level, state and data ownership, and client/server runtime boundaries. Do not project backend hexagon, ports, or composition-root vocabulary onto client code unless the frontend explicitly earns that boundary.

What is the safe order for migrating an existing folder structure?

Record the decision, map current behavior, add characterization tests, prepare enforcement, decompose god files, invert leaked dependencies, then reparent packages one capability at a time. Never combine mass file moves with behavior changes in one step.