coding-standards
Skill này làm gì
Skill này đặt ra các tiêu chuẩn viết code chung cho dự án TypeScript, JavaScript, React và Node.js, như đặt tên rõ ràng, giải pháp đơn giản và tránh lặp code. Dành cho lập trình viên muốn code nhất quán và dễ đọc.
Khi nào nên dùng
- ✓Khi bạn viết code TypeScript hoặc JavaScript mới và muốn nó rõ ràng, nhất quán.
- ✓Khi bạn rà soát code về tính dễ đọc, cách đặt tên và độ phức tạp không cần thiết.
- ✓Khi bạn muốn giữ một dự án React hoặc Node.js gọn gàng khi nó lớn dần.
Liên kết skill
https://github.com/WorldFlowAI/everything-claude-code/blob/main/skills/coding-standards/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy rà soát module TypeScript này về cách đặt tên, độ phức tạp và code lặp, rồi đề xuất các phiên bản rõ ràng hơn.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent kiểm tra code theo các quy tắc đơn giản, như tên mô tả, tránh thiết kế quá mức và tách logic dùng chung, rồi đề xuất các cải tiến dễ đọc.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Coding Standards & Best Practices
Universal coding standards applicable across all projects.
Code Quality Principles
1. Readability First
- Code is read more than written
- Clear variable and function names
- Self-documenting code preferred over comments
- Consistent formatting
2. KISS (Keep It Simple, Stupid)
- Simplest solution that works
- Avoid over-engineering
- No premature optimization
- Easy to understand > clever code
3. DRY (Don't Repeat Yourself)
- Extract common logic into functions
- Create reusable components
- Share utilities across modules
- Avoid copy-paste programming
4. YAGNI (You Aren't Gonna Need It)
- Don't build features before they're needed
- Avoid speculative generality
- Add complexity only when required
- Start simple, refactor when needed
TypeScript/JavaScript Standards
Variable Naming
// ✅ GOOD: Descriptive names
const marketSearchQuery = 'election'
const isUserAuthenticated = true
const totalRevenue = 1000
// ❌ BAD: Unclear names
const q = 'election'
const flag = true
const x = 1000
Function Naming
// ✅ GOOD: Verb-noun pattern
async function fetchMarketData(marketId: string) { }
function calculateSimilarity(a: number[], b: number[]) { }
function isValidEmail(email: string): boolean { }
// ❌ BAD: Unclear or noun-only
async function market(id: string) { }
function similarity(a, b) { }
function email(e) { }
Immutability Pattern (CRITICAL)
// ✅ ALWAYS use spread operator
const updatedUser = {
...user,
name: 'New Name'
}
const updatedArray = [...items, newItem]
// ❌ NEVER mutate directly
user.name = 'New Name' // BAD
items.push(newItem) // BAD
Error Handling
// ✅ GOOD: Comprehensive error handling
async function fetchData(url: string) {
try {
const response = await fetch(url)
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
}
return await response.json()
} catch (error) {
console.error('Fetch failed:', error)
throw new Error('Failed to fetch data')
}
}
// ❌ BAD: No error handling
async function fetchData(url) {
const response = await fetch(url)
return response.json()
}
Async/Await Best Practices
// ✅ GOOD: Parallel execution when possible
const [users, markets, stats] = await Promise.all([
fetchUsers(),
fetchMarkets(),
fetchStats()
])
// ❌ BAD: Sequential when unnecessary
const users = await fetchUsers()
const markets = await fetchMarkets()
const stats = await fetchStats()
Type Safety
// ✅ GOOD: Proper types
interface Market {
id: string
name: string
status: 'active' | 'resolved' | 'closed'
created_at: Date
}
function getMarket(id: string): Promise<Market> {
// Implementation
}
// ❌ BAD: Using 'any'
function getMarket(id: any): Promise<any> {
// Implementation
}
React Best Practices
Component Structure
// ✅ GOOD: Functional component with types
interface ButtonProps {
children: React.ReactNode
onClick: () => void
disabled?: boolean
variant?: 'primary' | 'secondary'
}
export function Button({
children,
onClick,
disabled = false,
variant = 'primary'
}: ButtonProps) {
return (
<button
onClick={onClick}
disabled={disabled}
className={`btn btn-${variant}`}
>
{children}
</button>
)
}
// ❌ BAD: No types, unclear structure
export function Button(props) {
return <button onClick={props.onClick}>{props.children}</button>
}
Custom Hooks
// ✅ GOOD: Reusable custom hook
export function useDebounce<T>(value: T, delay: number): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value)
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value)
}, delay)
return () => clearTimeout(handler)
}, [value, delay])
return debouncedValue
}
// Usage
const debouncedQuery = useDebounce(searchQuery, 500)
State Management
// ✅ GOOD: Proper state updates
const [count, setCount] = useState(0)
// Functional update for state based on previous state
setCount(prev => prev + 1)
// ❌ BAD: Direct state reference
setCount(count + 1) // Can be stale in async scenarios
Conditional Rendering
// ✅ GOOD: Clear conditional rendering
{isLoading && <Spinner />}
{error && <ErrorMessage error={error} />}
{data && <DataDisplay data={data} />}
//
Câu hỏi thường gặp
Nó có chạy formatter hoặc linter không?
Nó mô tả các nguyên tắc cần tuân theo, như định dạng nhất quán. Agent áp dụng chúng khi rà soát hoặc viết code.
Nó có bao quát Python hoặc Go không?
Không. Nó tập trung vào TypeScript, JavaScript, React và Node.js.
Nó có ưu tiên code khéo léo không?
Không. Nó ưu tiên code đơn giản, dễ đọc và tránh các tính năng suy đoán.
Chi tiết
Mô tả gốc của tác giả
Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.
Độ phổ biến
- Sao GitHub
- 5.8k
- Vị trí xếp hạng
- #14661
- Giấy phép
- —
- Cập nhật
- 23/1/2026
Bình luận
- …
Thêm skill từ kho mã này
continuous-learning
5.8kGiúp agent rà soát các phiên Claude Code đã xong và lưu lại mẫu hữu ích, như cách sửa lỗi và cách khắc phục tạm, thành skill để dùng sau.
frontend-patterns
5.8kGiúp agent của bạn dùng các mẫu React và Next.js đã kiểm chứng cho component, state, hiệu năng và code UI gọn gàng, kèm ví dụ rõ ràng.
tdd-workflow
5.8kDạy agent viết test trước cho tính năng mới, sửa lỗi và refactor, nhắm tới độ phủ 80 phần trăm trở lên ở các test unit, integration và end-to-end.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.