← ClaudeAtlas

clean-codelisted

Clean code principles adapted for TypeScript-first, functional development.
aiskillstore/marketplace · ★ 329 · Code & Development · score 79
Install: claude install-skill aiskillstore/marketplace
# Clean Code Skill for Node.js/TypeScript ## Overview Clean code principles adapted for TypeScript-first, functional development. ## DRY - Don't Repeat Yourself ### Principle Every piece of knowledge should have a single, unambiguous representation. ### Violations ```typescript // Bad: Duplicated validation logic const validateUserEmail = (email: string) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); const isValidEmail = (email: string) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); // Bad: Magic numbers everywhere if (password.length < 8) { ... } if (retries > 3) { ... } if (timeout > 30000) { ... } ``` ### Correct ```typescript // Good: Single source of truth const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; const validateEmail = (email: string): boolean => EMAIL_REGEX.test(email); // Good: Named constants const PASSWORD_MIN_LENGTH = 8; const MAX_RETRIES = 3; const REQUEST_TIMEOUT_MS = 30_000; if (password.length < PASSWORD_MIN_LENGTH) { ... } if (retries > MAX_RETRIES) { ... } if (timeout > REQUEST_TIMEOUT_MS) { ... } ``` ### Extract Shared Logic ```typescript // Before: Duplicated fetch logic const fetchUsers = async () => { const response = await fetch('/api/users'); if (!response.ok) throw new Error('Failed to fetch'); return response.json(); }; const fetchOrders = async () => { const response = await fetch('/api/orders'); if (!response.ok) throw new Error('Failed to fetch'); return response.json(); }; // After: Extracted common logic const fetchJs