File organization

From akillness/jeo-skills · View interactive version

File organization is an AI agent skill from the GitHub repository akillness/jeo-skills. Design or refactor project structure around the right boundary unit: feature, shared layer, route segment, or workspace package. Use when a repo feels scattered, a team needs naming/import conventions, or the user must choose between type-based, feature-based, framework-colocated, and workspace layo

How to use this skill

Skill file

File Organization

Use this skill when the main question is "what structural boundary should this codebase use, and how do we move toward it without turning a reorg into chaos?"

The job is not to dump a giant folder tree and pretend it fits every repo.

The job is to:

  1. identify the real organizing unit,
  2. separate feature/shared/framework/package boundaries,
  3. define naming and import rules that prevent drift,
  4. plan the migration safely,
  5. return a structure brief another engineer or agent can apply immediately.

Read references/boundary-decision-matrix.md before recommending a structure.

Read references/migration-checklist.md before moving files or renaming directories.

Read references/naming-and-import-rules.md when the problem includes barrel files, alias paths, or team conventions.

When to use this skill

When not to use this skill

Instructions

Step 1: Classify the structural pressure before drawing folders

Normalize the request into this intake first:

structure_intake:
  repo_shape: single-app | app-plus-api | monorepo | library-cli | content-site | unknown
  current_pattern: type-based | feature-based | route-colocated | package-workspace | mixed | unknown
  main_pressure:
    - scattered-feature-code
    - unclear-shared-boundaries
    - framework-routing-collision
    - premature-monorepo-split
    - monorepo-needed-now
    - naming-drift
    - import-chaos
    - migration-risk
    - onboarding-confusion
    - unknown
  change_scope: greenfield | incremental-refactor | major-reorg | audit-only
  primary_boundary_unit: feature | shared-layer | route-segment | package | unknown
  confidence: high | medium | low

If the user is vague, prefer the smallest obvious interpretation and state the assumption.

Step 2: Choose one primary organization mode

Pick exactly one primary mode for the current run:

  1. starter cleanup
  1. feature modularization
  1. framework colocation
  1. shared layer governance
  1. workspace split
  1. migration audit

Step 3: Choose the smallest boundary unit that solves the problem

Use these rules:

Step 4: Apply the decision ladder

Use feature modularization when
Use framework colocation when
Use shared layer governance when
Use workspace split when
Use migration audit when

Step 5: Keep structural boundaries honest

A good structure recommendation says what it does not own.

Examples:

Mixed requests are normal. Split them explicitly instead of forcing one folder strategy to solve everything.

Step 6: Set reusable naming and import guardrails

Any recommended structure should name these rules explicitly:

Bad smells:

Step 7: Plan the migration before changing files

Before moving anything, produce a change plan that covers:

  1. current hotspots and why they are painful
  2. target boundary model
  3. staged move order
  4. alias/import or barrel compatibility strategy
  5. test/build/docs verification steps
  6. rollback or partial-adoption safety

Prefer incremental refactors over one huge rename when the repo is active.

Step 8: Produce the file-organization brief

Return a concise artifact someone can act on immediately.

Preferred format:

# File Organization Brief

## Mode
- Primary mode:
- Why this mode fits:

## Boundary choice
- Primary organizing unit:
- What belongs in feature/shared/route/package boundaries:
- What stays out of scope:

## Recommended structure
- Top-level folders/packages:
- One example feature/package layout:
- Naming/import rules:

## Migration plan
1. First step
2. Second step
3. Verification step

## Handoffs
- Adjacent skills:
- Risks / follow-up work:

Step 9: Prefer clarity over template worship

When modernizing an existing structure:

Output format

Always return a file organization brief, repo structure recommendation, or migration audit.

Required qualities:

Examples

Example 1: Type-based starter tree is collapsing

Input

We have components, hooks, utils, and store, but every checkout change touches all four folders. How should we reorganize this React app?

Good output direction

Example 2: Next.js route folders are getting messy

Input

Our Next.js app router repo mixes route files, data helpers, and business logic all over app/. We need a clean structure that still respects framework conventions.

Good output direction

Example 3: Team wants to split into packages

Input

Should this repo become apps/ and packages/? We now have a web app, worker, and shared UI library.

Good output direction

Best practices

  1. Start from the pressure on the repo, not from a favorite architecture meme.
  2. Prefer the smallest boundary model that reduces change amplification.
  3. Treat shared code as a governed exception, not the default landing zone.
  4. Let framework conventions inform structure, but do not let them become accidental junk drawers.
  5. Split into packages only when dependencies, runtimes, or deployables truly require it.
  6. Name import and public-API rules early; they are part of the organization system.
  7. Use staged migrations and verification steps for live repos.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.