Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides clean architecture design with strict 200-line file limits. Use when starting new features, refactoring large files, or planning module structure. Enforces modular design and real testing.
.claude/skills/majiayu000-elegant-architecture/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 33% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 101% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 79% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 76% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 58% | 0% |
markdownBefore writing any code: - List all features/functionalities needed - Estimate code volume for each module - Identify shared components - Map dependencies between modules
markdownWhen estimated lines > 200: - Convert file to folder with index - Split by sub-functionality - Extract shared utilities Example transformation:
# Before (user.ts - 400+ lines)
user.ts
# After (user/ folder)
user/
├── index.ts # Public exports
├── types.ts # Interfaces, types
├── validation.ts # Input validation
├── repository.ts # Data access
└── service.ts # Business logictypescript// Define contracts before implementation interface UserService { create(input: CreateUserInput): Promise<User>; findById(id: string): Promise<User | null>; update(id: string, input: UpdateUserInput): Promise<User>; delete(id: string): Promise<void>; } interface UserRepository { save(user: User): Promise<User>; findById(id: string): Promise<User | null>; findByEmail(email: string): Promise<User | null>; delete(id: string): Promise<void>; }
markdownFor each module: 1. Create type definitions 2. Implement core logic 3. Add error handling 4. Write tests 5. Verify line count < 200
typescript// ❌ Avoid: Mock everything const mockRepo = jest.fn(); const service = new UserService(mockRepo); // ✅ Prefer: Real implementations const testDb = createTestDatabase(); const repo = new UserRepository(testDb); const service = new UserService(repo); // Test actual behavior const user = await service.create({ email: 'test@example.com' }); const found = await service.findById(user.id); expect(found).toEqual(user);
src/
├── modules/
│ ├── auth/
│ │ ├── index.ts
│ │ ├── types.ts
│ │ ├── service.ts
│ │ └── middleware.ts
│ ├── user/
│ │ ├── index.ts
│ │ ├── types.ts
│ │ ├── service.ts
│ │ └── repository.ts
│ └── order/
│ ├── index.ts
│ ├── types.ts
│ ├── service.ts
│ └── repository.ts
├── shared/
│ ├── database/
│ ├── errors/
│ └── utils/
└── index.tstypescript// Decouple components via constructor injection class OrderService { constructor( private readonly orderRepo: OrderRepository, private readonly userService: UserService, private readonly paymentGateway: PaymentGateway ) {} async createOrder(userId: string, items: OrderItem[]): Promise<Order> { const user = await this.userService.findById(userId); if (!user) throw new NotFoundError('User', userId); const order = Order.create(user, items); await this.paymentGateway.charge(user, order.total); return this.orderRepo.save(order); } } // Wire up in composition root const orderService = new OrderService( new PostgresOrderRepository(db), new UserService(userRepo), new StripePaymentGateway(stripeClient) );
typescript// Complex object creation class NotificationFactory { create(type: NotificationType, data: NotificationData): Notification { switch (type) { case 'email': return new EmailNotification(data, this.emailClient); case 'sms': return new SmsNotification(data, this.smsClient); case 'push': return new PushNotification(data, this.pushClient); default: throw new Error(`Unknown notification type: ${type}`); } } }
typescript// Replaceable algorithms interface PricingStrategy { calculate(order: Order): Money; } class StandardPricing implements PricingStrategy { calculate(order: Order): Money { return order.items.reduce((sum, item) => sum.add(item.price), Money.zero()); } } class DiscountPricing implements PricingStrategy { constructor(private readonly discount: Percentage) {} calculate(order: Order): Money { const standard = new StandardPricing().calculate(order); return standard.subtract(standard.multiply(this.discount)); } } class OrderProcessor { constructor(private pricing: PricingStrategy) {} setPricing(strategy: PricingStrategy) { this.pricing = strategy; } process(order: Order): ProcessedOrder { const total = this.pricing.calculate(order); return { ...order, total }; } }
| Indicator | Action | |-----------|--------| | File > 200 lines | Split immediately | | File > 150 lines | Plan split | | 3+ distinct responsibilities | Split by responsibility | | Shared types growing | Extract to types.ts | | Utility functions accumulating | Extract to utils.ts |
markdown1. Identify logical boundaries 2. Create folder with same name as file 3. Move related code to separate files 4. Create index.ts for public exports 5. Update imports in dependent files
module/
├── index.ts # Public API exports
├── types.ts # Interfaces, types, enums
├── constants.ts # Configuration, magic values
├── utils.ts # Helper functions
├── service.ts # Business logic
├── repository.ts # Data access
├── validation.ts # Input validation
└── errors.ts # Custom errorsmarkdown## Pre-Implementation - [ ] Requirements analyzed - [ ] Code volume estimated - [ ] File structure designed - [ ] Interfaces defined - [ ] Dependencies mapped ## Implementation - [ ] Each file < 200 lines - [ ] Single responsibility per module - [ ] Dependencies injected - [ ] Error handling complete - [ ] No hardcoded values ## Testing - [ ] Real implementations used - [ ] No mocks for core logic - [ ] Edge cases covered - [ ] Integration tests exist ## Review - [ ] Architecture documented - [ ] Public APIs clear - [ ] No circular dependencies - [ ] Easy to extend
markdown❌ God files (500+ lines doing everything) ❌ Mocking everything in tests ❌ Coding before planning ❌ Tight coupling between modules ❌ Hardcoded configuration ❌ Circular dependencies ❌ Unclear module boundaries
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 21,548 | 16,793 | -22% | 1 | 1 | 0% | 4,012 | 5,350 | +33% | 0 | 0 | — |
case-02 | fail→fail | 22,079 | 22,670 | +3% | 1 | 1 | 0% | 4,043 | 6,244 | +54% | 0 | 0 | — |
case-03 | fail→pass | 15,817 | 16,379 | +4% | 1 | 1 | 0% | 2,536 | 5,089 | +101% | 0 | 0 | — |
case-04 | pass→fail | 19,492 | 18,924 | -3% | 1 | 1 | 0% | 3,349 | 5,386 | +61% | 0 | 0 | — |
case-05 | pass→pass | 21,026 | 21,036 | +0% | 1 | 1 | 0% | 3,870 | 5,967 | +54% | 0 | 0 | — |
case-06 | pass→pass | 16,684 | 14,333 | -14% | 1 | 1 | 0% | 3,128 | 4,565 | +46% | 0 | 0 | — |
case-07 | fail→pass | 12,228 | 8,259 | -32% | 1 | 1 | 0% | 1,758 | 3,146 | +79% | 0 | 0 | — |
case-08 | fail→pass | 13,405 | 12,108 | -10% | 1 | 1 | 0% | 2,155 | 3,785 | +76% | 0 | 0 | — |
case-09 | fail→pass | 15,258 | 11,229 | -26% | 1 | 1 | 0% | 2,311 | 3,643 | +58% | 0 | 0 | — |
case-10 | pass→pass | 11,741 | 8,995 | -23% | 1 | 1 | 0% | 2,025 | 3,376 | +67% | 0 | 0 | — |
case-11 | pass→pass | 12,938 | 9,029 | -30% | 1 | 1 | 0% | 2,057 | 3,374 | +64% | 0 | 0 | — |
case-12 | pass→pass | 9,325 | 10,750 | +15% | 1 | 1 | 0% | 1,701 | 3,846 | +126% | 0 | 0 | — |
case-13 | fail→pass | 12,608 | 14,003 | +11% | 1 | 1 | 0% | 2,201 | 4,454 | +102% | 0 | 0 | — |
case-14 | fail→pass | 10,631 | 5,363 | -50% | 1 | 1 | 0% | 1,723 | 2,771 | +61% | 0 | 0 | — |
case-15 | fail→pass | 12,309 | 4,500 | -63% | 1 | 1 | 0% | 2,214 | 2,599 | +17% | 0 | 0 | — |
case-16 | fail→pass | 24,891 | 9,325 | -63% | 1 | 1 | 0% | 2,158 | 3,233 | +50% | 0 | 0 | — |
case-17 | fail→pass | 16,641 | 13,563 | -18% | 1 | 1 | 0% | 2,585 | 4,068 | +57% | 0 | 0 | — |
case-18 | pass→pass | 13,764 | 8,389 | -39% | 1 | 1 | 0% | 2,387 | 3,309 | +39% | 0 | 0 | — |
case-19 | fail→pass | 14,749 | 13,121 | -11% | 1 | 1 | 0% | 2,375 | 4,143 | +74% | 0 | 0 | — |
case-20 | fail→pass | 9,096 | 7,226 | -21% | 1 | 1 | 0% | 1,381 | 2,919 | +111% | 0 | 0 | — |
case-21 | pass→pass | 18,819 | 13,662 | -27% | 1 | 1 | 0% | 2,817 | 4,291 | +52% | 0 | 0 | — |
case-22 | pass→pass | 15,267 | 13,465 | -12% | 1 | 1 | 0% | 2,678 | 4,737 | +77% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +50 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.