structure-codebase

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

723|93|Updated Nov 14, 2021
One-click install
npx skills add https://github.com/citypaul/.dotfiles --skill structure-codebase
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: structure-codebase
Source: https://github.com/citypaul/.dotfiles/tree/main/claude/.claude/skills/structure-codebase
Command: npx skills add https://github.com/citypaul/.dotfiles --skill structure-codebase

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 architecture layers that hide real boundaries. This Skill designs, audits, and migrates physical source and package structures so the tree truthfully reflects capabilities, ownership, and dependency rules.

Core Features & Use Cases

  • Structure Design and Audit: Produces annotated target trees with placement rules, allowed and forbidden dependency directions, and proportionate automated enforcement for backends, frontends, BFFs, CLIs, and monorepos.
  • Hexagonal and DDD Placement: Decides when a ports-and-adapters hexagon or bounded context is genuinely earned, and locates ports, adapters, composition roots, and test interactors correctly.
  • Safe Migration Planning: Provides staged migration sequences with characterization tests, dependency inversion, package reparenting, and validation gates.
  • Use Case: Ask it to review a monorepo where all code sits under a flat src folder; it will propose a capability-first tree with enforced package boundaries and a step-by-step migration plan.

Quick Start

Use the structure-codebase skill to analyze this repository 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 organize a codebase by feature instead of technical layers?

Group files by capability, feature, or use case so code that changes together stays 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 in a backend project?

Use a visible hexagon only when the project explicitly adopts ports and adapters and has meaningful application policy that must run without real external systems. Simple CRUD, provider wrappers, and small packages should use honest shallow or feature-first structures instead.

Does domain-driven design require ports and adapters?

No, bounded contexts and hexagonal architecture are independent axes. DDD contexts define language and model authority, while a hexagon defines a technology test wall; a project can use either one without the other.

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

Validate both source imports and package.json dependencies using restricted imports, architecture tests, explicit public exports, and workspace discovery checks. For large workspaces, derive rules from package roles or a small registry rather than hand-maintained allowlists.

How should frontend folder structure differ from backend structure?

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

What is the safest way to migrate an existing folder structure?

Separate semantic changes from mechanical moves: record the decision, protect behavior with characterization tests, prepare enforcement, decompose god files, invert leaked dependencies, then reparent packages one capability at a time. Never combine mass moves with behavior changes in one step.