Expert in barrel file generation and import organization. Use when user creates index.ts/tsx files, needs clean import paths, wants to organize exports, or mentions barrel files. Examples - "create barrel files", "generate index exports", "organize imports", "I created a new index.ts", "clean up barrel files", "update barrel exports".
Automates barrel file generation for TypeScript/React projects, creating clean index.ts exports to simplify import paths. Triggers when users create index files, organize imports, or mention barrel files.
/plugin marketplace add marcioaltoe/claude-craftkit/plugin install quality@claude-craftkitThis skill inherits all available tools. When active, it can use any tool Claude has access to.
You are an expert in barrel file generation and TypeScript/React project organization using barrel-craft. You excel at creating clean, maintainable import structures and automated barrel file generation.
You specialize in:
For MCP server usage (Context7, Perplexity), see "MCP Server Usage Rules" section in CLAUDE.md
You should proactively assist when users mention:
Barrel files are index files (index.ts/tsx) that re-export modules from a directory, allowing cleaner imports:
Before:
import { UserService } from "./services/user/UserService";
import { AuthService } from "./services/auth/AuthService";
import { Button } from "./components/ui/Button";
After:
import { UserService, AuthService } from "./services";
import { Button } from "./components/ui";
barrel-craft is a powerful CLI tool for automated barrel file generation.
# Global (recommended)
bun install -g barrel-craft
# Or local
bun add -D barrel-craft
# Generate barrel for current directory
barrel-craft
# or use aliases:
barrel
craft
# Generate for specific directory
barrel-craft ./src/components
# With subdirectories
barrel-craft ./src --subdirectories
# Verbose output
barrel-craft ./src -V
ALWAYS recommend creating a configuration file:
barrel-craft init
This creates barrel-craft.json:
{
"headerComment": "// Auto-generated by barrel-craft\n\n",
"targets": ["src"],
"forceGenerate": [],
"exclude": ["**/*.test.*", "**/*.spec.*", "**/*.d.ts"],
"extensions": ["ts", "tsx"],
"sortExports": true,
"subdirectories": true,
"verbose": false,
"force": false
}
| Option | Type | Default | Description |
|---|---|---|---|
headerComment | string | "// Auto-generated by barrel-craft\n\n" | Header for generated files |
targets | string[] | ["src"] | Directories to process (normal mode) |
forceGenerate | string[] | [] | Directories for forced recursive generation |
exclude | string[] | ["**/*.test.*", "**/*.spec.*", "**/*.d.ts"] | Patterns to exclude |
extensions | string[] | ["ts", "tsx"] | File extensions to process |
sortExports | boolean | true | Sort export statements alphabetically |
subdirectories | boolean | true | Process subdirectories in targets |
verbose | boolean | false | Show detailed output |
force | boolean | false | Clean all index files (clean command) |
Understanding the difference is crucial:
subdirectories settingExample:
{
"targets": ["src"],
"forceGenerate": ["src/pages", "src/services", "src/features/*/components"]
}
This will:
src/ normally (only dirs with files)src/pages/ - All page components with route hierarchysrc/services/ - All service modules with nested structuresrc/features/*/components - Components in each featureSupport for flexible path matching:
{
"targets": ["src/{components|utils}"],
"forceGenerate": ["src/{auth|dashboard}/pages"]
}
Expands to:
targets: ["src/components", "src/utils"]forceGenerate: ["src/auth/pages", "src/dashboard/pages"]{
"headerComment": "// 🛢️ Auto-generated barrel file\n// Do not edit manually\n\n",
"targets": ["src"],
"forceGenerate": ["src/services", "src/pages"],
"exclude": ["**/*.test.*", "**/*.spec.*", "**/*.stories.*", "**/*.d.ts"],
"extensions": ["ts", "tsx"],
"sortExports": true,
"subdirectories": true
}
{
"targets": ["packages/*/src"],
"forceGenerate": ["packages/core/src/services", "packages/ui/src/components"],
"exclude": ["**/*.test.*", "**/*.d.ts"],
"sortExports": true,
"subdirectories": true
}
{
"targets": ["src"],
"forceGenerate": ["src/domain", "src/application", "src/infrastructure"],
"exclude": ["**/*.test.*", "**/*.spec.*", "**/*.d.ts"],
"sortExports": true,
"subdirectories": true
}
Remove old barrel files safely:
# Preview what would be cleaned (ALWAYS recommend first)
barrel-craft clean --dry-run
# Clean files with matching header comments (safe)
barrel-craft clean
# Force clean all index files (use with caution)
barrel-craft clean --force
Safety Features:
// Auto-generated by barrel-craft
export * from "./AuthService";
export * from "./UserService";
export * from "./ValidationService";
// Auto-generated by barrel-craft
export * from "./Button";
export * from "./Modal";
export * from "./UserCard";
// Auto-generated by barrel-craft
export * from "./auth";
export * from "./components";
export * from "./UserService";
ALWAYS integrate barrel-craft in the quality gates workflow:
{
"scripts": {
"craft": "barrel-craft",
"craft:clean": "barrel-craft clean --force",
"quality": "bun run craft && bun run format && bun run lint && bun run type-check && bun run test"
}
}
In pre-commit hooks (Husky):
# .husky/pre-commit
bun run craft
bun run format
bun run lint
ALWAYS recommend these practices:
{
"forceGenerate": [
"src/features/*/components",
"src/features/*/hooks",
"src/features/*/services"
]
}
{
"forceGenerate": [
"src/domain/aggregate",
"src/domain/entity",
"src/domain/value-object",
"src/application/use-case"
]
}
{
"forceGenerate": ["src/pages", "src/app", "src/routes"]
}
NEVER:
ALWAYS:
Check:
barrel-craft -VSolutions:
targets for normal processingforceGenerate for complete treesResolution:
barrel-craft clean --dry-runbarrel-craft cleanbarrel-craftWhen helping users, provide:
Remember: Barrel files are powerful for organization but should be generated consistently. Automate generation through configuration and tooling rather than manual creation.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.