| name | clean-code-scaffold |
| description | Scaffold a clean project structure organized by concern. Use this skill when the user asks to set up a new project, organize a messy codebase, create a project structure, restructure files, or says things like "set up the project," "organize this code," "create a clean folder structure," or "scaffold this project." Guides users through creating a well-organized codebase following Clean Code Pattern 7 (Clean Project Structure). |
Clean Code Scaffold Skill
Use this skill to create or reorganize a project into a clean structure following the Clean Code Handbook's Pattern 7: Clean Project Structure.
Scaffold Workflow
- Ask the user what kind of project they're building (web app, API, CLI, library, etc.)
- Ask what language/framework they're using
- Propose a structure based on the patterns below
- Create the directories and any starter files after user confirms
Structure Principles
- Organize by concern, not by file type
- Separate source from tests -- mirror the source structure in a tests directory
- Keep related code together -- a feature's components, services, and utils live near each other
- Flat over nested -- avoid directories more than 3 levels deep unless the project demands it
Recommended Structures by Project Type
Web Application (React / Next.js / Vue)
project/
āāā src/
ā āāā components/ # Reusable UI components
ā āāā pages/ # Route-level components
ā āāā services/ # API calls, business logic
ā āāā utils/ # Pure helper functions
ā āāā hooks/ # Custom hooks (React) or composables (Vue)
ā āāā types/ # Type definitions
ā āāā constants/ # Named constants and config
āāā tests/
ā āāā components/
ā āāā services/
ā āāā utils/
āāā public/ # Static assets
āāā package.json
API / Backend (Express / FastAPI / Django)
project/
āāā src/
ā āāā routes/ # Route definitions
ā āāā controllers/ # Request handlers
ā āāā services/ # Business logic
ā āāā models/ # Data models / schemas
ā āāā middleware/ # Request middleware
ā āāā utils/ # Helper functions
ā āāā config/ # Configuration and constants
āāā tests/
ā āāā routes/
ā āāā services/
ā āāā utils/
āāā package.json
CLI Tool
project/
āāā src/
ā āāā commands/ # Individual CLI commands
ā āāā services/ # Core logic
ā āāā utils/ # Helpers (formatting, validation)
ā āāā config/ # Defaults and constants
āāā tests/
ā āāā commands/
ā āāā services/
āāā package.json
Library / Package
project/
āāā src/
ā āāā core/ # Main library logic
ā āāā utils/ # Internal helpers
ā āāā types/ # Public type definitions
āāā tests/
ā āāā core/
ā āāā utils/
āāā examples/ # Usage examples
āāā package.json
What Goes Where
| Directory | Contains | Example |
|---|
components/ | Reusable UI pieces | Button.tsx, Modal.tsx |
services/ | Business logic, API calls | userService.ts, emailService.ts |
utils/ | Pure functions, small helpers | formatDate.ts, validateEmail.ts |
models/ | Data shapes, schemas | User.ts, Order.ts |
config/ | Constants, environment | constants.ts, database.ts |
tests/ | Mirrors src/ structure | tests/services/userService.test.ts |
Anti-Patterns to Avoid
- Everything in one folder --
src/ with 50 files and no subdirectories
- Organizing by file type --
src/interfaces/, src/classes/, src/functions/
- Deeply nested --
src/modules/users/services/internal/helpers/
- Tests next to source -- mixing
.test.ts files alongside source files (unless framework convention)
- Catch-all
helpers/ or misc/ -- if you can't name it, it needs to be split up