kid-sid/claude-spellbook/coding-standards

Claude Code and agent skill by kid-sid/claude-spellbook

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when reviewing code for quality, naming a class or function, choosing a design pattern, refactoring a code smell, or establishing coding conventions for a new project.

Install

npx vskill@latest install kid-sid/claude-spellbook/coding-standards

SKILL.md

Coding Standards

A comprehensive reference for writing clean, consistent, maintainable code across Python, TypeScript, and Go.

When to Activate

  • Reviewing a pull request for code quality
  • Refactoring legacy or unclear code
  • Naming a class, function, variable, or file
  • Deciding which design pattern to apply
  • Setting up coding standards for a new project
  • Identifying code smells and their root causes

Naming Conventions

ConstructPythonTypeScriptGo
Variablessnake_casecamelCasecamelCase
Functions / methodssnake_casecamelCasePascalCase (exported), camelCase (unexported)
Classes / typesPascalCasePascalCasePascalCase
ConstantsUPPER_SNAKE_CASEUPPER_SNAKE_CASE or camelCasePascalCase (exported), camelCase (unexported)
InterfacesN/AIFoo (avoid) or just Foo (preferred)Foo (no I prefix)
Filessnake_case.pykebab-case.ts or camelCase.tssnake_case.go
Test filestest_*.py*.test.ts / *.spec.ts*_test.go
Naming Heuristics
  • Be specific: user_registration_date not date; payment_amount_cents not amount
  • Avoid meaningless suffixes: UserManager, DataHelper, Utils — what does it manage/help/do?
  • Boolean names: use is_, has_, can_, should_ prefix: is_active, has_permission
  • Functions: verb phrases — calculate_tax(), send_email(), validate_schema()
  • Avoid abbreviations except universally understood ones (id, url, http, db)
  • Length proportional to scope: loop variable i is fine; module-level variable needs a full name
python
# BAD
def proc(d, f):
temp = d * f
return temp
# GOOD
def calculate_discounted_price(base_price: float, discount_factor: float) -> float:
return base_price * discount_factor

SOLID Principles

S — Single Responsibility

A class should have one reason to change.

typescript
// BAD — UserService does everything
class UserService {
createUser(data: CreateUserDto) { /* ... */ }
sendWelcomeEmail(user: User) { /* ... */ } // email is a separate concern
generateReport(users: User[]) { /* ... */ } // reporting is a separate concern
}
// GOOD — separated concerns
class UserService { createUser(data: CreateUserDto) { /* ... */ } }
class EmailService { sendWelcomeEmail(user: User) { /* ... */ } }
class UserReportService { generateReport(users: User[]) { /* ... */ } }
O — Open/Closed

Open for extension, closed for modification.

typescript
// BAD — must modify to add new discount type
function calculateDiscount(type: string, price: number): number {
if (type === 'student') return price * 0.8;
if (type === 'senior') return price * 0.75;
// must add else-if here for each new type
}
// GOOD — extend by adding a new class
interface DiscountStrategy { apply(price: number): number; }
class StudentDiscount implements DiscountStrategy { apply(p: number) { return p * 0.8; } }
class SeniorDiscount implements DiscountStrategy { apply(p: number) { return p * 0.75; } }
L — Liskov Substitution

Subtypes must be substitutable for their base type.

typescript
// BAD — Square overrides setWidth/setHeight inconsistently, breaking Rectangle contract
class Rectangle {
constructor(protected width: number, protected height: number) {}
setWidth(w: number) { this.width = w; }
setHeight(h: number) { this.height = h; }
area() { return this.width * this.height; }
}
class Square extends Rectangle {
setWidth(w: number) { this.width = this.height = w; } // violates LSP
setHeight(h: number) { this.width = this.height = h; } // caller expects independent dims
}
// GOOD — model separately; share via interface if needed
interface Shape { area(): number; }
class Rectangle implements Shape {
constructor(private w: number, private h: number) {}
area() { return this.w * this.h; }
}
class Square implements Shape {
constructor(private side: number) {}
area() { return this.side * this.side; }
}
I — Interface Segregation

Many specific interfaces are better than one general interface.

typescript
// BAD — not all workers can eat or sleep
interface Worker { work(): void; eat(): void; sleep(): void; }
// GOOD — split by capability
interface Workable { work(): void; }
interface Feedable { eat(): void; }
interface Restable { sleep(): void; }
class HumanWorker implements Workable, Feedable, Restable {
work() { /* ... */ }
eat() { /* ... */ }
sleep() { /* ... */ }
}
class RobotWorker implements Workable {
work() { /* ... */ }
}
D — Dependency Inversion

Depend on abstractions, not concretions.

typescript
// BAD — tightly coupled to PostgresDB
class UserRepository {
private db = new PostgresDB(); // concrete dependency
find(id: string) { return this.db.query(/* ... */); }
}
// GOOD — depends on interface, injected
interface Database { query(sql: string, params: unknown[]): Promise<unknown[]>; }
class UserRepository {
constructor(private db: Database) {}
find(id: string) { return this.db.query('SELECT * FROM users WHERE id = $1', [id]); }
}

Design Patterns Quick Reference

PatternCategoryOne-line use caseWhen to avoid
FactoryCreationalCreate objects without specifying concrete classWhen you only have one type
Abstract FactoryCreationalCreate families of related objectsOverkill for simple factories
SingletonCreationalOne shared instance (config, logger)When it becomes global mutable state
BuilderCreationalStep-by-step construction of complex objectsSimple objects with few fields
StrategyBehavioralSwap algorithms at runtimeWhen you only have one algorithm
ObserverBehavioralNotify dependents when state changesWhen observers outlive the subject
CommandBehavioralEncapsulate a request as an object (undo/redo)Simple one-off calls
Template MethodBehavioralDefine skeleton, let subclasses fill stepsDeep inheritance hierarchies
RepositoryStructuralIsolate data access from domain logicWhen ORM already provides this
AdapterStructuralWrap incompatible interfaceWhen both interfaces are yours (just fix one)
DecoratorStructuralAdd behavior to objects dynamicallyWhen subclassing is simpler
FacadeStructuralSimplified interface to complex subsystemOver-used to hide bad design
Full Code Examples
Factory
typescript
interface Logger { log(msg: string): void; }
class ConsoleLogger implements Logger { log(msg: string) { console.log(msg); } }
class FileLogger implements Logger { log(msg: string) { fs.appendFileSync('app.log', msg); } }
function createLogger(type: 'console' | 'file'): Logger {
if (type === 'console') return new ConsoleLogger();
return new FileLogger();
}
// Usage
const logger = createLogger('console');
logger.log('Server started');
Strategy
typescript
interface SortStrategy { sort(data: number[]): number[]; }
class QuickSort implements SortStrategy { sort(d: number[]) { /* quicksort impl */ return d; } }
class MergeSort implements SortStrategy { sort(d: number[]) { /* mergesort impl */ return d; } }
class DataSorter {
constructor(private strategy: SortStrategy) {}
sort(data: number[]) { return this.strategy.sort(data); }
setStrategy(strategy: SortStrategy) { this.strategy = strategy; }
}
// Swap strategy at runtime
const sorter = new DataSorter(new QuickSort());
sorter.setStrategy(new MergeSort());
sorter.sort([5, 3, 1, 4, 2]);
Observer
typescript
type Listener<T> = (event: T) => void;
class EventEmitter<T> {
private listeners: Listener<T>[] = [];
subscribe(fn: Listener<T>) { this.listeners.push(fn); }
unsubscribe(fn: Listener<T>) { this.listeners = this.listeners.filter(l => l !== fn); }
emit(event: T) { this.listeners.forEach(fn => fn(event)); }
}
const orderEvents = new EventEmitter<{ orderId: string; status: string }>();
orderEvents.subscribe(({ orderId }) => sendConfirmationEmail(orderId));
orderEvents.subscribe(({ orderId }) => updateInventory(orderId));
orderEvents.emit({ orderId: '123', status: 'paid' });
Repository
typescript
interface UserRepository {
findById(id: string): Promise<User | null>;
save(user: User): Promise<void>;
delete(id: string): Promise<void>;
}
class PostgresUserRepository implements UserRepository {
constructor(private db: Database) {}
async findById(id: string): Promise<User | null> {
const [row] = await this.db.query('SELECT * FROM users WHERE id = $1', [id]);
return row ? User.fromRow(row) : null;
}
async save(user: User): Promise<void> {
await this.db.query(
'INSERT INTO users (id, email) VALUES ($1, $2) ON CONFLICT (id) DO UPDATE SET email = $2',
[user.id, user.email]
);
}
async delete(id: string): Promise<void> {
await this.db.query('DELETE FROM users WHERE id = $1', [id]);
}
}

Code Smells Catalog

SmellSymptomRefactoring
Long MethodFunction > 30 linesExtract Method
Long Class / God ClassClass > 300 lines or too many responsibilitiesExtract Class
Data ClumpSame 3+ params appear together everywhereIntroduce Parameter Object
Primitive ObsessionUsing strings/ints for domain concepts (money, email)Introduce Value Object
Feature EnvyMethod uses data from another class more than its ownMove Method
Shotgun SurgeryOne change requires edits in many classesMove Method/Field, consolidate
Divergent ChangeClass changes for multiple unrelated reasonsExtract Class
Duplicate CodeSame logic in multiple placesExtract Method/Function
Magic NumbersUnexplained literals in codeReplace with Named Constant
Switch/Match on TypeRepeated instanceof or type checksReplace with Polymorphism
Smell Examples
typescript
// BAD — Primitive Obsession: money is a raw number, email is a raw string
function chargeUser(userId: string, amount: number, email: string) { /* ... */ }
// GOOD — Value Objects carry their own validation and behaviour
class Money {
constructor(readonly cents: number, readonly currency: 'USD' | 'EUR') {
if (cents < 0) throw new Error('Money cannot be negative');
}
}
class Email {
constructor(readonly value: string) {
if (!value.includes('@')) throw new Error('Invalid email');
}
}
function chargeUser(userId: string, amount: Money, email: Email) { /* ... */ }
typescript
// BAD — Magic Numbers
if (user.age >= 65) applyDiscount(price * 0.25);
// GOOD — Named Constants
const SENIOR_AGE_THRESHOLD = 65;
const SENIOR_DISCOUNT_RATE = 0.25;
if (user.age >= SENIOR_AGE_THRESHOLD) applyDiscount(price * SENIOR_DISCOUNT_RATE);

Language-Specific Idioms

Python
python
# Dataclass instead of verbose __init__
from dataclasses import dataclass, field
@dataclass
class Order:
id: str
items: list[str] = field(default_factory=list)
total: float = 0.0
# Context manager for resource management
with open('file.txt') as f:
data = f.read() # file auto-closed, even on exception
# Generator for memory-efficient processing
def process_large_file(path: str):
with open(path) as f:
for line in f: # reads line-by-line, not all into memory
yield parse(line)
# Walrus operator for readability
if (match := pattern.search(text)) is not None:
print(match.group(0))
# BAD — unpacking ignored with throwaway names
result = get_user_and_role()
user = result[0]
role = result[1]
# GOOD — structured unpacking
user, role = get_user_and_role()
TypeScript
typescript
// Discriminated union — exhaustive type narrowing
type Result<T> =
| { success: true; data: T }
| { success: false; error: string };

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
186
Repository forks
15
7-day trend score
26

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/kid-sid/claude-spellbook/coding-standards/badge)](https://verified-skill.com/skills/kid-sid/claude-spellbook/coding-standards)

Something wrong with this skill or its page? Tell us.