name: file-structure-optimization
description: Use for designing and maintaining repository file structure for clarity, modularity, discoverability, and low-duplication across app and documentation surfaces.
File Structure Optimization
Quick Index (Action-Routed)
Read First (All Actions)
MissionUse This Skill WhenScope BoundaryCore Principles
Action Modules (Read As Needed)
- Structural assessment:
Structure AuditSmell Detection
- Refactoring strategy:
Normalization RulesMigration Safety Rules
- Long-term hygiene:
Ownership and BoundariesAcceptance Checklist
Output
Deliverable FormatAnti-Patterns
Mission
Keep repository layout predictable, modular, and easy to navigate while minimizing duplication and stale artifacts.
Use This Skill When
- adding major features introducing new directories/files
- repo navigation or discoverability has become difficult
- duplicate or near-duplicate files are accumulating
- refactors require moving modules, docs, or scripts
- monorepo boundaries are unclear or leaking responsibilities
Scope Boundary
This skill governs filesystem information architecture and structural hygiene.
Use Doc Maintenance and File Maintenance for:
- content-level documentation correctness and lifecycle maintenance
Use Order of Operations for:
- dependency-safe execution order for moves/renames
Core Principles
- organize by stable domain boundaries, not temporary implementation details
- one canonical home per concern
- explicit boundaries between app code, tooling, tests, docs, and generated artifacts
- minimize path depth for high-frequency files
- prevent duplicated truth sources
Structure Audit
Evaluate current structure for:
- discoverability of core app entrypoints
- cohesion of modules inside each directory
- coupling/leakage across domains
- duplicate docs/scripts/config fragments
- dead or orphaned files
Smell Detection
Flag these smells:
- multiple directories claiming same ownership domain
- files named with vague terms (
misc, temp, new2, copy-final) - deeply nested directories with single-child chains
- duplicated docs differing by small stale edits
- generated files mixed with hand-edited source without clear separation
Normalization Rules
- define top-level directory purposes explicitly
- separate source, tests, docs, tooling, and build artifacts
- keep naming conventions consistent across sibling paths
- co-locate files that change together
- centralize shared utilities instead of cloning copies
Migration Safety Rules
- batch moves by domain and keep PR scope legible
- update imports, references, and docs in same change
- preserve history with rename/move-aware operations where possible
- validate commands, tests, and CI paths after moves
- capture temporary compatibility shims only when necessary and time-bound
Ownership and Boundaries
- define directory ownership or steward role for critical areas
- maintain clear public/internal module boundaries
- document canonical paths for runbooks and policy artifacts
- treat structure drift as maintenance debt with explicit remediation
Acceptance Checklist
- each top-level directory has a clear purpose
- duplicate/stale artifacts are removed or consolidated
- references/imports/docs updated to new paths
- structure supports fast onboarding and maintenance
- no orphaned files remain from migration
When applying this skill, provide:
- structure audit findings
- proposed/implemented directory map
- files moved/merged/removed summary
- validation results for references and tooling
- residual cleanup backlog
Source Reference
Primary references:
- Apple modular code organization guidance:
- https://developer.apple.com/documentation/xcode/organizing-your-code-with-local-packages
- Google engineering consistency/style guidance:
- https://google.github.io/styleguide/
- MIT software construction modularity and abstraction principles:
- https://ocw.mit.edu/courses/6-005-software-construction-spring-2016/
Anti-Patterns
- organizing primarily by framework internals over domain purpose
- preserving duplicate files "just in case" without ownership
- mixing generated and source artifacts without boundaries
- moving files without synchronized reference/doc updates
- deep nesting that hides high-traffic files