skills/logging-react/SKILL.md
Configure structured logging for React frontend applications. Covers client-side log collection, error boundary logging, API error logging, correlation IDs, and log shipping to backend services. Use when: setting up frontend logging, capturing errors, correlating frontend requests with backend traces, or debugging production issues in React.
npx skillsauth add congiuluc/my-awesome-copilot logging-reactInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
console.log in production — use a structured logger that can be configured per environment.type LogLevel = 'debug' | 'info' | 'warn' | 'error';
interface LogEntry {
level: LogLevel;
message: string;
context?: Record<string, unknown>;
timestamp: string;
correlationId?: string;
}
const LOG_LEVELS: Record<LogLevel, number> = {
debug: 0,
info: 1,
warn: 2,
error: 3,
};
const currentLevel: LogLevel = import.meta.env.PROD ? 'warn' : 'debug';
function shouldLog(level: LogLevel): boolean {
return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel];
}
export const logger = {
debug: (message: string, context?: Record<string, unknown>) =>
log('debug', message, context),
info: (message: string, context?: Record<string, unknown>) =>
log('info', message, context),
warn: (message: string, context?: Record<string, unknown>) =>
log('warn', message, context),
error: (message: string, context?: Record<string, unknown>) =>
log('error', message, context),
};
function log(level: LogLevel, message: string, context?: Record<string, unknown>): void {
if (!shouldLog(level)) return;
const entry: LogEntry = {
level,
message,
context: filterSensitiveData(context),
timestamp: new Date().toISOString(),
};
console[level](JSON.stringify(entry));
if (level === 'error') {
shipToBackend(entry);
}
}
import { Component, type ErrorInfo, type ReactNode } from 'react';
import { logger } from '@/utils/logger';
interface ErrorBoundaryProps {
fallback: ReactNode;
children: ReactNode;
}
interface ErrorBoundaryState {
hasError: boolean;
}
export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
state: ErrorBoundaryState = { hasError: false };
static getDerivedStateFromError(): ErrorBoundaryState {
return { hasError: true };
}
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
logger.error('React error boundary caught error', {
error: error.message,
stack: error.stack,
componentStack: errorInfo.componentStack ?? undefined,
});
}
render(): ReactNode {
return this.state.hasError ? this.props.fallback : this.props.children;
}
}
const SENSITIVE_KEYS = new Set([
'password', 'token', 'secret', 'apiKey', 'authorization', 'creditCard',
]);
function filterSensitiveData(
context?: Record<string, unknown>,
): Record<string, unknown> | undefined {
if (!context) return undefined;
const filtered = { ...context };
for (const key of Object.keys(filtered)) {
if (SENSITIVE_KEYS.has(key.toLowerCase())) {
filtered[key] = '***REDACTED***';
}
}
return filtered;
}
tools
Build VS Code extensions with TypeScript. Covers extension anatomy, activation events, commands, tree views, webview panels, language features, testing, and publishing. Use when: creating a new VS Code extension, adding commands/views/providers, building webview UIs, implementing language server features, testing extensions, or packaging for the marketplace.
development
Track implementations, features, bugs, and releases in a versioning document. Use when: adding a commit, completing a feature, fixing a bug, or preparing a release. Automatically updates CHANGELOG.md following Keep a Changelog format and Semantic Versioning.
development
Write frontend tests using Vitest and React Testing Library. Use when: testing React components, hooks, user interactions, form submissions, accessibility assertions, or mocking API services.
development
Write Angular frontend tests using Jasmine, Karma, and Angular TestBed. Use when: testing Angular components, services, pipes, directives, user interactions, form submissions, accessibility assertions, or mocking HTTP services.