Xpersona
C

Coding Standards

CLAWHUB · Unverified

Universal coding standards for TypeScript, JavaScript, React, and Node.js. Principles: readability first, KISS, DRY, YAGNI. Covers naming, type safety, error... Skill: Coding Standards Owner: djc00p Summary: Universal coding standards for TypeScript, JavaScript, React, and Node.js. Principles: readability first, KISS, DRY, YAGNI. Covers naming, type safety, error... Tags: latest:1.0.0 Version history: v1.0.0 | 2026-04-06T01:47:22.905Z | user Initial release. Universal TypeScript/JavaScript/React coding standards. Adapted from everything-claude-code by @affaan-m (MIT) Archive

62
Rank
84
Safety
1.3k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.3K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17akx17qd32yxnr1065qq0kdd83h2c3:coding-standards
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-djc00p-coding-standards/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

21,476 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: coding-standards
description: "Universal coding standards for TypeScript, JavaScript, React, and Node.js. Principles: readability first, KISS, DRY, YAGNI. Covers naming, type safety, error handling, async patterns, React hooks, API design, file organization, performance, testing, code smells. Trigger phrases: coding standards, best practices, code review, quality standards, naming conventions."
metadata: {"clawdbot":{"emoji":"📏","requires":{"bins":[],"env":[]},"os":["linux","darwin","win32"]}}
---

# Coding Standards & Best Practices

Universal standards for maintainable, scalable TypeScript/JavaScript code.

## Quick Start

1. **Readability First** — Clear names, self-documenting code
2. **Type Safety** — Avoid `any`, use explicit interfaces
3. **Error Handling** — Try-catch with specific error types
4. **Immutability** — Use spread operator, never direct mutation
5. **Test Structure** — AAA pattern (Arrange, Act, Assert)

## Core Principles

**KISS** — Simplest solution that works. No premature optimization.

**DRY** — Extract common logic into reusable functions and components.

**YAGNI** — Don't build before it's needed. Start simple, refactor when needed.

**Readability** — Code is read 10x more than written. Clarity over cleverness.

## Naming Standards

### Variables

```typescript
// Good: Descriptive, type-hinted by name
const marketSearchQuery = 'election'
const isUserAuthenticated = true
const totalRevenue = 1000

// Bad: Single-letter, unclear
const q = 'election'
const flag = true
const x = 1000
```

### Functions

```typescript
// Good: Verb-noun pattern
async function fetchMarketData(id: 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) { }
```

## References

- `references/typescript.md` — type safety, immutability, async patterns
- `references/react.md` — component structure, hooks, state management
- `references/api-design.md` — REST conventions, validation, error responses
- `references/file-org.md` — project structure, file naming
- `references/testing.md` — test patterns, AAA structure, test naming
- `references/code-smells.md` — anti-patterns, long functions, deep nesting, magic numbers

---

**Adapted from everything-claude-code by @affaan-m (MIT)**

_meta.json

{
  "ownerId": "kn75k4jwpn9qgy3pk38e93gkt982zqmg",
  "slug": "coding-standards",
  "version": "1.0.0",
  "publishedAt": 1775440042905
}

references/api-design.md

# API Design Standards

## REST Conventions

```bash
GET    /api/markets              # List all
GET    /api/markets/:id          # Get one
POST   /api/markets              # Create
PUT    /api/markets/:id          # Replace
PATCH  /api/markets/:id          # Update
DELETE /api/markets/:id          # Delete

# Query parameters for filtering
GET /api/markets?status=active&limit=10&offset=0
```

## Response Format

```typescript
interface ApiResponse<T> {
  success: boolean
  data?: T
  error?: string
  meta?: {
    total: number
    page: number
    limit: number
  }
}

// Success
return NextResponse.json({
  success: true,
  data: markets,
  meta: { total: 100, page: 1, limit: 10 }
})

// Error
return NextResponse.json({
  success: false,
  error: 'Invalid request'
}, { status: 400 })
```

## Input Validation

```typescript
import { z } from 'zod'

const CreateMarketSchema = z.object({
  name: z.string().min(1).max(200),
  description: z.string().min(1).max(2000),
  endDate: z.string().datetime(),
  categories: z.array(z.string()).min(1)
})

export async function POST(request: Request) {
  const body = await request.json()

  try {
    const validated = CreateMarketSchema.parse(body)
    // Proceed with validated data
  } catch (error) {
    if (error instanceof z.ZodError) {
      return NextResponse.json({
        success: false,
        error: 'Validation failed',
        details: error.errors
      }, { status: 400 })
    }
  }
}
```

## Error Responses

```typescript
class ApiError extends Error {
  constructor(
    public statusCode: number,
    public message: string
  ) {
    super(message)
  }
}

export function handleError(error: unknown): Response {
  if (error instanceof ApiError) {
    return NextResponse.json({
      success: false,
      error: error.message
    }, { status: error.statusCode })
  }

  if (error instanceof z.ZodError) {
    return NextResponse.json({
      success: false,
      error: 'Validation failed',
      details: error.errors
    }, { status: 400 })
  }

  console.error('Unexpected error:', error)

  return NextResponse.json({
    success: false,
    error: 'Internal server error'
  }, { status: 500 })
}
```

references/code-smells.md

# Code Smell Detection

## Long Functions

```typescript
// Bad: Function > 50 lines
function processMarketData() {
  // 100 lines of validation, transformation, saving...
}

// Good: Break into smaller functions
function processMarketData() {
  const validated = validateData()
  const transformed = transformData(validated)
  return saveData(transformed)
}
```

## Deep Nesting

```typescript
// Bad: 5+ levels of nesting
if (user) {
  if (user.isAdmin) {
    if (market) {
      if (market.isActive) {
        if (hasPermission) {
          // Do something
        }
      }
    }
  }
}

// Good: Use early returns
if (!user) return
if (!user.isAdmin) return
if (!market) return
if (!market.isActive) return
if (!hasPermission) return

// Do something
```

## Magic Numbers

```typescript
// Bad: Unexplained numbers
if (retryCount > 3) { }
setTimeout(callback, 500)
const fee = price * 0.15

// Good: Named constants
const MAX_RETRIES = 3
const DEBOUNCE_DELAY_MS = 500
const PROCESSING_FEE_RATE = 0.15

if (retryCount > MAX_RETRIES) { }
setTimeout(callback, DEBOUNCE_DELAY_MS)
const fee = price * PROCESSING_FEE_RATE
```

## Unused Code

```typescript
// Bad: Dead code commented out
function calculateTotal(items: Item[]) {
  // const subtotal = items.reduce((sum, item) => sum + item.price, 0)
  // const tax = subtotal * 0.08
  // return subtotal + tax
  return 0
}

// Good: Delete it, git history has it if needed
function calculateTotal(items: Item[]) {
  const subtotal = items.reduce((sum, item) => sum + item.price, 0)
  const tax = subtotal * TAX_RATE
  return subtotal + tax
}
```

## Boolean Parameter Trap

```typescript
// Bad: Unclear what true/false means
function processData(data, true, false) { }
processData(data, true, false)  // What does this do?

// Good: Use explicit object or separate functions
function processData(data, options: {
  includeArchived: boolean
  sortDesc: boolean
}) { }

processData(data, { includeArchived: true, sortDesc: false })
```

## Too Many Parameters

```typescript
// Bad: Hard to remember parameter order
function createUser(
  name: string,
  email: string,
  age: number,
  isAdmin: boolean,
  isActive: boolean,
  lastLogin: Date,
  preferences: object
) { }

// Good: Use object for related parameters
interface CreateUserInput {
  name: string
  email: string
  age: number
  isAdmin?: boolean
  isActive?: boolean
  lastLogin?: Date
  preferences?: object
}

function createUser(input: CreateUserInput) { }
```

## Inconsistent Naming

```typescript
// Bad: Inconsistent patterns
function getUsers() { }        // fetch
function fetchMarkets() { }    // get
function listPositions() { }   // get/fetch

// Good: Consistent patterns
function getUsers() { }
function getMarkets() { }
function getPositions() { }

// Or for async operations:
async function fetchUsers() { }
async function fetchMarkets() { }
async function fetchPositions() { }
```

## Tight Coupling

```typescript
// Bad: Hard-coded dependencies
function processOrder(o

references/file-org.md

# File Organization & Naming

## Project Structure

```bash
src/
├── app/               # Next.js App Router
│   ├── api/           # API routes
│   ├── markets/       # Market pages
│   └── (auth)/        # Auth pages (route groups)
├── components/        # React components
│   ├── ui/            # Generic UI components
│   ├── forms/         # Form components
│   └── layouts/       # Layout components
├── hooks/             # Custom React hooks
├── lib/               # Utilities and configs
│   ├── api/           # API clients
│   ├── utils/         # Helper functions
│   └── constants/     # Constants
├── types/             # TypeScript types
└── styles/            # Global styles
```

## File Naming Conventions

```bash
components/Button.tsx         # PascalCase for components
hooks/useAuth.ts              # camelCase with 'use' prefix
lib/formatDate.ts             # camelCase for utilities
types/market.types.ts         # camelCase with .types suffix
```

## Organizing Imports

```typescript
// 1. External dependencies
import React, { useState } from 'react'
import { z } from 'zod'

// 2. Relative imports (lib, utils, config)
import { API_BASE_URL } from '@/lib/constants'
import { formatDate } from '@/lib/utils'

// 3. Components and types
import { Button } from '@/components/Button'
import type { Market } from '@/types/market.types'
```

## Collocating Related Files

Keep related files together:

```bash
components/
├── MarketCard/
│   ├── MarketCard.tsx
│   ├── MarketCard.test.tsx
│   ├── useMarketCard.ts
│   └── MarketCard.types.ts

lib/
├── api/
│   ├── markets.ts       # Market API client
│   ├── users.ts         # User API client
│   └── __tests__/       # API tests
```

## Constants Organization

```typescript
// lib/constants.ts
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000'

export const MARKET_STATUSES = ['active', 'resolved', 'closed'] as const

export const PAGINATE = {
  DEFAULT_LIMIT: 10,
  MAX_LIMIT: 100
}

export const TIMINGS = {
  DEBOUNCE_MS: 500,
  REQUEST_TIMEOUT_MS: 10000
}
```

## Avoid These Patterns

```typescript
// Bad: Generic 'utils' folder with unrelated code
utils/
├── parseDate.ts
├── api.ts
├── math.ts
├── validation.ts
└── random.ts

// Good: Organized by domain
lib/
├── date/
│   └── parseDate.ts
├── api/
│   └── client.ts
├── math/
│   └── calculate.ts
└── validation/
    └── schema.ts
```

Sponsored

Ads related to Coding Standards and adjacent AI workflows.