Communitygithub.com

codierungsstandards

Basisübergreifende Codierungskonventionen für Benennung, Lesbarkeit, Unveränderlichkeit und Codequalitätsprüfung.

Was ist codierungsstandards?

Dieser Skill definiert grundlegende Codierungsstandards, die projektübergreifend angewendet werden. Er dient als gemeinsame Basis für Lesbarkeit, KISS, DRY und YAGNI. Entwickler können ihn beim Start neuer Projekte, bei Code-Reviews oder beim Refactoring einsetzen. Der Skill umfasst Richtlinien für TypeScript/JavaScript, React, API-Design, Dateiorganisation, Kommentare, Performance und Testen. Er arbeitet plattformunabhängig und ergänzt spezifischere Skills wie `frontend-patterns` oder `backend-patterns`.

Funktioniert mit~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/coding-standards

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Codierungsstandards & Best Practices

Basis-Codierungskonventionen, die projektübergreifend anwendbar sind.

Dieser Skill ist die gemeinsame Basis, nicht das detaillierte Framework-Handbuch.

  • Verwende frontend-patterns für React, State, Formulare, Rendering und UI-Architektur.
  • Verwende backend-patterns oder api-design für Repository-/Service-Schichten, Endpunkt-Design, Validierung und serverspezifische Belange.
  • Verwende rules/common/coding-style.md, wenn du die kürzeste, wiederverwendbare Regel-Ebene anstelle eines vollständigen Skill-Durchlaufs benötigst.

Wann dieser Skill aktiviert werden sollte

  • Ein neues Projekt oder Modul beginnen
  • Code auf Qualität und Wartbarkeit überprüfen
  • Vorhandenen Code umgestalten, um Konventionen zu folgen
  • Benennung, Formatierung oder strukturelle Konsistenz durchsetzen
  • Lint-, Formatierungs- oder Typprüfungsregeln einrichten
  • Neue Mitwirkende in Codierungskonventionen einweisen

Umfangsgrenzen

Aktiviere diesen Skill für:

  • beschreibende Benennung
  • Unveränderlichkeit als Standard
  • Lesbarkeit, KISS, DRY und YAGNI-Durchsetzung
  • Fehlerbehandlungserwartungen und Code-Geruchsprüfung

Verwende diesen Skill nicht als primäre Quelle für:

  • React-Komposition, Hooks oder Rendering-Muster
  • Backend-Architektur, API-Design oder Datenbankschichten
  • domänenspezifische Framework-Anleitungen, wenn ein engerer ECC-Skill bereits existiert

Grundsätze der Codequalität

1. Lesbarkeit zuerst

  • Code wird öfter gelesen als geschrieben
  • Klare Variablen- und Funktionsnamen
  • Selbstdokumentierender Code bevorzugt gegenüber Kommentaren
  • Einheitliche Formatierung

2. KISS (Halte es einfach, dumm)

  • Einfachste Lösung, die funktioniert
  • Über-Engineering vermeiden
  • Keine vorzeitige Optimierung
  • Leicht verständlich > kluger Code

3. DRY (Wiederhole dich nicht)

  • Gemeinsame Logik in Funktionen extrahieren
  • Wiederverwendbare Komponenten erstellen
  • Hilfsfunktionen über Module hinweg teilen
  • Copy-Paste-Programmierung vermeiden

4. YAGNI (Du wirst es nicht brauchen)

  • Baue keine Funktionen, bevor sie benötigt werden
  • Vermeide spekulative Allgemeinheit
  • Füge Komplexität nur hinzu, wenn erforderlich
  • Fang einfach an, gestalte um, wenn nötig

TypeScript/JavaScript-Standards

Variablenbenennung

// BESTANDEN: GUT: Beschreibende Namen
const marketSearchQuery = 'election'
const isUserAuthenticated = true
const totalRevenue = 1000

// FEHLGESCHLAGEN: SCHLECHT: Unklare Namen
const q = 'election'
const flag = true
const x = 1000

Funktionsbenennung

// BESTANDEN: GUT: Verb-Nomen-Muster
async function fetchMarketData(marketId: string) { }
function calculateSimilarity(a: number[], b: number[]) { }
function isValidEmail(email: string): boolean { }

// FEHLGESCHLAGEN: SCHLECHT: Unklar oder nur Nomen
async function market(id: string) { }
function similarity(a, b) { }
function email(e) { }

Unveränderlichkeitsmuster (KRITISCH)

// BESTANDEN: IMMER Spread-Operator verwenden
const updatedUser = {
  ...user,
  name: 'Neuer Name'
}

const updatedArray = [...items, newItem]

// FEHLGESCHLAGEN: NIEMALS direkt mutieren
user.name = 'Neuer Name'  // SCHLECHT
items.push(newItem)     // SCHLECHT

Fehlerbehandlung

// BESTANDEN: GUT: Umfassende Fehlerbehandlung
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('Abruf fehlgeschlagen:', error)
    throw new Error('Fehler beim Abrufen der Daten')
  }
}

// FEHLGESCHLAGEN: SCHLECHT: Keine Fehlerbehandlung
async function fetchData(url) {
  const response = await fetch(url)
  return response.json()
}

Async/Await Best Practices

// BESTANDEN: GUT: Parallele Ausführung wenn möglich
const [users, markets, stats] = await Promise.all([
  fetchUsers(),
  fetchMarkets(),
  fetchStats()
])

// FEHLGESCHLAGEN: SCHLECHT: Sequentiell wenn unnötig
const users = await fetchUsers()
const markets = await fetchMarkets()
const stats = await fetchStats()

Typsicherheit

// BESTANDEN: GUT: Korrekte Typen
interface Market {
  id: string
  name: string
  status: 'active' | 'resolved' | 'closed'
  created_at: Date
}

function getMarket(id: string): Promise<Market> {
  // Implementierung
}

// FEHLGESCHLAGEN: SCHLECHT: 'any' verwenden
function getMarket(id: any): Promise<any> {
  // Implementierung
}

React Best Practices

Komponentenstruktur

// BESTANDEN: GUT: Funktionale Komponente mit Typen
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>
  )
}

// FEHLGESCHLAGEN: SCHLECHT: Keine Typen, unklare Struktur
export function Button(props) {
  return <button onClick={props.onClick}>{props.children}</button>
}

Benutzerdefinierte Hooks

// BESTANDEN: GUT: Wiederverwendbarer benutzerdefinierter 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
}

// Verwendung
const debouncedQuery = useDebounce(searchQuery, 500)

State Management

// BESTANDEN: GUT: Korrekte State-Updates
const [count, setCount] = useState(0)

// Funktionelles Update basierend auf vorherigem State
setCount(prev => prev + 1)

// FEHLGESCHLAGEN: SCHLECHT: Direkter State-Referenz
setCount(count + 1)  // Kann in asynchronen Szenarien veraltet sein

Bedingte Darstellung

// BESTANDEN: GUT: Klare bedingte Darstellung
{isLoading && <Spinner />}
{error && <ErrorMessage error={error} />}
{data && <DataDisplay data={data} />}

// FEHLGESCHLAGEN: SCHLECHT: Ternary-Hölle
{isLoading ? <Spinner /> : error ? <ErrorMessage error={error} /> : data ? <DataDisplay data={data} /> : null}

API-Design-Standards

REST-API-Konventionen

GET    /api/markets              # Alle Märkte auflisten
GET    /api/markets/:id          # Bestimmten Markt abrufen
POST   /api/markets              # Neuen Markt erstellen
PUT    /api/markets/:id          # Markt aktualisieren (vollständig)
PATCH  /api/markets/:id          # Markt aktualisieren (teilweise)
DELETE /api/markets/:id          # Markt löschen

# Abfrageparameter zum Filtern
GET /api/markets?status=active&limit=10&offset=0

Antwortformat

// BESTANDEN: GUT: Konsistente Antwortstruktur
interface ApiResponse<T> {
  success: boolean
  data?: T
  error?: string
  meta?: {
    total: number
    page: number
    limit: number
  }
}

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

// Fehlerantwort
return NextResponse.json({
  success: false,
  error: 'Ungültige Anfrage'
}, { status: 400 })

Eingabevalidierung

import { z } from 'zod'

// BESTANDEN: GUT: Schema-Validierung
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)
    // Mit validierten Daten fortfahren
  } catch (error) {
    if (error instanceof z.ZodError) {
      return NextResponse.json({
        success: false,
        error: 'Validierung fehlgeschlagen',
        details: error.issues
      }, { status: 400 })
    }
  }
}

Dateiorganisation

Projektstruktur

src/
├── app/                    # Next.js App Router
│   ├── api/               # API-Routen
│   ├── markets/           # Marktseiten
│   └── (auth)/           # Auth-Seiten (Route-Gruppen)
├── components/            # React-Komponenten
│   ├── ui/               # Generische UI-Komponenten
│   ├── forms/            # Formularkomponenten
│   └── layouts/          # Layout-Komponenten
├── hooks/                # Benutzerdefinierte React Hooks
├── lib/                  # Hilfsfunktionen und Konfigurationen
│   ├── api/             # API-Clients
│   ├── utils/           # Hilfsfunktionen
│   └── constants/       # Konstanten
├── types/                # TypeScript-Typen
└── styles/              # Globale Styles

Dateibenennung

components/Button.tsx          # PascalCase für Komponenten
hooks/useAuth.ts              # camelCase mit 'use'-Präfix
lib/formatDate.ts             # camelCase für Hilfsfunktionen
types/market.types.ts         # camelCase mit .types-Suffix

Kommentare & Dokumentation

Wann kommentieren

// BESTANDEN: GUT: Erkläre WARUM, nicht WAS
// Exponentielles Backoff verwenden, um die API bei Ausfällen nicht zu überlasten
const delay = Math.min(1000 * Math.pow(2, retryCount), 30000)

// Bewusste Mutation hier für Performance bei großen Arrays
items.push(newItem)

// FEHLGESCHLAGEN: SCHLECHT: Das Offensichtliche benennen
// Zähler um 1 erhöhen
count++

// Name auf Benutzername setzen
name = user.name

JSDoc für öffentliche APIs

/**
 * Durchsucht Märkte mittels semantischer Ähnlichkeit.
 *
 * @param query - Natürlichsprachliche Suchanfrage
 * @param limit - Maximale Anzahl von Ergebnissen (Standard: 10)
 * @returns Array von Märkten, sortiert nach Ähnlichkeitswert
 * @throws {Error} Wenn OpenAI API fehlschlägt oder Redis nicht verfügbar ist
 *
 * @example
 * ```typescript
 * const results = await searchMarkets('Wahl', 5)
 * console.log(results[0].name) // "Trump vs Biden"
 * ```
 */
export async function searchMarkets(
  query: string,
  limit: number = 10
): Promise<Market[]> {
  // Implementierung
}

Performance Best Practices

Memoization

import { useMemo, useCallback } from 'react'

// BESTANDEN: GUT: Teure Berechnungen memoizieren
// Vor dem Sortieren kopieren - Array.prototype.sort mutiert in-place
const sortedMarkets = useMemo(() => {
  return [...markets].sort((a, b) => b.volume - a.volume)
}, [markets])

// BESTANDEN: GUT: Callbacks memoizieren
const handleSearch = useCallback((query: string) => {
  setSearchQuery(query)
}, [])

Lazy Loading

import { lazy, Suspense } from 'react'

// BESTANDEN: GUT: Schwere Komponenten lazy laden
const HeavyChart = lazy(() => import('./HeavyChart'))

export function Dashboard() {
  return (
    <Suspense fallback={<Spinner />}>
      <HeavyChart />
    </Suspense>
  )
}

Datenbankabfragen

// BESTANDEN: GUT: Nur benötigte Spalten auswählen
const { data } = await supabase
  .from('markets')
  .select('id, name, status')
  .limit(10)

// FEHLGESCHLAGEN: SCHLECHT: Alles auswählen
const { data } = await supabase
  .from('markets')
  .select('*')

Teststandards

Teststruktur (AAA-Muster)

test('berechnet Ähnlichkeit korrekt', () => {
  // Arrange (Anordnen)
  const vector1 = [1, 0, 0]
  const vector2 = [0, 1, 0]

  // Act (Handeln)
  const similarity = calculateCosineSimilarity(vector1, vector2)

  // Assert (Behaupten)
  expect(similarity).toBe(0)
})

Testbenennung

// BESTANDEN: GUT: Beschreibende Testnamen
test('gibt leeres Array zurück, wenn keine Märkte der Abfrage entsprechen', () => { })
test('wirft Fehler, wenn OpenAI API-Schlüssel fehlt', () => { })
test('fällt auf Substring-Suche zurück, wenn Redis nicht verfügbar ist', () => { })

// FEHLGESCHLAGEN: SCHLECHT: Vage Testnamen
test('funktioniert', () => { })
test('teste Suche', () => { })

Code-Geruchserkennung

Achte auf diese Anti-Patterns:

1. Lange Funktionen

// FEHLGESCHLAGEN: SCHLECHT: Funktion > 50 Zeilen
function processMarketData() {
  // 100 Zeilen Code
}

// BESTANDEN: GUT: In kleinere Funktionen aufteilen
function processMarketData() {
  const validated = validateData()
  const transformed = transformData(validated)
  return saveData(transformed)
}

2. Tiefe Verschachtelung

// FEHLGESCHLAGEN: SCHLECHT: 5+ Ebenen Verschachtelung
if (user) {
  if (user.isAdmin) {
    if (market) {
      if (market.isActive) {
        if (hasPermission) {
          // Etwas tun
        }
      }
    }
  }
}

// BESTANDEN: GUT: Frühe Rückgaben
if (!user) return
if (!user.isAdmin) return
if (!market) return
if (!market.isActive) return
if (!hasPermission) return

// Etwas tun

3. Magische Zahlen

// FEHLGESCHLAGEN: SCHLECHT: Unerklärte Zahlen
if (retryCount > 3) { }
setTimeout(callback, 500)

// BESTANDEN: GUT: Benannte Konstanten
const MAX_RETRIES = 3
const DEBOUNCE_DELAY_MS = 500

if (retryCount > MAX_RETRIES) { }
setTimeout(callback, DEBOUNCE_DELAY_MS)

Denke daran: Codequalität ist nicht verhandelbar. Klarer, wartbarer Code ermöglicht schnelle Entwicklung und sicheres Refactoring.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

Verwandte Skills