barrel-craft

Generate barrel files to consolidate exports in TypeScript/React projects.

14|1|Updated Oct 23, 2025
One-click install
npx skills add https://github.com/marcioaltoe/claude-craftkit --skill barrel-craft
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: barrel-craft
Source: https://github.com/marcioaltoe/claude-craftkit/tree/main/plugins/quality/skills/barrel-craft
Command: npx skills add https://github.com/marcioaltoe/claude-craftkit --skill barrel-craft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates the creation and maintenance of barrel files (index.ts/tsx), which consolidate exports from a directory. This simplifies import paths, reduces boilerplate, and keeps project structures clean and organized.

Core Features & Use Cases

  • Automated Barrel Generation: Creates index.ts/tsx files for specified directories, re-exporting modules.
  • Configurable Generation: Uses barrel-craft.json to define targets, exclusions, and force-generation for complex structures (e.g., pages, services).
  • Clean Import Paths: Transforms deep imports like from "./services/user/UserService" to from "./services".
  • Use Case: "Configure barrel-craft.json to automatically generate barrel files for all src/features/*/components and src/services directories, excluding test files."

Quick Start

Initialize barrel-craft for your project and generate barrel files for the src directory, including subdirectories.

Frequently Asked Questions about barrel-craft

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

FAQPage Schema
How do I simplify import paths in my TypeScript project?

Barrel files consolidate exports from a directory into a single index.ts/tsx file, letting you import from `./services` instead of `./services/user/UserService`. This reduces import boilerplate and keeps your project structure clean.

What is a barrel file and when do I need one?

A barrel file is an index.ts/tsx that re-exports all modules from a directory. Use barrels to organize large codebases, simplify imports, and maintain a clear public API for each directory without exposing internal structure.

Can I automatically generate barrel files for my React project?

Yes. Barrel-craft generates index.ts/tsx files automatically using a barrel-craft.json configuration that defines target directories, exclusions (like test files), and behavior across subdirectories, keeping barrels in sync as your code changes.

How do I configure barrel generation for specific directories?

Create a barrel-craft.json file in your project root specifying targets (e.g., `src/features/*/components`, `src/services`), exclusions (tests, d.ts files), extensions, and subdirectory processing to generate barrels deterministically across your structure.

Does barrel file generation work with TypeScript and React?

Yes. Barrel-craft generates index.ts/tsx files that work with both TypeScript and React projects, supporting nested directories, selective exclusions, and configurable export sorting to organize imports across features and services.

What happens if my barrel file structure changes?

Barrel-craft enforces your barrel-craft.json configuration, regenerating index.ts/tsx files deterministically. You can enable forced generation and header comments to ensure barrels stay consistent even as modules are added, removed, or reorganized.