Skip to content
Back to skills

1692 Code Guide 23e43f0c

ASecurity

Universal principles for writing maintainable code. Stack-specific details should live in project CLAUDE.md files.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 1, 2026
testingtypescriptgotestingapidatabasefrontendbackend

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned June 1, 2026

npx -y skills add tools-only/X-Skills --skill 1692-code_guide_23e43f0c --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 1692 Code Guide 23e43f0c?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 1692 Code Guide 23e43f0c
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-1692-code-guide-23e43f0c/badge)](https://www.skillsdirectory.com/skills/tools-only-1692-code-guide-23e43f0c)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Code Guide

Universal principles for writing maintainable code. Stack-specific details should live in project CLAUDE.md files.

## Type Safety

Type safety is non-negotiable. The compiler is your first line of defense.

- Write as if strict mode is enabled. Type errors are build blockers.
- Never use `any` — use `unknown` with type guards instead
- Reuse types from libraries (`@types/*`, built-in exports) — never recreate types a library already exports
- Be explicit at boundaries (function params, return types, API types, public interfaces). Let TypeScript infer internally.
- Use discriminated unions for state: `{ status: 'loading' } | { status: 'success', data: T } | { status: 'error', error: E }`
- Validate external data (HTTP, files, user input) with schema validation (Zod, etc.) at boundaries

## Error Handling

- Fail explicitly — no silent fallbacks (`data || {}`, empty catch blocks)
- Actionable messages with context: "User 123 not found in database" not "Not found"
- Use a consistent error shape `{ code, message, details }` so callers can handle programmatically

## Code Organization

- Group by feature/domain (`billing/`, `users/`), not technical layer (`controllers/`, `services/`)
- Consistent structure — similar things should look similar across the codebase
- Flat over nested — 2-3 directory levels is usually enough

## Breaking Changes

- Extend rather than modify existing interfaces when possible
- Deprecate before removing — give consumers time to migrate
- Version APIs when breaking changes are necessary

## Logging

- Structured format: JSON with consistent fields (level, timestamp, message, context)
- Include context: request IDs, user IDs, operation, relevant entity IDs
- Never log passwords, tokens, PII, or secrets

## Testing

- Fast unit tests for pure logic, integration tests at boundaries, E2E for critical paths only
- Tests must be deterministic — no flaky tests
- Test behavior, not implementation

## Frontend

- Server by default — fetch data and render on server when possible
- Handle all states: every async operation has loading, success, and error states

## Backend

- Transactions for consistency — multi-step writes should be atomic
- Idempotent operations — safe to retry without unintended side effects
- Timeouts everywhere — network calls, database queries, external APIs

Files in this skill

  • README.md809 B
  • skill.md2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.