Index of every page on this site: llms.txt
All skills
grahamcrackers avatar

/bulletproof-react-patterns

@ca83de4
Run it yourself

Bulletproof React architecture patterns for scalable, maintainable applications. Covers feature-based project structure, component patterns, state management boundaries, API layer design, error handling, security, and testing strategies. Use when structuring a React project, designing application architecture, organizing features, or when the user asks about React project structure or scalable patterns.

Use this Skill: https://skilld.dev/gh/grahamcrackers/skills/bulletproof-react-patterns

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referenceserror-handling.md

≈531 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Error Handling

API Errors

Implement an interceptor on the API client to manage errors centrally:

  • Trigger notification toasts for user-facing errors.
  • Log out unauthorized users (401 responses).
  • Refresh tokens automatically.
  • Never expose raw error objects to users.
api.interceptors.response.use(
    (response) => response.data,
    (error) => {
        const status = error.response?.status;
        const message = error.response?.data?.message || error.message;

        if (status === 401) {
            // Log out or refresh token
        }

        // Show user-friendly notification
        addNotification({ type: "error", title: "Error", message });

        return Promise.reject(error);
    },
);

Error Boundaries

Use multiple error boundaries placed at different levels rather than a single one for the entire app. If an error occurs, it is contained locally without disrupting the whole application.

Error Hierarchy

App Error Boundary          → catches unrecoverable crashes
  └── Route Error Boundary     → catches route-level failures, shows retry
        └── Feature Error Boundary   → catches feature-specific errors

Usage Pattern

<ErrorBoundary fallback={<FeatureError />}>
    <Suspense fallback={<FeatureSkeleton />}>
        <UserDashboard />
    </Suspense>
</ErrorBoundary>

Wrap each route and major feature section in its own boundary with meaningful fallback UI.

Error Tracking

Use tools like Sentry to track production errors. Don't build custom solutions — purpose-built tools provide:

  • Platform and browser context
  • Stack traces with source maps
  • Error grouping and deduplication
  • Alerting and dashboards

Upload source maps to Sentry to see exactly where in your source code the error occurred.

Typed Error Responses

Define consistent error response types:

type ApiError = {
    message: string;
    statusCode: number;
    errors?: Record<string, string[]>;
};

Use these types in error handling to provide structured, user-friendly messages.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill is an architectural guide for React development, providing best practices for project structure, state management, and testing. It contains exclusively educational content and code examples with no executable or malicious scripts.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer9mo

    1/11 files flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at ca83de4. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago

README badge

README badge for grahamcrackers/skills/bulletproof-react-patterns