xiaohongshu
xiaohongshu
barrel-craft
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 ...
Full skill instructions
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.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience