Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Standardized guidelines for defining and enforcing boundaries between features to prevent tight coupling. Use when scaling applications, preventing circular dependencies, and maintaining module independence.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 112% | 0% |
| case-07 | ✗→✓ | ▲ Improved | -2% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 41% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 59% | 0% |
| case-23 | ✗→✓ | ▲ Improved | 48% | 0% |
Rule 1: No Direct Cross-Feature Imports
typescript// ❌ BAD: Direct import from another feature import { ProductCard } from '../../products/components/ProductCard'; // ✅ GOOD: Import from public API import { ProductCard } from '@features/products';
Rule 2: Public API Pattern
typescript// features/products/index.ts (Public API) // Only export what other features need export { ProductCard } from './components/ProductCard'; export { useProducts } from './hooks/useProducts'; export type { Product } from './types'; // DON'T export internal helpers // ❌ export { internal Helper } from './utils';
Rule 3: Shared Kernel
src/
├── features/
│ ├── products/
│ ├── cart/
│ └── checkout/
├── shared/ # Shared Kernel
│ ├── types/
│ │ └── common.types.ts
│ ├── components/
│ │ └── Button.tsx
│ └── utils/
└── core/ # Framework codejavascript// .eslintrc.js module.exports = { rules: { 'import/no-restricted-paths': ['error', { zones: [ { target: './src/features/products', from: './src/features/cart', message: 'Products cannot import from Cart' }, { target: './src/features/*', from: './src/features/*', except: ['./index.ts'], message: 'Must use public API (index.ts)' } ] }] } };
1. Events (Decoupled)
typescript// features/cart/index.ts export const cartEvents = { itemAdded: (productId: string) => { window.dispatchEvent(new CustomEvent('cart:item-added', { detail: { productId } })); } }; // features/analytics/index.ts window.addEventListener('cart:item-added', (e) => { trackEvent('cart_add', e.detail); });
2. Shared State (Zustand)
typescript// shared/store/cartStore.ts export const useCartStore = create<CartState>((set) => ({ items: [], addItem: (item) => set((state) => ({ items: [...state.items, item] })) })); // Any feature can use the store import { useCartStore } from '@shared/store/cartStore';
3. Context/Props (Direct)
typescript// Only when features have parent-child relationship <CheckoutFeature cartItems={cartItems} />
┌─────────────┐
│ Shared │
│ Kernel │
└──────┬──────┘
│
┌───┴───┬───────┬────────┐
│ │ │ │
┌──▼───┐ ┌─▼────┐ ┌▼─────┐ ┌▼──────┐
│ Auth │ │ Cart │ │ Shop │ │ Admin │
└──────┘ └──────┘ └──────┘ └───────┘
↑ ↑ ↑ ↑
└───────┴───────┴────────┘
No cycles!Other measured skills in the registry, with their headline benchmark lift.