fractal-file-structuring

Organizes TypeScript and JavaScript files using fractal tree structuring rules.

1.6k|122|Updated Jul 15, 2019
One-click install
npx skills add https://github.com/hashintel/hash --skill fractal-file-structuring
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fractal-file-structuring
Source: https://github.com/hashintel/hash/tree/main/.agents/skills/fractal-file-structuring
Command: npx skills add https://github.com/hashintel/hash --skill fractal-file-structuring

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Deciding where to create, move, or split TypeScript and JavaScript files creates cognitive overhead and inconsistent codebases. This Skill applies a deterministic fractal tree file-structuring methodology so every file has an obvious, predictable location.

Core Features & Use Cases

  • Fractal Tree Rules: Enforces kebab-case naming, bans index files, treats each file as a named mini-library, and splits outgrown files into private same-named subtrees.
  • Shared Resource Placement: Places shared helpers, hooks, and components in the nearest applicable shared/ folder based on current consumers, not speculative reuse.
  • Import Boundaries: Keeps private subtrees private, mandates relative imports within a workspace, and co-locates unit tests next to the files they cover.
  • Use Case: When a React component file grows too large, split its private panels and helpers into a same-named folder while keeping the root file as the public API boundary.

Quick Start

Ask the AI to decide where a new TypeScript file should go or to reorganize an oversized file using the fractal file-structuring rules.

Frequently Asked Questions about fractal-file-structuring

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

FAQPage Schema
How do I organize TypeScript files and folders in a large codebase?

Use a fractal tree structure: name files in kebab-case, treat each file as a mini-library with named exports, and split large files into same-named folders holding private implementation files. Place shared code in the nearest shared folder covering all current consumers.

How should I split a large React component file?

Create a same-named folder next to the component file and move private pieces such as sub-components and helpers into it. Only the root file imports from its subtree, keeping it as the public API boundary while the folder holds the implementation.

Should I use index.ts files for folder imports?

No. This approach forbids index.ts, index.tsx, index.js, and index.jsx files. Prefer explicit file entry points with meaningful names, and if a subtree needs a public entry point, name that file after the concept it exposes.

Where should shared helper functions live in a project?

Place shared helpers in the nearest shared folder that covers all current consumers, as deep in the tree as possible. Do not move code to a high-level shared folder based on speculative future reuse; move it later if usage changes.

Where should unit tests be placed relative to source files?

Co-locate unit tests next to the file they cover, such as foo.test.ts beside foo.ts. Tests for private extracted files sit next to those files, though testing through the public mini-library is preferred when coverage is sufficient.

When should I avoid creating utils or components folders?

Avoid broad components, hooks, utils, types, or services folders unless absolutely necessary. If they exist, they must only be imported from by files named components.ts, hooks.ts, and so on, preserving the mini-library boundary pattern.