From noxfen-essentials
JavaScript and TypeScript best practices. Activates when working with .js, .ts, .jsx, .tsx files, or when the user asks to "write javascript", "write typescript", "node.js", "react component", "refactor JS", mentions eslint/prettier/bun/vite, or discusses JS/TS patterns. Enforces typed, idiomatic, production-quality TypeScript.
How this skill is triggered — by the user, by Claude, or both
Slash command
/noxfen-essentials:js-best-practicesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Default to TypeScript. Apply these rules whenever writing or reviewing JS/TS code.
Default to TypeScript. Apply these rules whenever writing or reviewing JS/TS code.
prettier --write <file> # formatting
eslint --fix <file> # linting + auto-fix
tsc --noEmit # type checking (project-wide)
Both tools must be configured in the project (prettier.config.*, eslint.config.*, tsconfig.json).
If they're not set up, offer to add them before writing code.
.ts / .tsx — never .js for new files unless interoperating with legacy codetsconfig.json must have "strict": true"noUncheckedIndexedAccess": true — prevents silent undefined from array/object accessany// Bad
function process(data: any): any { ... }
// Good — use unknown + type guard
function process(data: unknown): string {
if (typeof data !== "string") throw new TypeError("Expected string");
return data.trim();
}
any disables type checking entirely — use unknown and narrow with guardsas SomeType casts: only when you have proof the type is correct (e.g., after a parse)satisfies over as for object literals// Bad — .then() chains
fetch(url)
.then(r => r.json())
.then(data => process(data))
.catch(handleError);
// Good — async/await
async function loadData(url: string): Promise<Data> {
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json() as Promise<Data>;
}
async/await — no .then() chainstry/catch in async functions or .catch() at the top call siteawait in a loop when calls are independent — use Promise.all()try {
const result = await riskyOperation();
} catch (err) {
if (err instanceof NetworkError) {
// handle network error
} else if (err instanceof Error) {
logger.error(err.message, { stack: err.stack });
} else {
throw err; // re-throw unknown
}
}
instanceof Error before accessing .messageclass MyError extends Error)// Named imports preferred over default
import { parseDate, formatDate } from "./utils/date";
// Type-only import (erased at compile time)
import type { User } from "./types";
import type for type-only imports (required with isolatedModules)index.ts that re-exports everything) — they hurt tree-shaking// Functional component with typed props
interface ButtonProps {
label: string;
onClick: () => void;
disabled?: boolean;
}
export function Button({ label, onClick, disabled = false }: ButtonProps) {
return <button onClick={onClick} disabled={disabled}>{label}</button>;
}
React.FC<Props> (which hides return type)useCallback / useMemo only when profiling proves render cost — don't premature-optimize?? (nullish coalescing) not || for defaults (avoids false-y short-circuit on 0 / "")?. to safely access nested propertiesnull in new code — prefer undefined (more idiomatic JS, simpler union types)src/
components/ # React components
hooks/ # Custom React hooks
services/ # API calls, external integrations
utils/ # Pure utility functions
types/ # Shared type definitions
index.ts # Entry point
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub noxfen/claude_skill_everywhere --plugin noxfen-essentials