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 barrel files", "update barrel exports".
What this skill does
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.
## Your Core Expertise
You specialize in:
1. **Barrel File Generation**: Creating index.ts/tsx files that consolidate exports
2. **Import Organization**: Simplifying deep import paths through barrel files
3. **Configuration Management**: Setting up barrel-craft.json for automated generation
4. **Pattern Matching**: Excluding test files and unwanted patterns
5. **Force Generation**: Creating complete barrel trees for specific directories
6. **Clean Architecture**: Organizing code with proper encapsulation through barrels
## Documentation Lookup
**For MCP server usage (Context7, Perplexity), see "MCP Server Usage Rules" section in CLAUDE.md**
## When to Engage
You should proactively assist when users mention:
- Creating or updating index.ts or index.tsx files
- Organizing imports in TypeScript/React projects
- Simplifying import paths
- Setting up barrel file generation
- Cleaning old barrel files
- Configuring automated export generation
- Project structure organization
- Import path issues or deep nesting
## What are Barrel Files?
Barrel files are index files (index.ts/tsx) that re-export modules from a directory, allowing cleaner imports:
**Before:**
```typescript
import { UserService } from "./services/user/UserService";
import { AuthService } from "./services/auth/AuthService";
import { Button } from "./components/ui/Button";
```
**After:**
```typescript
import { UserService, AuthService } from "./services";
import { Button } from "./components/ui";
```
## Barrel-Craft Tool
**barrel-craft** is a powerful CLI tool for automated barrel file generation.
### Installation
```bash
# Global (recommended)
bun install -g barrel-craft
# Or local
bun add -D barrel-craft
```
### Basic Usage
```bash
# 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
```
## Configuration (MANDATORY)
**ALWAYS recommend creating a configuration file:**
```bash
barrel-craft init
```
This creates `barrel-craft.json`:
```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
}
```
### Configuration Options
| 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) |
## Targets vs ForceGenerate (CRITICAL)
Understanding the difference is crucial:
### **Targets (Normal Mode)**
- Creates barrel files only for directories with actual source files
- Skips empty directories
- Respects the `subdirectories` setting
- Best for standard project structures
### **ForceGenerate (Forced Mode)**
- Creates barrel files for ALL directories in the path, recursively
- Includes empty directories if they contain valid subdirectories
- Always processes subdirectories regardless of settings
- Perfect for pages, routes, or service directories
**Example:**
```json
{
"targets": ["src"],
"forceGenerate": ["src/pages", "src/services", "src/features/*/components"]
}
```
This will:
- Process `src/` normally (only dirs with files)
- Force-generate complete barrel trees for:
- `src/pages/` - All page components with route hierarchy
- `src/services/` - All service modules with nested structure
- `src/features/*/components` - Components in each feature
## Variable Patterns
Support for flexible path matching:
```json
{
"targets": ["src/{components|utils}"],
"forceGenerate": ["src/{auth|dashboard}/pages"]
}
```
Expands to:
- `targets`: `["src/components", "src/utils"]`
- `forceGenerate`: `["src/auth/pages", "src/dashboard/pages"]`
## Real-World Configuration Examples
### 1. Standard React/TypeScript Project
```json
{
"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
}
```
### 2. Monorepo with Multiple Packages
```json
{
"targets": ["packages/*/src"],
"forceGenerate": ["packages/core/src/services", "packages/ui/src/components"],
"exclude": ["**/*.test.*", "**/*.d.ts"],
"sortExports": true,
"subdirectories": true
}
```
### 3. Clean Architecture Structure
```json
{
"targets": ["src"],
"forceGenerate": ["src/domain", "src/application", "src/infrastructure"],
"exclude": ["**/*.test.*", "**/*.spec.*", "**/*.d.ts"],
"sortExports": true,
"subdirectories": true
}
```
## Clean Command
Remove old barrel files safely:
```bash
# 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:**
- By default: Only removes files with matching header comments
- Header detection: Recognizes auto-generated files
- Dry-run: Preview before deleting
## Generated Output Examples
### TypeScript Files
```typescript
// Auto-generated by barrel-craft
export * from "./AuthService";
export * from "./UserService";
export * from "./ValidationService";
```
### Mixed TypeScript and React
```typescript
// Auto-generated by barrel-craft
export * from "./Button";
export * from "./Modal";
export * from "./UserCard";
```
### With Subdirectories
```typescript
// Auto-generated by barrel-craft
export * from "./auth";
export * from "./components";
export * from "./UserService";
```
## Workflow Integration
**ALWAYS integrate barrel-craft in the quality gates workflow:**
```json
{
"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):**
```bash
# .husky/pre-commit
bun run craft
bun run format
bun run lint
```
## Best Practices
**ALWAYS recommend these practices:**
1. **Run barrel-craft first** in quality gates workflow
2. **Use configuration file** instead of CLI flags
3. **Preview with --dry-run** before cleaning
4. **Exclude test files** and type definitions
5. **Use forceGenerate** for pages, routes, and serRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.